integral_goods_list.vue 10 KB

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