card-mini/pages/mine/order/ordersuccess.js
2021-09-01 16:55:20 +08:00

72 lines
1.8 KiB
JavaScript

// pages/mine/order/ordersuccess.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
totalPrice: 0,
shopId: '',
orderId: '',
hintMsg: '商品下单成功',
funcMsg: '查看订单详情',
type: 1, //1.商品订单 2.名片
prepayId: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
totalPrice: options.price,
shopId: options.shopId,
orderId: options.orderId,
hintMsg: options.msg,
funcMsg: options.fMsg,
type: options.type,
prepayId: options.prepayId
})
if (options.prepayId) {
this.doSaveOrderState()
}
},
//保存订单状态
doSaveOrderState() {
var _self = this
wx.showLoading({
title: '加载中...',
})
app.http.get(app.urls.doSaveOrderPayState.format({
cardChargeOrderNumber: _self.data.prepayId
}), {
header: {
token: app.globalData.token
}
})
.then(res => {
wx.hideLoading({})
})
.catch(err => {
})
},
toShowOrderDetail() {
var _self = this
if (_self.data.type == 1) {
//商品订单
wx.redirectTo({
url: './orderdetail?shopId=' + this.data.shopId + '&orderId=' + this.data.orderId,
})
} else if (_self.data.type == 2) {
//名片订单
let arr = getCurrentPages()
let lastPage = (arr.length >= 2) ? arr[arr.length - 2] : undefined
lastPage.setData({
isRefresh: true
})
wx.navigateBack({})
}
}
})