接口顺序调整,会员充值调整

This commit is contained in:
GaoHao 2024-08-09 10:31:45 +08:00
parent 8ca9a73775
commit bf5460c304
6 changed files with 60 additions and 66 deletions

34
App.vue
View File

@ -1,14 +1,17 @@
<template> <template>
</template> </template>
<script> <script>
import Api from '@/common/js/api.js'
export default { export default {
onLaunch: function() { onLaunch: function() {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
uni.cache.set('menuInfo', uni.getMenuButtonBoundingClientRect()); uni.cache.set('menuInfo', uni.getMenuButtonBoundingClientRect());
// #endif // #endif
uni.cache.set('NAME', '零点八零'); uni.cache.set('NAME', '零点八零');
this.userlogin()
},
onLoad() {
}, },
onLoad() {},
onShow: function() { onShow: function() {
this.$store.dispatch("HeightActions"); // this.$store.dispatch("HeightActions"); //
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
@ -48,6 +51,35 @@
onHide: function() { onHide: function() {
// console.log('App Hide'); // console.log('App Hide');
}, },
methods: {
userlogin() {
if (!uni.cache.get('token')) {
uni.login({
provider: 'weixin',
success: (data) => {
uni.getUserInfo({
provider: 'weixin',
success: async (infoRes) => {
uni.cache.set('weixincode', data.code);
let res = await 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);
this.$isResolve()
}
},
fail: (err) => {}
});
},
})
}
}
}
}; };
</script> </script>

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

@ -23,6 +23,10 @@ uni.$u.config.unit = 'rpx'
Vue.prototype.useStorage = useStorage Vue.prototype.useStorage = useStorage
Vue.prototype.api = Api; Vue.prototype.api = Api;
Vue.prototype.shop = Shop; Vue.prototype.shop = Shop;
Vue.prototype.$onLaunched = new Promise(resolve => {
Vue.prototype.$isResolve = resolve
})
// #ifdef VUE3 // #ifdef VUE3
import { import {
createSSRApp createSSRApp

View File

@ -46,45 +46,24 @@
usershopUserinfo: null, usershopUserinfo: null,
} }
}, },
onLoad(e) { async onLoad(e) {
console.log(e) console.log(e)
if ( e.type == 'list' || e.type == 'index') { // if ( e.type == 'list' || e.type == 'index') {
this.shopId = e.shopId; // this.shopId = e.shopId;
this.init(); // this.init();
} // }
if (e.q) { if (e.q) {
this.shopId = this.getQueryString(decodeURIComponent(e.q), 'shopId') this.shopId = this.getQueryString(decodeURIComponent(e.q), 'shopId')
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);
this.tokenShow = false; this.tokenShow = false;
//
if (!uni.cache.get('token')) {
await this.$onLaunched;
}
this.init(); this.init();
}
},
fail: (err) => {}
});
} catch (e) {}
}
});
} else{ } else{
this.shopId = e.shopId;
this.init(); this.init();
} }
}
console.log(this.shopId) console.log(this.shopId)
}, },
methods: { methods: {

View File

@ -409,40 +409,18 @@
uni.$off('message') uni.$off('message')
this.fixedtrue = true this.fixedtrue = true
}, },
onShow() { async onShow() {
let _this = this; let _this = this;
this.orderdetailFlag = true; this.orderdetailFlag = true;
uni.pageScrollTo({ uni.pageScrollTo({
scrollTop: 0, scrollTop: 0,
duration: 0 duration: 0
}); });
uni.login({ if (!uni.cache.get('token')) {
provider: 'weixin', await this.$onLaunched;
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) uni.$on('message', this.getMessage)
_this.getLocation() _this.getLocation()
}
},
fail: (err) => {}
});
} catch (e) {}
}
});
}, },
methods: { methods: {
navigateBacknav() { navigateBacknav() {

View File

@ -78,6 +78,7 @@ const store = new Vuex.Store({
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);
this.$isResolve()
} }
}, },
fail: (err) => {} fail: (err) => {}