var Api = require('../../../utils/common.js'); var re = require('../../../utils/request.js'); Page({ /** * 页面的初始数据 */ data: { type:[ {value:'0',name:'所有活动'}, {value:'1',name:'指定俱乐部所有活动'}, {value:'2',name:'俱乐部指定活动'}, ], indexed:'0', startTime:'2021-06-07', endTime:'2021-06-07', array:[], index:0, circleId:'', arrays:[], indexs:0, activityId:'', couponPrice:'', couponLimit:'', couponTotal:'', personLimit:'', couponType:'0', club:true, active:true }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, bindstartTimeChange: function (e) { this.setData({ startTime: e.detail.value }) }, bindendTimeChange: function (e) { this.setData({ endTime: e.detail.value }) }, couponPriceInput:function(e){ this.setData({ couponPrice: e.detail.value }) }, couponLimitInput:function(e){ this.setData({ couponLimit: e.detail.value }) }, couponTotalInput:function(e){ this.setData({ couponTotal: e.detail.value }) }, personLimitInput:function(e){ this.setData({ personLimit: e.detail.value }) }, radioChange:function(e){ var that = this; this.setData({ couponType: that.data.type[e.detail.value].value, indexed:e.detail.value }) if (e.detail.value == '0') { this.setData({ club: true, active:true }) }else if (e.detail.value == '1') { this.setData({ club: false, active:true }) this.getClubHave(); }else { this.setData({ club: false, active:false }) this.getClubHave(); } }, getClubHave:function(){ var that = this; var header = { token:wx.getStorageSync('token'), "Content-Type": "application/x-www-form-urlencoded" }; re.request(Api.getClubHave(), '', header).then((res) => { let datas = res.data.data; console.log(datas); that.setData({ array:datas, circleId:datas[1].clubId }) that.getClubActive(datas[1].clubId); }) }, bindPickerChange: function(e) { var that = this; console.log(e) console.log(that.data.array[e.detail.value].clubId) that.setData({ index: e.detail.value, circleId:that.data.array[e.detail.value].clubId }) that.getClubActive(that.data.array[e.detail.value].clubId); }, getClubActive:function(clubId){ var that = this; var header = { token:wx.getStorageSync('token'), "Content-Type": "application/x-www-form-urlencoded" }; var postDatas = { clubId:clubId } re.request(Api.getClubActive(), postDatas, header).then((res) => { let datas = res.data.data; console.log(datas); that.setData({ arrays:datas, }) }) }, activePickerChange: function(e) { var that = this; console.log(that.data.arrays); console.log(e.detail.value); if(that.data.circleId){ that.setData({ indexs: e.detail.value, activityId:that.data.arrays[e.detail.value].activityId }) }else{ wx.showToast({ title: '请先选择俱乐部', icon: 'none', duration: 1000 }) } }, toadd:function(){ var that = this; var postData = { activityId: that.data.activityId, clubId: that.data.circleId, couponLimit: that.data.couponLimit, couponPrice: that.data.couponPrice, couponTotal: that.data.couponTotal, couponType: that.data.couponType, endTime: that.data.endTime, personLimit: that.data.personLimit, startTime: that.data.startTime, }; console.log(postData) var header = { token: wx.getStorageSync('token'), "Content-Type": "application/x-www-form-urlencoded" }; re.request(Api.addCoupon(), postData, header).then((res) => { console.log(res) wx.showToast({ title: '提交成功,等待审核', icon: 'none', duration: 1000 }) wx.navigateBack({ delta: 1 }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })