index.vue 11 KB

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