list.vue 4.6 KB

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