推拿小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

196 lines
4.0 KiB

<template>
<view class="card order order-card__view" @click="onClick">
<view class="flex overview">
<text class="title">{{ data.title }}</text>
<text class="state">{{ stateCodeAndDescFieldsMapping[data.state] }}</text>
</view>
<view class="flex detail">
<image class="img" :src="data.imgUrl"></image>
<view class="info">
<view class="flex flex-column desc">
<view class="row">{{ `服务内容:${data.desc || '-'}` }}</view>
<view class="row">{{ `下单时间:${data.createTime || '-'}` }}</view>
<view class="row">{{ `订单号:${data.orderNo || '-'}` }}</view>
</view>
<view class="price">
总价格<text class="unit">¥</text><text class="count">{{ data.price }}</text>
</view>
<view class="btns" v-if="[0, 1].includes(data.state)">
<!-- 待付款 -->
<template v-if="data.state === 0">
<button plain class="btn btn-plain" @click="onCancel">取消订单</button>
<button plain class="btn" @click="onPay">立即付款</button>
</template>
<!-- 待核销 -->
<template v-if="data.state === 1">
<button plain class="btn" @click="onVerify">去核销</button>
</template>
</view>
</view>
</view>
</view>
</template>
<script>
import mixinsOrder from '@/mixins/order.js'
const TEST_DATA = {
id: '001',
imgUrl: '../../static/image/home/temp-product.png',
title: '60分钟肩颈推拿按摩',
desc: '疏通经络 放松肌肉',
price: 264,
orderNo: 'da123567',
createTime: '2024-12-24 18:45:23',
state: 2,
}
export default {
mixins: [mixinsOrder],
props: {
data: {
type: Object,
default() {
// todo: delete
return TEST_DATA
}
},
},
data() {
return {
stateCodeAndDescFieldsMapping: {
0: '待付款',
1: '待核销',
2: '已完成',
3: '已取消',
}
}
},
methods: {
onClick() {
if (this.data.state === 2) { // 已完成
// todo: check
this.$utils.navigateTo(`/pages_order/order/orderDetail?id=${this.data.id}`)
}
},
onCancel() {
this.cancelOrder(this.data)
},
onPay() {
this.toPayOrder(this.data)
},
onVerify() {
// todo
this.$utils.navigateTo(`/pages_order/order/verifyOrder?id=${this.data.id}`)
}
},
}
</script>
<style scoped lang="scss">
.order {
background-color: $uni-fg-color;
padding: 15rpx 33rpx 0 30rpx;
& + & {
margin-top: 20rpx;
}
}
.overview {
justify-content: space-between;
font-size: 28rpx;
.title {
color: #000000;
font-weight: 700;
}
.state {
color: $uni-color-light;
}
}
.detail {
margin-top: 9rpx;
align-items: flex-start;
.img {
width: 167rpx;
height: 167rpx;
margin-right: 15rpx;
margin-bottom: 29rpx;
}
}
.info {
flex: 1;
font-size: 22rpx;
.desc {
background-color: #F5F5F5;
border-radius: 5rpx;
padding: 13rpx 16rpx;
color: #999999;
min-height: 128rpx;
box-sizing: border-box;
align-items: flex-start;
justify-content: space-between;
}
.row + .row {
margin-top: 6rpx;
}
.price {
margin-top: 8rpx;
text-align: right;
color: #000000;
.count,
.unit {
color: #FF2A2A;
}
.unit {
font-size: 18rpx;
}
}
.btns {
margin-top: 16rpx;
margin-bottom: 9rpx;
text-align: right;
font-size: 0;
}
}
.btn {
display: inline-block;
width: auto;
min-width: 145rpx;
height: auto;
padding: 14rpx 28rpx;
box-sizing: border-box;
border: none;
border-radius: 29rpx;
margin: 0;
font-size: 22rpx;
line-height: 1;
color: #FFFFFF;
background-image: linear-gradient(to right, #84A73F, #D8FF8F);
& + & {
margin-left: 39rpx;
}
&-plain {
border: 2rpx solid #999999;
color: #999999;
background: none;
}
}
</style>