list.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view>
  3. <view style="position: relative;z-index: 999;height:150px;">
  4. <view style="position: fixed;width: 100%;background-color: white;">
  5. <u-tabs :list="tab" @click="clickSearchType" :lineHeight="5"></u-tabs>
  6. <view class="search">
  7. <u-search placeholder="搜索商品名或车牌号" v-model="param.goodsName" bgColor="#e2e2e2" @search="refresh()"
  8. :animation="true" actionText="取消" @clear="refresh()"></u-search>
  9. <view class="clear"></view>
  10. </view>
  11. <view class="sort-list">
  12. <view class="sort-item" :class="{ active: item.check }" v-for="(item, index) in sort" :key="index"
  13. @click="select(item, index)">
  14. <text>{{ item.name }}</text>
  15. <text v-if="index > 0 && item.isAsc == 'desc'" class="icon">&#xeb0a;</text>
  16. <text v-if="index > 0 && item.isAsc == 'asc'" class="icon">&#xeb0b;</text>
  17. </view>
  18. <!-- <view class="type" @click="go()">
  19. <text>{{ param.goodsType || '分类' }}</text>
  20. <text class="icon">&#xe8f2;</text>
  21. </view> -->
  22. </view>
  23. </view>
  24. </view>
  25. <view class="goodsList">
  26. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  27. <view class="title">
  28. <text v-if="currentOrderType==2">{{ item.leaderName }}</text>
  29. <text v-if="currentOrderType==1">{{ item.shopName }}</text>
  30. </view>
  31. <view class="check" @click.stop="selected(item)" v-if="user.userType == 3">
  32. <text class="check icon" v-if="item.check" style="color: #4581fb">&#xe631;</text>
  33. <text class="check icon" v-else>&#xe60c;</text>
  34. </view>
  35. <view class="con">
  36. <view class="productName omit">
  37. <text v-if="currentOrderType==2">{{ item.goodsName }}</text>
  38. <text v-if="currentOrderType==1">{{ item.goodsNames }}</text>
  39. </view>
  40. <view class="desc">车牌号 <text style="font-weight: bold;margin-left: 5px;"> {{ item.veNo }}</text>
  41. </view>
  42. <view class="desc omit">
  43. <text v-if="currentOrderType==2">重量 {{ item.totalWeight }}{{ item.goodsUnit }}</text>
  44. <text v-if="currentOrderType==1">重量 {{ item.sumNetWt }} kg</text>
  45. <text>{{ item.tradeAreaName }}</text>
  46. </view>
  47. <view class="price" v-if="currentOrderType==2"> ¥ {{ item.resalePrice }}</view>
  48. <view class="price" v-if="currentOrderType==1"> ¥ {{ item.sumUpPrice }}</view>
  49. <view class="op">
  50. <view class="date">{{ item.createTime }}</view>
  51. <template>
  52. <view class="icon btn" v-if="user.userType == 3&&currentOrderType==2"
  53. @click.stop="addCar(item)">&#xe600;</view>
  54. <view class="btn" v-if="user.userType == 3" @click.stop="buy(item)">购买</view>
  55. </template>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  60. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  61. </view>
  62. <productType v-model="show"></productType>
  63. <button class="addBtn" @click="goCar()" v-if="user.userType == 3&&currentOrderType==2">
  64. <text class="icon">&#xe600;</text>
  65. <view class="bag animated" :class="{ bounce: add }" v-if="cars > 0">{{ cars }}</view>
  66. </button>
  67. <view class="mfooter" v-if="selects.length > 0">
  68. <view class="flex">
  69. <view class="f">
  70. <button class="btn" @click="buy({})">立即购买({{ selects.length }})</button>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data() {
  79. return {
  80. tab: [{
  81. name: '整车',
  82. orderType: 1
  83. },
  84. {
  85. name: '非整车',
  86. orderType: 2
  87. },
  88. ],
  89. currentOrderType: 1,
  90. user: this.getUser(),
  91. show: false,
  92. isAsc: 'desc',
  93. cars: 0,
  94. add: false,
  95. sort: [{
  96. name: '综合',
  97. sortName: 'id',
  98. isAsc: 'desc',
  99. check: false
  100. },
  101. {
  102. name: '日期',
  103. sortName: 'create_time',
  104. isAsc: 'desc',
  105. check: false
  106. },
  107. {
  108. name: '金额',
  109. sortName: 'resale_price',
  110. isAsc: 'desc',
  111. check: false
  112. }
  113. ],
  114. list: [],
  115. param: {
  116. pageNo: 1,
  117. pageSize: 10
  118. },
  119. loadMore: true,
  120. selects: []
  121. };
  122. },
  123. onLoad(e) {
  124. //选择商品分类
  125. uni.$on('productType', res => {
  126. this.param.typeCode = res.no;
  127. this.param.goodsType = res.name;
  128. this.refresh();
  129. });
  130. },
  131. onShow() {
  132. this.init();
  133. this.query();
  134. },
  135. methods: {
  136. clickSearchType(e) {
  137. let orderType = e.orderType;
  138. if (this.currentOrderType == orderType) {
  139. return;
  140. }
  141. this.currentOrderType = orderType;
  142. this.init();
  143. this.query();
  144. },
  145. init() {
  146. this.list = [];
  147. this.param = {
  148. pageNo: 1,
  149. pageSize: 10
  150. }
  151. },
  152. query() {
  153. if (this.currentOrderType == 2) {
  154. this.getData();
  155. } else {
  156. this.getWholeData();
  157. }
  158. },
  159. select(item, index) {
  160. this.sort.forEach(it => (it.check = false));
  161. item.check = true;
  162. if (index > 0) {
  163. this.isAsc = this.isAsc == 'desc' ? 'asc' : 'desc';
  164. item.isAsc = this.isAsc;
  165. }
  166. item.sortName=item.sortName=='resale_price'&&this.currentOrderType==1?item.sortName='sumUpPrice':item.sortName;
  167. this.param.orderBy = item.sortName + ' ' + this.isAsc;
  168. this.refresh();
  169. },
  170. getWholeData() {
  171. this.http.request({
  172. url: '/level-one-server/app/HtTradeSettlement/getOnSaleList',
  173. data: this.param,
  174. loading: 'false',
  175. success: res => {
  176. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  177. this.list.push(...res.data.data);
  178. }
  179. });
  180. },
  181. getData() {
  182. this.http.request({
  183. url: '/level-two-server/app/TbOrders/getLevelTwoList',
  184. data: this.param,
  185. loading: 'false',
  186. success: res => {
  187. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  188. this.list.push(...res.data.data);
  189. }
  190. });
  191. },
  192. //多选购买
  193. selected(item) {
  194. item.check = !item.check;
  195. this.$forceUpdate();
  196. this.selects = this.list.filter(item => item.check);
  197. },
  198. //选择分类
  199. go() {
  200. uni.navigateTo({
  201. url: '/pages/market/productType?current=' + this.param.current + '&now=' + this.param.now
  202. });
  203. },
  204. detail(item) {
  205. uni.navigateTo({
  206. url: '/pages/market/two/purchaser/buy/detail?id=' + item.id + '&type=' + this.currentOrderType
  207. });
  208. },
  209. addCar(item) {
  210. this.add = true;
  211. this.http.request({
  212. url: '/level-two-server/app/TbOrdersCart/add',
  213. method: 'POST',
  214. data: {
  215. orderId: item.id
  216. },
  217. success: res => {
  218. this.cars++;
  219. setTimeout(() => {
  220. this.add = false;
  221. }, 500);
  222. uni.showToast({
  223. title: '添加成功'
  224. });
  225. }
  226. });
  227. },
  228. goCar() {
  229. uni.navigateTo({
  230. url: '/pages/market/two/purchaser/order/cart'
  231. });
  232. },
  233. buy(item) {
  234. let ids = undefined;
  235. if (item.id) {
  236. ids = item.id;
  237. } else {
  238. ids = this.selects.map(item => item.id)
  239. }
  240. if (this.currentOrderType == 2) {
  241. uni.navigateTo({
  242. url: '/pages/market/two/purchaser/buy/buy?orderId=' + ids
  243. });
  244. return;
  245. }
  246. uni.navigateTo({
  247. url: '/pages/market/two/purchaser/buy/buyWhole?ids=' + ids
  248. });
  249. },
  250. //刷新数据
  251. refresh() {
  252. this.loadMore = true;
  253. this.param.pageNo = 1;
  254. this.list = [];
  255. this.selects = [];
  256. this.query();
  257. }
  258. },
  259. //下拉刷新
  260. onPullDownRefresh() {
  261. setTimeout(() => {
  262. this.refresh();
  263. uni.stopPullDownRefresh();
  264. }, 1000);
  265. },
  266. //上拉加载
  267. onReachBottom() {
  268. if (this.loadMore) {
  269. this.param.pageNo++;
  270. this.query();
  271. }
  272. }
  273. };
  274. </script>
  275. <style lang="scss">
  276. page {
  277. background-color: $pg;
  278. }
  279. .goodsList .item .con {
  280. width: 98%;
  281. }
  282. .con {
  283. .btn {
  284. float: right;
  285. background-color: $main-color;
  286. height: 20px;
  287. position: relative;
  288. color: white;
  289. padding: 5px 20px;
  290. margin-left: 10px;
  291. }
  292. .icon {
  293. line-height: 20px;
  294. }
  295. }
  296. .mfooter {
  297. background-color: #ffffff00;
  298. border: 0px;
  299. .btn {
  300. background-color: #F44336;
  301. }
  302. }
  303. </style>