list.vue 5.6 KB

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