index.vue 11 KB

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