diff --git a/src/App.vue b/src/App.vue index 841ee90..6792a14 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,7 +15,7 @@ export default { this.$store.dispatch('app/getArticle'); /* #ifdef MP-WEIXIN */ - // wxMnpLogin() + // wxMnpLogin() /* #endif */ // #ifdef APP-PLUS @@ -29,11 +29,13 @@ export default { // #endif }, onShow(option) { - console.log(option); let invite_code = option.query.invite_code || strToParams(decodeURIComponent(option.query.scene)).invite_code uni.setStorageSync('INVITE_CODE',invite_code) /* #ifdef MP-WEIXIN */ - wxMnpLogin() + if(!invite_code){ + wxMnpLogin() + } + /* #endif */ }, onHide: function () { diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index bdfff27..a221165 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -27,7 +27,7 @@ - + 忘记密码? 注册 @@ -98,8 +98,8 @@ export default { // this.$refs.uForm.setRules(this.rules); }, async onLoad({ type, phone,redirec}) { - - + + this.redirec = redirec this.form.phone = phone ?? ''; /* #ifdef MP-WEIXIN */ diff --git a/src/pages/welcome/index.vue b/src/pages/welcome/index.vue index 0fffdbf..e5324d4 100644 --- a/src/pages/welcome/index.vue +++ b/src/pages/welcome/index.vue @@ -8,37 +8,23 @@ import { strToParams } from '@/utils/tools'; + import { wxMnpLogin } from '@/utils/login' export default { data() { return { - + scene:null }; }, onLoad(e) { const scene = strToParams(decodeURIComponent(e.scene)) - console.log(scene); + this.scene=scene + uni.setStorageSync('INVITE_CODE', scene.invite_code) if (scene.product) { uni.redirectTo({ url: '/pages/product_details/index?skuId=' + scene.product }) uni.setStorageSync('INVITE_CODE', scene.code) } else if (scene.order_pre) { - setTimeout(async () => { - uni.showLoading({ - title: '加载中', - mask: true - }); - const obj = { - id: scene.order_pre - } - const { - order_id - } = await this.$api.post(`/v1/order-pre/order`, obj) - uni.hideLoading() - uni.redirectTo({ - url: '/pages/order_details/index?id=' + order_id - }) - }, 1000) }else if(scene.invite_code){ uni.redirectTo({ url: '/pages/index/index' @@ -46,6 +32,33 @@ uni.setStorageSync('INVITE_CODE', scene.invite_code) } }, + onShow() { + if(this.scene.order_pre){ + this.getOrder(this.scene.order_pre) + } + }, + methods:{ + //生成订单 + async getOrder(id){ + try{ + const obj = { + id:id + } + const {order_id}=await this.$api.post(`/v1/order-pre/order`,obj,{ + custom:{ + silence:true + } + }) + uni.redirectTo({ + url: '/pages/order_details/index?id=' + order_id + }) + }catch(err){ + if(err.errcode==401){ + uni.navigateTo({ url: '/pages/login/index' }) + } + } + } + } }