diff --git a/ebike-user/pages/user/home/home.vue b/ebike-user/pages/user/home/home.vue index a6733af..24f3649 100644 --- a/ebike-user/pages/user/home/home.vue +++ b/ebike-user/pages/user/home/home.vue @@ -133,7 +133,8 @@ import config from '@/utils/config'; import { onShow, - onUnload + onUnload, + onLoad } from "@dcloudio/uni-app"; import * as map from "@/utils/usermap.js"; @@ -182,10 +183,58 @@ let arrBikeData = []; const showBikeInfo = ref(false); const bikeData = ref({}); - + const onLoadData = ref(null) let ismount = false; let arrSiteData = [] + onLoad((query) => { + if (query.q) { + const q = decodeURIComponent(query.q) // 获取到二维码原始链接内容 + const scancode_time = parseInt(query.scancode_time) // 获取用户扫码时间 UNIX 时间戳 + const queryString = q.split('?')[1]; + const params = queryString.split('&'); + let p = {}; + params.forEach(param => { + const [key, value] = param.split('='); + p[key] = value; + }); + console.log("p===>" + JSON.stringify(p)) + onLoadData.value = p; + } else if (query.number) { + onLoadData.value['number'] = query.number; + onLoadData.value['_tbScancodeApproach_'] = query._tbScancodeApproach_; + } + }) + + onMounted(() => { + const instance = getCurrentInstance(); + oMap = uni.createMapContext("mapRef", { + this: instance.proxy + }); + ismount = true; + getLoalcationData(); + console.log("loadValue===>" + JSON.stringify(onLoadData.value)) + if (onLoadData.value) { + if (onLoadData.value['_tbScancodeApproach_'] == 'scan') { + if (!oUser) { + tologin(); + } + map.addOrder(onLoadData.value["number"], (res) => { + console.log("00000000000000000000", res); + if (!res) { + setTimeout(() => { + bikeCode = null; + getOrder(); + }, 1000); + return; + } else { + showWorn.value = true; + } + }) + } + } + }) + //加载数据 function getLoalcationData() { map.getLoalcation(res => { @@ -468,8 +517,12 @@ } function tologin() { + let url = '/pages/user/login/wx_login' + if (onLoadData.value) { + url += '?number=' + onLoadData.value['number'] + "&_tbScancodeApproach_=scan" + } uni.navigateTo({ - url: "/pages/user/login/wx_login" + url: url }) } @@ -612,14 +665,6 @@ showTools.value = true; } - onMounted(() => { - const instance = getCurrentInstance(); - oMap = uni.createMapContext("mapRef", { - this: instance.proxy - }); - ismount = true; - getLoalcationData(); - }) onShow(() => { if (uni.getStorageSync("wechat_user")) { oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user"))); @@ -634,8 +679,7 @@ if (ismount) getLoalcationData(); }); - onUnload(() => { - }) + onUnload(() => {}) function parseDate(createTime) { // 将日期字符串转换为 iOS 支持的格式 diff --git a/ebike-user/pages/user/login/wx_login.vue b/ebike-user/pages/user/login/wx_login.vue index be19e28..07e34f7 100644 --- a/ebike-user/pages/user/login/wx_login.vue +++ b/ebike-user/pages/user/login/wx_login.vue @@ -63,6 +63,7 @@ const agreed = ref([{ value: true // true 表示选中 }]); + const onLoadData = ref(null) import { onLoad } from '@dcloudio/uni-app'; @@ -76,6 +77,10 @@ }) onLoad((options) => { + if (options['number']) { + onLoadData.value['number'] = options['number'] + onLoadData.value['_tbScancodeApproach_'] = options['_tbScancodeApproach_'] + } login(); }) @@ -227,14 +232,18 @@ //如果头像为空 弹出设置头像页面 login(); let wechat_user = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user"))); - if (!wechat_user.avatar) { + if (!wechat_user.avatar) { setTimeout(() => { uni.navigateTo({ url: "/pages/user/login/userphtoinfo" }) }, 500); } else { - + let url = "/pages/user/home/home" + let q = ""; + if (onLoadData.value) { + url += '?number=' + onLoadData.value['number'] + "&_tbScancodeApproach_=scan" + } setTimeout(() => { uni.navigateTo({ url: "/pages/user/home/home" diff --git a/ebike-user/pages/user/scan/scancode.vue b/ebike-user/pages/user/scan/scancode.vue index eaa3362..1bca492 100644 --- a/ebike-user/pages/user/scan/scancode.vue +++ b/ebike-user/pages/user/scan/scancode.vue @@ -46,7 +46,8 @@ } from "@dcloudio/uni-app"; import { showModelMessage, - getUrlParams,jkcBaseDecode + getUrlParams, + jkcBaseDecode } from "@/utils/tools.js"; import { @@ -64,7 +65,7 @@ const showWorn = ref(false); const oUser = JSON.parse(jkcBaseDecode(uni.getStorageSync("wechat_user"))); let type = null; - let errdata=null; + let errdata = null; onLoad((options) => { type = options["type"]; @@ -81,8 +82,8 @@ result } = res.detail; if (!result || result.indexOf("number") == -1) { - if(errdata==result) return; - errdata=result; + if (errdata == result) return; + errdata = result; showModelMessage("无效的车辆二维码"); return; }