|
@@ -1,5 +1,6 @@
|
|
// pages/orders/order-detail.ts
|
|
// pages/orders/order-detail.ts
|
|
import { api_executeOrder, api_executePayment, api_queryByParamName, api_userPaymentOrderUnpaid } from "../../api/login";
|
|
import { api_executeOrder, api_executePayment, api_queryByParamName, api_userPaymentOrderUnpaid } from "../../api/login";
|
|
|
|
+import { formatPrice } from "../../utils/util";
|
|
|
|
|
|
// 获取应用实例
|
|
// 获取应用实例
|
|
const app = getApp<IAppOption>()
|
|
const app = getApp<IAppOption>()
|
|
@@ -17,6 +18,14 @@ Page({
|
|
},
|
|
},
|
|
},
|
|
},
|
|
goodsInfo: {} as any,
|
|
goodsInfo: {} as any,
|
|
|
|
+ hasInstrument: false, // 是否有乐器
|
|
|
|
+ receiveAddress: '', // 选择的地址信息
|
|
|
|
+ receiveAddressInfo: {
|
|
|
|
+ addressDetail: '',
|
|
|
|
+ name: '',
|
|
|
|
+ phoneNumber: ''
|
|
|
|
+ },
|
|
|
|
+ userBeneficiaryId: '', // 添加购买人信息
|
|
paymentType: null as any, // 支付类型
|
|
paymentType: null as any, // 支付类型
|
|
paymentChannel: null as any,
|
|
paymentChannel: null as any,
|
|
showService: false,
|
|
showService: false,
|
|
@@ -28,11 +37,51 @@ Page({
|
|
onLoad(options: any) {
|
|
onLoad(options: any) {
|
|
this.queryPayType()
|
|
this.queryPayType()
|
|
if (options.orderInfo) {
|
|
if (options.orderInfo) {
|
|
|
|
+ console.log('goods', options)
|
|
const goods = JSON.parse(decodeURIComponent(options.orderInfo));
|
|
const goods = JSON.parse(decodeURIComponent(options.orderInfo));
|
|
- console.log(goods, 'goods')
|
|
|
|
|
|
+ console.log(goods, 'goods', options)
|
|
|
|
+ const infos = {
|
|
|
|
+ allSalePrice: 0,
|
|
|
|
+ allOriginPrice: 0,
|
|
|
|
+ allDiscountPrice: '',
|
|
|
|
+ integerPart: '',
|
|
|
|
+ decimalPart: '',
|
|
|
|
+ name: '',
|
|
|
|
+ shopId: '',
|
|
|
|
+ orderNo: options.orderNo || '',
|
|
|
|
+ goodsList: [] as any
|
|
|
|
+ }
|
|
|
|
+ // 是否有乐器
|
|
|
|
+ let hasInstrument = false
|
|
|
|
+ for (let i in goods) {
|
|
|
|
+ const item = goods[i]
|
|
|
|
+
|
|
|
|
+ if (item.goodsType === "INSTRUMENTS") {
|
|
|
|
+ hasInstrument = true
|
|
|
|
+ }
|
|
|
|
+ infos.name = infos.name ? infos.name + '+' + item.name : item.name
|
|
|
|
+ infos.shopId = item.shopId
|
|
|
|
+
|
|
|
|
+ const afterPrice: any = formatPrice(item.salePrice)
|
|
|
|
+ infos.goodsList.push({
|
|
|
|
+ ...item,
|
|
|
|
+ ...afterPrice
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ infos.allSalePrice += Number(item.salePrice)
|
|
|
|
+ infos.allOriginPrice += Number(item.originalPrice)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const allAfterPrice: any = formatPrice(infos.allSalePrice)
|
|
|
|
+ // console.log(infos.allOriginPrice, infos.allSalePrice)
|
|
|
|
+ infos.allDiscountPrice = formatPrice(infos.allOriginPrice - infos.allSalePrice, 'ALL') as string
|
|
|
|
+ infos.integerPart = allAfterPrice.integerPart
|
|
|
|
+ infos.decimalPart = allAfterPrice.decimalPart
|
|
|
|
+ // console.log(infos, 'infos')
|
|
this.setData({
|
|
this.setData({
|
|
- goodsInfo: goods,
|
|
|
|
- status: goods.status
|
|
|
|
|
|
+ goodsInfo: infos,
|
|
|
|
+ status: options.status || '',
|
|
|
|
+ hasInstrument
|
|
});
|
|
});
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -54,6 +103,12 @@ Page({
|
|
console.log(error, "error");
|
|
console.log(error, "error");
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ /** 添加收货地址 */
|
|
|
|
+ onSelectAddress() {
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: `../address/index`,
|
|
|
|
+ })
|
|
|
|
+ },
|
|
onPayError(message?: string) {
|
|
onPayError(message?: string) {
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
wx.showToast({
|
|
wx.showToast({
|
|
@@ -69,8 +124,8 @@ Page({
|
|
});
|
|
});
|
|
try {
|
|
try {
|
|
const { salePrice, shopId, name, id, orderNo } = this.data.goodsInfo
|
|
const { salePrice, shopId, name, id, orderNo } = this.data.goodsInfo
|
|
- if(orderNo) {
|
|
|
|
- const {data} = await api_userPaymentOrderUnpaid({
|
|
|
|
|
|
+ if (orderNo) {
|
|
|
|
+ const { data } = await api_userPaymentOrderUnpaid({
|
|
orderNo: orderNo,
|
|
orderNo: orderNo,
|
|
paymentType: 'WECHAT_MINI'
|
|
paymentType: 'WECHAT_MINI'
|
|
})
|
|
})
|
|
@@ -101,7 +156,7 @@ Page({
|
|
if (data.code === 200) {
|
|
if (data.code === 200) {
|
|
const { paymentConfig, paymentType, orderNo } = data.data
|
|
const { paymentConfig, paymentType, orderNo } = data.data
|
|
this.onExecutePay(paymentConfig, paymentType, orderNo)
|
|
this.onExecutePay(paymentConfig, paymentType, orderNo)
|
|
- } else if(data.code === 5200) {
|
|
|
|
|
|
+ } else if (data.code === 5200) {
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
wx.showToast({
|
|
wx.showToast({
|
|
title: data.message,
|
|
title: data.message,
|
|
@@ -115,7 +170,7 @@ Page({
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- async onExecutePay( paymentConfig: any, paymentType: string, orderNo: string) {
|
|
|
|
|
|
+ async onExecutePay(paymentConfig: any, paymentType: string, orderNo: string) {
|
|
wx.login({
|
|
wx.login({
|
|
success: async (wxres: any) => {
|
|
success: async (wxres: any) => {
|
|
const res = await api_executePayment({
|
|
const res = await api_executePayment({
|
|
@@ -129,7 +184,7 @@ Page({
|
|
// wxPubAppId: 'wxbde13f59d40cb4f2'
|
|
// wxPubAppId: 'wxbde13f59d40cb4f2'
|
|
})
|
|
})
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
- if(res.data.code === 200) {
|
|
|
|
|
|
+ if (res.data.code === 200) {
|
|
this.onPay(paymentType, res.data.data.reqParams, orderNo)
|
|
this.onPay(paymentType, res.data.data.reqParams, orderNo)
|
|
} else {
|
|
} else {
|
|
this.onPayError(res.data.message)
|
|
this.onPayError(res.data.message)
|