6
0
Fork 0

修改bug

hui.zhou
h30830569 2022-06-10 15:45:37 +08:00
commit fdf57f72ce
5 changed files with 40 additions and 17 deletions

View File

@ -29,13 +29,10 @@ export default {
// #endif
},
onShow(option) {
let invite_code = option.query.invite_code || strToParams(decodeURIComponent(option.query.scene)).invite_code
let invite_code = option.query.invite_code || strToParams(decodeURIComponent(option.query.scene)).invite_code||''
uni.setStorageSync('INVITE_CODE',invite_code)
/* #ifdef MP-WEIXIN */
if(!invite_code){
wxMnpLogin()
}
// wxMnpLogin(invite_code)
/* #endif */
},
onHide: function () {

View File

@ -121,7 +121,7 @@ export default {
const invite_code = uni.getStorageSync('INVITE_CODE');
// const code = await getWxCode();
if(!this.$store.getters.token){
await wxMnpLogin()
await wxMnpLogin(invite_code)
}
const params = {}
if(!!invite_code) params.inviter_code = invite_code
@ -130,6 +130,7 @@ export default {
code:code,
...params
});
//invite_code%3D1%26order_pre%3D1
await this.LOGIN(resData.token);
// await this.LOGIN('555|bZL3mr19Tpgs4jRvpKkguoH865lL2zGLa35WdU7Z')
if(!!this.redirec) this.$u.route({

View File

@ -382,6 +382,9 @@ export default {
isFirstLoading: true,
isNull: false,
loading: false,
// SPU-ID
productId: '',
// SKU-ID
skuId: '',
number: 1,
products: {},
@ -482,7 +485,7 @@ export default {
if (showShrough) {
this.showShrough = showShrough;
}
this.skuId = skuId;
this.productId = skuId;
this.getProducts();
this.$store.dispatch('goods/getCartList');
},
@ -495,7 +498,7 @@ export default {
let code = this.user.code ? this.user.code : '';
let shareObj = {
title: this.detail.name,
path: `/pages/product_details/index?skuId=${this.skuId}&invite_code=${code}`,
path: `/pages/product_details/index?product=${this.productId}&invite_code=${code}`,
imageUrl: this.detail.cover,
};
return shareObj;
@ -604,8 +607,9 @@ export default {
async getProducts() {
try {
this.loading = true;
const resData = await this.$api.get(`/v1/product/products/${this.skuId}`);
const resData = await this.$api.get(`/v1/product/products/${this.productId}`);
this.products = resData;
this.skuId = this.products?.sku.id
if (resData?.sku?.is_bargaing) {
this.bargainOrderLog();
@ -649,7 +653,7 @@ export default {
this.loading = true;
const resData = await this.$api.get(`/v1/product/sku/${this.skuId}`);
this.products = resData;
if (resData?.sku?.is_bargaing) {
this.bargainOrderLog();
}

View File

@ -18,18 +18,39 @@
onLoad(e) {
const scene = strToParams(decodeURIComponent(e.scene))
this.scene=scene
uni.setStorageSync('INVITE_CODE', scene.invite_code)
// invite_code
if (scene.invite_code) {
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) {
}else if(scene.invite_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 {
uni.redirectTo({
url: '/pages/index/index'
})
uni.setStorageSync('INVITE_CODE', scene.invite_code)
}
},
onShow() {

View File

@ -19,10 +19,10 @@ export function getWxCode() {
}
//小程序静默登录
export async function wxMnpLogin(){
export async function wxMnpLogin(invite_code){
store.commit('user/LOGOUT')
const code = await getWxCode()
const invite_code= uni.getStorageSync('INVITE_CODE')||null
invite_code=invite_code?invite_code: uni.getStorageSync('INVITE_CODE')
await silentLogin({code,invite_code})
}