推拿小程序前端代码仓库
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.

195 lines
4.0 KiB

  1. <template>
  2. <view class="card order order-card__view" @click="onClick">
  3. <view class="flex overview">
  4. <text class="title">{{ data.title }}</text>
  5. <text class="state">{{ stateCodeAndDescFieldsMapping[data.state] }}</text>
  6. </view>
  7. <view class="flex detail">
  8. <image class="img" :src="data.imgUrl"></image>
  9. <view class="info">
  10. <view class="flex flex-column desc">
  11. <view class="row">{{ `服务内容:${data.desc || '-'}` }}</view>
  12. <view class="row">{{ `下单时间:${data.createTime || '-'}` }}</view>
  13. <view class="row">{{ `订单号:${data.orderNo || '-'}` }}</view>
  14. </view>
  15. <view class="price">
  16. 总价格<text class="unit">¥</text><text class="count">{{ data.price }}</text>
  17. </view>
  18. <view class="btns" v-if="[0, 1].includes(data.state)">
  19. <!-- 待付款 -->
  20. <template v-if="data.state === 0">
  21. <button plain class="btn btn-plain" @click="onCancel">取消订单</button>
  22. <button plain class="btn" @click="onPay">立即付款</button>
  23. </template>
  24. <!-- 待核销 -->
  25. <template v-if="data.state === 1">
  26. <button plain class="btn" @click="onVerify">去核销</button>
  27. </template>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import mixinsOrder from '@/mixins/order.js'
  35. const TEST_DATA = {
  36. id: '001',
  37. imgUrl: '../../static/image/home/temp-product.png',
  38. title: '60分钟肩颈推拿按摩',
  39. desc: '疏通经络 放松肌肉',
  40. price: 264,
  41. orderNo: 'da123567',
  42. createTime: '2024-12-24 18:45:23',
  43. state: 2,
  44. }
  45. export default {
  46. mixins: [mixinsOrder],
  47. props: {
  48. data: {
  49. type: Object,
  50. default() {
  51. // todo: delete
  52. return TEST_DATA
  53. }
  54. },
  55. },
  56. data() {
  57. return {
  58. stateCodeAndDescFieldsMapping: {
  59. 0: '待付款',
  60. 1: '待核销',
  61. 2: '已完成',
  62. 3: '已取消',
  63. }
  64. }
  65. },
  66. methods: {
  67. onClick() {
  68. if (this.data.state === 2) { // 已完成
  69. // todo: check
  70. this.$utils.navigateTo(`/pages_order/order/orderDetail?id=${this.data.id}`)
  71. }
  72. },
  73. onCancel() {
  74. this.cancelOrder(this.data)
  75. },
  76. onPay() {
  77. this.toPayOrder(this.data)
  78. },
  79. onVerify() {
  80. // todo
  81. this.$utils.navigateTo(`/pages_order/order/verifyOrder?id=${this.data.id}`)
  82. }
  83. },
  84. }
  85. </script>
  86. <style scoped lang="scss">
  87. .order {
  88. background-color: $uni-fg-color;
  89. padding: 15rpx 33rpx 0 30rpx;
  90. & + & {
  91. margin-top: 20rpx;
  92. }
  93. }
  94. .overview {
  95. justify-content: space-between;
  96. font-size: 28rpx;
  97. .title {
  98. color: #000000;
  99. font-weight: 700;
  100. }
  101. .state {
  102. color: $uni-color-light;
  103. }
  104. }
  105. .detail {
  106. margin-top: 9rpx;
  107. align-items: flex-start;
  108. .img {
  109. width: 167rpx;
  110. height: 167rpx;
  111. margin-right: 15rpx;
  112. margin-bottom: 29rpx;
  113. }
  114. }
  115. .info {
  116. flex: 1;
  117. font-size: 22rpx;
  118. .desc {
  119. background-color: #F5F5F5;
  120. border-radius: 5rpx;
  121. padding: 13rpx 16rpx;
  122. color: #999999;
  123. min-height: 128rpx;
  124. box-sizing: border-box;
  125. align-items: flex-start;
  126. justify-content: space-between;
  127. }
  128. .row + .row {
  129. margin-top: 6rpx;
  130. }
  131. .price {
  132. margin-top: 8rpx;
  133. text-align: right;
  134. color: #000000;
  135. .count,
  136. .unit {
  137. color: #FF2A2A;
  138. }
  139. .unit {
  140. font-size: 18rpx;
  141. }
  142. }
  143. .btns {
  144. margin-top: 16rpx;
  145. margin-bottom: 9rpx;
  146. text-align: right;
  147. font-size: 0;
  148. }
  149. }
  150. .btn {
  151. display: inline-block;
  152. width: auto;
  153. min-width: 145rpx;
  154. height: auto;
  155. padding: 14rpx 28rpx;
  156. box-sizing: border-box;
  157. border: none;
  158. border-radius: 29rpx;
  159. margin: 0;
  160. font-size: 22rpx;
  161. line-height: 1;
  162. color: #FFFFFF;
  163. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  164. & + & {
  165. margin-left: 39rpx;
  166. }
  167. &-plain {
  168. border: 2rpx solid #999999;
  169. color: #999999;
  170. background: none;
  171. }
  172. }
  173. </style>