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.

94 lines
2.1 KiB
JavaScript

var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
map: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log(options);
var map = JSON.parse(options.json);
this.setData({
map: map,
imgurl: map.coverLogo,
title: map.title,
sendOutNum: map.sendOutNum,
startDate: map.startDate,
endDate: map.endDate,
worth: map.worth,
});
},
cy_startexchange: function() {
var that = this;
wx.showModal({
title: '提示',
content: '确认进行积分兑换',
success: function(res) {
if (res.confirm == true) {
console.log(res);
that.cy_leadCoupon();
}
}
})
},
/**
*
*/
cy_leadCoupon: function(e) {
wx.showLoading({
title: '处理中...',
})
var that = this;
var params = {
"method": "elec.coupon.exchange",
"schemeId": this.data.map.id,
"memberId": app.memberId,
"number": 1,
"shopNo": app.shopNo,
"posNo": app.posNo,
"workerNo": app.workerNo,
"sourceSign": app.sourceSign
};
console.log(params);
var ignores = [];
app.jsapi.memberApi(app.globalData.appMemberKey, app.globalData.appMemberSecret, app.globalData.serverMemberUrl).ajax(params, ignores,
function(json) {
console.log(json);
var result = json.data;
if (result.status == 1) {
wx.hideLoading();
wx.showModal({
title: '兑换成功',
content: '积分商品兑换成功',
success: function(res) {
if (res.errMsg == "showModal:ok") {
wx.navigateBack({
});
}
}
})
} else {
wx.hideLoading();
wx.showModal({
title: '提示',
content: result.errMessage,
})
}
},
function(error) {
wx.showModal({
title: '提示',
content: "积分兑换失败",
})
}
);
}
})