From b67f1381ca2ab3e609c9c2eeabd45cce5cb0ff44 Mon Sep 17 00:00:00 2001 From: GaoHao <1210693421@qq.com> Date: Thu, 8 Aug 2024 17:06:26 +0800 Subject: [PATCH] *** --- common/js/api.js | 2 +- framework/0-conf.js | 8 ++-- pages/member/index.vue | 19 ++++++-- pages/order_food/order_food.vue | 82 ++++++++++++--------------------- 4 files changed, 51 insertions(+), 60 deletions(-) diff --git a/common/js/api.js b/common/js/api.js index 05e8744..8d7b8a6 100644 --- a/common/js/api.js +++ b/common/js/api.js @@ -166,7 +166,7 @@ export default { return uni.api.get("/product/queryShopIdByTableCode", data); }, geocodelocation(data) { //根据经纬度获取信息 - return uni.api.get("/location/geocode", data); + return uni.api.get("/location/geocode", data, false); }, // 修改头像和昵称 upUserInfo(data) { diff --git a/framework/0-conf.js b/framework/0-conf.js index a9b4c7d..ab5aecc 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -16,11 +16,11 @@ const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService' // #endif // #ifdef APP || MP-WEIXIN -const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上 -const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上 +// const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上 +// const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上 -// const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上 -// const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上/ +const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上 +const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上/ // #endif // import VConsole from "./vConsole.js" diff --git a/pages/member/index.vue b/pages/member/index.vue index afa681d..605f666 100644 --- a/pages/member/index.vue +++ b/pages/member/index.vue @@ -216,9 +216,22 @@ title: "支付成功" }) uni.hideLoading() - setTimeout(res => { - uni.navigateBack() - }, 500) + let pages = getCurrentPages() + if ( pages.length > 1) { + setTimeout(res => { + uni.navigateBack() + }, 500) + } else { + uni.exitMiniProgram({ + success: function () { + console.log('退出成功'); + }, + fail: function () { + console.log('退出失败'); + } + }); + } + }, fail: (res) => { uni.hideLoading() diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue index 1c9115d..d294b50 100644 --- a/pages/order_food/order_food.vue +++ b/pages/order_food/order_food.vue @@ -424,38 +424,33 @@ scrollTop: 0, duration: 0 }); - if (!uni.cache.get('token')) { - uni.login({ - provider: 'weixin', - success: async (data) => { - try { - uni.getUserInfo({ - provider: 'weixin', - success: async (infoRes) => { - uni.cache.set('weixincode', data.code); - let res = await this.api.userwxlogin({ - code: uni.cache.get('weixincode'), //临时登录凭证 - rawData: infoRes.rawData - }) - if (res.code == 0) { - uni.cache.set('token', res.data.token); - uni.cache.set('miniAppOpenId', res.data.userInfo - .miniAppOpenId) - uni.cache.set('userInfo', res.data.userInfo); - uni.$on('message', this.getMessage) - - _this.getLocation() - } - }, - fail: (err) => {} - }); - } catch (e) {} - } - }); - } else { - uni.$on('message', this.getMessage) - _this.getLocation() - } + uni.login({ + provider: 'weixin', + success: async (data) => { + try { + uni.getUserInfo({ + provider: 'weixin', + success: async (infoRes) => { + uni.cache.set('weixincode', data.code); + let res = await this.api.userwxlogin({ + code: uni.cache.get('weixincode'), //临时登录凭证 + rawData: infoRes.rawData + }) + if (res.code == 0) { + uni.cache.set('token', res.data.token); + uni.cache.set('miniAppOpenId', res.data.userInfo + .miniAppOpenId) + uni.cache.set('userInfo', res.data.userInfo); + uni.$on('message', this.getMessage) + + _this.getLocation() + } + }, + fail: (err) => {} + }); + } catch (e) {} + } + }); }, methods: { navigateBacknav() { @@ -508,24 +503,7 @@ }, fail: async (err) => { console.log(err, '获取错误') //测试用于app - let successres = await this.api.geocodelocation({ - lng: '', - lat: '', - }) - if (successres.code == 0) { - console.log(successres.data.addressComponent.streetNumber.location.split(',')) - let res = successres.data.addressComponent.streetNumber.location.split(',') - let datastorage = { - country: successres.data.addressComponent.country, // "中国" - province: successres.data.addressComponent.province, //province: "陕西省" - address: successres.data.addressComponent.city, //district: "西安市" - district: successres.data.addressComponent.district, //district: "未央区" - lng: res[0], - lat: res[1], - } - uni.cache.set('getLocationstorage', datastorage); - this.productqueryShop(); - } + this.productqueryShop(); } }); }, @@ -536,8 +514,8 @@ async productqueryShop() { let res = await this.api.productqueryShop({ code: uni.cache.get('tableCode'), - lng: uni.cache.get('getLocationstorage').lng, - lat: uni.cache.get('getLocationstorage').lat, + lng: uni.cache.get('getLocationstorage').lng?uni.cache.get('getLocationstorage').lng:'', + lat: uni.cache.get('getLocationstorage').lat? uni.cache.get('getLocationstorage').lat:'', }) if (res.code == 0) { uni.cache.set('shopUser', res.data.storeInfo.id)