126 lines
2.7 KiB
JavaScript
126 lines
2.7 KiB
JavaScript
var app = getApp();
|
|
// var Notify = require('../../../../dist/notify/index')
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
Num: '', // 发放数量
|
|
id: '', // 优惠券ID
|
|
Text: '', // 文本框内容
|
|
result: '1' // 选择的发放对象
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
id: options.id
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {},
|
|
publish() {
|
|
if (app._isTextEmpty(this.data.Num) || isNaN(this.data.Num)) {
|
|
wx.showToast({
|
|
title: '请输入发放数量,必须是整数',
|
|
icon: 'none'
|
|
});
|
|
return;
|
|
}
|
|
if (!(isNaN(this.data.result))) {
|
|
if (app._isTextEmpty(this.data.Text)) {
|
|
wx.showToast({
|
|
title: '请输入会员ID',
|
|
icon: 'none'
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
let json = {
|
|
id: this.data.id,
|
|
send_total: this.data.Num,
|
|
sendtype: this.data.result,
|
|
send_memberids: this.data.Text
|
|
};
|
|
let urlStr = app.getNetAddresss('plugin.store-cashier.frontend.store.center.coupon.send');
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: json,
|
|
success: (resdata) => {
|
|
var response = resdata.data;
|
|
if (response.result == 1) {
|
|
wx.showToast({
|
|
title: '发放成功',
|
|
icon: 'none'
|
|
});
|
|
setTimeout(() => {
|
|
wx.navigateTo({
|
|
url: '/packageB/member/commodity_coupon/commodity_coupon/commodity_coupon'
|
|
});
|
|
}, 2000);
|
|
}else if (response.result === 0) {
|
|
if (response.data.url) {
|
|
wx.navigateTo({
|
|
url: response.data.url
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: response.msg,
|
|
icon: 'none'
|
|
});
|
|
}
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
conFim(e) {
|
|
this.setData({
|
|
Text: e.detail.value
|
|
});
|
|
},
|
|
// 失去焦点
|
|
clearSrcoll(e) {
|
|
this.setData({
|
|
Num: e.detail.value
|
|
});
|
|
}
|
|
});
|