list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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-buyer" v-if="item.status === 4 && item.orderInfo">
  48. <image :src="item.orderInfo.buyerUserPic ? (imageUrl + item.orderInfo.buyerUserPic) : require('@/static/common/logo.png')"></image>
  49. <view class="name">{{item.orderInfo.buyerUserName}}</view>
  50. <view class="text">买到了</view>
  51. </view>
  52. <view class="left-location" v-else><text class="iconfont icon-dingwei"></text>{{item.city}} {{item.area}}</view>
  53. <view class="right-btn" @tap.stop>
  54. <block v-if="item.status === 4 && item.sendStatus === 'NO'">
  55. <u-button text="确认发货" shape="circle" @click="openDeliver(item.id)"></u-button>
  56. </block>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <Loading :loadStatus="loadStatus" :dataList="dataList" />
  62. </zj-page-layout>
  63. <zj-dialog-deliver
  64. ref="deliverDialog"
  65. :isShow="isShowDeliverDialog"
  66. @close="isShowDeliverDialog = false">
  67. </zj-dialog-deliver>
  68. </view>
  69. <!-- #endif -->
  70. <!-- #ifndef H5 -->
  71. <web-view :src="webViewHref(`/pages/mine/myIssue/list`, pam)" @message="crossPage.$listener"></web-view>
  72. <!-- #endif -->
  73. </template>
  74. <script>
  75. // #ifdef H5
  76. import zjDialogDeliver from '@/components/zj-dialog/zj-dialog-deliver.vue';
  77. export default {
  78. components: {
  79. zjDialogDeliver
  80. },
  81. filters: {
  82. statusFilter(val) {
  83. const MAP = {
  84. 1: '上架中',
  85. 2: '已转让',
  86. 0: '已下架',
  87. 3: '已冻结',
  88. 4: '已卖出',
  89. }
  90. return MAP[val];
  91. }
  92. },
  93. data() {
  94. return {
  95. imageUrl: this.$imageUrl,
  96. tabList: [
  97. {name: '我发布的', value: 0},
  98. {name: '已卖出', value: 1},
  99. {name: '已下架', value: 2},
  100. ],
  101. tabCurrent: 0,
  102. dataList: [],
  103. pageNum: 1,
  104. loadStatus: 0,
  105. refresherTriggered: false,
  106. isShowDeliverDialog: false,
  107. }
  108. },
  109. async onLoad({tab}) {
  110. this.tabCurrent = tab ? Number(tab) : 0;
  111. await this.getList();
  112. uni.$on('refreshMyIssueList', () => {
  113. this.refreshLish();
  114. })
  115. },
  116. onUnload() {
  117. uni.$off('refreshMyIssueList');
  118. },
  119. methods: {
  120. //获取列表数据
  121. async getList() {
  122. const statusMap = {
  123. 0: '',
  124. 1: 4,
  125. 2: 0
  126. }
  127. this.$api.get('/goods/list', {
  128. pageNum: this.pageNum,
  129. pageSize: 10,
  130. status: statusMap[this.tabCurrent],
  131. userId: this.$store.state.user.userId
  132. }).then(res => {
  133. this.loadStatus = 0;
  134. let list = res.data.records;
  135. if(list.length < 10){
  136. this.loadStatus = 2;
  137. }
  138. this.dataList = this.dataList.concat(list);
  139. }).catch(() => {
  140. this.loadStatus = 2;
  141. }).finally(res => {
  142. this.refresherTriggered = false;
  143. })
  144. },
  145. // 滚动到底部
  146. scrolltolower(e) {
  147. if (this.loadStatus === 0) {
  148. this.pageNum++;
  149. this.getList();
  150. }
  151. },
  152. // 触发下拉刷新
  153. refresherrefresh(e) {
  154. this.refresherTriggered = true;
  155. this.refreshLish();
  156. },
  157. refreshLish() {
  158. this.dataList = [];
  159. this.pageNum = 1;
  160. this.getList();
  161. },
  162. clickTab(item) {
  163. this.tabCurrent = item.value;
  164. this.refreshLish();
  165. },
  166. toDetail(id) {
  167. this.$navToPage({
  168. url: `/pages/goods/detail?id=${id}`
  169. })
  170. },
  171. openDeliver(id) {
  172. this.$refs.deliverDialog.setValue(id);
  173. this.isShowDeliverDialog = true;
  174. }
  175. }
  176. }
  177. // #endif
  178. // #ifndef H5
  179. import zjDialogDeliver from '@/components/zj-dialog/zj-dialog-deliver.vue';
  180. export default {
  181. components: {
  182. zjDialogDeliver
  183. },
  184. data() {
  185. return {
  186. pam: {},
  187. }
  188. },
  189. onLoad(pam) {
  190. this.pam = pam;
  191. },
  192. }
  193. // #endif
  194. </script>
  195. <style lang="scss" scoped>
  196. .header-container {
  197. background: #ffffff;
  198. }
  199. </style>