list.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view>
  3. <view class="search">
  4. <u-search placeholder="搜索商品或车牌号" v-model="param.goodsName" bgColor="white" @search="refresh()" :animation="true" actionText="取消" @clear="refresh()"></u-search>
  5. <view class="clear"></view>
  6. </view>
  7. <view class="goodsList">
  8. <view class="sort-list">
  9. <view class="sort-item" :class="{ active: item.check }" v-for="(item, index) in sort" :key="index" @click="select(item, index)">
  10. <text>{{ item.name }}</text>
  11. <text v-if="index > 0 && item.isAsc == 'desc'" class="icon">&#xeb0a;</text>
  12. <text v-if="index > 0 && item.isAsc == 'asc'" class="icon">&#xeb0b;</text>
  13. </view>
  14. <view class="type" @click="go()">
  15. <text>{{ param.goodsType || '分类' }}</text>
  16. <text class="icon">&#xe8f2;</text>
  17. </view>
  18. </view>
  19. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  20. <view class="title">{{ item.LeaderName }}</view>
  21. <view class="check" @click.stop="selected(item)" v-if="user.userType == 3">
  22. <text class="check icon" v-if="item.check" style="color: #4581fb">&#xe631;</text>
  23. <text class="check icon" v-else>&#xe60c;</text>
  24. </view>
  25. <image src="../../../static/news.jpg" mode="aspectFill" class="pic"></image>
  26. <view class="con">
  27. <view class="productName omit">{{ item.goodsName }}</view>
  28. <view class="price">¥ {{ item.resalePrice }}</view>
  29. <view class="desc">车牌号:{{ item.veNo }}</view>
  30. <view class="icon btn" v-if="user.userType == 3" @click.stop="addCar(item)">&#xe600;</view>
  31. <view class="btn" v-if="user.userType == 3" @click.stop="buy(item)">购买</view>
  32. </view>
  33. </view>
  34. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  35. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  36. </view>
  37. <productType v-model="show"></productType>
  38. <button class="addBtn" @click="goCar()" v-if="user.userType == 3">
  39. <text class="icon">&#xe600;</text>
  40. <view class="bag animated" :class="{ bounce: add }" v-if="cars > 0">{{ cars }}</view>
  41. </button>
  42. <view class="mfooter" v-if="selects.length > 0&&user.userType == 3">
  43. <view class="flex">
  44. <view class="f">
  45. <button class="btn" @click="buy({})">立即购买({{ selects.length }})</button>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. user: this.getUser(),
  56. show: false,
  57. isAsc: 'desc',
  58. cars: 0,
  59. add: false,
  60. sort: [
  61. { name: '综合', sortName: 'id', isAsc: 'desc', check: false },
  62. { name: '日期', sortName: 'create_time', isAsc: 'desc', check: false },
  63. { name: '数量', sortName: 'goods_quantity', isAsc: 'desc', check: false }
  64. ],
  65. list: [],
  66. param: { pageNo: 1, pageSize: 10 },
  67. loadMore: true,
  68. selects: []
  69. };
  70. },
  71. /* onShow(){
  72. this.refresh();
  73. }, */
  74. onLoad(e) {
  75. this.getData();
  76. //选择商品分类
  77. uni.$on('productType', res => {
  78. this.param.typeCode = res.no;
  79. this.param.goodsType = res.name;
  80. this.refresh();
  81. });
  82. },
  83. methods: {
  84. select(item, index) {
  85. this.sort.forEach(it => (it.check = false));
  86. item.check = true;
  87. if (index > 0) {
  88. this.isAsc = this.isAsc == 'desc' ? 'asc' : 'desc';
  89. item.isAsc = this.isAsc;
  90. }
  91. this.param.orderBy = item.sortName + ' ' + this.isAsc;
  92. this.refresh();
  93. },
  94. getData() {
  95. this.http.request({
  96. url: '/level-two-server/app/TbOrders/getLevelTwoList',
  97. data: this.param,
  98. loading: 'false',
  99. success: res => {
  100. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  101. this.list.push(...res.data.data);
  102. }
  103. });
  104. },
  105. //多选购买
  106. selected(item) {
  107. item.check = !item.check;
  108. this.$forceUpdate();
  109. this.selects = this.list.filter(item => item.check);
  110. },
  111. //选择分类
  112. go() {
  113. uni.navigateTo({ url: '/pages/market/productType?current=' + this.param.current + '&now=' + this.param.now });
  114. },
  115. detail(item) {
  116. uni.navigateTo({ url: '/pages/market/two/detail?orderId=' + item.id });
  117. },
  118. addCar(item) {
  119. this.add = true;
  120. this.http.request({
  121. url: '/level-two-server/app/TbOrdersCart/add',
  122. method: 'POST',
  123. data: { orderId: item.id },
  124. success: res => {
  125. this.cars++;
  126. setTimeout(() => {
  127. this.add = false;
  128. }, 500);
  129. uni.showToast({ title: '添加成功' });
  130. }
  131. });
  132. },
  133. goCar() {
  134. uni.navigateTo({ url: '/pages/market/two/purchaser/order/cart' });
  135. },
  136. buy(item) {
  137. if (item.id) {
  138. uni.navigateTo({
  139. url: '/pages/market/two/purchaser/buy/buy?orderId=' + item.id
  140. });
  141. } else {
  142. uni.navigateTo({
  143. url: '/pages/market/two/purchaser/buy/buy?orderId=' + this.selects.map(item => item.id)
  144. });
  145. }
  146. },
  147. //刷新数据
  148. refresh() {
  149. this.loadMore = true;
  150. this.param.pageNum = 1;
  151. this.list = [];
  152. this.selects=[];
  153. this.getData();
  154. }
  155. },
  156. //下拉刷新
  157. onPullDownRefresh() {
  158. setTimeout(() => {
  159. this.refresh();
  160. uni.stopPullDownRefresh();
  161. }, 1000);
  162. },
  163. //上拉加载
  164. onReachBottom() {
  165. if (this.loadMore) {
  166. this.param.pageNum++;
  167. this.getData();
  168. }
  169. }
  170. };
  171. </script>
  172. <style lang="scss">
  173. page {
  174. background-color: $pg;
  175. }
  176. .con {
  177. .btn {
  178. float: right;
  179. background-color: $main-color;
  180. color: #000;
  181. height: 20px;
  182. position: relative;
  183. color: white;
  184. padding: 5px 20px;
  185. margin-left: 10px;
  186. }
  187. .icon {
  188. line-height: 30px;
  189. line-height: 20px;
  190. }
  191. }
  192. .mfooter {
  193. background-color: #ffffff00;
  194. border: 0px;
  195. .btn{
  196. background-color: #F44336;
  197. }
  198. }
  199. </style>