旅居支付

parent bfec95e4
......@@ -327,7 +327,8 @@ import {
getItinerary,
getStoreInformation,
} from '@/api/assistingAgriculture/route';
import { groupBuyConfirm, groupBuyUpdate } from '@/api/confirmOrder';
import { sgyOrderOrderInfo } from '@/api/assistingAgriculture/shop';
import { groupBuyConfirm, groupBuyUpdate, groupBuyCreate } from '@/api/confirmOrder';
import { getCollect } from '@/api/packageDetail';
const swiperList = ref([
......@@ -362,6 +363,41 @@ watch(show, (value) => {
index = Math.min(priceList.value.length - 3, index);
viewPriceList.value = priceList.value.slice(index - 1, index + 3);
});
onShow(() => {
if (outTradeNos.value) {
// 查询订单状态决定是否支付
sgyOrderOrderInfo({ orderNumber: outTradeNos.value }).then((res) => {
switch (res.data.baseOrder.subStatus) {
case '1':
xma.showToast({
title: '支付失败',
icon: 'error',
duration: 1000,
success() {
setTimeout(() => {
xma.redirectTo({
url: `/pages/order/order?status=not_pay`,
});
}, 1500);
},
});
break;
case '2':
xma.redirectTo({
url: `/pages/order/detail?orderNumber=${outTradeNos.value}`,
});
break;
case '3':
xma.redirectTo({
url: `/pages/order/detail?orderNumber=${outTradeNos.value}`,
});
break;
default:
break;
}
});
}
});
const getWeek = (date) => {
const week = ['日', '一', '二', '三', '四', '五', '六'];
return week[new Date(date).getDay()];
......@@ -382,7 +418,7 @@ function jumpPage() {
}
function groupBuyConfirmFn(prodId, skuId) {
return new Promise((resolve, reject) => {
groupBuyConfirm({ prodId, skuId }).then((res) => {
groupBuyConfirm({ prodId, skuId, orderType: 'store' }).then((res) => {
if (res.code === 0) {
orderInfo.value = res.data;
resolve(res.data.shopId);
......@@ -417,33 +453,51 @@ function formatDate(inputDate) {
}
const payNow = async (data) => {
groupBuyConfirmFn(activeMeal.value.prodId, activeMeal.value.skuId).then((res) => {
groupBuyUpdateFnQg().then(() => {});
});
params.value.id = orderInfo.value.key;
params.value.tradeType = data.selectType;
params.value.basketIds = basketIds.value;
groupBuyUpdateFnQg().then(() => {
const qgParams = {
id: orderInfo.value.key,
placeOrderWay: 'sgy',
payWayCode: 5,
tradeType: data.selectType,
};
// groupBuyCreate(qgParams).then((res) => {
// if (res.code === 0) {
// openUrl(res.data.result);
// } else {
// groupBuyConfirmFn(prodIds.value, skuIds.value);
// }
// });
groupBuyCreate(qgParams).then((res) => {
if (res.code === 0) {
openUrl(res.data.result);
} else {
groupBuyConfirmFn(activeMeal.value.prodId, activeMeal.value.skuId);
}
});
});
});
};
function groupBuyUpdateFnQg(couponUserId = '') {
const outTradeNos = ref(null);
const openUrl = (result) => {
const { paymentUrl, outTradeNo } = result;
outTradeNos.value = outTradeNo;
window.location.href = paymentUrl;
// 设置一个延时器
const start = Date.now();
setTimeout(() => {
const end = Date.now();
if (end - start < 1200) {
// 如果 iframe 加载时间小于 1.2 秒,说明应用没有安装
xma.showToast({
title: '未安装App',
icon: 'error',
});
// 这里可以跳转到应用下载页面
}
}, 1600);
};
function groupBuyUpdateFnQg() {
return new Promise((resolve, reject) => {
groupBuyUpdate({
key: orderInfo.value.key,
receiverTime: formatDate(activePrice.value.priceDay),
receiverTime: activePrice.value.priceDay.replace(' ', '-'),
}).then((res) => {
if (res.code === 0) {
orderInfo.value = res.data;
resolve();
}
});
});
......
......@@ -10,8 +10,8 @@ import { getTokenUser } from '../../api/index';
import { getToken } from '../../utils/auth';
onLoad(async (options) => {
await signIn();
// if (!getToken()) await signIn2();
// await signIn();
if (!getToken()) await signIn2();
const { type } = options;
switch (type) {
case '0':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment