Compare commits

...

3 Commits

Author SHA1 Message Date
002e507aaa 【类 型】:feat
【原  因】:
【过  程】:收银台 订单超时功能 并在超时之后跳转到首页
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-12-13 16:09:42 +08:00
02e1daa419 【类 型】:feat
【原  因】:
【过  程】:新增一个 秒数格式化函数 格式化成 00:00 格式
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-12-13 16:09:04 +08:00
f4c5104fa9 【类 型】:factor
【原  因】:
【过  程】:"收银台" 页面ui重置
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-12-13 15:30:41 +08:00
5 changed files with 139 additions and 20 deletions

24
App.vue
View File

@ -3,8 +3,10 @@
// //
onLaunch: function(options) { onLaunch: function(options) {
//id id //id id
this.$store.commit('setShopId', options.query.s); // this.$store.commit('setShopId', options.query.s);
this.$store.commit('setSiteId', options.query.z); // this.$store.commit('setSiteId', options.query.z);
this.$store.commit('setShopId', '2dc23dcfecc05fb1');
this.$store.commit('setSiteId', '13');
// //
this.$store.dispatch('fetchShopCon') this.$store.dispatch('fetchShopCon')
// //
@ -55,6 +57,19 @@
float: right; float: right;
} }
.fc {
text-align: center;
}
.fr {
text-align: right;
}
.checkBox {
weight: 40rpx;
height: 40rpx;
}
.ls { .ls {
background-color: #007aff; background-color: #007aff;
} }
@ -163,14 +178,17 @@
.flex4 { .flex4 {
flex: 4; flex: 4;
} }
// //
.boxshadow { .boxshadow {
box-shadow: 0px 4rpx 4rpx rgba(0, 0, 0, 0.1); box-shadow: 0px 4rpx 4rpx rgba(0, 0, 0, 0.1);
} }
// //
.border { .border {
border: 1rpx solid $uni-border-color; border: 1rpx solid $uni-border-color;
} }
// //
.border4 { .border4 {
border: 4rpx solid $uni-border-color; border: 4rpx solid $uni-border-color;
@ -187,10 +205,12 @@
.borderno { .borderno {
border: none; border: none;
} }
// 线 // 线
.borderB { .borderB {
border-bottom: 1rpx solid $uni-border-color; border-bottom: 1rpx solid $uni-border-color;
} }
// 线 // 线
.borderBDas { .borderBDas {
border-bottom: 1rpx dashed $uni-border-color; border-bottom: 1rpx dashed $uni-border-color;

View File

@ -37,8 +37,7 @@
+{{priceDifference(sku.id) | formatPrice}} +{{priceDifference(sku.id) | formatPrice}}
</text> </text>
</view> </view>
<view class="border rad-c m-r-12" :class="isSel(sku.id)?'border-m bg-m':''" <view class="border rad-c m-r-12 checkBox" :class="isSel(sku.id)?'border-m bg-m':''">
style="width: 40rpx;height: 40rpx;">
<u-icon name="checkbox-mark" size="40rpx" color="#fff" v-if="isSel(sku.id)"></u-icon> <u-icon name="checkbox-mark" size="40rpx" color="#fff" v-if="isSel(sku.id)"></u-icon>
</view> </view>
</view> </view>

View File

@ -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',

View File

@ -6,15 +6,35 @@
<u-icon name="arrow-left" color="#fff" size="19"></u-icon> <u-icon name="arrow-left" color="#fff" size="19"></u-icon>
</view> </view>
</u-navbar> </u-navbar>
<!-- 价格 --> <!-- body -->
<view>{{fullPrice | formatPrice}}</view> <view class="flex column msb bodyBox">
<button @click="pay" type="primary" style="margin-top:200rpx;">确认支付</button> <view>
<view class="priceBox fb flex mc">¥{{fullPrice | formatPrice}}</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 mac">
<u--image src="/static/icons/wxPayLogo.svg" width="75rpx" height="60rpx" />
<view class="fz36 m-l-24">微信支付</view>
</view>
<view class="flex border rad-c border-m bg-m checkBox">
<u-icon name="checkbox-mark" size="40rpx" color="#fff"></u-icon>
</view>
</view>
</view>
<view @click="pay" class="butBox fci bg-m rad8 fb fz36 flex mc p-24 m-l-24 m-r-24">确认支付</view>
<!-- <button @click="pay" type="primary">确认支付</button> -->
</view>
</view> </view>
</template> </template>
<script> <script>
import { import {
formatPrice formatPrice,
formatSeconds
} from '@/utils/index.js' } from '@/utils/index.js'
export default { export default {
@ -22,19 +42,65 @@
return { return {
order_sn: '', // order_sn: '', //
fullPrice: 0, // fullPrice: 0, //
order_time: 0, //
countdown: '', //
timer: null, //
} }
}, },
onLoad(options) { onLoad(options) {
this.order_sn = options.order_sn; // this.$store.dispatch('fetchOrderList')
this.fullPrice = Number(options.fullPrice); // this.order_sn = options.order_sn //
this.fullPrice = Number(options.fullPrice) //
//
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)
},
computed: {
//
orderShow() {
if (this.$store.state.orderList && this.$store.state.orderList.length > 0) {
// 使 find null
return this.$store.state.orderList.find((item) => item.order_sn === this.order_sn) || null;
}
return null; // orderList null
}, },
computed(){
}, },
filters: { filters: {
formatPrice, // formatPrice, //
}, },
watch: {
'orderShow': {
handler(newVal, oldVal) {
if (newVal) {
this.order_time = Number(newVal.order_time)
}
},
deep: true
}
},
methods: { methods: {
// 00:00
formatSeconds,
// //
pay() { pay() {
uni.$u.http.post('/Api/Pay/pay', { uni.$u.http.post('/Api/Pay/pay', {
@ -82,10 +148,27 @@
} }
}); });
}, },
},
destroyed() {
//
clearInterval(this.timer) //
} }
} }
</script> </script>
<style> <style lang="scss" scoped>
.priceBox {
font-size: 72rpx;
margin-top: 140rpx;
}
.butBox {
margin-bottom: 72rpx;
}
.bodyBox {
height: calc(100vh - 176rpx);
}
</style> </style>

View File

@ -75,6 +75,23 @@ export function formatTime(value) {
return `(${period})${hour}:${minute}` return `(${period})${hour}:${minute}`
} }
/**
* 格式化秒数为 mm:ss 的格式
* @param {number} seconds 总秒数
* @returns {string} 格式化后的时间字符串
*/
export function formatSeconds(seconds) {
if (seconds < 0) return '00:00' // 如果秒数为负,则返回 00:00
let minutes = Math.floor(seconds / 60)
let remainingSeconds = seconds % 60
minutes = minutes.toString().padStart(2, '0')
remainingSeconds = remainingSeconds.toString().padStart(2, '0')
return `${minutes}:${remainingSeconds}`
}
/** /**
* 过滤价格数值 超过小数点两位得 保留两位 * 过滤价格数值 超过小数点两位得 保留两位
* @param {string} value * @param {string} value