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

237 lines
5.1 KiB

3 weeks ago
  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. // uni.showModal({
  105. // title: '确认核销订单吗?',
  106. // success : e => {
  107. // if(e.confirm){
  108. // this.$api('overOrder', {
  109. // orderId : this.data.id,
  110. // }, res => {
  111. // this.$emit('done')
  112. // this.$utils.navigateTo(`/pages_order/order/verifyOrder?id=${this.data.id}`)
  113. // })
  114. // }
  115. // }
  116. // })
  117. // todo
  118. this.$utils.navigateTo(`/pages_order/order/verifyOrder?id=${this.data.id}`)
  119. }
  120. },
  121. }
  122. </script>
  123. <style scoped lang="scss">
  124. .order {
  125. background-color: $uni-fg-color;
  126. padding: 15rpx 33rpx 0 30rpx;
  127. & + & {
  128. margin-top: 20rpx;
  129. }
  130. }
  131. .overview {
  132. justify-content: space-between;
  133. font-size: 28rpx;
  134. .title {
  135. color: #000000;
  136. font-weight: 700;
  137. }
  138. .status {
  139. color: $uni-color-light;
  140. }
  141. }
  142. .detail {
  143. margin-top: 9rpx;
  144. align-items: flex-start;
  145. .img {
  146. width: 167rpx;
  147. height: 167rpx;
  148. margin-right: 15rpx;
  149. margin-bottom: 29rpx;
  150. }
  151. }
  152. .info {
  153. flex: 1;
  154. font-size: 22rpx;
  155. .desc {
  156. background-color: #F5F5F5;
  157. border-radius: 5rpx;
  158. padding: 13rpx 16rpx;
  159. color: #999999;
  160. min-height: 128rpx;
  161. box-sizing: border-box;
  162. align-items: flex-start;
  163. justify-content: space-between;
  164. }
  165. .row + .row {
  166. margin-top: 6rpx;
  167. }
  168. .price {
  169. margin-top: 8rpx;
  170. text-align: right;
  171. color: #000000;
  172. .count,
  173. .unit {
  174. color: #FF2A2A;
  175. }
  176. .unit {
  177. font-size: 18rpx;
  178. }
  179. }
  180. .btns {
  181. text-align: right;
  182. font-size: 0;
  183. }
  184. }
  185. .btn {
  186. margin-top: 16rpx;
  187. margin-bottom: 9rpx;
  188. display: inline-block;
  189. width: auto;
  190. min-width: 145rpx;
  191. height: auto;
  192. padding: 14rpx 28rpx;
  193. box-sizing: border-box;
  194. border: none;
  195. border-radius: 29rpx;
  196. // margin: 0;
  197. font-size: 22rpx;
  198. line-height: 1;
  199. color: #FFFFFF;
  200. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  201. & + & {
  202. margin-left: 39rpx;
  203. }
  204. &-plain {
  205. padding: 12rpx 26rpx;
  206. border: 2rpx solid #999999;
  207. color: #999999;
  208. background: none;
  209. }
  210. }
  211. </style>