index.vue 11 KB

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