// pages/orderDetailsProject/orderDetailsProject.js import { get, post } from '../../utils/http' import { trackUserEvent } from '../../utils/util' const app = getApp() Page({ /** * 页面的初始数据 */ data: { orderDetailsId: '', orderDetails: '', storeDataid: '' }, onCopy: function (e) { let content = e.currentTarget.dataset.no var that = this; wx.setClipboardData({ data: content, success: function (res) { wx.showToast({ title: '复制成功!', icon: "none" }) } }); }, /** * 取消订单 */ btmBack(e) { let that = this wx.showModal({ title: '提示', content: '是否申请退款', success(res) { if (res.confirm) { console.log('用户点击确定') post( 'v2/api/order/cancel', { id: that.data.orderDetails.id }, (res) => { wx.showToast({ title: res.msg, icon: 'success', duration: 2000 }) that.getOrderData() } ) } else if (res.cancel) { console.log('用户点击取消') } } }) }, /** * 获取订单详情 */ async getOrderData() { let resp = await get('v2/api/order/info', { id: this.data.orderDetailsId }) if (resp.code === 200) { this.setData({ orderDetails: resp.data }) } }, /** * 获取订单详情 */ productRecommend() { get('v2/api/product/recommend', { store_id:this.data.storeDataid, page: 1, limit:10 }, (res) => { this.setData({ productRecommend: res.data.list }, ) }) }, /** * 生命周期函数--监听页面加载 */ onLoad: async function (options) { this.setData({ orderDetailsId: options.id }) await this.getOrderData() let storeDataid = this.data.orderDetails.store_id let lat1 = app.address.latitude let lng1 = app.address.longitude this.setData({ storeDataid:storeDataid, lat1: lat1, lng1: lng1, }) this.productRecommend() if (options.click) { trackUserEvent(options.click) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })