wangfukang 7 months ago
parent
commit
df0569c391
  1. 143
      package1/order/orderList.vue

143
package1/order/orderList.vue

@ -166,19 +166,19 @@
</view>
</view>
<view style="height: 100rpx;border-bottom: 1px solid #F5F5F5;display: flex;line-height: 100rpx;">
<view style="flex: 1;color: #777;" v-if="item.status == 0">
待支付 <text style="font-size: 32rpx;color: red;font-weight: 700;">{{ formatTime(item.timeLeft) }}</text>
</view>
<view style="font-size: 24rpx;font-weight: 700;">
实付<text v-if="tab1Checked == 'fantuan'" style="font-size: 20rpx;color: #777;">(含包装/配送费)</text> <text
style="color: red;">¥24</text>
style="color: red;">¥{{item.totalAmount}}</text>
</view>
</view>
<view class="bottom-btn">
<view class="btn1">
<view class="btn1" v-if="orderStatus(item)" @tap="returnOrder(item)">
取消订单
</view>
<view class="btn1" v-
<view class="btn1" v-if="item.status == 5">
申请售后
</view>
<view class="btn1" v-if="item.status == 0" @tap="payAgain(item)"
style="background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));color: #000;">
去支付
</view>
@ -193,6 +193,49 @@
</view> -->
</view>
</view>
<!-- 支付弹出层 -->
<uni-popup ref="payPopup" background-color="#fff">
<view class="pay-popup" style="height: 290px;background: #fff;border-radius: 40rpx 40rpx 0 0;padding-top: 40rpx;">
<view class="content" style="height: 100%;margin-top:0">
<view class="box1">
<view
style="height: 90rpx;line-height: 90rpx;text-align: center;font-weight: 700;font-size: 30rpx;">
¥<text
style="font-size: 60rpx;">{{payData.totalAmount ? payData.totalAmount.toFixed(2) : '0.00'}}</text>
</view>
<view style="height: 40rpx;text-align: center;color: #777;">
<text v-if="payData.groupInfo && payData.orderType == 3 && payData.deliveryType == 1">配送费(均摊) {{payData.deliveryFee}} 元 </text>
<text v-if="payData.groupInfo && payData.orderType == 2 && payData.deliveryType == 1">配送费 {{payData.deliveryFee}} 元 </text>
<text v-if="payData.packageFee > 0"> 打包费 {{payData.packageFee}} 元</text>
</view>
<view style="height: 40rpx;text-align: center;color: red;" v-if="payData.groupInfo">
若拼团失败,将会为您自动退款
</view>
</view>
<view class="box1" style="display: flex;padding: 40rpx;">
<view style="flex: 1;">
<view style="height: 42rpx;line-height: 42rpx;display: flex;">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4c8e0cc311db4d38ab43e019673c4b8c.png"
alt="" style="width: 42rpx;height: 42rpx;margin-right: 20rpx;" />
<text style="font-size: 30rpx;font-weight: 700;">微信支付</text>
</view>
<view style="text-align: right;margin-left: 60rpx;color: #777;width: 146rpx;">
使用微信支付
</view>
</view>
<view style="width: 36rpx;padding-top: 20rpx;">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/02bff7edc4e04caaa1868955ff684f1f.png"
alt="" style="width: 36rpx;height: 36rpx;" />
</view>
</view>
<view class="btn" style="background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));width: 90%;height: 100rpx;border-radius: 100rpx;text-align: center;font-size: 28rpx;font-weight: 700;line-height: 100rpx;margin: 40rpx auto;" @tap="wxPayment">
确认付款
</view>
</view>
</view>
</uni-popup>
<uni-load-more :status="loadStatus" @change="onChange" />
</view>
</view>
@ -207,7 +250,7 @@
tab2Checked: 'quanbu',
totalPages: 1,
pageNum:1,
timer: null,
payData:{},
orderList:[],
searchForm:{
pageNum:1,
@ -227,72 +270,11 @@
},
onLoad(option) {
this.getOrderList()
this.startGlobalTimer()
},
onUnload() {
// 页面卸载清除定时器
if (this.timer) clearInterval(this.timer)
},
onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
},
methods: {
// 1. 开启全局定时器
startGlobalTimer() {
// 立即执行一次,避免等待1秒才显示
this.updateCountdown()
this.timer = setInterval(() => {
this.updateCountdown()
}, 1000)
},
// 2. 核心逻辑:计算每条数据的剩余时间
updateCountdown() {
const now = new Date().getTime()
this.orderList.forEach(item => {
const reg = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/
const match = item.createTime.match(reg)
if (match) {
// 2. 手动构造时间 (注意:月份要减 1,因为 JS 月份是 0-11)
// 这种写法在 iOS 上绝对不会报错
let targetTime = new Date(
parseInt(match[1]), // 年
parseInt(match[2]) - 1, // 月 (记得减1)
parseInt(match[3]), // 日
parseInt(match[4]), // 时
parseInt(match[5]), // 分
parseInt(match[6]) // 秒
).getTime()
// 3. 加上 1 小时
targetTime = targetTime + (60 * 60 * 1000)
// 4. 计算差值
const diff = targetTime - new Date().getTime()
// 如果时间已过期,设为0
item.timeLeft = diff > 0 ? diff : 0
}
})
},
// 3. 格式化时间 (毫秒 -> 天时分秒)
formatTime(ms) {
const second = Math.floor(ms / 1000)
const day = Math.floor(second / 86400)
const hour = Math.floor((second % 86400) / 3600)
const minute = Math.floor((second % 3600) / 60)
const sec = second % 60
// 补零操作
const pad = (n) => n < 10 ? '0' + n : n
// 根据需要返回格式,例如:1天 02时 05分 10秒
return `${day > 0 ? day + '天' : ''}${pad(hour)}时${pad(minute)}分${pad(sec)}秒`
},
checkTab1(type) {
this.tab1Checked = type
if(type == 'quanbu'){
@ -307,9 +289,19 @@
this.searchForm.pageNum = 1
this.getOrderList()
},
orderStatus(item){
if(item.status == 0 || item.status == 10 || item.status == 2 || (item.status == 3 && item.deliveryType == 1) || (item.status == 3 && item.deliveryType == 2) || item.status == 4){
return true;
}
return false;
},
checkTabs2(type) {
this.tab2Checked = type
},
payAgain(item){
this.payData = item;
this.$refs.payPopup.open('bottom');
},
getOrderList(){
this.loadStatus = 'loading'
let that = this
@ -331,6 +323,21 @@
uni.hideLoading();
}).catch((res) => {});
},
returnOrder(item){
let that = this
that.tui.request("/mall/order/cancel", "POST", {orderId:item.id,userId:uni.getStorageSync('id')}, false, true).then((res) => {
if (res.code == 200) {
that.tui.toast("取消订单成功");
that.searchForm.pageNum = 1
that.getOrderList()
that.$forceUpdate();
} else {
that.tui.toast(res.message);
return;
}
uni.hideLoading();
}).catch((res) => {});
},
back() {
uni.navigateBack()
}

Loading…
Cancel
Save