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

221 lines
4.7 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. this.$store.commit('setPayOrderProduct', [
  80. this.data.massageItem
  81. ])
  82. this.$utils.navigateTo(`/pages_order/order/createOrder?id=${this.data.id}`)
  83. return
  84. // todo
  85. this.$api('payOrder', {
  86. orderId : this.data.id,
  87. // todo: payType -> 支付方式(payType):0-微信支付 1-余额支付
  88. }, res => {
  89. if(res.code == 200){
  90. uni.requestPaymentWxPay(res)
  91. .then(res => {
  92. uni.showToast({
  93. title: '支付成功',
  94. icon: 'none'
  95. })
  96. this.$emit('done')
  97. }).catch(n => {
  98. this.$emit('done')
  99. })
  100. }
  101. })
  102. },
  103. onVerify() {
  104. // todo
  105. this.$utils.navigateTo(`/pages_order/order/verifyOrder?id=${this.data.id}`)
  106. }
  107. },
  108. }
  109. </script>
  110. <style scoped lang="scss">
  111. .order {
  112. background-color: $uni-fg-color;
  113. padding: 15rpx 33rpx 0 30rpx;
  114. & + & {
  115. margin-top: 20rpx;
  116. }
  117. }
  118. .overview {
  119. justify-content: space-between;
  120. font-size: 28rpx;
  121. .title {
  122. color: #000000;
  123. font-weight: 700;
  124. }
  125. .status {
  126. color: $uni-color-light;
  127. }
  128. }
  129. .detail {
  130. margin-top: 9rpx;
  131. align-items: flex-start;
  132. .img {
  133. width: 167rpx;
  134. height: 167rpx;
  135. margin-right: 15rpx;
  136. margin-bottom: 29rpx;
  137. }
  138. }
  139. .info {
  140. flex: 1;
  141. font-size: 22rpx;
  142. .desc {
  143. background-color: #F5F5F5;
  144. border-radius: 5rpx;
  145. padding: 13rpx 16rpx;
  146. color: #999999;
  147. min-height: 128rpx;
  148. box-sizing: border-box;
  149. align-items: flex-start;
  150. justify-content: space-between;
  151. }
  152. .row + .row {
  153. margin-top: 6rpx;
  154. }
  155. .price {
  156. margin-top: 8rpx;
  157. text-align: right;
  158. color: #000000;
  159. .count,
  160. .unit {
  161. color: #FF2A2A;
  162. }
  163. .unit {
  164. font-size: 18rpx;
  165. }
  166. }
  167. .btns {
  168. text-align: right;
  169. font-size: 0;
  170. }
  171. }
  172. .btn {
  173. margin-top: 16rpx;
  174. margin-bottom: 9rpx;
  175. display: inline-block;
  176. width: auto;
  177. min-width: 145rpx;
  178. height: auto;
  179. padding: 14rpx 28rpx;
  180. box-sizing: border-box;
  181. border: none;
  182. border-radius: 29rpx;
  183. // margin: 0;
  184. font-size: 22rpx;
  185. line-height: 1;
  186. color: #FFFFFF;
  187. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  188. & + & {
  189. margin-left: 39rpx;
  190. }
  191. &-plain {
  192. padding: 12rpx 26rpx;
  193. border: 2rpx solid #999999;
  194. color: #999999;
  195. background: none;
  196. }
  197. }
  198. </style>