integral_goods_list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. onLoad: function(options) {
  116. this.where.cid = options.cid || 0;
  117. this.$set(this.where, 'sid', options.sid || 0);
  118. this.title = options.title || '';
  119. this.$set(this.where, 'store_name', options.searchValue || '');
  120. this.get_product_list();
  121. this.get_host_product();
  122. },
  123. methods: {
  124. // 去详情页
  125. godDetail(item) {
  126. goShopDetail(item, this.uid).then(res => {
  127. uni.navigateTo({
  128. url: `/pages/points_mall/integral_goods_details?id=${item.id}`
  129. })
  130. })
  131. },
  132. Changswitch: function() {
  133. let that = this;
  134. that.is_switch = !that.is_switch
  135. },
  136. searchSubmit: function(e) {
  137. let that = this;
  138. that.$set(that.where, 'store_name', e.detail.value);
  139. that.loadend = false;
  140. that.$set(that.where, 'page', 1)
  141. this.get_product_list(true);
  142. },
  143. /**
  144. * 获取我的推荐
  145. */
  146. get_host_product: function() {
  147. let that = this;
  148. if (that.hotScroll) return
  149. getProductHot(
  150. that.hotPage,
  151. that.hotLimit,
  152. ).then(res => {
  153. that.hotPage++
  154. that.hotScroll = res.data.length < that.hotLimit
  155. that.hostProduct = that.hostProduct.concat(res.data)
  156. // that.$set(that, 'hostProduct', res.data)
  157. });
  158. },
  159. //点击事件处理
  160. set_where: function(e) {
  161. switch (e) {
  162. case 1:
  163. this.where = {
  164. store_name: '',
  165. priceOrder: '',
  166. salesOrder: '',
  167. page: 1,
  168. limit: 20,
  169. }
  170. this.price = 0
  171. this.stock = 0
  172. break;
  173. case 2:
  174. if (this.price == 0) this.price = 1;
  175. else if (this.price == 1) this.price = 2;
  176. else if (this.price == 2) this.price = 0;
  177. this.stock = 0;
  178. break;
  179. case 3:
  180. if (this.stock == 0) this.stock = 1;
  181. else if (this.stock == 1) this.stock = 2;
  182. else if (this.stock == 2) this.stock = 0;
  183. this.price = 0
  184. break;
  185. case 4:
  186. this.nows = !this.nows;
  187. break;
  188. }
  189. this.loadend = false;
  190. this.$set(this.where, 'page', 1);
  191. this.get_product_list(true);
  192. },
  193. //设置where条件
  194. setWhere: function() {
  195. if (this.price == 0) this.where.priceOrder = '';
  196. else if (this.price == 1) this.where.priceOrder = 'asc';
  197. else if (this.price == 2) this.where.priceOrder = 'desc';
  198. if (this.stock == 0) this.where.salesOrder = '';
  199. else if (this.stock == 1) this.where.salesOrder = 'asc';
  200. else if (this.stock == 2) this.where.salesOrder = 'desc';
  201. this.where.news = this.nows ? 1 : 0;
  202. },
  203. //查找产品
  204. get_product_list: function(isPage) {
  205. let that = this;
  206. that.setWhere();
  207. if (that.loadend) return;
  208. if (that.loading) return;
  209. if (isPage === true) that.$set(that, 'productList', []);
  210. that.loading = true;
  211. that.loadTitle = '';
  212. getStoreIntegralList(that.where).then(res => {
  213. let list = res.data;
  214. let productList = that.$util.SplitArray(list, that.productList);
  215. let loadend = list.length < that.where.limit;
  216. that.loadend = loadend;
  217. that.loading = false;
  218. that.loadTitle = loadend ? that.$t(`我也是有底线的`) : that.$t(`加载更多`);
  219. that.$set(that, 'productList', productList);
  220. that.$set(that.where, 'page', that.where.page + 1);
  221. }).catch(err => {
  222. that.loading = false;
  223. that.loadTitle = that.$t(`加载更多`);
  224. });
  225. },
  226. },
  227. onPullDownRefresh() {
  228. },
  229. onReachBottom() {
  230. if (this.productList.length > 0) {
  231. this.get_product_list();
  232. } else {
  233. this.get_host_product();
  234. }
  235. }
  236. }
  237. </script>
  238. <style scoped lang="scss">
  239. .productList .search {
  240. width: 100%;
  241. height: 86rpx;
  242. padding-left: 23rpx;
  243. box-sizing: border-box;
  244. position: fixed;
  245. left: 0;
  246. top: 0;
  247. z-index: 9;
  248. }
  249. .productList .search .input {
  250. width: 640rpx;
  251. height: 60rpx;
  252. background-color: #fff;
  253. border-radius: 50rpx;
  254. padding: 0 20rpx;
  255. box-sizing: border-box;
  256. }
  257. .productList .search .input input {
  258. width: 548rpx;
  259. height: 100%;
  260. font-size: 26rpx;
  261. }
  262. .productList .search .input .placeholder {
  263. color: #999;
  264. }
  265. .productList .search .input .iconfont {
  266. font-size: 35rpx;
  267. color: #555;
  268. }
  269. .productList .search .icon-pailie,
  270. .productList .search .icon-tupianpailie {
  271. color: #fff;
  272. width: 62rpx;
  273. font-size: 40rpx;
  274. height: 86rpx;
  275. line-height: 86rpx;
  276. }
  277. .productList .nav {
  278. height: 86rpx;
  279. color: #454545;
  280. position: fixed;
  281. left: 0;
  282. width: 100%;
  283. font-size: 28rpx;
  284. background-color: #fff;
  285. margin-top: 86rpx;
  286. top: 0;
  287. z-index: 9;
  288. }
  289. .productList .nav .item {
  290. width: 33%;
  291. text-align: center;
  292. }
  293. .productList .nav .item.font-color {}
  294. .productList .nav .item image {
  295. width: 15rpx;
  296. height: 19rpx;
  297. margin-left: 10rpx;
  298. }
  299. .productList .list {
  300. padding: 0 20rpx;
  301. margin-top: 172rpx;
  302. }
  303. .productList .list.on {
  304. background-color: #fff;
  305. border-top: 1px solid #f6f6f6;
  306. }
  307. .productList .list .item {
  308. width: 345rpx;
  309. margin-top: 20rpx;
  310. background-color: #fff;
  311. border-radius: 20rpx;
  312. }
  313. .productList .list .item.on {
  314. width: 100%;
  315. display: flex;
  316. border-bottom: 1rpx solid #f6f6f6;
  317. padding: 30rpx 0;
  318. margin: 0;
  319. }
  320. .productList .list .item .pictrue {
  321. position: relative;
  322. width: 100%;
  323. height: 345rpx;
  324. }
  325. .productList .list .item .pictrue.on {
  326. width: 180rpx;
  327. height: 180rpx;
  328. }
  329. .productList .list .item .pictrue image {
  330. width: 100%;
  331. height: 100%;
  332. border-radius: 20rpx 20rpx 0 0;
  333. }
  334. .productList .list .item .pictrue image.on {
  335. border-radius: 6rpx;
  336. }
  337. .productList .list .item .text {
  338. padding: 20rpx 17rpx 26rpx 17rpx;
  339. font-size: 30rpx;
  340. color: #222;
  341. }
  342. .productList .list .item .text.on {
  343. width: 508rpx;
  344. padding: 0 0 0 22rpx;
  345. }
  346. .productList .list .item .text .money {
  347. font-size: 22rpx;
  348. margin-top: 8rpx;
  349. }
  350. .productList .list .item .text .money.on {
  351. margin-top: 50rpx;
  352. }
  353. .productList .list .item .text .money .num {
  354. font-size: 34rpx;
  355. }
  356. .productList .list .item .text .vip {
  357. font-size: 22rpx;
  358. margin-top: 7rpx;
  359. .sales {
  360. color: #aaa;
  361. width: 100%;
  362. display: flex;
  363. justify-content: space-between;
  364. .exchange {
  365. border: 1px solid var(--view-theme);
  366. border-radius: 20rpx;
  367. padding: 0 12rpx;
  368. color: var(--view-theme);
  369. }
  370. }
  371. }
  372. .productList .list .item .text .vip.on {
  373. margin-top: 12rpx;
  374. }
  375. .productList .list .item .text .vip .vip-money {
  376. font-size: 24rpx;
  377. color: #282828;
  378. font-weight: bold;
  379. }
  380. .productList .list .item .text .vip .vip-money image {
  381. width: 46rpx;
  382. height: 21rpx;
  383. margin-left: 4rpx;
  384. }
  385. .noCommodity {
  386. background-color: #fff;
  387. padding-bottom: 30rpx;
  388. .emptyBox{
  389. text-align: center;
  390. padding-top: 20rpx;
  391. .tips{
  392. color: #aaa;
  393. font-size: 26rpx;
  394. }
  395. image {
  396. width: 414rpx;
  397. height: 304rpx;
  398. }
  399. }
  400. }
  401. </style>