{"ast":null,"code":"import { myMixins } from '@/utils/myMixins.js';\nimport { getAmount, pay, getCurrentOrder } from '@/api/order';\nimport AttentionItem from '@/components/attentionItem';\nimport commonBtn from \"@/components/commonBtn\";\nimport operationBtn from \"@/components/operationBtn\";\nexport default {\n name: \"payPage\",\n data() {\n return {\n map: '',\n extraFee: 0,\n ticketId: '',\n orderInfo: '',\n marker: '',\n lat: '',\n lng: '',\n userPhone: '',\n plateNumber: '',\n timer: '',\n currentHref: ''\n };\n },\n mixins: [myMixins],\n components: {\n AttentionItem,\n commonBtn,\n operationBtn\n },\n async mounted() {\n console.log('mounted');\n await this.initInfo();\n await this.initMap();\n await this.getAmountHandler();\n await this.getOrderInfo();\n await this.setTimer();\n // 事发地 marker\n if (this.lat && this.lng) {\n this.markerFn(this.lng, this.lat, this.marker, 'my-position');\n }\n // 暂时注释\n document.addEventListener('visibilitychange', async e => {\n console.log(document.visibilityState);\n let state = document.visibilityState;\n if (state == 'hidden') {// 用户离开了\n // this.timer && clearInterval(this.timer)\n }\n if (state == 'visible') {\n await this.getOrderInfo();\n //调用接口,获取订单状态\n }\n });\n },\n\n beforeDestroy() {\n console.log('beforeDestroy');\n this.timer && clearInterval(this.timer);\n },\n methods: {\n initInfo() {\n this.ticketId = this.$route.query.ticketId;\n this.lat = this.$route.query.lat;\n this.lng = this.$route.query.lng;\n this.userPhone = this.$route.query?.userPhone || '';\n this.plateNumber = this.$route.query?.plateNumber || '';\n },\n setTimer() {\n this.timer && clearInterval(this.timer);\n this.timer = setInterval(async () => {\n await this.getOrderInfo();\n }, 1500);\n },\n markerFn(lng, lat, marker, markerCls) {\n if (marker) {\n this.map.remove(marker);\n }\n let content = `
`;\n marker = new AMap.Marker({\n position: new AMap.LngLat(lng, lat),\n content: content,\n offset: new AMap.Pixel(-13, -30)\n });\n this.map.add(marker);\n },\n callClient() {\n window.location.href = 'tel:' + localStorage.getItem('client');\n },\n initMap() {\n this.map = new AMap.Map('mapId', {\n viewMode: '2D',\n // 默认使用 2D 模式\n zoom: 13,\n //初始化地图层级\n center: [this.lng, this.lat] //初始化地图中心点\n });\n },\n\n async getAmountHandler() {\n let res = await getAmount({\n appCode: localStorage.getItem('appCode'),\n ticketId: this.ticketId\n });\n this.extraFee = res.extraFee;\n },\n async payHandler() {\n let ran = navigator.userAgent;\n // let isAndroid = ran.indexOf('Android') > -1 || ran.indexOf('Linux') > -1\n let isIOS = !!ran.match(/\\(i[^;]+;( U;)? CPU.+Mac OS X/);\n let res = await pay({\n amount: this.extraFee,\n // amount: 0.02,\n code: this.ticketId,\n appid: 'wxd6e70d02102c9cff'\n });\n if (res) {\n if (isIOS) {\n this.currentHref = window.location.href;\n let result = res + '&redirect_url=' + decodeURIComponent(this.currentHref);\n window.location.href = result;\n } else {\n window.location.href = res;\n }\n }\n },\n async getOrderInfo() {\n this.orderInfo = await getCurrentOrder({\n ticketId: this.ticketId,\n appCode: localStorage.getItem('appCode'),\n userPhone: this.userPhone,\n plateNumber: this.plateNumber\n });\n await this.goDetail(this.orderInfo);\n },\n goDetail(result) {\n if (result.orderStatus != 17) {\n // 代付款页\n this.goPage('orderStatus', {\n ticketId: result.ticketId,\n userPhone: this.userPhone,\n plateNumber: this.plateNumber\n });\n }\n }\n }\n};","map":{"version":3,"names":["myMixins","getAmount","pay","getCurrentOrder","AttentionItem","commonBtn","operationBtn","name","data","map","extraFee","ticketId","orderInfo","marker","lat","lng","userPhone","plateNumber","timer","currentHref","mixins","components","mounted","console","log","initInfo","initMap","getAmountHandler","getOrderInfo","setTimer","markerFn","document","addEventListener","e","visibilityState","state","beforeDestroy","clearInterval","methods","$route","query","setInterval","markerCls","remove","content","AMap","Marker","position","LngLat","offset","Pixel","add","callClient","window","location","href","localStorage","getItem","Map","viewMode","zoom","center","res","appCode","payHandler","ran","navigator","userAgent","isIOS","match","amount","code","appid","result","decodeURIComponent","goDetail","orderStatus","goPage"],"sources":["src/views/index/pay.vue"],"sourcesContent":["\r\n