6
0
Fork 0
hui.zhou
panliang 2022-06-10 13:05:03 +08:00
parent 77b80fe18b
commit 4bc06cd1a6
2 changed files with 23 additions and 12 deletions

View File

@ -382,6 +382,9 @@ export default {
isFirstLoading: true, isFirstLoading: true,
isNull: false, isNull: false,
loading: false, loading: false,
// SPU-ID
productId: '',
// SKU-ID
skuId: '', skuId: '',
number: 1, number: 1,
products: {}, products: {},
@ -478,11 +481,11 @@ export default {
return price return price
} }
}, },
onLoad({ skuId, showShrough }) { onLoad({ productId, showShrough }) {
if (showShrough) { if (showShrough) {
this.showShrough = showShrough; this.showShrough = showShrough;
} }
this.skuId = skuId; this.productId = productId;
this.getProducts(); this.getProducts();
this.$store.dispatch('goods/getCartList'); this.$store.dispatch('goods/getCartList');
}, },
@ -495,7 +498,7 @@ export default {
let code = this.user.code ? this.user.code : ''; let code = this.user.code ? this.user.code : '';
let shareObj = { let shareObj = {
title: this.detail.name, 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, imageUrl: this.detail.cover,
}; };
return shareObj; return shareObj;
@ -604,8 +607,9 @@ export default {
async getProducts() { async getProducts() {
try { try {
this.loading = true; 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.products = resData;
this.skuId = this.products?.id
if (resData?.sku?.is_bargaing) { if (resData?.sku?.is_bargaing) {
this.bargainOrderLog(); this.bargainOrderLog();
@ -649,7 +653,7 @@ export default {
this.loading = true; this.loading = true;
const resData = await this.$api.get(`/v1/product/sku/${this.skuId}`); const resData = await this.$api.get(`/v1/product/sku/${this.skuId}`);
this.products = resData; this.products = resData;
if (resData?.sku?.is_bargaing) { if (resData?.sku?.is_bargaing) {
this.bargainOrderLog(); this.bargainOrderLog();
} }

View File

@ -17,12 +17,20 @@
onLoad(e) { onLoad(e) {
const scene = strToParams(decodeURIComponent(e.scene)) const scene = strToParams(decodeURIComponent(e.scene))
console.log(scene); console.log(scene);
// invite_code
if (scene.invite_code) {
uni.setStorageSync('INVITE_CODE', scene.invite_code)
}
//
if (scene.product) { if (scene.product) {
uni.redirectTo({ uni.redirectTo({
url: '/pages/product_details/index?skuId=' + scene.product url: '/pages/product_details/index?skuId=' + scene.product
}) })
uni.setStorageSync('INVITE_CODE', scene.code) }
} else if (scene.order_pre) { //
else if (scene.order_pre) {
setTimeout(async () => { setTimeout(async () => {
uni.showLoading({ uni.showLoading({
title: '加载中', title: '加载中',
@ -31,19 +39,18 @@
const obj = { const obj = {
id: scene.order_pre id: scene.order_pre
} }
const { const { order_id } = await this.$api.post(`/v1/order-pre/order`, obj)
order_id
} = await this.$api.post(`/v1/order-pre/order`, obj)
uni.hideLoading() uni.hideLoading()
uni.redirectTo({ uni.redirectTo({
url: '/pages/order_details/index?id=' + order_id url: '/pages/order_details/index?id=' + order_id
}) })
}, 1000) }, 1000)
}else if(scene.invite_code){ }
//
else {
uni.redirectTo({ uni.redirectTo({
url: '/pages/index/index' url: '/pages/index/index'
}) })
uni.setStorageSync('INVITE_CODE', scene.invite_code)
} }
}, },
} }