123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- const Parse = getApp().Parse
- const company = getApp().globalData.company
- const dateF = require('../../../../utils/date')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- orderId: '',
- address: null,
- goods: null,
- shipper: null,
- trackingNumber: null,
- order: null,
- companyInfo: null
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- let orderId = options.id
- console.log(orderId);
- this.setData({
- orderId: orderId
- })
- this.queryOrder(orderId)
- },
- async queryOrder(id) {
- let ShopOrder = new Parse.Query('Order')
- ShopOrder.include('goods')
- ShopOrder.include('address')
- let shopOrder = await ShopOrder.get(id)
- if (shopOrder && shopOrder.id) {
- let order = shopOrder.toJSON()
- order.orderTime = dateF.formatTime("YYYY-mm-dd HH:MM:SS", order.createdAt)
- this.setData({
- order: order,
- goods: order.goods,
- address: order.address,
- shipper: order.shipper,
- trackingNumber: order.trackingNumber
- })
- console.log(this.data.order);
- }
- },
- async getCompany() {
- let Company = new Parse.Query('Company')
- let companyInfo = await Company.get(company)
- if (companyInfo) {
- this.setData({
- companyInfo: companyInfo.toJSON()
- })
- }
- console.log(this.data.companyInfo);
- },
- //更换地址
- toAddress() {
- let { order } = this.data
- if (order.status != 200) {
- wx.showToast({
- title: '已发货物件不支持更换地址',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false,
- });
- return
- }
- wx.navigateTo({
- url: "/common-page/pages/address/index?type=1"
- })
- },
- async refund() {
- let that = this
- wx.showModal({
- title: '',
- content: '你确定要申请退款吗?',
- showCancel: true,
- cancelText: '取消',
- cancelColor: '#000000',
- confirmText: '确定',
- confirmColor: '#3CC51F',
- success: (result) => {
- if (result.confirm) {
- that.upRefund()
- }
- },
- fail: () => {},
- complete: () => {}
- });
- },
- async upRefund() {
- let { order } = this.data
- let ShopOrder = new Parse.Query("Order")
- let res = await ShopOrder.get(order.objectId)
- if (res && res.id) {
- res.set("status", '500')
- await res.save()
- wx.showToast({
- title: '已申请退款',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false,
- });
- order.status = '500'
- this.setData({
- order
- })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- this.getCompany()
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|