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

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