// pages/order/admin/info/info.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { loading: true, isStraumann: false, checkId: null, active: false, selectIndex: 0, orderList: [], userInfo: wx.getStorageSync('userInfo') }, /** * 生命周期函数--监听页面加载 */ async onLoad(options) { this.setData({ checkId: options.checkId, isStraumann: wx.getStorageSync('isStraumann') }) await this.initData(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, async initData() { let that = this; let { data } = await app.ajax.gets(`/admin/bxdordercheck/${this.data.checkId}`); let orderList = await Promise.all(data.data.map(async v => { v['check'] = await that.getCheckOrder(v.orderCheckId); v.bxdOrderItem = v.bxdOrderItem.map(v1 => { v1["picArr"] = v1.pic ? v1.pic.split(",") : []; return v1; }); return v; })); this.setData({ orderList: orderList, loading: false }); }, async getCheckOrder(orderCheckId) { let { data: check } = await app.ajax.gets(`/admin/bxdauditlog/getByCheckId/${orderCheckId}`); return check.data; }, activeOrder() { this.setData({ active: !this.data.active }) }, chooseOrder(e) { if (this.data.selectIndex == e.currentTarget.dataset.index) { return; } this.setData({ active: !this.data.active }) }, chooseOrderItem(e) { if (this.data.selectIndex == e.currentTarget.dataset.index) { return; } this.setData({ active: !this.data.active, selectIndex: e.currentTarget.dataset.index }) }, async approve(e) { let row = e.currentTarget.dataset.item; let data = await wx.showModal({ // title: '提示', title: `确认审核通过订单吗?`, editable: true, placeholderText: "请输入审核意见", }); if (data.cancel) { return; } await app.ajax.post({ url: "/admin/bxdordercheck/audit", data: { checkId: this.data.orderList[0].orderCheckId, checkReason: data.content, checkStatus: 1 } }); wx.showToast({ title: '审核通过成功', }); this.setData({ orderList: [], current: 0 }) setTimeout(async () => { wx.navigateBack({ delta: 1 }) // await that.initData(); }, 1000); }, async approve2(e) { let row = e.currentTarget.dataset.item; let that = this; wx.showModal({ // title: '提示', title: `确认终止订单(${this.data.orderList[0].orderCheckNumber})吗?`, editable: true, placeholderText: "请输入终止订单原因", complete: async (res) => { if (res.confirm) { if (!res.content) { wx.showToast({ title: '请填写终止订单原因!', icon: "none" }) return; } await app.ajax.post({ url: "/admin/bxdordercheck/audit", data: { checkId: that.data.orderList[0].orderCheckId, checkReason: res.content, checkStatus: 2, } }); wx.showToast({ title: '中止订单成功', }); that.setData({ orderList: [], current: 0 }) setTimeout(async () => { // await that.initData(); wx.navigateBack({ delta: 1 }) }, 1000); } } }) }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })