index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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. that.$set(that.where, 'current', that.where.current + 1);
  225. if (!that.productList.length) this.get_host_product();
  226. }).catch(err => {
  227. that.loading = false;
  228. that.loadTitle = that.$t(`加载更多`);
  229. });
  230. },
  231. },
  232. onPullDownRefresh() {
  233. },
  234. onReachBottom() {
  235. if (this.productList.length > 0) {
  236. this.get_product_list();
  237. } else {
  238. this.get_host_product();
  239. }
  240. }
  241. }
  242. </script>
  243. <style scoped lang="scss">
  244. .productList .search {
  245. width: 100%;
  246. height: 86rpx;
  247. padding-left: 23rpx;
  248. box-sizing: border-box;
  249. position: fixed;
  250. left: 0;
  251. top: 0;
  252. z-index: 9;
  253. }
  254. .productList .search .input {
  255. width: 640rpx;
  256. height: 60rpx;
  257. background-color: #fff;
  258. border-radius: 50rpx;
  259. padding: 0 20rpx;
  260. box-sizing: border-box;
  261. }
  262. .productList .search .input input {
  263. width: 548rpx;
  264. height: 100%;
  265. font-size: 26rpx;
  266. }
  267. .productList .search .input .placeholder {
  268. color: #999;
  269. }
  270. .productList .search .input .iconfont {
  271. font-size: 35rpx;
  272. color: #555;
  273. }
  274. .productList .search .icon-pailie,
  275. .productList .search .icon-tupianpailie {
  276. color: #fff;
  277. width: 62rpx;
  278. font-size: 40rpx;
  279. height: 86rpx;
  280. line-height: 86rpx;
  281. }
  282. .productList .nav {
  283. height: 86rpx;
  284. color: #454545;
  285. position: fixed;
  286. left: 0;
  287. width: 100%;
  288. font-size: 28rpx;
  289. background-color: #fff;
  290. margin-top: 86rpx;
  291. top: 0;
  292. z-index: 9;
  293. }
  294. .productList .nav .item {
  295. width: 25%;
  296. text-align: center;
  297. }
  298. .productList .nav .item.font-color {
  299. font-weight: bold;
  300. }
  301. .productList .nav .item image {
  302. width: 15rpx;
  303. height: 19rpx;
  304. margin-left: 10rpx;
  305. }
  306. .productList .list {
  307. padding: 0 20rpx;
  308. margin-top: 12rpx;
  309. }
  310. .productList .list.on {
  311. background-color: #fff;
  312. border-top: 1px solid #f6f6f6;
  313. }
  314. .productList .list .item {
  315. width: 345rpx;
  316. margin-top: 20rpx;
  317. background-color: #fff;
  318. border-radius: 20rpx;
  319. }
  320. .productList .list .item.on {
  321. width: 100%;
  322. display: flex;
  323. border-bottom: 1rpx solid #f6f6f6;
  324. padding: 30rpx 0;
  325. margin: 0;
  326. }
  327. .productList .list .item .pictrue {
  328. position: relative;
  329. width: 100%;
  330. height: 345rpx;
  331. }
  332. .productList .list .item .pictrue.on {
  333. width: 180rpx;
  334. height: 180rpx;
  335. }
  336. .productList .list .item .pictrue image {
  337. width: 100%;
  338. height: 100%;
  339. border-radius: 20rpx 20rpx 0 0;
  340. }
  341. .productList .list .item .pictrue image.on {
  342. border-radius: 6rpx;
  343. }
  344. .productList .list .item .text {
  345. padding: 20rpx 17rpx 26rpx 17rpx;
  346. font-size: 30rpx;
  347. color: #222;
  348. }
  349. .productList .list .item .text.on {
  350. width: 508rpx;
  351. padding: 0 0 0 22rpx;
  352. }
  353. .productList .list .item .text .money {
  354. font-size: 26rpx;
  355. font-weight: bold;
  356. margin-top: 8rpx;
  357. }
  358. .productList .list .item .text .money.on {
  359. margin-top: 50rpx;
  360. }
  361. .productList .list .item .text .money .num {
  362. font-size: 34rpx;
  363. }
  364. .productList .list .item .text .vip {
  365. font-size: 22rpx;
  366. color: #aaa;
  367. margin-top: 7rpx;
  368. }
  369. .text-info {
  370. .title {
  371. color: #222222;
  372. }
  373. .tags {
  374. display: inline-block;
  375. font-size: 20rpx;
  376. padding: 6rpx;
  377. background-color: #FCE9EC;
  378. color: #EB4C63;
  379. margin: 6rpx 0;
  380. }
  381. .old-price {
  382. margin-top: 4rpx;
  383. font-size: 26rpx;
  384. color: #f51414;
  385. // text-decoration: line-through;
  386. text {
  387. margin-right: 2px;
  388. font-size: 20rpx;
  389. }
  390. }
  391. .price {
  392. display: flex;
  393. align-items: flex-end;
  394. font-size: 36rpx;
  395. font-weight: 550;
  396. text {
  397. padding-bottom: 4rpx;
  398. font-size: 26rpx;
  399. font-weight: normal;
  400. }
  401. .txt {
  402. display: flex;
  403. align-items: center;
  404. justify-content: center;
  405. width: 28rpx;
  406. height: 28rpx;
  407. margin-left: 15rpx;
  408. margin-bottom: 10rpx;
  409. border-radius: 4rpx;
  410. font-size: 20rpx;
  411. font-weight: normal;
  412. &.on {
  413. margin-left: 0;
  414. }
  415. }
  416. }
  417. }
  418. .productList .list .item .text .vip.on {
  419. margin-top: 12rpx;
  420. }
  421. .productList .list .item .text .vip .vip-money {
  422. font-size: 24rpx;
  423. color: #282828;
  424. font-weight: bold;
  425. }
  426. .productList .list .item .text .vip .vip-money image {
  427. width: 46rpx;
  428. height: 21rpx;
  429. margin-left: 4rpx;
  430. }
  431. .noCommodity {
  432. background-color: #fff;
  433. padding-bottom: 30rpx;
  434. .emptyBox {
  435. text-align: center;
  436. padding-top: 20rpx;
  437. .tips {
  438. color: #aaa;
  439. font-size: 26rpx;
  440. }
  441. image {
  442. width: 414rpx;
  443. height: 304rpx;
  444. }
  445. }
  446. }
  447. </style>