list.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <view>
  4. <zj-page-layout :hasFooter="false" :isScroll="true" :refresherTriggered="refresherTriggered"
  5. @refresherrefresh="refresherrefresh" @scrolltolower="scrolltolower">
  6. <template slot="header">
  7. <view class="header-container">
  8. <u-tabs :scrollable="false" :list="tabList" :current="tabCurrent" @click="clickTab" lineColor="#01C30B"
  9. :activeStyle="{
  10. color: '#01C30B'
  11. }" :inactiveStyle="{
  12. color: '#666666'
  13. }" itemStyle="padding-left: 0; padding-right: 0; height: 88rpx;">
  14. </u-tabs>
  15. </view>
  16. </template>
  17. <view class="common-order-list">
  18. <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toDetail(item.id)">
  19. <view class="top">
  20. <image :src="item.userPic ? (imageUrl + item.userPic) : require('@/static/common/logo.png')"></image>
  21. <view class="user">
  22. <view class="name">{{item.userName}}</view>
  23. <view class="time">{{item.createTime | timeFilter}}发布</view>
  24. </view>
  25. <view class="status" v-if="item.status === 4 && item.orderInfo">{{item.orderInfo.status | orderStatusFilter}}</view>
  26. <view class="status" v-else>{{item.status | statusFilter}}</view>
  27. </view>
  28. <view class="goods">
  29. <image :src="imageUrl + item.goodsPicUrl" mode="aspectFill"></image>
  30. <view class="main">
  31. <view class="name">{{item.title}}<text v-if="item.num > 1">×{{item.num}}</text></view>
  32. <view class="des">{{item.content}}</view>
  33. <view class="price">{{item.amount | priceFilter2}}</view>
  34. </view>
  35. </view>
  36. <view class="bottom">
  37. <view class="left-buyer" v-if="item.status === 4 && item.orderInfo">
  38. <image
  39. :src="item.orderInfo.buyerUserPic ? (imageUrl + item.orderInfo.buyerUserPic) : require('@/static/common/logo.png')">
  40. </image>
  41. <view class="name">{{item.orderInfo.buyerUserName}}</view>
  42. <view class="text">买到了</view>
  43. </view>
  44. <view class="left-location" v-else><text class="iconfont icon-dingwei"></text>{{item.city}} {{item.area}}
  45. </view>
  46. <view class="right-btn" @tap.stop>
  47. <block v-if="item.status === 4 && item.sendStatus === 'NO' && (item.orderInfo && item.orderInfo.status === 'PAID')">
  48. <u-button text="确认发货" shape="circle" @click="openDeliver(item.id)"></u-button>
  49. </block>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <Loading :loadStatus="loadStatus" :dataList="dataList" />
  55. </zj-page-layout>
  56. <zj-dialog-deliver ref="deliverDialog" :isShow="isShowDeliverDialog" @close="isShowDeliverDialog = false">
  57. </zj-dialog-deliver>
  58. </view>
  59. <!-- #endif -->
  60. <!-- #ifndef H5 -->
  61. <web-view :src="webViewHref(`/pages/mine/myIssue/list`, pam,crossPagePam)" @message="crossPage.$listener"></web-view>
  62. <!-- #endif -->
  63. </template>
  64. <script>
  65. // #ifdef H5
  66. import zjDialogDeliver from '@/components/zj-dialog/zj-dialog-deliver.vue';
  67. export default {
  68. components: {
  69. zjDialogDeliver
  70. },
  71. filters: {
  72. statusFilter(val) {
  73. const MAP = {
  74. 0: '已下架',
  75. 1: '上架中',
  76. 2: '已转让',
  77. 3: '已冻结',
  78. 4: '已卖出',
  79. }
  80. return MAP[val];
  81. },
  82. orderStatusFilter(val) {
  83. const MAP = {
  84. WAIT: '待支付',
  85. CANCEL: '取消支付',
  86. TIMEOUT: '超时取消',
  87. PAID: '待发货',
  88. SEND: '已发货',
  89. COMPLETE: '已完成',
  90. AFTER_WAIT: '售后中',
  91. REFUND: '退款成功',
  92. NO_REFUND: '不退款',
  93. }
  94. return MAP[val];
  95. },
  96. },
  97. data() {
  98. return {
  99. imageUrl: this.$imageUrl,
  100. tabList: [{
  101. name: '我发布的',
  102. value: 0
  103. },
  104. {
  105. name: '已卖出',
  106. value: 1
  107. },
  108. {
  109. name: '已下架',
  110. value: 2
  111. },
  112. ],
  113. tabCurrent: 0,
  114. dataList: [],
  115. pageNum: 1,
  116. loadStatus: 0,
  117. refresherTriggered: false,
  118. isShowDeliverDialog: false,
  119. }
  120. },
  121. async onLoad({
  122. tab
  123. }) {
  124. this.crossPage.$on('reloadMyIssueListPage', () => {
  125. this.refreshList();
  126. })
  127. this.tabCurrent = tab ? Number(tab) : 0;
  128. await this.getList();
  129. },
  130. onUnload() {
  131. this.crossPage.$off('reloadMyIssueListPage');
  132. },
  133. methods: {
  134. //获取列表数据
  135. async getList() {
  136. const statusMap = {
  137. 0: '',
  138. 1: 4,
  139. 2: 0
  140. }
  141. this.$api.get('/goods/list', {
  142. pageNum: this.pageNum,
  143. pageSize: 10,
  144. status: statusMap[this.tabCurrent],
  145. userId: this.$store.state.user.userId
  146. }).then(res => {
  147. this.loadStatus = 0;
  148. let list = res.data.records;
  149. if (list.length < 10) {
  150. this.loadStatus = 2;
  151. }
  152. this.dataList = this.dataList.concat(list);
  153. }).catch(() => {
  154. this.loadStatus = 2;
  155. }).finally(res => {
  156. this.refresherTriggered = false;
  157. })
  158. },
  159. // 滚动到底部
  160. scrolltolower(e) {
  161. if (this.loadStatus === 0) {
  162. this.pageNum++;
  163. this.getList();
  164. }
  165. },
  166. // 触发下拉刷新
  167. refresherrefresh(e) {
  168. this.refresherTriggered = true;
  169. this.refreshList();
  170. },
  171. refreshList() {
  172. this.dataList = [];
  173. this.pageNum = 1;
  174. this.getList();
  175. },
  176. clickTab(item) {
  177. this.tabCurrent = item.value;
  178. this.refreshList();
  179. },
  180. toDetail(id) {
  181. this.$navToPage({
  182. url: `/pages/goods/detail?id=${id}`
  183. })
  184. },
  185. openDeliver(id) {
  186. this.$refs.deliverDialog.setValue(id);
  187. this.isShowDeliverDialog = true;
  188. }
  189. }
  190. }
  191. // #endif
  192. // #ifndef H5
  193. import zjDialogDeliver from '@/components/zj-dialog/zj-dialog-deliver.vue';
  194. export default {
  195. components: {
  196. zjDialogDeliver
  197. },
  198. data() {
  199. return {
  200. pam: {},
  201. }
  202. },
  203. onLoad(pam) {
  204. this.pam = pam;
  205. },
  206. }
  207. // #endif
  208. </script>
  209. <style lang="scss" scoped>
  210. .header-container {
  211. background: #ffffff;
  212. }
  213. </style>