// pages/orderDetail/orderDetail.js const app = getApp() import http from "../../utils/http" import util from "../../utils/util" Page({ /** * 页面的初始数据 */ data: { info: '', settle: '', safeBottom: `30px`, }, allocation(){ util.skip('/pages/allocation/allocation?id='+this.data.info.id) }, accept(){ wx.requestSubscribeMessage({ tmplIds: [app.globalData.templateconfig.shop_order_template,app.globalData.templateconfig.shop_finish_template,app.globalData.templateconfig.shop_sales_template], complete :(res) =>{ http.post('order/shopaccept', { id: this.data.info.id }, true, false).then(res => { util.toast('抢单成功,请派单') this.getInfo() }).catch(e => { let data = e.data if(data.code === 2){ util.toast(data.msg) setTimeout(()=>{ util.skip('/service/earnestMoney/earnestMoney') },1000) }else if(data.code === 0){ util.toast(data.data) } }) } }) }, copy(event){ wx.setClipboardData({ data: event.currentTarget.dataset.content, success (res) { util.toast('已复制') } }) }, navigation(){ wx.openLocation({ latitude : Number(this.data.info.orderAddress.lat), longitude : Number(this.data.info.orderAddress.lng), name: this.data.info.orderAddress.area, scale: 18 }) }, call(event){ wx.makePhoneCall({ phoneNumber: event.currentTarget.dataset.content }) }, getInfo(){ http.post('order/orderInfo', { id: this.data.order_id }).then(res => { this.setData({ info: res.data }) if(res.data.is_settle > 0 ){ this.getSettle() } }) }, getSettle(){ http.post('order/priceInfo', { id: this.data.order_id }).then(res => { this.setData({ settle: res.data }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { const high = app.globalData.safeBottom this.setData({ safeBottom: `${high}px`, order_id: options.order_id }) }, /** * 生命周期函数--监听页面显示 */ onShow() { this.getInfo() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })