list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view>
  3. <view class="tab">
  4. <u-tabs :list="tab" @click="click" :lineHeight="5"></u-tabs>
  5. </view>
  6. <view class="goodsManageList">
  7. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  8. <view class="top">
  9. <view class="title omit">{{ item.goodsName }}</view>
  10. <view class="state" v-if="item.isRelease == 0" @click.stop="del(item)" style="color: #f44336">删除</view>
  11. <view class="state" style="color: #4581fb" v-if="item.isRelease == 1">发布中</view>
  12. <view class="state" style="color: #4CAF50" v-if="item.isOrders == 1">已接单</view>
  13. </view>
  14. <view class="con">
  15. <view class="flex fs">
  16. <view class="f left" style="flex: 0.5">
  17. <view class="tag">商品量:{{ item.goodsQuantity }}</view>
  18. </view>
  19. <view class="f left">
  20. <view class="tag">{{ item.createTime }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="op">
  25. <view class="flex">
  26. <view class="f rline" v-if="item.isRelease == 0" @click.stop="edit(item)">编辑</view>
  27. <view class="f" v-if="item.isRelease == 0" style="color: #4581fb" @click.stop="op(item, 1)">发布</view>
  28. <view class="f" v-if="item.isRelease == 1" style="color: #f44336" @click.stop="op(item, 0)">取消发布</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  33. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. tab: [
  42. //isRelease:是否发布[0=待发布,1=已发布] isOrders:是否被接单[0=待接单,1=已被接单]
  43. { name: '全部', isRelease: '', isOrders: '' },
  44. { name: '待发布', isRelease: 0, isOrders: 0 },
  45. { name: '发布中', isRelease: 1, isOrders: 0 },
  46. { name: '已接单', isRelease: 1, isOrders: 1 }
  47. //{ name: '已确认', isRelease: 1 ,isOrders: 1},
  48. //{ name: '已完成', isRelease: 1 ,isOrders: 1}
  49. ],
  50. list: [],
  51. param: { pageNo: 1, pageSize: 10 },
  52. loadMore: true
  53. };
  54. },
  55. onLoad(e) {
  56. this.getData();
  57. uni.$on('purchaser_buy_list', res => {
  58. this.refresh();
  59. });
  60. },
  61. methods: {
  62. getData() {
  63. this.http.request({
  64. url: '/level-two-server/app/TbGoodsDemand/getAppList',
  65. data: this.param,
  66. loading: 'false',
  67. success: res => {
  68. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  69. this.list.push(...res.data.data);
  70. }
  71. });
  72. },
  73. //点击tab切换
  74. click(e) {
  75. this.param.isRelease = e.isRelease;
  76. this.param.isOrders = e.isOrders;
  77. this.refresh();
  78. },
  79. detail(item) {
  80. uni.navigateTo({ url: '/pages/market/two/purchaser/buy/detail?id=' + item.id });
  81. },
  82. edit(item) {
  83. uni.navigateTo({ url: '/pages/market/two/purchaser/buy/add?id=' + item.id });
  84. },
  85. op(item, isRelease) {
  86. uni.showModal({
  87. title: '提示',
  88. content: isRelease == 0 ? '确定取消发布' : '确定发布到市场?',
  89. success: res => {
  90. if (res.confirm) {
  91. this.http.request({
  92. url: '/level-two-server/app/TbGoodsDemand/changeState',
  93. method: 'POST',
  94. data: { id: item.id, isRelease: isRelease },
  95. success: res => {
  96. uni.showToast({ title: '操作成功' });
  97. item.isRelease = isRelease;
  98. }
  99. });
  100. }
  101. }
  102. });
  103. },
  104. del(item) {
  105. uni.showModal({
  106. title: '提示',
  107. content: '确定删除该需求?',
  108. success: res => {
  109. if (res.confirm) {
  110. this.http.request({
  111. url: '/level-two-server/app/TbGoodsDemand/delete?id=' + item.id,
  112. success: res => {
  113. uni.showToast({ title: '删除成功' });
  114. this.list.splice(this.list.indexOf(item), 1);
  115. }
  116. });
  117. }
  118. }
  119. });
  120. },
  121. //刷新数据
  122. refresh() {
  123. this.loadMore = true;
  124. this.param.pageNo = 1;
  125. this.list = [];
  126. this.getData();
  127. }
  128. },
  129. //下拉刷新
  130. onPullDownRefresh() {
  131. setTimeout(() => {
  132. this.refresh();
  133. uni.stopPullDownRefresh();
  134. }, 1000);
  135. },
  136. //上拉加载
  137. onReachBottom() {
  138. if (this.loadMore) {
  139. this.param.pageNo++;
  140. this.getData();
  141. }
  142. },
  143. onNavigationBarButtonTap() {
  144. uni.navigateTo({ url: '/pages/market/two/purchaser/buy/add' });
  145. }
  146. };
  147. </script>
  148. <style lang="scss">
  149. page {
  150. background-color: $pg;
  151. }
  152. </style>