173 lines
3.3 KiB
JavaScript
173 lines
3.3 KiB
JavaScript
// packageH/cpsDetail/cpsDetail.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
id: '',
|
|
num: 1,
|
|
info: {},
|
|
has_one_share: ''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if (options.id) {
|
|
this.setData({
|
|
id: options.id
|
|
});
|
|
}
|
|
let language = wx.getStorageSync('langIndex');
|
|
this.setData({
|
|
'language': language.en
|
|
});
|
|
this.getdata();
|
|
},
|
|
goHome() {
|
|
wx.navigateTo({
|
|
url: '/packageG/index/index',
|
|
});
|
|
},
|
|
goOrder() {
|
|
wx.navigateTo({
|
|
url: '/packageA/member/myOrder_v2/myOrder_v2?status=0',
|
|
});
|
|
},
|
|
cut(e) {
|
|
if (this.data.num == 1) {
|
|
wx.showToast({
|
|
title: '购买数量最小为1',
|
|
icon: 'none',
|
|
duration: 1000
|
|
});
|
|
return;
|
|
}
|
|
this.setData({
|
|
num: Number(this.data.num) - 1
|
|
});
|
|
},
|
|
add(e) {
|
|
this.setData({
|
|
num: Number(this.data.num) + 1
|
|
});
|
|
},
|
|
submit(){
|
|
let that = this;
|
|
if(that.data.info.type == '1'){
|
|
if(that.num > 1){
|
|
wx.showToast({
|
|
title: '直冲只支持单个购买',
|
|
icon:'none',
|
|
duration:1000
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
if(that.data.info.status == '2'){
|
|
wx.showToast({
|
|
title: '商品已售罄',
|
|
icon:'none',
|
|
duration:1000
|
|
});
|
|
return;
|
|
}
|
|
wx.navigateTo({
|
|
url: '/packageD/buy/myOrder_v2/myOrder_v2?tag=-2'+`&goodsId=${that.data.info.goods_id}&optionsId=&total=${that.data.num}&iscps=true&cpstype=`+that.data.info.type,
|
|
});
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
if(this.data.has_one_share) {
|
|
var value = wx.getStorageSync("yz_uid");
|
|
var mid = "";
|
|
if (value) {
|
|
mid = value;
|
|
}
|
|
return {
|
|
path: "/packageH/cpsDetail/cpsDetail?id=" + this.data.id + "&mid=" + mid,
|
|
title: this.data.has_one_share.share_desc,
|
|
imageUrl: this.data.has_one_share.share_thumb,
|
|
};
|
|
}
|
|
},
|
|
getdata() {
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
});
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss('plugin.aggregation-cps.api.equity.goods-detail');
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
id: that.data.id
|
|
},
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
wx.hideLoading();
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
info: res.data,
|
|
has_one_share: res.data.has_one_share
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
duration: 1000,
|
|
icon: 'none'
|
|
});
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.msg);
|
|
}
|
|
});
|
|
},
|
|
}); |