// index.js let myPro = require("../../../../utils/wxRequest.js"); let util = require("../../../../utils/util.js"); Page({ data: { begin_at: null, end_at: null, status: 1, // 1正常 0禁用 showBegin: false, showEnd: false, currentBegin: null, currentEnd: null, id: null }, onLoad: function (options) { // Do some initialize when page load. let that = this; if(options.id){ that.getDetail(options.id); that.setData({ id: options.id }); }; }, onShow: function () { // Do something when page show. let that = this; }, onReady: function () { // Do something when page ready. }, onHide: function () { // Do something when page hide. }, onUnload: function () { // Do something when page close. }, onPullDownRefresh: function () { // Do something when pull down. }, onReachBottom: function () { // Do something when page reach bottom. }, onShareAppMessage: function () { // return custom share data when user share. }, onPageScroll: function () { // Do something when page scroll }, onResize: function () { // Do something when page resize }, // 详情 getDetail(id){ let that = this; let params = { id: id }; myPro.wxRequest("store/businessHours/detail","GET",params).then(res=>{ that.setData({ begin_at: res.result.begin_at, end_at: res.result.end_at, status: res.result.status, currentBegin: res.result.begin_at, currentEnd: res.result.end_at }); }).catch(err=>{ console.log('报错信息',err); wx.showToast({ title: err, icon: "none" }) }) }, // 开店时间 beginTimeFun(){ let that = this; that.setData({ showBegin: true }) }, confirmBeginTime(event){ // console.log('开始时间',event) let that = this; that.setData({ begin_at: event.detail, showBegin: false }); }, closeBeginTimePop(){ let that = this; that.setData({ showBegin: false }) }, // 闭店时间 endTimeFun(){ let that = this; that.setData({ showEnd: true }) }, confirmEndTime(event){ // console.log('闭店时间',event) let that = this; that.setData({ end_at: event.detail, showEnd: false }) }, closeEndTimePop(){ let that = this; that.setData({ showEnd: false }) }, // 状态 onChangeStatus(event){ let that = this; that.setData({ status: event.detail }); }, // 提交 bindTijiao(){ let that = this; if(!that.data.begin_at || !that.data.end_at){ wx.showToast({ title: "请检查信息是否完整", icon: "none" }); return; }else{ let params = { begin_at: that.data.begin_at, end_at: that.data.end_at, status: that.data.status }; // 编辑 if(that.data.id){ params.id = that.data.id; myPro.wxRequest("store/businessHours/edit","POST",params).then(res=>{ wx.showToast({ title: res.msg, icon: "none" }); wx.navigateBack(); }).catch(err=>{ console.log('报错信息',err); wx.showToast({ title: err, icon: "none" }); }); }else{ // 新增 myPro.wxRequest("store/businessHours/create","POST",params).then(res=>{ wx.showToast({ title: res.msg, icon: "none" }); wx.navigateBack(); }).catch(err=>{ console.log('报错信息',err); wx.showToast({ title: err, icon: "none" }); }); } } } });