integral_goods_list.vue 10 KB

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