This commit is contained in:
GaoHao
2024-08-08 17:06:26 +08:00
parent d82bd93033
commit b67f1381ca
4 changed files with 51 additions and 60 deletions

View File

@@ -166,7 +166,7 @@ export default {
return uni.api.get("/product/queryShopIdByTableCode", data); return uni.api.get("/product/queryShopIdByTableCode", data);
}, },
geocodelocation(data) { //根据经纬度获取信息 geocodelocation(data) { //根据经纬度获取信息
return uni.api.get("/location/geocode", data); return uni.api.get("/location/geocode", data, false);
}, },
// 修改头像和昵称 // 修改头像和昵称
upUserInfo(data) { upUserInfo(data) {

View File

@@ -16,11 +16,11 @@ const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService'
// #endif // #endif
// #ifdef APP || MP-WEIXIN // #ifdef APP || MP-WEIXIN
const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上 // const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上
const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上 // const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上
// const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上 const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上
// const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上/ const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上/
// #endif // #endif
// import VConsole from "./vConsole.js" // import VConsole from "./vConsole.js"

View File

@@ -216,9 +216,22 @@
title: "支付成功" title: "支付成功"
}) })
uni.hideLoading() uni.hideLoading()
setTimeout(res => { let pages = getCurrentPages()
uni.navigateBack() if ( pages.length > 1) {
}, 500) setTimeout(res => {
uni.navigateBack()
}, 500)
} else {
uni.exitMiniProgram({
success: function () {
console.log('退出成功');
},
fail: function () {
console.log('退出失败');
}
});
}
}, },
fail: (res) => { fail: (res) => {
uni.hideLoading() uni.hideLoading()

View File

@@ -424,38 +424,33 @@
scrollTop: 0, scrollTop: 0,
duration: 0 duration: 0
}); });
if (!uni.cache.get('token')) { uni.login({
uni.login({ provider: 'weixin',
provider: 'weixin', success: async (data) => {
success: async (data) => { try {
try { uni.getUserInfo({
uni.getUserInfo({ provider: 'weixin',
provider: 'weixin', success: async (infoRes) => {
success: async (infoRes) => { uni.cache.set('weixincode', data.code);
uni.cache.set('weixincode', data.code); let res = await this.api.userwxlogin({
let res = await this.api.userwxlogin({ code: uni.cache.get('weixincode'), //临时登录凭证
code: uni.cache.get('weixincode'), //临时登录凭证 rawData: infoRes.rawData
rawData: infoRes.rawData })
}) if (res.code == 0) {
if (res.code == 0) { uni.cache.set('token', res.data.token);
uni.cache.set('token', res.data.token); uni.cache.set('miniAppOpenId', res.data.userInfo
uni.cache.set('miniAppOpenId', res.data.userInfo .miniAppOpenId)
.miniAppOpenId) uni.cache.set('userInfo', res.data.userInfo);
uni.cache.set('userInfo', res.data.userInfo); uni.$on('message', this.getMessage)
uni.$on('message', this.getMessage)
_this.getLocation()
_this.getLocation() }
} },
}, fail: (err) => {}
fail: (err) => {} });
}); } catch (e) {}
} catch (e) {} }
} });
});
} else {
uni.$on('message', this.getMessage)
_this.getLocation()
}
}, },
methods: { methods: {
navigateBacknav() { navigateBacknav() {
@@ -508,24 +503,7 @@
}, },
fail: async (err) => { fail: async (err) => {
console.log(err, '获取错误') //测试用于app console.log(err, '获取错误') //测试用于app
let successres = await this.api.geocodelocation({ this.productqueryShop();
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();
}
} }
}); });
}, },
@@ -536,8 +514,8 @@
async productqueryShop() { async productqueryShop() {
let res = await this.api.productqueryShop({ let res = await this.api.productqueryShop({
code: uni.cache.get('tableCode'), code: uni.cache.get('tableCode'),
lng: uni.cache.get('getLocationstorage').lng, lng: uni.cache.get('getLocationstorage').lng?uni.cache.get('getLocationstorage').lng:'',
lat: uni.cache.get('getLocationstorage').lat, lat: uni.cache.get('getLocationstorage').lat? uni.cache.get('getLocationstorage').lat:'',
}) })
if (res.code == 0) { if (res.code == 0) {
uni.cache.set('shopUser', res.data.storeInfo.id) uni.cache.set('shopUser', res.data.storeInfo.id)