const app = getApp() var util = require('../../utils/util.js'); var api = require('../../utils/service-api.js'); Page({ /** * 页面的初始数据 */ data: { model: 0, userName: "", tel: "", accept:"" }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { console.log(options); var _this = this; var serviceOrder = util.getOutStorage("serviceOrder"); if (options.model == 0) { //新建订单场景 serviceOrder.vipName = app.userInfo.nickName; serviceOrder.tel = app.userInfo.phoneNumber; debugger if (!serviceOrder.staffInfo) { serviceOrder.staffInfo = { staffName: "到店安排" } } this.setData({ model: options.model, serviceOrder: serviceOrder }) } else if (options.model == 1 || options.model == 2 ) { //查看已有订单 util.request({ api: api.yuyue.getServiceOrderById + options.id, callback: function(data) { serviceOrder = data.mapInfo.serviceOrder; if (!util.isNotBlank(serviceOrder.staffInfo) || !util.isNotBlank(serviceOrder.staffInfo.staffName)) { serviceOrder.staffInfo = { staffName: "到店安排" } } _this.setData({ model: options.model, serviceOrder: serviceOrder }) } }); } }, cancel: function() { console.log("cancel"); var _this = this; wx.showModal({ title: '提示', content: '确定要取消吗?', success: function(sm) { if (sm.confirm) { var id = _this.data.serviceOrder.id; util.request({ api: api.yuyue.cancelOrderById, data: { id: id }, callback: function(data) { wx.showToast({ title: '取消成功', success: function() { wx.navigateBack({}); } }) } }); } } }) }, backKhyuyue: function() { if (this.data.model == 0 || this.data.model == 1 ){ wx.switchTab({ url: '/pages/yuyue/khyuyue' }) } else if (this.data.model == 2){ wx.navigateBack({ }) } }, shouquan(){ var _this=this; //TODO 去后台查询这个通知的id不要写死 wx.requestSubscribeMessage({ tmplIds: ['aNQKkJkNHZzUOwo2skrlfiw4qBZxkPgtNuPQ0dC5-DU'], success(res) { console.log("同意授权"); _this.setData({ "accept": 'aNQKkJkNHZzUOwo2skrlfiw4qBZxkPgtNuPQ0dC5-DU' }); }, fail: function (res) { console.log(res); } }) }, submitYuyue: function(e) { var vipName = e.detail.value.vipName; var tel = e.detail.value.tel; var remark = e.detail.value.remark; var orderService = this.data.serviceOrder; var orderInfo = { shopId: orderService.shopInfo.id, staffId: orderService.staffInfo.suId, productId: orderService.shopProduct.id, vipName: vipName, tel: tel, remark: remark, timeStr: orderService.time, formId: this.data.accept } debugger util.request({ api: api.yuyue.createServiceOrder, data: orderInfo, callback: function (data) { var id = data.rows[0].id; wx.redirectTo({ url: '/pages/yuyue/yySuccess?id=' + id, }) } }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })