integral_goods_list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <!-- 商品列表模块 -->
  3. <view :style="colorStyle">
  4. <view class='productList'>
  5. <view class='search bg-color acea-row row-between-wrapper'>
  6. <view class='input acea-row row-between-wrapper'><text class='iconfont icon-sousuo'></text>
  7. <input placeholder='搜索商品名称' placeholder-class='placeholder' confirm-type='search' name="search"
  8. :value='where.store_name' @confirm="searchSubmit"></input>
  9. </view>
  10. <view class='iconfont' :class='is_switch==true?"icon-pailie":"icon-tupianpailie"' @click='Changswitch'>
  11. </view>
  12. </view>
  13. <view class='nav acea-row row-middle'>
  14. <view class='item line1' :class='title ? "font-num":""' @click='set_where(1)'>默认</view>
  15. <view class='item' @click='set_where(2)'>
  16. 积分
  17. <image v-if="price==1" src='../../static/images/up.png'></image>
  18. <image v-else-if="price==2" src='../../static/images/down.png'></image>
  19. <image v-else src='../../static/images/horn.png'></image>
  20. </view>
  21. <view class='item' @click='set_where(3)'>
  22. 销量
  23. <image v-if="stock==1" src='../../static/images/up.png'></image>
  24. <image v-else-if="stock==2" src='../../static/images/down.png'></image>
  25. <image v-else src='../../static/images/horn.png'></image>
  26. </view>
  27. </view>
  28. <view class='list acea-row row-between-wrapper' :class='is_switch==true?"":"on"'>
  29. <view class='item' :class='is_switch==true?"":"on"' hover-class='none'
  30. v-for="(item,index) in productList" :key="index" @click="godDetail(item)">
  31. <view class='pictrue' :class='is_switch==true?"":"on"'>
  32. <image :src='item.image' :class='is_switch==true?"":"on"'></image>
  33. </view>
  34. <view class='text' :class='is_switch==true?"":"on"'>
  35. <view class='name line1'>{{item.title}}</view>
  36. <view class='money font-color' :class='is_switch==true?"":"on"'>
  37. <text class="num" v-if="parseFloat(item.integral)">{{ item.integral }}积分</text>
  38. <text class="num" v-if="parseFloat(item.integral) && parseFloat(item.price)">+</text>
  39. <text class="num" v-if="parseFloat(item.price)">{{ item.price }}元</text>
  40. </view>
  41. <view class='vip acea-row row-between-wrapper' :class='is_switch==true?"":"on"'>
  42. <view class='vip-money' v-if="item.vip_price && item.vip_price > 0">{{item.vip_price}}积分
  43. <image src='../../static/images/vip.png'></image>
  44. </view>
  45. <view class="sales">
  46. <view class="">
  47. {{item.sales}}人兑换
  48. </view>
  49. <view class="exchange">兑换</view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class='loadingicon acea-row row-center-wrapper' v-if='productList.length > 0'>
  55. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  56. </view>
  57. </view>
  58. </view>
  59. <view class='noCommodity' v-if="productList.length==0 && where.page > 1">
  60. <view class='emptyBox'>
  61. <image :src="imgHost + '/statics/images/no-thing.png'"></image>
  62. <view class="tips">暂无商品,去看点别的吧</view>
  63. </view>
  64. <recommend :hostProduct="hostProduct"></recommend>
  65. </view>
  66. <home v-if="navigation"></home>
  67. </view>
  68. </template>
  69. <script>
  70. import home from '@/components/home';
  71. import {
  72. getProductHot
  73. } from '@/api/store.js';
  74. import {
  75. getStoreIntegralList
  76. } from '@/api/activity.js';
  77. import recommend from '@/components/recommend';
  78. import {
  79. mapGetters
  80. } from "vuex";
  81. import {
  82. goShopDetail
  83. } from '@/libs/order.js'
  84. import colors from "@/mixins/color";
  85. import {
  86. HTTP_REQUEST_URL
  87. } from '@/config/app';
  88. export default {
  89. computed: mapGetters(['uid']),
  90. components: {
  91. recommend,
  92. home
  93. },
  94. mixins: [colors],
  95. data() {
  96. return {
  97. productList: [],
  98. is_switch: true,
  99. where: {
  100. store_name: '',
  101. priceOrder: '',
  102. salesOrder: '',
  103. page: 1,
  104. limit: 20,
  105. },
  106. price: 0,
  107. stock: 0,
  108. nows: false,
  109. loadend: false,
  110. loading: false,
  111. loadTitle: '加载更多',
  112. title: '',
  113. hostProduct: [],
  114. hotPage: 1,
  115. hotLimit: 10,
  116. hotScroll: false,
  117. imgHost: HTTP_REQUEST_URL
  118. };
  119. },
  120. onLoad: function(options) {
  121. this.where.cid = options.cid || 0;
  122. this.$set(this.where, 'sid', options.sid || 0);
  123. this.title = options.title || '';
  124. this.$set(this.where, 'store_name', options.searchValue || '');
  125. this.get_product_list();
  126. this.get_host_product();
  127. },
  128. onShow() {
  129. uni.removeStorageSync('form_type_cart');
  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 ? '没有更多内容啦~' : '加载更多';
  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 = '加载更多';
  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: 28rpx;
  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: 26rpx;
  363. font-weight: 500;
  364. }
  365. .productList .list .item .text .vip {
  366. font-size: 22rpx;
  367. margin-top: 7rpx;
  368. .sales {
  369. color: #aaa;
  370. width: 100%;
  371. display: flex;
  372. justify-content: space-between;
  373. .exchange {
  374. border: 1px solid var(--view-theme);
  375. border-radius: 20rpx;
  376. padding: 0 12rpx;
  377. color: var(--view-theme);
  378. }
  379. }
  380. }
  381. .productList .list .item .text .vip.on {
  382. margin-top: 12rpx;
  383. }
  384. .productList .list .item .text .vip .vip-money {
  385. font-size: 24rpx;
  386. color: #282828;
  387. font-weight: bold;
  388. }
  389. .productList .list .item .text .vip .vip-money image {
  390. width: 56rpx;
  391. height: 20rpx;
  392. margin-left: 4rpx;
  393. }
  394. .noCommodity {
  395. background-color: #fff;
  396. padding-bottom: 30rpx;
  397. .emptyBox {
  398. text-align: center;
  399. margin-top: 40rpx;
  400. .tips {
  401. color: #aaa;
  402. font-size: 26rpx;
  403. }
  404. image {
  405. width: 414rpx;
  406. height: 304rpx;
  407. }
  408. }
  409. }
  410. </style>