orders.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view style="padding: 20rpx;">
  3. <view style="margin-bottom: 10rpx;">
  4. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
  5. activeColor="#006eff"></uni-segmented-control>
  6. </view>
  7. <view>
  8. <view v-for="item in orderList" :key="item.id" class="box" style="margin-bottom: 10rpx;"
  9. @click="goDetail(item.id)">
  10. <view style="display: flex; align-items: center; margin-bottom: 20rpx;">
  11. <view style="flex: 1;">
  12. <uni-tag text="餐品" size="small" type="success" v-if="item.type === '代取餐品'"></uni-tag>
  13. <uni-tag text="快递" size="small" type="primary" v-if="item.type === '代拿快递'"></uni-tag>
  14. <uni-tag text="零食" size="small" type="warning" v-if="item.type === '代买零食'"></uni-tag>
  15. <uni-tag text="鲜花" size="small" type="error" v-if="item.type === '代送鲜花'"></uni-tag>
  16. <text style="margin-left: 10rpx;">{{ item.name }}</text>
  17. </view>
  18. <view style="flex: 1; text-align: right;">
  19. <text style="color: #888;">跑腿费</text>
  20. <text style="color: red; font-size: 34rpx;">¥{{ item.price }}</text>
  21. </view>
  22. </view>
  23. <view style="display: flex; align-items: center;">
  24. <view style="flex: 1;">
  25. <text style="margin-right: 20rpx;"
  26. v-if="item.status === '待接单' || item.status === '待送达' || item.status === '待收货'">已下单{{ item.range }}分钟</text>
  27. <text style="color: #888;" v-if="item.status === '已取消'">{{ item.status }}</text>
  28. <text style="color: orange;" v-if="item.status === '待接单'">{{ item.status }}</text>
  29. <text style="color: dodgerblue" v-if="item.status === '待送达'">{{ item.status }}</text>
  30. <text style="color: mediumpurple;" v-if="item.status === '待收货'">{{ item.status }}</text>
  31. <text style="color: indianred;" v-if="item.status === '待评价'">{{ item.status }}</text>
  32. <text style="color: #18bc37;" v-if="item.status === '已完成'">{{ item.status }}</text>
  33. </view>
  34. <view style="flex: 1; text-align: right;">
  35. <view style="display: inline-block;" v-if="item.status === '已取消' || item.status === '已完成'">
  36. <uni-icons type="trash" size="18" color="#888"
  37. style="position: relative; top: 4rpx;"></uni-icons>
  38. <text style="color: #888;" @click.native.stop="handleDel(item.id)">删除</text>
  39. </view>
  40. <uni-tag text="确认收货" type="primary" size="small" v-if="item.status === '待收货'" @click.native.stop="changeStatus(item,'待评价')"></uni-tag>
  41. <uni-tag text="取消订单" type="default" size="small" v-if="item.status === '待接单'" @click.native.stop="changeStatus(item,'已取消')"></uni-tag>
  42. <uni-tag text="评价" type="success" size="small" v-if="item.status === '待评价'" @click.native.stop="goComment(item.id)"></uni-tag>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view>
  48. <!-- 提示窗示例 -->
  49. <uni-popup ref="alertDialog" type="dialog">
  50. <uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" title="删除确认" content="您确认删除订单吗?"
  51. @confirm="del"></uni-popup-dialog>
  52. </uni-popup>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. items: ['全部订单', '待接单', '待送达', '待收货', '待评价'],
  61. orderList: [],
  62. current: '全部订单',
  63. user: uni.getStorageSync('xm-user'),
  64. orderId: 0
  65. }
  66. },
  67. onShow() {
  68. this.load()
  69. },
  70. methods: {
  71. goComment(orderId) {
  72. uni.navigateTo({
  73. url: '/pages/comment/comment?orderId=' + orderId
  74. })
  75. },
  76. changeStatus(orders, status) {
  77. orders.status = status
  78. this.$request.put('/orders/update', orders).then(res => {
  79. if (res.code === '200') {
  80. uni.showToast({
  81. icon: 'success',
  82. title: '操作成功'
  83. })
  84. this.load()
  85. } else {
  86. uni.showToast({
  87. icon: 'none',
  88. title: res.msg
  89. })
  90. }
  91. })
  92. },
  93. del() {
  94. this.$request.del('/orders/delete/' + this.orderId).then(res => {
  95. if (res.code === '200') {
  96. uni.showToast({
  97. icon: 'success',
  98. title: '操作成功'
  99. })
  100. this.load()
  101. } else {
  102. uni.showToast({
  103. icon: 'none',
  104. title: res.msg
  105. })
  106. }
  107. })
  108. },
  109. handleDel(orderId) {
  110. this.orderId = orderId
  111. this.$refs.alertDialog.open()
  112. },
  113. goDetail(orderId) {
  114. uni.navigateTo({
  115. url: '/pages/detail/detail?orderId=' + orderId
  116. })
  117. },
  118. onClickItem(e) { // 点击菜单的时候触发
  119. this.current = this.items[e.currentIndex]
  120. this.load()
  121. },
  122. load() {
  123. let params = {
  124. userId: this.user.id
  125. }
  126. if (this.current !== '全部订单') {
  127. params.status = this.current
  128. }
  129. this.$request.get('/orders/selectAll', params).then(res => {
  130. this.orderList = res.data || []
  131. })
  132. }
  133. }
  134. }
  135. </script>
  136. <style>
  137. </style>