分享朋友圈调整

This commit is contained in:
唐明明
2023-09-14 09:25:37 +08:00
parent 510cbeb181
commit 0dcf23bfde
43 changed files with 458 additions and 219 deletions

View File

@@ -32,8 +32,8 @@ Page({
onLoad(options) {
this.setData({
goodsId: options.id,
invite : options.invite || ''
})
getApp().globalData.invite = options.invite || ''
},
/**
@@ -44,27 +44,95 @@ Page({
this.goodsInfo();
},
/**
* 输入产品数量
*/
goodsNumberInput(e){
let inventory = this.data.selectSkusValues.stock
if(inventory < e.detail.value ){
wx.showToast({
title: '超出库存数量',
icon : 'none',
})
this.setData({
qtyNumber: Math.min(inventory, e.detail.value)
})
return
}
this.setData({
qtyNumber: e.detail.value
})
},
/**
* 离开产品数量
*/
goodsNumberBlur(e){
let { value } = e.detail
if(value == '' || value <= 0){
this.setData({
qtyNumber: 1
})
}
},
/**
* 商品详情
*/
goodsInfo() {
// 因分享朋友圈启动时未挂载全局接口方法,故这里只能使用微信原生方法
wx.showLoading({
title: '加载中...',
mask : true
})
wx.$api.mall.goodsSee(this.data.goodsId).then(res => {
this.setData({
goodsData : res.data,
mallContent : res.data.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
skus : res.data.skus,
skuid : res.data.skus[0].sku_id,
selectSkusValues: res.data.skus[0],
specselect : res.data.skus[0].unit.split('|'),
invite : res.data.invite
})
}).catch(err =>{}).finally(() => {
wx.hideLoading()
wx.request({
url : 'https://api.xhtest.douhuofalv.com/api/mall/goods/' + this.data.goodsId,
header : {
"Accept" : "application/json",
"channel" : "client",
"Authorization" : wx.getStorageSync("token") || ""
},
success: res => {
wx.hideLoading()
let { statusCode, data } = res
if(statusCode == 200){
let dataOBJ = data.data
this.setData({
goodsData : dataOBJ,
mallContent : dataOBJ.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
skus : dataOBJ.skus,
skuid : dataOBJ.skus[0].sku_id,
selectSkusValues: dataOBJ.skus[0],
specselect : dataOBJ.skus[0].unit.split('|'),
invite : dataOBJ.invite
})
return
}
wx.showToast({
title: data.message,
icon : 'none'
})
},
fail: err => {
wx.showToast({
title: err.errMsg,
icon : 'none'
})
}
})
// wx.$api.mall.goodsSee(this.data.goodsId).then(res => {
// this.setData({
// goodsData : res.data,
// mallContent : res.data.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
// skus : res.data.skus,
// skuid : res.data.skus[0].sku_id,
// selectSkusValues: res.data.skus[0],
// specselect : res.data.skus[0].unit.split('|'),
// invite : res.data.invite
// })
// }).catch(err =>{
// console.log(err)
// }).finally(() => {
// wx.hideLoading()
// })
},
/**
@@ -185,11 +253,11 @@ Page({
} = this.data.selectSkusValues;
if (stock > 0) {
this.setData({
skuid: sku_id,
goodsSize: false
skuid : sku_id,
goodsSize : false
})
wx.navigateTo({
url: '/pages/mall/confirm/confirm?skuId=' + sku_id + '&qty=' + this.data.qtyNumber
url: '/pages/mall/confirm/confirm?skuId=' + sku_id + '&qty=' + this.data.qtyNumber || 1
})
} else {
uni.showToast({
@@ -270,7 +338,7 @@ Page({
onShareTimeline(){
return{
title : this.data.goodsData.name,
query : '/pages/mall/details/details?id=' + this.data.goodsId + '&invite=' + this.data.invite,
query : 'id=' + this.data.goodsId + '&invite=' + this.data.invite,
imageUrl : this.data.goodsData.cover
}
}