hookehuyr

支付组件逻辑优化调整

<!--
* @Date: 2023-12-20 14:11:11
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-12-25 07:08:02
* @LastEditTime: 2023-12-27 11:37:35
* @FilePath: /meihuaApp/src/components/payCard.vue
* @Description: 文件描述
-->
......@@ -21,12 +21,13 @@
<script setup>
import Taro from '@tarojs/taro'
import { ref, watch, onMounted, onUnmounted } from 'vue'
import { getCurrentPageUrl } from "@/utils/weapp";
/**
* 格式化时间
* @param {*} seconds
*/
function formatTime(seconds) {
function formatTime(seconds) {
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const remainingSeconds = seconds % 60;
......@@ -86,6 +87,10 @@ onMounted(() => {
// 进入页面后,开始倒计时
timeId = setInterval(() => {
remain_time.value ? remain_time.value -= 1 : 0;
if (remain_time.value === 0) { // 倒计时结束
clearInterval(timeId);
emit('close');
}
}, 1000);
})
......@@ -94,9 +99,29 @@ onUnmounted(() => {
})
const goToPay = () => {
Taro.navigateTo({
url: '/pages/payInfo/index?id=123',
// TODO:支付成功后的操作
emit('close'); // 关闭支付弹框
//
Taro.showToast({
title: '支付成功',
icon: 'success',
duration: 1000
});
setTimeout(() => {
let current_page = getCurrentPageUrl();
if (current_page === 'pages/my/index') { // 我的页面打开
// 刷新当前页面
Taro.reLaunch({
url: '/pages/my/index'
});
}
if (current_page === 'pages/detail/index') { // 订房确认页打开
// 跳转订单成功页
Taro.navigateTo({
url: '/pages/payInfo/index',
});
}
}, 1000);
// this.$parent.sdk.post('c/app/prepay', {
// id: this.params.id
// }).then(res => {
......@@ -114,9 +139,6 @@ const goToPay = () => {
// }).then(pRes => {
// if (pRes.data.ret === 'OK') {
// that.Toast('success', '感谢您的捐赠', 3000)
// wx.navigateBack({
// delta: 1
// });
// } else {
// that.Toast('fail', pRes.data.err, 3000);
// }
......