|
@@ -1,7 +1,6 @@
|
|
|
// pages/orders/order-detail.ts
|
|
|
-import drawQrcode from "../../utils/weapp.qrcode.esm";
|
|
|
-import { api_userPaymentCancelRefund, api_userPaymentOrderDetail, api_userPaymentOrderRefundPayment } from "../../api/login";
|
|
|
-import { formatPrice } from "../../utils/util";
|
|
|
+import { api_userPaymentOrderDetail } from "../../api/login";
|
|
|
+import { formatPrice, GRADE_ENUM } from "../../utils/util";
|
|
|
|
|
|
// 获取应用实例
|
|
|
Page({
|
|
@@ -46,12 +45,6 @@ Page({
|
|
|
timer: null as any,
|
|
|
goodsInfo: {} as any,
|
|
|
orderNo: "" as string,
|
|
|
- showCanvas: false, // 是否显示二维码
|
|
|
- tabIdx: 0, // 当前是从哪个tab来的
|
|
|
- canvasImg: "" as string,
|
|
|
- showService: false,
|
|
|
- refoundStatus: false,
|
|
|
- cancelRefoundStatus: false,
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -60,8 +53,7 @@ Page({
|
|
|
onLoad(options: any) {
|
|
|
if (options.orderNo) {
|
|
|
this.setData({
|
|
|
- orderNo: options.orderNo,
|
|
|
- tabIdx: options.tabIdx
|
|
|
+ orderNo: options.orderNo
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -80,21 +72,44 @@ Page({
|
|
|
goodsInfos.forEach((item: any) => {
|
|
|
tempGoods.push({
|
|
|
...item,
|
|
|
- // shortUrl: item.activationCodeInfo.shortUrl,
|
|
|
- // code: item.activationCodeInfo.activationCode,
|
|
|
- originalPrice: formatPrice(item.paymentCashAmount, 'ALL'),
|
|
|
- // typeName: this.formatPeriod(item.activationCodeInfo?.times || 1, item.activationCodeInfo.type)
|
|
|
+ // originalPrice: formatPrice(item.originalPrice, 'ALL'),
|
|
|
+ typeName: this.formatPeriod(item.activationCodeInfo?.times || 1, item.activationCodeInfo?.type)
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
+ const addresses = {
|
|
|
+ id: result.addresses?.id,
|
|
|
+ name: result.addresses?.name,
|
|
|
+ phoneNumber: result.addresses?.phoneNumber,
|
|
|
+ addressDetail: result.addresses?.detailAddress
|
|
|
+ }
|
|
|
+
|
|
|
+ const tempSchoolAddress = [result.beneficiary?.provinceName || '', result.beneficiary?.cityName || '', result.beneficiary?.regionName || '', result.beneficiary?.schoolAreaName, GRADE_ENUM[result.beneficiary?.currentGradeNum], result.beneficiary?.currentClass + '班']
|
|
|
+ const beneficiary = {
|
|
|
+ id: result.beneficiary?.schoolAreaId,
|
|
|
+ name: result.beneficiary?.name,
|
|
|
+ phoneNumber: result.beneficiary?.phone,
|
|
|
+ schoolInfo: tempSchoolAddress.join('')
|
|
|
+ }
|
|
|
+
|
|
|
+ const allDiscountPrice: any = formatPrice(result.originalPrice - result.paymentCashAmount)
|
|
|
+ const allAfterPrice: any = formatPrice(result.paymentCashAmount)
|
|
|
|
|
|
- const firstGoods = tempGoods[0]
|
|
|
const goodsInfo = {
|
|
|
+ discountIntegerPart: allDiscountPrice.integerPart,
|
|
|
+ discountDecimalPart: allDiscountPrice.decimalPart,
|
|
|
+ paymentCashAmount: result.paymentCashAmount,
|
|
|
+ originalPrice: result.originalPrice,
|
|
|
+ integerPart: allAfterPrice.integerPart,
|
|
|
+ decimalPart: allAfterPrice.decimalPart,
|
|
|
orderNo: result.orderNo,
|
|
|
createTime: result.createTime,
|
|
|
wechatStatus: result.wechatStatus,
|
|
|
goods: tempGoods,
|
|
|
- code: firstGoods.code || ''
|
|
|
+ addresses,
|
|
|
+ beneficiary
|
|
|
}
|
|
|
+ console.log(goodsInfos, "goodsInfo")
|
|
|
this.setData({
|
|
|
goodsInfo,
|
|
|
status: result.wechatStatus
|
|
@@ -128,78 +143,24 @@ Page({
|
|
|
},
|
|
|
onTimeout() {
|
|
|
// 轮询10次查询订单状态
|
|
|
- const goodsInfo = this.data.goodsInfo
|
|
|
- const timerCount = this.data.timerCount
|
|
|
- const timer = this.data.timer
|
|
|
- if(goodsInfo.wechatStatus === 'WAIT_PAY' && timerCount <= 10) {
|
|
|
- let count = timerCount
|
|
|
- const tempT = setTimeout(async () => {
|
|
|
- count += 1
|
|
|
- await this.getDetail()
|
|
|
- this.setData({
|
|
|
- timer: tempT,
|
|
|
- timerCount: count
|
|
|
- }, () => {
|
|
|
- this.onTimeout()
|
|
|
- })
|
|
|
- }, 3000);
|
|
|
- } else {
|
|
|
- clearTimeout(timer)
|
|
|
- }
|
|
|
- },
|
|
|
- /** 客服 */
|
|
|
- onService() {
|
|
|
- this.setData({
|
|
|
- showService: true
|
|
|
- })
|
|
|
- },
|
|
|
- changePop(event: { detail: any }) {
|
|
|
- this.setData({
|
|
|
- showService: event.detail
|
|
|
- })
|
|
|
- },
|
|
|
- /** 申请退款 */
|
|
|
- async cancelRefound() {
|
|
|
- this.setData({
|
|
|
- cancelRefoundStatus: true
|
|
|
- }, async () => {
|
|
|
- try {
|
|
|
- const {data} = await api_userPaymentCancelRefund(this.data.goodsInfo.refundOrderId)
|
|
|
- // console.log(data, 'data')
|
|
|
- if(data.code == 200) {
|
|
|
- wx.showToast({ title: '取消退款成功', icon: 'none' })
|
|
|
- this.getDetail()
|
|
|
- } else {
|
|
|
- wx.showToast({ title: data.message, icon: 'none' })
|
|
|
- }
|
|
|
- setTimeout(() => {
|
|
|
- this.setData({
|
|
|
- cancelRefoundStatus: false
|
|
|
- })
|
|
|
- }, 500);
|
|
|
- } catch {}
|
|
|
- })
|
|
|
-
|
|
|
- },
|
|
|
- /** 申请退款 */
|
|
|
- useRefound() {
|
|
|
- this.setData({
|
|
|
- refoundStatus: true
|
|
|
- })
|
|
|
- },
|
|
|
- changeRefoundStatus(e: {detail: any}) {
|
|
|
- this.setData({
|
|
|
- refoundStatus: e.detail
|
|
|
- })
|
|
|
- },
|
|
|
- onRefoundComfirm() {
|
|
|
- this.setData({
|
|
|
- refoundStatus: false
|
|
|
- })
|
|
|
- // wx.navigateBack({
|
|
|
- // delta: 1
|
|
|
- // })
|
|
|
- this.getDetail()
|
|
|
+ // const goodsInfo = this.data.goodsInfo
|
|
|
+ // const timerCount = this.data.timerCount
|
|
|
+ // const timer = this.data.timer
|
|
|
+ // if(goodsInfo.wechatStatus === 'WAIT_PAY' && timerCount <= 10) {
|
|
|
+ // let count = timerCount
|
|
|
+ // const tempT = setTimeout(async () => {
|
|
|
+ // count += 1
|
|
|
+ // await this.getDetail()
|
|
|
+ // this.setData({
|
|
|
+ // timer: tempT,
|
|
|
+ // timerCount: count
|
|
|
+ // }, () => {
|
|
|
+ // this.onTimeout()
|
|
|
+ // })
|
|
|
+ // }, 3000);
|
|
|
+ // } else {
|
|
|
+ // clearTimeout(timer)
|
|
|
+ // }
|
|
|
},
|
|
|
onCopy(e: { currentTarget: any }) {
|
|
|
wx.setClipboardData({
|
|
@@ -212,36 +173,6 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- onActivation(e: { currentTarget: any }) {
|
|
|
- const code = e.currentTarget.dataset.code || ''
|
|
|
- if(!code) {
|
|
|
- wx.showToast({
|
|
|
- title: '暂无法激活',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- wx.navigateTo({
|
|
|
- url: '../protocol/register?type=activation&code=' + code
|
|
|
- })
|
|
|
- },
|
|
|
- onDownload() {
|
|
|
- wx.saveImageToPhotosAlbum({
|
|
|
- filePath: this.data.canvasImg,
|
|
|
- success: () => {
|
|
|
- wx.showToast({
|
|
|
- title: '保存成功',
|
|
|
- icon: 'success',
|
|
|
- });
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- wx.showToast({
|
|
|
- title: '保存失败',
|
|
|
- icon: 'none',
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
onShareAppMessage() {
|
|
|
return {
|
|
|
title: '器乐数字AI工具',
|