fix: 优化提交订单页面js警告,充值订单跳转bug以及其他bug。refactor: 重构地址选择

This commit is contained in:
黄少君
2024-03-05 12:16:58 +08:00
parent 3fc1284094
commit a9533e2d7f
18 changed files with 553 additions and 671 deletions

View File

@ -9,7 +9,7 @@
import { useRouter } from "@/hooks/useRouter";
import { computed, nextTick, ref, unref } from "vue";
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
import {checkPay, orderInfo} from "@/api/order";
import { checkPay, checkRecharge, orderInfo } from "@/api/order";
import { CacheKey } from "@/utils/config";
import Header from '@/components/Header/index.vue'
import Recommend from '@/components/Recommend/index.vue'
@ -47,7 +47,7 @@ const retryTime = ref(3) // 重试次数
* 查询服务端支付状态
*/
async function queryOrderStatus() {
loading({title: '查询中...'})
loading?.({title: '查询中...'})
// 异步去查,有可能接口比微信快
setTimeout(async () => {
try {
@ -57,36 +57,62 @@ async function queryOrderStatus() {
return orderType.value === 2 ? toMyBalance() : toOrderList(0)
}
const parse = JSON.parse(payInfoStr);
if(parse.options && parse.options.isGroup){
campaignType.value = 1
}
const res = await checkPay({
...parse.payData,
uni:parse.payData.orderId || ''
});
if (!res) {
// 支付失败重新查询
if (retryTime.value > 0) {
retryTime.value--
await queryOrderStatus()
// 商品
if (orderType.value === 1) {
if (parse.options && parse.options.isGroup) {
campaignType.value = 1
}
const res = await checkPay({
...parse.payData,
uni: parse.payData.orderId || ''
});
if (!res) {
// 支付失败重新查询
if (retryTime.value > 0) {
retryTime.value--
await queryOrderStatus()
} else {
type.value = 2
uni.removeStorageSync(CacheKey.PAY_INFO)
}
return
} else {
type.value = 2
type.value = 1
uni.removeStorageSync(CacheKey.PAY_INFO)
}
return
}
// todo 查询订单详情
if(parse.options && parse.options.isGroup){
const order = await orderInfo({key:parse.payData.orderId})
if(order && order._status._type === '8'){
campaignType.value=4
// 平团
if (parse.options && parse.options.isGroup) {
const order = await orderInfo({key: parse.payData.orderId})
if (order && order._status._type === '8') {
campaignType.value = 4
}
}
console.log(campaignType.value)
}
type.value = 1
if (orderType.value === 2) {
const res = await checkRecharge({
id: parse.payData.orderId
})
console.log(res)
if (Number(res) === 0) {
// 支付失败重新查询
if (retryTime.value > 0) {
retryTime.value--
await queryOrderStatus()
} else {
type.value = 2
uni.removeStorageSync(CacheKey.PAY_INFO)
}
} else {
type.value = 1
uni.removeStorageSync(CacheKey.PAY_INFO)
}
}
} catch (e) {
retryTime.value = 0
type.value = 2
uni.removeStorageSync(CacheKey.PAY_INFO)
} finally {
hideLoading()
hideLoading?.()
}
}, 500)
}
@ -98,15 +124,15 @@ async function queryOrderStatus() {
*/
function toOrderList(status) {
// 支付成功才走
if(type.value===1){
if(campaignType.value === 1){
if (type.value === 1) {
if (campaignType.value === 1) {
status = 5
}
if(campaignType.value === 4){
status=1
if (campaignType.value === 4) {
status = 1
}
}
push({url: '/pages/orderList/orderList'}, {data: {type:status}, type: 'reLaunch'})
push({url: '/pages/orderList/orderList'}, {data: {type: status}, type: 'reLaunch'})
}
function toMyBalance() {
@ -129,8 +155,12 @@ onReachBottom(() => {
const orderType = ref(1) // 1商品 2充值
onLoad(async (options) => {
if (options.details) {
options = getParams?.(options)
}
console.log(options)
// type
orderType.value = options.type
orderType.value = Number(options.type) || 1
// const params = getParams(options)
// campaignType.value = params.campaignType
// H5 和 APP 需要弹窗去确认
@ -177,14 +207,14 @@ onLoad(async (options) => {
text="查询中..." />
</view>
<view class="button-group flex flex-ai__center flex-jc__center">
<view
class="animation-button button white-button"
v-if="Number(type)===1"
@click="toBackHome"
>
继续逛逛
</view>
<template v-if="orderType !== 1">
<template v-if="orderType === 1">
<view
class="animation-button button white-button"
v-if="Number(type)===1"
@click="toBackHome"
>
继续逛逛
</view>
<view
class="animation-button button"
v-if="Number(type)===1"