【类 型】:feat
【原 因】: 【过 程】:收银台 订单超时功能 并在超时之后跳转到首页 【影 响】: # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
02e1daa419
commit
002e507aaa
@ -188,7 +188,7 @@
|
|||||||
//跳转到支付页面
|
//跳转到支付页面
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/shop/pay?order_sn=${res.data.order_sn}&fullPrice=${fullPrice}`
|
url: `/pages/shop/pay?order_sn=${res.data.order_sn}&fullPrice=${fullPrice}`
|
||||||
});
|
})
|
||||||
} else if (res.data.status === -1) {
|
} else if (res.data.status === -1) {
|
||||||
uni.removeStorage({ //清除用户信息 跳转首页
|
uni.removeStorage({ //清除用户信息 跳转首页
|
||||||
key: 'userInfo',
|
key: 'userInfo',
|
||||||
|
@ -10,7 +10,10 @@
|
|||||||
<view class="flex column msb bodyBox">
|
<view class="flex column msb bodyBox">
|
||||||
<view>
|
<view>
|
||||||
<view class="priceBox fb flex mc">¥{{fullPrice | formatPrice}}</view>
|
<view class="priceBox fb flex mc">¥{{fullPrice | formatPrice}}</view>
|
||||||
<view class="fcb fz24 flex mc">支付剩余时间 {{ countdown }}</view>
|
<view class="fcb fz24 flex mc">
|
||||||
|
<span class="m-r-24">支付剩余时间</span>
|
||||||
|
<span v-if="order_time!==0">{{ countdown }}</span>
|
||||||
|
</view>
|
||||||
<view class="flex msb mac rad8 bg-w m-l-24 m-r-24 m-t-24 p-24">
|
<view class="flex msb mac rad8 bg-w m-l-24 m-r-24 m-t-24 p-24">
|
||||||
<view class="flex mac">
|
<view class="flex mac">
|
||||||
<u--image src="/static/icons/wxPayLogo.svg" width="75rpx" height="60rpx" />
|
<u--image src="/static/icons/wxPayLogo.svg" width="75rpx" height="60rpx" />
|
||||||
@ -30,7 +33,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
formatPrice
|
formatPrice,
|
||||||
|
formatSeconds
|
||||||
} from '@/utils/index.js'
|
} from '@/utils/index.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -40,15 +44,35 @@
|
|||||||
fullPrice: 0, //总价格 包括附加费用
|
fullPrice: 0, //总价格 包括附加费用
|
||||||
order_time: 0, //订单创建时间
|
order_time: 0, //订单创建时间
|
||||||
countdown: '', // 用于显示倒计时
|
countdown: '', // 用于显示倒计时
|
||||||
timer: null ,// 存储计时器
|
timer: null, // 存储计时器
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.$store.dispatch('fetchOrderList')
|
this.$store.dispatch('fetchOrderList')
|
||||||
this.order_sn = options.order_sn // 从提交订单页面传递过来的订单号
|
this.order_sn = options.order_sn // 从提交订单页面传递过来的订单号
|
||||||
this.fullPrice = Number(options.fullPrice) // 从提交订单页面传递过来的订单号
|
this.fullPrice = Number(options.fullPrice) // 从提交订单页面传递过来的订单号
|
||||||
setInterval(() => {
|
//倒计时
|
||||||
this.countdown = Date.now() / 1000;
|
this.timer = setInterval(() => {
|
||||||
|
if (this.order_time && this.order_time > 0) {
|
||||||
|
let tempTime = this.order_time + 100 - Math.floor(Date.now() / 1000)
|
||||||
|
if (tempTime <= 0) {
|
||||||
|
this.countdown = '00:00'
|
||||||
|
clearInterval(this.timer) // 清除定时器
|
||||||
|
// 倒计时结束后跳转到首页
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/index/index' // 非 Tab 页的路径
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.countdown = this.formatSeconds(tempTime)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.countdown = '00:00'
|
||||||
|
clearInterval(this.timer) // 清除定时器
|
||||||
|
// 如果没有有效的 order_time,也跳转到首页
|
||||||
|
uni.switchTab({
|
||||||
|
url: '/pages/index/index' // 首页的路径
|
||||||
|
})
|
||||||
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -67,12 +91,16 @@
|
|||||||
watch: {
|
watch: {
|
||||||
'orderShow': {
|
'orderShow': {
|
||||||
handler(newVal, oldVal) {
|
handler(newVal, oldVal) {
|
||||||
this.order_time = Number(newVal.order_time)
|
if (newVal) {
|
||||||
|
this.order_time = Number(newVal.order_time)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
deep: true // 如果需要深度监视对象或数组的变化,则需要设置为true
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
//秒格式化成 00:00格式
|
||||||
|
formatSeconds,
|
||||||
// 支付方法
|
// 支付方法
|
||||||
pay() {
|
pay() {
|
||||||
uni.$u.http.post('/Api/Pay/pay', {
|
uni.$u.http.post('/Api/Pay/pay', {
|
||||||
@ -125,7 +153,7 @@
|
|||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
// 在组件销毁前清除定时器
|
// 在组件销毁前清除定时器
|
||||||
// this.clearInterval()
|
clearInterval(this.timer) // 倒计时结束后清除定时器
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -142,6 +170,5 @@
|
|||||||
|
|
||||||
.bodyBox {
|
.bodyBox {
|
||||||
height: calc(100vh - 176rpx);
|
height: calc(100vh - 176rpx);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue
Block a user