dt_order_item.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="dt-order-item" @tap="$emit('order', dataDetail)">
  3. <view class="state-row">
  4. <view v-if="isTimer && dataDetail.status == orderState.waitForPay" class="timer">
  5. <!-- <text v-if="isOutDate()">已过期</text>
  6. <block v-else> -->
  7. <DtTimer :start="dataDetail.expire" @timeover="onTimeover" />
  8. <text class="tips">后订单自动取消</text>
  9. <!-- </block> -->
  10. </view>
  11. <view v-else class="order-no" @click.stop="copyOrderSn(dataDetail.sn)">
  12. 订单编号:{{ dataDetail.sn }}
  13. <text class="copy">复制</text>
  14. </view>
  15. <view
  16. class="state"
  17. :class="{
  18. 'dt-color-primary': isColorPrimary.includes(dataDetail.status),
  19. 'dt-color-error': isColorDanger.includes(dataDetail.status)
  20. }"
  21. >
  22. {{ dataDetail.statusTxt }}
  23. </view>
  24. </view>
  25. <view class="mid-row">
  26. <view v-for="(item, idx) in dataDetail.products" :key="idx" class="goods-item">
  27. <image class="main-pic" :src="item.thumbnail" mode="aspectFit"></image>
  28. <view class="rt-wrap">
  29. <view class="good-mn">
  30. <view class="goods-name dt-text-row-one">{{ item.name }}</view>
  31. <view class="goods-num">x {{ item.quantity }}</view>
  32. </view>
  33. <view class="specifications">{{ item.specificationsDesc }}</view>
  34. <view class="price">¥{{ item.price }}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <view v-if="isFootShow" class="ft-row">
  39. <view class="real-pay">实付金额:¥{{ dataDetail.amount }}</view>
  40. <view class="opts">
  41. <!-- 待付款 -->
  42. <block v-if="dataDetail.status == orderState.waitForPay">
  43. <button class="btn-base btn-plain" hover-class="button-hover-scale" @tap.stop="tapDepatch('cancel')">取消订单</button>
  44. <button class="btn-base btn-primary" hover-class="button-hover-scale" @tap.stop="tapDepatch('pay')">立即支付</button>
  45. </block>
  46. <!-- 待发货,虽然是取消订单的文字按钮,但执行的是申请售后(退货) -->
  47. <block v-else-if="dataDetail.status == orderState.waitForDelive">
  48. <button class="btn-base btn-plain" hover-class="button-hover-scale" @tap.stop="tapDepatch('refund')">取消订单</button>
  49. </block>
  50. <!-- 待收货 -->
  51. <block v-else-if="dataDetail.status == orderState.waitForReceive">
  52. <button class="btn-base btn-plain" hover-class="button-hover-scale" @tap.stop="tapDepatch('refund_choose')">申请售后</button>
  53. <button class="btn-base btn-primary" hover-class="button-hover-scale" @tap.stop="tapDepatch('receive')">确认收货</button>
  54. </block>
  55. <!-- 待评价 -->
  56. <block v-else-if="dataDetail.status == orderState.waitForAppraise">
  57. <button class="btn-base btn-plain" hover-class="button-hover-scale" @tap.stop="tapDepatch('refund_choose')">申请售后</button>
  58. <button class="btn-base btn-primary" hover-class="button-hover-scale" @tap.stop="tapDepatch('appraise')">评价商品</button>
  59. </block>
  60. <!-- 已取消、已失败、已拒绝 -->
  61. <block v-else-if="isDel.includes(dataDetail.status)">
  62. <button class="btn-base btn-plain" hover-class="button-hover-scale" @tap.stop="tapDepatch('delete')">删除订单</button>
  63. </block>
  64. <!-- 售后等待审核 -->
  65. <block v-else-if="dataDetail.status == orderState.saled_pending">
  66. <button class="btn-base btn-primary" hover-class="button-hover-scale" @tap.stop="tapDepatch('cancelRefund')">取消售后</button>
  67. </block>
  68. <!-- 售后审核通过 -->
  69. <!-- <block v-else-if="dataDetail.status == orderState.saled_approved">
  70. <button class="btn-base btn-primary"
  71. hover-class="button-hover-scale"
  72. @tap.stop="tapDepatch('cancelRefund')">审核通过</button>
  73. </block> -->
  74. <!-- 售后审核失败 -->
  75. <!-- <block v-else-if="dataDetail.status == orderState.saled_failed">
  76. <button class="btn-base btn-primary"
  77. hover-class="button-hover-scale"
  78. @tap.stop="tapDepatch('cancelRefund')">审核失败</button>
  79. </!-->
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import DtTimer from './dt_timer.vue';
  86. export default {
  87. components: {
  88. DtTimer
  89. },
  90. props: {
  91. isTimer: {
  92. type: Boolean,
  93. default: true
  94. },
  95. isFootShow: {
  96. type: Boolean,
  97. default: true
  98. },
  99. dataDetail: {
  100. type: Object,
  101. default: {}
  102. }
  103. },
  104. data() {
  105. return {
  106. timer: null
  107. };
  108. },
  109. computed: {
  110. isOutDate() {
  111. if (!this.dataDetail) {
  112. return false;
  113. }
  114. let item = this.dataDetail;
  115. let expire = this.$util.createDate(item.expire);
  116. let diffMills = expire.getTime() - new Date().getTime();
  117. if (diffMills < 0) {
  118. return true;
  119. }
  120. return false;
  121. },
  122. orderState() {
  123. return this.$global.orderState;
  124. },
  125. saledStatus() {
  126. return this.$global.saledStatus;
  127. },
  128. isDel() {
  129. return [
  130. // FAILED("已失败"), CANCELED("已取消"), DENIED("已拒绝")
  131. this.orderState.failed,
  132. this.orderState.cancel,
  133. this.orderState.denied
  134. ];
  135. },
  136. isColorPrimary() {
  137. return [this.orderState.waitForPay, this.orderState.waitForDelive, this.orderState.waitForReceive, this.saledStatus.PENDING, this.saledStatus.APPROVED];
  138. },
  139. isColorDanger() {
  140. return [this.orderState.failed, this.orderState.denied, this.saledStatus.FAILED];
  141. }
  142. },
  143. methods: {
  144. //复制订单号
  145. copyOrderSn(sn) {
  146. uni.setClipboardData({ data: sn });
  147. },
  148. tapDepatch(flag) {
  149. this.$emit('tapbtn', {
  150. flag,
  151. item: this.dataDetail
  152. });
  153. },
  154. onTimeover() {
  155. this.$emit('timer');
  156. }
  157. },
  158. created() {}
  159. };
  160. </script>
  161. <style lang="scss">
  162. .dt-order-item {
  163. background-color: #fff;
  164. .state-row {
  165. display: flex;
  166. justify-content: space-between;
  167. padding: 0 30upx;
  168. line-height: 80upx;
  169. border-bottom: 1upx solid #e5e5e5;
  170. .timer {
  171. color: $dt-color-error;
  172. .tips {
  173. padding-left: 10upx;
  174. }
  175. }
  176. .order-no {
  177. color: #666666;
  178. .copy {
  179. color: #0081ff;
  180. margin: 0rpx 10rpx;
  181. }
  182. }
  183. .order-state {
  184. font-size: 30upx;
  185. color: #666666;
  186. }
  187. }
  188. .mid-row {
  189. .goods-item {
  190. display: flex;
  191. padding: 30upx;
  192. height: 220rpx;
  193. box-sizing: border-box;
  194. border-bottom: 1upx solid #e5e5e5;
  195. .main-pic {
  196. width: 152upx;
  197. height: 152upx;
  198. }
  199. .rt-wrap {
  200. padding-left: 26upx;
  201. flex: 1;
  202. .good-mn {
  203. display: flex;
  204. justify-content: space-between;
  205. align-items: flex-end;
  206. font-size: 30upx;
  207. .goods-name {
  208. flex: 1;
  209. margin-right: 20upx;
  210. line-height: 1.5;
  211. }
  212. }
  213. .specifications {
  214. margin: 30upx 0 20upx;
  215. line-height: 1;
  216. color: #999999;
  217. font-size: 26upx;
  218. font-weight: 500;
  219. }
  220. .price {
  221. font-size: 30upx;
  222. }
  223. }
  224. }
  225. }
  226. .ft-row {
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. padding: 0 30upx;
  231. height: 105upx;
  232. .opts {
  233. display: flex;
  234. .btn-base {
  235. margin-left: 20upx;
  236. }
  237. }
  238. }
  239. .btn-base {
  240. position: relative;
  241. width: 150upx;
  242. height: 56upx;
  243. line-height: 56upx;
  244. font-size: 28upx;
  245. border-radius: 25px;
  246. box-sizing: border-box;
  247. }
  248. .btn-base:before {
  249. // position: absolute;
  250. // top: 0;
  251. // left: 0;
  252. // width: 100%;
  253. // height: 100%;
  254. // border: 2upx solid $dt-color-primary;
  255. // border-radius: 6upx;
  256. // box-sizing: border-box;
  257. // content: '';
  258. }
  259. .btn-plain {
  260. background-color: transparent;
  261. color: $dt-text-color;
  262. border: 1upx solid #999;
  263. }
  264. .btn-plain:before {
  265. // border-color: #ccc;
  266. // box-sizing: border-box;
  267. // content: '';
  268. }
  269. .btn-primary {
  270. background-color: $base;
  271. color: #fff;
  272. }
  273. .btn-primary:before {
  274. border-color: $base;
  275. box-sizing: border-box;
  276. content: '';
  277. }
  278. }
  279. </style>