You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
4.1 KiB
JavaScript
149 lines
4.1 KiB
JavaScript
9 months ago
|
const app = getApp();
|
||
|
const util = require("../../utils/util.js")
|
||
|
const card = require('../../utils/card.js');
|
||
|
var WxParse = require('../../utils/wxParse/wxParse.js');
|
||
|
Page({
|
||
|
data: {
|
||
|
worth: 0
|
||
|
},
|
||
|
|
||
|
onLoad: function(options) {
|
||
|
this.setData({color:app.globalData.color})
|
||
|
if (options.data) {
|
||
|
var data = JSON.parse(options.data);
|
||
|
if (data.shopType == 0 || data.shopType == 1) {
|
||
|
this.setData({
|
||
|
detail: data,
|
||
|
productDetailLogUrl:app.globalData.productDetailLogUrl
|
||
|
});
|
||
|
if (data.shopType == 1) {
|
||
|
this.get_pointProductDetail(data.productid, data.schemeid);
|
||
|
} else {
|
||
|
this.setData({
|
||
|
worth: data.couponDetail.worth + " 积分 "
|
||
|
})
|
||
|
if (data.couponDetail.couponDesc) {
|
||
|
this.setData({
|
||
|
list: data.couponDetail.couponDesc.split('\n')
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
wx.showToast({
|
||
|
title: '缺少必要参数shopType系统将自动返回',
|
||
|
duration: 1800,
|
||
|
icon: "none"
|
||
|
})
|
||
|
setTimeout(function() {
|
||
|
wx.navigateBack({})
|
||
|
}, 2000)
|
||
|
}
|
||
|
} else {
|
||
|
wx.showToast({
|
||
|
title: '缺少必要参数系统将自动返回',
|
||
|
duration: 1800,
|
||
|
icon: "none"
|
||
|
})
|
||
|
setTimeout(function() {
|
||
|
wx.navigateBack({})
|
||
|
}, 2000)
|
||
|
}
|
||
|
|
||
|
},
|
||
|
get_pointProductDetail(productid, schemeid) {
|
||
|
if (productid != "" & productid != undefined & schemeid != "" & schemeid != undefined) {
|
||
|
var that = this;
|
||
|
card.queryPointProductDetail(productid, schemeid, function(success) {
|
||
|
var result = success.data;
|
||
|
if (result.status == 1) {
|
||
|
var list = result.list[0];
|
||
|
var type = list.type;
|
||
|
var worth = 0;
|
||
|
if (type == 0) {
|
||
|
worth = list.pointWorth + " 积分 ";
|
||
|
} else if (type == 1) {
|
||
|
worth = list.pointWorth + " 积分 " + list.amountWorth + " 元";
|
||
|
} else if (type == 2) {
|
||
|
worth = list.amountWorth + " 元";
|
||
|
}
|
||
|
that.setData({
|
||
|
productDetail: result.list[0],
|
||
|
worth: worth
|
||
|
})
|
||
|
var a = WxParse.wxParse('commodityAttr', 'html', result.list[0].describe, that, 3);
|
||
|
} else {
|
||
|
util.showFailureMsg(result);
|
||
|
}
|
||
|
}, function(error) {
|
||
|
console.log(err);
|
||
|
wx.showToast({
|
||
|
title: "网络连接不稳定, 请重试",
|
||
|
icon: "none"
|
||
|
})
|
||
|
})
|
||
|
} else {
|
||
|
wx.showToast({
|
||
|
title: '缺少商品参数系统将自动返回',
|
||
|
duration: 1800,
|
||
|
icon: "none"
|
||
|
})
|
||
|
setTimeout(function() {
|
||
|
wx.navigateBack({})
|
||
|
}, 2000)
|
||
|
}
|
||
|
},
|
||
|
exchange: function() {
|
||
|
this.dialog = this.selectComponent("#dialog");
|
||
|
this.dialog.show();
|
||
|
},
|
||
|
exchange_pointCoupon: function() {
|
||
|
var that=this;
|
||
|
card.exchangeCouponScheme(that.data.detail.id, function(success) {
|
||
|
var result = success.data;
|
||
|
if (result.status == 1) {
|
||
|
var shopType = that.data.detail.shopType;
|
||
|
var msg = that.data.detail.couponDetail.worth + " 积分";
|
||
|
wx.navigateTo({
|
||
|
url: 'exchangeSuccess?shopType=' + shopType + "&msg=" + msg,
|
||
|
})
|
||
|
} else {
|
||
|
util.showFailureMsg(result);
|
||
|
}
|
||
|
}, function(error) {
|
||
|
console.log(err);
|
||
|
wx.showToast({
|
||
|
title: "网络连接不稳定, 请重试",
|
||
|
icon: "none"
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
goto: function() {
|
||
|
this.dialog = this.selectComponent("#dialog");
|
||
|
this.dialog.hide();
|
||
|
},
|
||
|
cancel: function() {
|
||
|
this.dialog = this.selectComponent("#dialog");
|
||
|
this.dialog.hide();
|
||
|
var shopType = this.data.detail.shopType;
|
||
|
console.error(shopType + ".....")
|
||
|
if (shopType == 0) {
|
||
|
this.exchange_pointCoupon();
|
||
|
} else if (shopType == 1) {
|
||
|
this.goto_productSureOrder();
|
||
|
}
|
||
|
},
|
||
|
goto_productSureOrder: function() {
|
||
|
app.temData.orderPointProduct = this.data.productDetail;
|
||
|
app.temData.orderPointNum = 1;;
|
||
|
wx.navigateTo({
|
||
|
url: 'pointExchangeConfirm',
|
||
|
})
|
||
|
},
|
||
|
onShow: function() {
|
||
|
|
||
|
},
|
||
|
|
||
|
onHide: function() {
|
||
|
|
||
|
}
|
||
|
})
|