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

214 lines
4.6 KiB

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