index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="order">
  3. <view class="tab-box">
  4. <view class="tab" :class="[query.orderType == null ? 'active' : '']" @click="handleTab(null)">
  5. 全部
  6. </view>
  7. <!-- <view class="tab" :class="[query.orderType == 'USED'?'active':'']" @click="handleTab('USED')">
  8. 已使用
  9. </view> -->
  10. <view class="tab" :class="[query.orderType == 'WAIT_PAYMENT' ? 'active' : '']" @click="handleTab('WAIT_PAYMENT')">
  11. 待付款
  12. </view>
  13. <view class="tab" :class="[query.orderType == 'WAIT_USE' ? 'active' : '']" @click="handleTab('WAIT_USE')">
  14. 待使用
  15. </view>
  16. <view class="tab" :class="[query.orderType == 'APPLY_REFUND' ? 'active' : '']" @click="handleTab('APPLY_REFUND')">
  17. 退款
  18. </view>
  19. </view>
  20. <u-empty v-if="!list.length && status == 'noMore'" mode="order" iconSize="200rpx" textSize="28rpx">
  21. </u-empty>
  22. <zs-list mt="0" @load="loadMore" :status="status">
  23. <view class="order-item" v-for="(item, index) in list" :key="index" @click="jump(item)">
  24. <view class="top-box">
  25. <view class="label">
  26. {{ item.shopInfo.shopName }}
  27. </view>
  28. <view class="status">
  29. {{ item.goodsModelList[0].goodsState | filterType }}
  30. </view>
  31. </view>
  32. <view class="order-box">
  33. <zs-img radius="full"
  34. :src="item.goodsModelList[0].goodsInfo.goodsPath || item.goodsModelList[0].goodsInfo.activityCover"
  35. width="164rpx" height="164rpx"></zs-img>
  36. <view class="info">
  37. <view class="title">
  38. {{ item.goodsModelList[0].goodsInfo.goodsName || item.goodsModelList[0].goodsInfo.activityName }}
  39. </view>
  40. <view class="time">
  41. {{ $u.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}
  42. </view>
  43. <view class="price">
  44. ¥{{ item.payAmount }}
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </zs-list>
  50. </view>
  51. </template>
  52. <script>
  53. import { getOrderList } from '@/api/order.js'
  54. export default {
  55. data() {
  56. return {
  57. status: 'more',
  58. loading: false,
  59. query: {
  60. orderType: null,
  61. page: 0,
  62. size: 10,
  63. userId: JSON.parse(uni.getStorageSync('userInfo')).userId
  64. },
  65. total: 0,
  66. list: []
  67. }
  68. },
  69. filters: {
  70. filterType: function (val) {
  71. if (val == 'APPLY_REFUND') {
  72. return '申请退款'
  73. } else if (val == 'CLOSE') {
  74. return '关闭订单'
  75. } else if (val == 'REFUNDED') {
  76. return '已退款'
  77. } else if (val == 'REFUSAL_REFUND') {
  78. return '拒绝退款'
  79. } else if (val == 'USED') {
  80. return '已使用'
  81. } else if (val == 'WAIT_PAYMENT') {
  82. return '待付款'
  83. } else if (val == 'WAIT_USE') {
  84. return '待使用'
  85. }
  86. }
  87. },
  88. methods: {
  89. handleTab(val) {
  90. this.query.orderType = val
  91. this.query.page = 0
  92. this.list = []
  93. this.getOrderList()
  94. },
  95. loadMore() {
  96. this.getOrderList()
  97. },
  98. jump(item) {
  99. console.log('item',item);
  100. // 如果是活动则跳转到活动支付页
  101. if (item.goodsModelList[0].goodsInfo.hasOwnProperty('activityEnable')) {
  102. const enable = item.goodsModelList[0].goodsInfo.activityEnable
  103. if(enable){
  104. uni.navigateTo({
  105. url: '/signUp/makeOut?id=' + item.activityId
  106. })
  107. }else{
  108. uni.showToast({
  109. title: '活动已结束',
  110. icon: 'none'
  111. })
  112. }
  113. return
  114. } else {
  115. uni.setStorageSync('order', JSON.stringify(item))
  116. uni.navigateTo({
  117. url: './detail?id=' + item.orderNo
  118. })
  119. }
  120. },
  121. getOrderList() {
  122. this.status = 'loading'
  123. getOrderList(this.query).then(res => {
  124. if (res.state == 'Success') {
  125. this.total = res.content.totalElements
  126. this.list = this.list.concat(res.content.content)
  127. this.list.length >= this.total ? this.status = 'noMore' : this.status = 'more'
  128. this.query.page++
  129. uni.stopPullDownRefresh()
  130. }
  131. })
  132. }
  133. },
  134. onPullDownRefresh() {
  135. this.query.page = 0
  136. this.list = []
  137. this.status = 'more'
  138. this.getOrderList()
  139. },
  140. onLoad(option) {
  141. this.query.orderType = option.type || null
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. .order {
  147. background: #efefef;
  148. padding: 90rpx 30rpx 0;
  149. min-height: 100vh;
  150. .tab-box {
  151. display: flex;
  152. position: fixed;
  153. width: 750rpx;
  154. height: 70rpx;
  155. left: 0%;
  156. top: 0%;
  157. z-index: 9;
  158. background: #fff;
  159. .tab {
  160. flex: 1;
  161. text-align: center;
  162. padding: 15rpx 0;
  163. font-size: 28rpx;
  164. color: #999999;
  165. }
  166. .tab.active {
  167. font-size: 32rpx;
  168. color: #222222;
  169. position: relative;
  170. &::after {
  171. content: '';
  172. width: 40rpx;
  173. height: 8rpx;
  174. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  175. border-radius: 46rpx 46rpx 46rpx 46rpx;
  176. background: $uni-color-primary;
  177. position: absolute;
  178. bottom: 0%;
  179. left: 50%;
  180. transform: translateX(-50%);
  181. }
  182. }
  183. }
  184. .zs-list {
  185. .order-item {
  186. background-color: #fff;
  187. border-radius: 8px;
  188. margin-bottom: 20rpx;
  189. .top-box {
  190. display: flex;
  191. justify-content: space-between;
  192. align-items: center;
  193. padding: 20rpx;
  194. border-bottom: 2rpx solid #F3F3F3;
  195. .label {
  196. font-weight: bold;
  197. color: #222222;
  198. font-size: 32rpx;
  199. width: 500rpx;
  200. white-space: nowrap;
  201. overflow: hidden;
  202. text-overflow: ellipsis;
  203. }
  204. .status {
  205. font-size: 28rpx;
  206. color: #999999;
  207. }
  208. }
  209. .order-box {
  210. padding: 25rpx;
  211. display: flex;
  212. .icon {
  213. width: 164rpx;
  214. height: 164rpx;
  215. border-radius: 16rpx;
  216. background-color: #999;
  217. }
  218. .info {
  219. margin-left: 25rpx;
  220. display: flex;
  221. flex-direction: column;
  222. justify-content: space-between;
  223. .title {
  224. color: #0F0F0F;
  225. font-size: 28rpx;
  226. }
  227. .time {
  228. font-size: 26rpx;
  229. color: #999999;
  230. }
  231. .price {
  232. font-weight: bold;
  233. color: #181818;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. </style>