list.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view>
  3. <view class="search">
  4. <u-search placeholder="搜索商品名称" v-model="param.customerName" 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="show = true">
  15. <text>分类</text>
  16. <text class="icon">&#xe8f2;</text>
  17. </view>
  18. <view class="clear"></view>
  19. </view>
  20. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item.id)">
  21. <view class="title">广西京东自营店南宁分店</view>
  22. <image src="../../../static/news.jpg" mode="aspectFill" class="pic"></image>
  23. <view class="con">
  24. <view class="productName omit">{{ item.goodsName }}</view>
  25. <view class="desc">
  26. <text>50吨</text>
  27. <text>{{ item.tradeAreaName }}</text>
  28. </view>
  29. <view class="price">¥ {{ item.price }}</view>
  30. <view class="icon buy" @click.stop="addCar(item)">&#xe604;</view>
  31. </view>
  32. <view class="clear"></view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. show: false,
  42. user: this.getUser(),
  43. sort: [
  44. {
  45. name: '综合',
  46. key: 1,
  47. isAsc: 'desc',
  48. check: false
  49. },
  50. {
  51. name: '日期',
  52. key: 2,
  53. isAsc: 'desc',
  54. check: false
  55. },
  56. {
  57. name: '价格',
  58. key: 3,
  59. isAsc: 'desc',
  60. check: false
  61. }
  62. ],
  63. list: [],
  64. param: { pageNo: 1, pageSize: 10 },
  65. loadMore: true
  66. };
  67. },
  68. onLoad() {
  69. this.getData();
  70. },
  71. methods: {
  72. getData() {
  73. this.http.request({
  74. url: '/level-one-server/TbGoodsTransit/getTransitList',
  75. data: this.param,
  76. loading: 'false',
  77. success: res => {
  78. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  79. this.list.push(...res.data.data);
  80. }
  81. });
  82. },
  83. // 添加购物车
  84. addCar(goods) {
  85. let params = {
  86. buyUserId: this.user.id,
  87. enterpriseId: goods.merchantId,
  88. shopId: goods.shopId,
  89. tradeAreaId: goods.tradeAreaId,
  90. saleGoodsInfoId: goods.id,
  91. goodsImg: goods.goodsImg,
  92. goodsName: goods.goodsName
  93. // buyNum: parseInt(this.num)
  94. };
  95. this.http.request({
  96. url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart',
  97. data: params,
  98. contentType: 'application/json; charset=utf-8',
  99. method: 'POST',
  100. success: res => {
  101. uni.showToast({ title: '添加成功' });
  102. }
  103. });
  104. },
  105. detail(id) {
  106. uni.navigateTo({ url: '/pages/market/one/detail?id=' + id });
  107. }
  108. }
  109. };
  110. </script>
  111. <style lang="scss">
  112. page {
  113. background-color: $pg;
  114. }
  115. .search {
  116. padding: 12px 12px 0px 12px;
  117. }
  118. </style>