index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. import { getActivityDetail } from '@/api/activity.js'
  55. export default {
  56. data() {
  57. return {
  58. status: 'more',
  59. loading: false,
  60. query: {
  61. orderType: null,
  62. page: 0,
  63. size: 10,
  64. userId: JSON.parse(uni.getStorageSync('userInfo')).userId
  65. },
  66. activity: null,
  67. total: 0,
  68. list: []
  69. }
  70. },
  71. filters: {
  72. filterType: function (val) {
  73. if (val == 'APPLY_REFUND') {
  74. return '申请退款'
  75. } else if (val == 'CLOSE') {
  76. return '关闭订单'
  77. } else if (val == 'REFUNDED') {
  78. return '已退款'
  79. } else if (val == 'REFUSAL_REFUND') {
  80. return '拒绝退款'
  81. } else if (val == 'USED') {
  82. return '已使用'
  83. } else if (val == 'WAIT_PAYMENT') {
  84. return '待付款'
  85. } else if (val == 'WAIT_USE') {
  86. return '待使用'
  87. }
  88. }
  89. },
  90. methods: {
  91. handleTab(val) {
  92. this.query.orderType = val
  93. this.query.page = 0
  94. this.list = []
  95. this.getOrderList()
  96. },
  97. loadMore() {
  98. this.getOrderList()
  99. },
  100. jump(item) {
  101. // 如果是活动则跳转到活动支付页
  102. if (item.goodsModelList[0].goodsInfo.hasOwnProperty('activityEnable')) {
  103. const enable = item.goodsModelList[0].goodsInfo.activityEnable
  104. if (enable) {
  105. uni.showLoading({
  106. title: '获取信息中...'
  107. })
  108. getActivityDetail({
  109. id: item.goodsModelList[0].goodsInfo.id
  110. }).then(res => {
  111. this.activity = res.content
  112. this.activity.activityDetail = res.content.activityDetail.replace(/<img/gi, '<img class="img_class" ')
  113. let { activityStartTime, activityEndTime, limited, activityName, id, price, shopId } = this.activity
  114. let obj = {
  115. activityStartTime,
  116. activityEndTime,
  117. limited,
  118. activityName,
  119. id,
  120. price,
  121. shopId
  122. }
  123. uni.hideLoading()
  124. uni.setStorageSync('activity', JSON.stringify(obj))
  125. uni.navigateTo({
  126. url: '/signUp/makeOut?id=' + item.activityId
  127. })
  128. })
  129. } else {
  130. uni.showToast({
  131. title: '活动已结束',
  132. icon: 'none'
  133. })
  134. }
  135. return
  136. } else {
  137. uni.setStorageSync('order', JSON.stringify(item))
  138. uni.navigateTo({
  139. url: './detail?id=' + item.orderNo
  140. })
  141. }
  142. },
  143. getOrderList() {
  144. this.status = 'loading'
  145. getOrderList(this.query).then(res => {
  146. if (res.state == 'Success') {
  147. this.total = res.content.totalElements
  148. this.list = this.list.concat(res.content.content)
  149. this.list.length >= this.total ? this.status = 'noMore' : this.status = 'more'
  150. this.query.page++
  151. uni.stopPullDownRefresh()
  152. }
  153. })
  154. }
  155. },
  156. onPullDownRefresh() {
  157. this.query.page = 0
  158. this.list = []
  159. this.status = 'more'
  160. this.getOrderList()
  161. },
  162. onLoad(option) {
  163. this.query.orderType = option.type || null
  164. }
  165. }
  166. </script>
  167. <style lang="scss">
  168. .order {
  169. background: #efefef;
  170. padding: 90rpx 30rpx 0;
  171. min-height: 100vh;
  172. .tab-box {
  173. display: flex;
  174. position: fixed;
  175. width: 750rpx;
  176. height: 70rpx;
  177. left: 0%;
  178. top: 0%;
  179. z-index: 9;
  180. background: #fff;
  181. .tab {
  182. flex: 1;
  183. text-align: center;
  184. padding: 15rpx 0;
  185. font-size: 28rpx;
  186. color: #999999;
  187. }
  188. .tab.active {
  189. font-size: 32rpx;
  190. color: #222222;
  191. position: relative;
  192. &::after {
  193. content: '';
  194. width: 40rpx;
  195. height: 8rpx;
  196. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  197. border-radius: 46rpx 46rpx 46rpx 46rpx;
  198. background: $uni-color-primary;
  199. position: absolute;
  200. bottom: 0%;
  201. left: 50%;
  202. transform: translateX(-50%);
  203. }
  204. }
  205. }
  206. .zs-list {
  207. .order-item {
  208. background-color: #fff;
  209. border-radius: 8px;
  210. margin-bottom: 20rpx;
  211. .top-box {
  212. display: flex;
  213. justify-content: space-between;
  214. align-items: center;
  215. padding: 20rpx;
  216. border-bottom: 2rpx solid #F3F3F3;
  217. .label {
  218. font-weight: bold;
  219. color: #222222;
  220. font-size: 32rpx;
  221. width: 500rpx;
  222. white-space: nowrap;
  223. overflow: hidden;
  224. text-overflow: ellipsis;
  225. }
  226. .status {
  227. font-size: 28rpx;
  228. color: #999999;
  229. }
  230. }
  231. .order-box {
  232. padding: 25rpx;
  233. display: flex;
  234. .icon {
  235. width: 164rpx;
  236. height: 164rpx;
  237. border-radius: 16rpx;
  238. background-color: #999;
  239. }
  240. .info {
  241. margin-left: 25rpx;
  242. display: flex;
  243. flex-direction: column;
  244. justify-content: space-between;
  245. .title {
  246. color: #0F0F0F;
  247. font-size: 28rpx;
  248. }
  249. .time {
  250. font-size: 26rpx;
  251. color: #999999;
  252. }
  253. .price {
  254. font-weight: bold;
  255. color: #181818;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. </style>