products.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view>
  3. <!--promote/products/products.wxml-->
  4. <view class="top dflex">
  5. <view class="search dflex flex">
  6. <image src="/promote/static/promote/images/ssico.png"></image>
  7. <input placeholder="查询" placeholder-class="placeholder" class="flex" @input="intTitle" @confirm="confirmInt"></input>
  8. </view>
  9. <view class="filter dflex">
  10. <picker @change="bindPickerChange" :value="timeIndex" :range="timeType" range-key="name">
  11. <view class="picker">
  12. {{timeType[timeIndex].name}}
  13. </view>
  14. </picker>
  15. <image src="/promote/static/promote/images/bico.png"></image>
  16. </view>
  17. </view>
  18. <view class="list" v-if="pageList.length > 0">
  19. <view v-for="(item, index) in pageList" :key="index" class="li">
  20. <view class="info dflex">
  21. <image :src="item.pic" mode="aspectFit"></image>
  22. <view class="infos flex">
  23. <view class="title">{{item.title}}</view>
  24. <view class="nums">规格:<block v-for="(itemGuige,idx) in item.specs" :key="idx">{{itemGuige.value}}</block><text>编码:{{item.productNumber}}</text></view>
  25. </view>
  26. </view>
  27. <view class="datas dflex">
  28. <view class="dflex">销售额<text>{{item.payMoney}}</text></view>
  29. <view class="dflex">转化购买数<text>{{item.quantity}}</text></view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="nodata" v-if="ishow">
  34. <image :src="picUrlss+'empty_sp.png'"></image>
  35. <text>暂无商品</text>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. // promote/products/products.js
  41. const app = getApp();
  42. const req = require("../../utils/request.js");
  43. export default {
  44. data() {
  45. return {
  46. picUrlss: req.public.picUrls,
  47. pageList: [],
  48. form: {
  49. page: 1,
  50. limit: 10
  51. },
  52. title: '',
  53. timeType: [{
  54. name: '全部',
  55. value: 0
  56. }, {
  57. name: '今天',
  58. value: 1
  59. }, {
  60. name: '近7天',
  61. value: 7
  62. }, {
  63. name: '近一月',
  64. value: 30
  65. }],
  66. timeIndex: 0,
  67. isLoad: true,
  68. isShow: false,
  69. ishow: false
  70. };
  71. },
  72. components: {},
  73. props: {},
  74. /**
  75. * 生命周期函数--监听页面加载
  76. */
  77. onLoad: function (options) {
  78. this.getList(this.timeType[this.timeIndex].value);
  79. },
  80. onReachBottom() {
  81. this.form.page++;
  82. this.getList(this.timeType[this.timeIndex].value);
  83. },
  84. methods: {
  85. intTitle(e) {
  86. this.setData({
  87. title: e.detail.value
  88. });
  89. },
  90. confirmInt() {
  91. this.setData({
  92. form: {
  93. page: 1,
  94. limit: 10
  95. },
  96. isLoad: true
  97. });
  98. this.getList(this.timeType[this.timeIndex].value);
  99. },
  100. bindPickerChange: function (e) {
  101. this.setData({
  102. timeIndex: e.detail.value,
  103. form: {
  104. page: 1,
  105. limit: 10
  106. },
  107. isLoad: true
  108. });
  109. this.getList(this.timeType[this.timeIndex].value);
  110. },
  111. getList(timeType) {
  112. let isShowLoading = false;
  113. if (this.form.page == 1 && !isShowLoading) {
  114. // console.log('一直在加载');
  115. req.loadIng('加载中');
  116. isShowLoading = true;
  117. }
  118. let that = this;
  119. // console.log("===============", that.isLoad);
  120. if (!that.isLoad) return false;
  121. // console.log("11111111111111111");
  122. that.isLoad = false;
  123. if (timeType == 0) {
  124. that.form.timeType = '';
  125. } else {
  126. that.form.timeType = timeType;
  127. }
  128. this.form.title = this.title;
  129. req.getRequest('/api/distribution/getDistributionProduct', that.form, data => {
  130. if (data && data.length >= 10) that.isLoad = true;
  131. if (that.form.page > 1) data = that.pageList.concat(data);
  132. that.setData({
  133. pageList: data
  134. });
  135. if (this.pageList && this.pageList.length <= 0) {
  136. that.setData({
  137. ishow: true
  138. });
  139. } else {
  140. that.setData({
  141. ishow: false
  142. });
  143. }
  144. if (isShowLoading) {
  145. uni.hideLoading();
  146. isShowLoading = false;
  147. }
  148. });
  149. }
  150. }
  151. };
  152. </script>
  153. <style>
  154. @import "./products.css";
  155. </style>