integral_goods_list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='productList'>
  4. <view class='search bg-color acea-row row-between-wrapper'>
  5. <view class='input acea-row row-between-wrapper'><text class='iconfont icon-sousuo'></text>
  6. <input :placeholder='$t(`搜索商品名称`)' placeholder-class='placeholder' confirm-type='search'
  7. name="search" :value='where.store_name' @confirm="searchSubmit"></input>
  8. </view>
  9. <view class='iconfont' :class='is_switch==true?"icon-pailie":"icon-tupianpailie"' @click='Changswitch'>
  10. </view>
  11. </view>
  12. <view class='nav acea-row row-middle'>
  13. <view class='item line1' :class='title ? "font-num":""' @click='set_where(1)'>{{$t(`默认`)}}</view>
  14. <view class='item' @click='set_where(2)'>
  15. {{$t(`积分`)}}
  16. <image v-if="price==1" src='../../static/images/up.png'></image>
  17. <image v-else-if="price==2" src='../../static/images/down.png'></image>
  18. <image v-else src='../../static/images/horn.png'></image>
  19. </view>
  20. <view class='item' @click='set_where(3)'>
  21. {{$t(`销量`)}}
  22. <image v-if="stock==1" src='../../static/images/up.png'></image>
  23. <image v-else-if="stock==2" src='../../static/images/down.png'></image>
  24. <image v-else src='../../static/images/horn.png'></image>
  25. </view>
  26. </view>
  27. <view class='list acea-row row-between-wrapper' :class='is_switch==true?"":"on"'>
  28. <view class='item' :class='is_switch==true?"":"on"' hover-class='none'
  29. v-for="(item,index) in productList" :key="index" @click="godDetail(item)">
  30. <view class='pictrue' :class='is_switch==true?"":"on"'>
  31. <image :src='item.image' :class='is_switch==true?"":"on"'></image>
  32. </view>
  33. <view class='text' :class='is_switch==true?"":"on"'>
  34. <view class='name line1'>{{item.title}}</view>
  35. <view class='money font-color' :class='is_switch==true?"":"on"'><text
  36. class='num'>{{item.price}}{{$t(`积分`)}}</text></view>
  37. <view class='vip acea-row row-between-wrapper' :class='is_switch==true?"":"on"'>
  38. <view class='vip-money' v-if="item.vip_price && item.vip_price > 0">{{item.vip_price}}
  39. {{$t(`积分`)}}
  40. <image src='../../static/images/vip.png'></image>
  41. </view>
  42. <view class="sales">
  43. <view class="">
  44. {{item.sales}}{{$t(`人兑换`)}}
  45. </view>
  46. <view class="exchange">{{$t(`兑换`)}}</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class='loadingicon acea-row row-center-wrapper' v-if='productList.length > 0'>
  52. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  53. </view>
  54. </view>
  55. </view>
  56. <view class='noCommodity' v-if="productList.length==0 && where.page > 1">
  57. <view class='emptyBox'>
  58. <image :src="imgHost + '/statics/images/no-thing.png'"></image>
  59. </view>
  60. <recommend :hostProduct="hostProduct"></recommend>
  61. </view>
  62. <!-- #ifndef MP -->
  63. <home></home>
  64. <!-- #endif -->
  65. </view>
  66. </template>
  67. <script>
  68. import home from '@/components/home';
  69. import {
  70. getProductHot
  71. } from '@/api/store.js';
  72. import {
  73. getStoreIntegralList
  74. } from '@/api/activity.js';
  75. import recommend from '@/components/recommend';
  76. import {
  77. mapGetters
  78. } from "vuex";
  79. import {
  80. goShopDetail
  81. } from '@/libs/order.js'
  82. import colors from "@/mixins/color";
  83. import {
  84. HTTP_REQUEST_URL
  85. } from '@/config/app';
  86. export default {
  87. computed: mapGetters(['uid']),
  88. components: {
  89. recommend,
  90. home
  91. },
  92. mixins: [colors],
  93. data() {
  94. return {
  95. imgHost: HTTP_REQUEST_URL,
  96. productList: [],
  97. is_switch: true,
  98. where: {
  99. store_name: '',
  100. priceOrder: '',
  101. salesOrder: '',
  102. page: 1,
  103. limit: 20,
  104. },
  105. price: 0,
  106. stock: 0,
  107. nows: false,
  108. loadend: false,
  109. loading: false,
  110. loadTitle: this.$t(`加载更多`),
  111. title: '',
  112. hostProduct: [],
  113. hotPage: 1,
  114. hotLimit: 10,
  115. hotScroll: false
  116. };
  117. },
  118. // 滚动监听
  119. onPageScroll(e) {
  120. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  121. uni.$emit('scroll');
  122. },
  123. onLoad: function(options) {
  124. this.where.cid = options.cid || 0;
  125. this.$set(this.where, 'sid', options.sid || 0);
  126. this.title = options.title || '';
  127. this.$set(this.where, 'store_name', options.searchValue || '');
  128. this.get_product_list();
  129. this.get_host_product();
  130. },
  131. methods: {
  132. // 去详情页
  133. godDetail(item) {
  134. goShopDetail(item, this.uid).then(res => {
  135. uni.navigateTo({
  136. url: `/pages/points_mall/integral_goods_details?id=${item.id}`
  137. })
  138. })
  139. },
  140. Changswitch: function() {
  141. let that = this;
  142. that.is_switch = !that.is_switch
  143. },
  144. searchSubmit: function(e) {
  145. let that = this;
  146. that.$set(that.where, 'store_name', e.detail.value);
  147. that.loadend = false;
  148. that.$set(that.where, 'page', 1)
  149. this.get_product_list(true);
  150. },
  151. /**
  152. * 获取我的推荐
  153. */
  154. get_host_product: function() {
  155. let that = this;
  156. if (that.hotScroll) return
  157. getProductHot(
  158. that.hotPage,
  159. that.hotLimit,
  160. ).then(res => {
  161. that.hotPage++
  162. that.hotScroll = res.data.length < that.hotLimit
  163. that.hostProduct = that.hostProduct.concat(res.data)
  164. // that.$set(that, 'hostProduct', res.data)
  165. });
  166. },
  167. //点击事件处理
  168. set_where: function(e) {
  169. switch (e) {
  170. case 1:
  171. this.where = {
  172. store_name: '',
  173. priceOrder: '',
  174. salesOrder: '',
  175. page: 1,
  176. limit: 20,
  177. }
  178. this.price = 0
  179. this.stock = 0
  180. break;
  181. case 2:
  182. if (this.price == 0) this.price = 1;
  183. else if (this.price == 1) this.price = 2;
  184. else if (this.price == 2) this.price = 0;
  185. this.stock = 0;
  186. break;
  187. case 3:
  188. if (this.stock == 0) this.stock = 1;
  189. else if (this.stock == 1) this.stock = 2;
  190. else if (this.stock == 2) this.stock = 0;
  191. this.price = 0
  192. break;
  193. case 4:
  194. this.nows = !this.nows;
  195. break;
  196. }
  197. this.loadend = false;
  198. this.$set(this.where, 'page', 1);
  199. this.get_product_list(true);
  200. },
  201. //设置where条件
  202. setWhere: function() {
  203. if (this.price == 0) this.where.priceOrder = '';
  204. else if (this.price == 1) this.where.priceOrder = 'asc';
  205. else if (this.price == 2) this.where.priceOrder = 'desc';
  206. if (this.stock == 0) this.where.salesOrder = '';
  207. else if (this.stock == 1) this.where.salesOrder = 'asc';
  208. else if (this.stock == 2) this.where.salesOrder = 'desc';
  209. this.where.news = this.nows ? 1 : 0;
  210. },
  211. //查找产品
  212. get_product_list: function(isPage) {
  213. let that = this;
  214. that.setWhere();
  215. if (that.loadend) return;
  216. if (that.loading) return;
  217. if (isPage === true) that.$set(that, 'productList', []);
  218. that.loading = true;
  219. that.loadTitle = '';
  220. getStoreIntegralList(that.where).then(res => {
  221. let list = res.data;
  222. let productList = that.$util.SplitArray(list, that.productList);
  223. let loadend = list.length < that.where.limit;
  224. that.loadend = loadend;
  225. that.loading = false;
  226. that.loadTitle = loadend ? that.$t(`我也是有底线的`) : that.$t(`加载更多`);
  227. that.$set(that, 'productList', productList);
  228. that.$set(that.where, 'page', that.where.page + 1);
  229. }).catch(err => {
  230. that.loading = false;
  231. that.loadTitle = that.$t(`加载更多`);
  232. });
  233. },
  234. },
  235. onPullDownRefresh() {
  236. },
  237. onReachBottom() {
  238. if (this.productList.length > 0) {
  239. this.get_product_list();
  240. } else {
  241. this.get_host_product();
  242. }
  243. }
  244. }
  245. </script>
  246. <style scoped lang="scss">
  247. .productList .search {
  248. width: 100%;
  249. height: 86rpx;
  250. padding-left: 23rpx;
  251. box-sizing: border-box;
  252. position: fixed;
  253. left: 0;
  254. top: 0;
  255. z-index: 9;
  256. }
  257. .productList .search .input {
  258. width: 640rpx;
  259. height: 60rpx;
  260. background-color: #fff;
  261. border-radius: 50rpx;
  262. padding: 0 20rpx;
  263. box-sizing: border-box;
  264. }
  265. .productList .search .input input {
  266. width: 548rpx;
  267. height: 100%;
  268. font-size: 26rpx;
  269. }
  270. .productList .search .input .placeholder {
  271. color: #999;
  272. }
  273. .productList .search .input .iconfont {
  274. font-size: 35rpx;
  275. color: #555;
  276. }
  277. .productList .search .icon-pailie,
  278. .productList .search .icon-tupianpailie {
  279. color: #fff;
  280. width: 62rpx;
  281. font-size: 40rpx;
  282. height: 86rpx;
  283. line-height: 86rpx;
  284. }
  285. .productList .nav {
  286. height: 86rpx;
  287. color: #454545;
  288. position: fixed;
  289. left: 0;
  290. width: 100%;
  291. font-size: 28rpx;
  292. background-color: #fff;
  293. margin-top: 86rpx;
  294. top: 0;
  295. z-index: 9;
  296. }
  297. .productList .nav .item {
  298. width: 33%;
  299. text-align: center;
  300. }
  301. .productList .nav .item.font-color {}
  302. .productList .nav .item image {
  303. width: 15rpx;
  304. height: 19rpx;
  305. margin-left: 10rpx;
  306. }
  307. .productList .list {
  308. padding: 0 20rpx;
  309. margin-top: 172rpx;
  310. }
  311. .productList .list.on {
  312. background-color: #fff;
  313. border-top: 1px solid #f6f6f6;
  314. }
  315. .productList .list .item {
  316. width: 345rpx;
  317. margin-top: 20rpx;
  318. background-color: #fff;
  319. border-radius: 20rpx;
  320. }
  321. .productList .list .item.on {
  322. width: 100%;
  323. display: flex;
  324. border-bottom: 1rpx solid #f6f6f6;
  325. padding: 30rpx 0;
  326. margin: 0;
  327. }
  328. .productList .list .item .pictrue {
  329. position: relative;
  330. width: 100%;
  331. height: 345rpx;
  332. }
  333. .productList .list .item .pictrue.on {
  334. width: 180rpx;
  335. height: 180rpx;
  336. }
  337. .productList .list .item .pictrue image {
  338. width: 100%;
  339. height: 100%;
  340. border-radius: 20rpx 20rpx 0 0;
  341. }
  342. .productList .list .item .pictrue image.on {
  343. border-radius: 6rpx;
  344. }
  345. .productList .list .item .text {
  346. padding: 20rpx 17rpx 26rpx 17rpx;
  347. font-size: 30rpx;
  348. color: #222;
  349. }
  350. .productList .list .item .text.on {
  351. width: 508rpx;
  352. padding: 0 0 0 22rpx;
  353. }
  354. .productList .list .item .text .money {
  355. font-size: 22rpx;
  356. margin-top: 8rpx;
  357. }
  358. .productList .list .item .text .money.on {
  359. margin-top: 50rpx;
  360. }
  361. .productList .list .item .text .money .num {
  362. font-size: 34rpx;
  363. }
  364. .productList .list .item .text .vip {
  365. font-size: 22rpx;
  366. margin-top: 7rpx;
  367. .sales {
  368. color: #aaa;
  369. width: 100%;
  370. display: flex;
  371. justify-content: space-between;
  372. .exchange {
  373. border: 1px solid var(--view-theme);
  374. border-radius: 20rpx;
  375. padding: 0 12rpx;
  376. color: var(--view-theme);
  377. }
  378. }
  379. }
  380. .productList .list .item .text .vip.on {
  381. margin-top: 12rpx;
  382. }
  383. .productList .list .item .text .vip .vip-money {
  384. font-size: 24rpx;
  385. color: #282828;
  386. font-weight: bold;
  387. }
  388. .productList .list .item .text .vip .vip-money image {
  389. width: 64rpx;
  390. height: 26rpx;
  391. margin-left: 4rpx;
  392. }
  393. .noCommodity {
  394. background-color: #fff;
  395. padding-bottom: 30rpx;
  396. .emptyBox {
  397. text-align: center;
  398. padding-top: 20rpx;
  399. .tips {
  400. color: #aaa;
  401. font-size: 26rpx;
  402. }
  403. image {
  404. width: 414rpx;
  405. height: 304rpx;
  406. }
  407. }
  408. }
  409. </style>