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

211 lines
4.5 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="status">{{ statusCodeAndDescFieldsMapping[data.status] }}</text>
  6. </view>
  7. <view class="flex detail">
  8. <image class="img" :src="data.massageItem.image"></image>
  9. <view class="info">
  10. <view class="flex flex-column desc">
  11. <view class="row">{{ `服务内容:${data.massageItem.title || '-'}` }}</view>
  12. <view class="row">{{ `下单时间:${$dayjs(data.createTime).format('YYYY-MM-DD HH:mm:ss')}` }}</view>
  13. <view class="row">{{ `订单号:${data.id || '-'}` }}</view>
  14. </view>
  15. <view class="price">
  16. 总价格<text class="unit">¥</text><text class="count">{{ data.amount }}</text>
  17. </view>
  18. <view class="btns" v-if="[0, 1].includes(data.status)">
  19. <!-- 待付款 -->
  20. <template v-if="data.status === 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.status === 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. export default {
  36. mixins: [mixinsOrder],
  37. props: {
  38. data: {
  39. type: Object,
  40. default() {
  41. return {}
  42. }
  43. },
  44. },
  45. data() {
  46. return {
  47. statusCodeAndDescFieldsMapping: {
  48. 0: '待付款',
  49. 1: '待核销',
  50. 2: '已完成',
  51. 3: '已取消',
  52. }
  53. }
  54. },
  55. methods: {
  56. onClick() {
  57. if (this.data.status === 2) { // 已完成
  58. // todo: check
  59. this.$utils.navigateTo(`/pages_order/order/orderDetail?id=${this.data.id}`)
  60. }
  61. },
  62. onCancel() {
  63. // todo
  64. uni.showModal({
  65. title: '确认取消订单吗?',
  66. success : e => {
  67. if(e.confirm){
  68. this.$api('cancelOrder', {
  69. orderId : this.data.id,
  70. }, res => {
  71. this.$emit('done')
  72. })
  73. }
  74. }
  75. })
  76. },
  77. onPay() {
  78. // todo
  79. this.$api('createSumOrderAgain', {
  80. orderId : this.data.id,
  81. }, res => {
  82. if(res.code == 200){
  83. uni.requestPaymentWxPay(res)
  84. .then(res => {
  85. uni.showToast({
  86. title: '支付成功',
  87. icon: 'none'
  88. })
  89. this.$emit('done')
  90. }).catch(n => {
  91. this.$emit('done')
  92. })
  93. }
  94. })
  95. },
  96. onVerify() {
  97. // todo
  98. this.$utils.navigateTo(`/pages_order/order/verifyOrder?id=${this.data.id}`)
  99. }
  100. },
  101. }
  102. </script>
  103. <style scoped lang="scss">
  104. .order {
  105. background-color: $uni-fg-color;
  106. padding: 15rpx 33rpx 0 30rpx;
  107. & + & {
  108. margin-top: 20rpx;
  109. }
  110. }
  111. .overview {
  112. justify-content: space-between;
  113. font-size: 28rpx;
  114. .title {
  115. color: #000000;
  116. font-weight: 700;
  117. }
  118. .status {
  119. color: $uni-color-light;
  120. }
  121. }
  122. .detail {
  123. margin-top: 9rpx;
  124. align-items: flex-start;
  125. .img {
  126. width: 167rpx;
  127. height: 167rpx;
  128. margin-right: 15rpx;
  129. margin-bottom: 29rpx;
  130. }
  131. }
  132. .info {
  133. flex: 1;
  134. font-size: 22rpx;
  135. .desc {
  136. background-color: #F5F5F5;
  137. border-radius: 5rpx;
  138. padding: 13rpx 16rpx;
  139. color: #999999;
  140. min-height: 128rpx;
  141. box-sizing: border-box;
  142. align-items: flex-start;
  143. justify-content: space-between;
  144. }
  145. .row + .row {
  146. margin-top: 6rpx;
  147. }
  148. .price {
  149. margin-top: 8rpx;
  150. text-align: right;
  151. color: #000000;
  152. .count,
  153. .unit {
  154. color: #FF2A2A;
  155. }
  156. .unit {
  157. font-size: 18rpx;
  158. }
  159. }
  160. .btns {
  161. margin-top: 16rpx;
  162. margin-bottom: 9rpx;
  163. text-align: right;
  164. font-size: 0;
  165. }
  166. }
  167. .btn {
  168. display: inline-block;
  169. width: auto;
  170. min-width: 145rpx;
  171. height: auto;
  172. padding: 14rpx 28rpx;
  173. box-sizing: border-box;
  174. border: none;
  175. border-radius: 29rpx;
  176. margin: 0;
  177. font-size: 22rpx;
  178. line-height: 1;
  179. color: #FFFFFF;
  180. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  181. & + & {
  182. margin-left: 39rpx;
  183. }
  184. &-plain {
  185. border: 2rpx solid #999999;
  186. color: #999999;
  187. background: none;
  188. }
  189. }
  190. </style>