index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. uni.redirectTo({
  129. url: "/signUp/orderDetail?id=" + item.orderNo,
  130. success() {
  131. // this.loading = false;
  132. uni.hideLoading();
  133. },
  134. });
  135. })
  136. } else {
  137. uni.showToast({
  138. title: '活动已结束',
  139. icon: 'none'
  140. })
  141. }
  142. return
  143. } else {
  144. uni.setStorageSync('order', JSON.stringify(item))
  145. uni.navigateTo({
  146. url: './detail?id=' + item.orderNo
  147. })
  148. }
  149. },
  150. getOrderList() {
  151. this.status = 'loading'
  152. getOrderList(this.query).then(res => {
  153. if (res.state == 'Success') {
  154. this.total = res.content.totalElements
  155. this.list = this.list.concat(res.content.content)
  156. this.list.length >= this.total ? this.status = 'noMore' : this.status = 'more'
  157. this.query.page++
  158. uni.stopPullDownRefresh()
  159. }
  160. })
  161. }
  162. },
  163. onPullDownRefresh() {
  164. this.query.page = 0
  165. this.list = []
  166. this.status = 'more'
  167. this.getOrderList()
  168. },
  169. onLoad(option) {
  170. this.query.orderType = option.type || null
  171. }
  172. }
  173. </script>
  174. <style lang="scss">
  175. .order {
  176. background: #efefef;
  177. padding: 90rpx 30rpx 0;
  178. min-height: 100vh;
  179. .tab-box {
  180. display: flex;
  181. position: fixed;
  182. width: 750rpx;
  183. height: 70rpx;
  184. left: 0%;
  185. top: 0%;
  186. z-index: 9;
  187. background: #fff;
  188. .tab {
  189. flex: 1;
  190. text-align: center;
  191. padding: 15rpx 0;
  192. font-size: 28rpx;
  193. color: #999999;
  194. }
  195. .tab.active {
  196. font-size: 32rpx;
  197. color: #222222;
  198. position: relative;
  199. &::after {
  200. content: '';
  201. width: 40rpx;
  202. height: 8rpx;
  203. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  204. border-radius: 46rpx 46rpx 46rpx 46rpx;
  205. background: $uni-color-primary;
  206. position: absolute;
  207. bottom: 0%;
  208. left: 50%;
  209. transform: translateX(-50%);
  210. }
  211. }
  212. }
  213. .zs-list {
  214. .order-item {
  215. background-color: #fff;
  216. border-radius: 8px;
  217. margin-bottom: 20rpx;
  218. .top-box {
  219. display: flex;
  220. justify-content: space-between;
  221. align-items: center;
  222. padding: 20rpx;
  223. border-bottom: 2rpx solid #F3F3F3;
  224. .label {
  225. font-weight: bold;
  226. color: #222222;
  227. font-size: 32rpx;
  228. width: 500rpx;
  229. white-space: nowrap;
  230. overflow: hidden;
  231. text-overflow: ellipsis;
  232. }
  233. .status {
  234. font-size: 28rpx;
  235. color: #999999;
  236. }
  237. }
  238. .order-box {
  239. padding: 25rpx;
  240. display: flex;
  241. .icon {
  242. width: 164rpx;
  243. height: 164rpx;
  244. border-radius: 16rpx;
  245. background-color: #999;
  246. }
  247. .info {
  248. margin-left: 25rpx;
  249. display: flex;
  250. flex-direction: column;
  251. justify-content: space-between;
  252. .title {
  253. color: #0F0F0F;
  254. font-size: 28rpx;
  255. }
  256. .time {
  257. font-size: 26rpx;
  258. color: #999999;
  259. }
  260. .price {
  261. font-weight: bold;
  262. color: #181818;
  263. }
  264. }
  265. }
  266. }
  267. }
  268. }
  269. </style>