index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <view class="home tui-skeleton clearfix">
  3. <tui-skeleton v-if="skeletonShow" :isLoading="true" :loadingType="2"></tui-skeleton>
  4. <!-- 首页自定义导航栏 -->
  5. <view
  6. class="navbar-wrap"
  7. :style="{ height: CustomBar + 55 + 'px', paddingTop: StatusBar + 'px' }"
  8. :class="inputActive"
  9. >
  10. <view
  11. class="navbar-text"
  12. :style="{
  13. color: navbarData.textColor ? navbarData.textColor : '',
  14. lineHeight: CustomBar - StatusBar + 'px;',
  15. fontSize: fontSizeSetting + 'px;',
  16. paddingLeft: navbarData.textLeft ? '' : 12 + 'px'
  17. }"
  18. :class="platformClass"
  19. >
  20. {{ navbarData.title ? navbarData.title : ' ' }}
  21. </view>
  22. <view class="search-input">
  23. <view class="gosearch-btn" @click="this.$api.navigateTo(clickPath)">
  24. <view class="search-icon"> <text class="iconfont icon-sousuo"></text> </view>
  25. <view class="search-text">搜索商品</view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 主页内容 -->
  30. <view class="container-home " :style="{ paddingTop: CustomBar + 'px' }">
  31. <!-- 轮播 -->
  32. <banner :list="bannerImageList"></banner>
  33. </view>
  34. <!-- 商品列表 -->
  35. <view class="container-section">
  36. <view class="clearfix" v-for="(floor, index1) in productFloor" :key="index1">
  37. <!-- 楼层标题区域 -->
  38. <view class="tui-group-name">
  39. <view class="tui-group-title ">
  40. <view class="tui-group-l">{{ floor.title }}</view>
  41. <view class="tui-group-r" @click="NavToDetailPage(floor)" v-if="floor.productList.length >= 6">
  42. <text>更多</text> <tui-icon name="arrowright" :size="20" margin="0 0 0 -4rpx"></tui-icon>
  43. </view>
  44. </view>
  45. <view class="tui-sub__desc">{{ floor.description }}</view>
  46. </view>
  47. <!-- 商品列表区域 -->
  48. <view
  49. class="product-list"
  50. v-for="(pro, index2) in floor.productList"
  51. :key="index2"
  52. @click.stop="Details(pro)"
  53. >
  54. <view class="product-list-image">
  55. <image class="product-image" :src="pro.mainImage" mode=""></image>
  56. <!-- 推荐 -->
  57. <image
  58. class="product-icon"
  59. :src="StaticUrl + 'recommend.png'"
  60. mode=""
  61. v-if="pro.recommend === '1'"
  62. ></image>
  63. </view>
  64. <view class="product-list-msg">
  65. <view class="product-msg-name">{{ pro.name }}</view>
  66. <view class="product-list-tag" v-if="pro.activeStatus == 1">
  67. <text class="tag tag-02">活动价</text>
  68. </view>
  69. <view class="product-list-pri">
  70. <view class="price">¥{{ pro.price | PriceFormat }}</view>
  71. <view class="carts" @click.stop="handAddCarts(pro)">
  72. <view class="carts-add"> <text class="iconfont icon-gouwuche"></text> </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 侧边 -->
  80. <scroll-top :isScrollTop="isScrollTop" :bottom="160"></scroll-top>
  81. <!-- 活动弹窗 -->
  82. <active-popup
  83. :visible="activePopupVisible"
  84. :image="StaticUrl + 'icon-coupons-news.png'"
  85. @click="activeClick"
  86. @closed="activeClosed"
  87. ></active-popup>
  88. <!-- 领取优惠券提醒 -->
  89. <selector-coupons
  90. :top="CustomBar"
  91. :visible="tipVisible"
  92. title="呵呵商城"
  93. subTitle="您已获得优惠券奖励,赶紧去领取吧!"
  94. :image="StaticUrl + 'logo.png'"
  95. ></selector-coupons>
  96. </view>
  97. </template>
  98. <script>
  99. import authorize from '@/common/authorize.js'
  100. import banner from '@/components/cm-module/homeIndex/banner.vue'
  101. import ActivePopup from '@/components/cm-module/active-popup/active-popup.vue'
  102. import SelectorCoupons from '@/components/cm-module/selector-coupons/selector-coupons.vue'
  103. import { mapGetters, mapMutations, mapActions } from 'vuex'
  104. export default {
  105. components: {
  106. banner,
  107. ActivePopup,
  108. SelectorCoupons
  109. },
  110. data() {
  111. return {
  112. StaticUrl: this.$Static,
  113. navbarData: {
  114. //顶部自定义导航
  115. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  116. showSearch: 0,
  117. title: '呵呵商城', // 导航栏 中间的标题
  118. haveBack: false,
  119. textLeft: this.$store.getters.isIphone,
  120. textColor: '#FFFFFF'
  121. },
  122. inputActive: 'bgnone',
  123. clickPath: '/pages/goods/search',
  124. CustomBar: this.CustomBar, // 顶部导航栏高度
  125. StatusBar: this.StatusBar,
  126. fontSizeSetting: this.fontSizeSetting,
  127. screenWidth: this.screenWidth,
  128. capsule: this.capsule,
  129. platformClass: this.platformClass,
  130. modallayer: false,
  131. skeletonShow: true,
  132. productFloor: [], //商品列表
  133. bannerImageList: [], //轮播
  134. pageNum: 1,
  135. pageSize: 20,
  136. hasNextPage: false,
  137. isScrollTop: false,
  138. isRequest: false,
  139. activePopupVisible: false, // 活动弹窗
  140. tipVisible: true //优惠券领取提示
  141. }
  142. },
  143. filters: {
  144. //处理金额
  145. PriceFormat: function(text) {
  146. return Number(text).toFixed(2)
  147. }
  148. },
  149. async onLoad() {
  150. this.modallayer = false
  151. this.wechatlogin()
  152. this.GetHomeBanner()
  153. this.GetHomeProductList()
  154. setTimeout(() => {
  155. this.tipVisible = false
  156. }, 5000)
  157. },
  158. computed: {
  159. ...mapGetters(['hasLogin', 'userIdentity', 'userId'])
  160. },
  161. methods: {
  162. ...mapMutations('app', ['login', 'logout', 'updateStatus']),
  163. ...mapActions('user', ['wechatlogin']),
  164. ...mapActions('cart', ['addToCart', 'getCartNumber']),
  165. GetHomeBanner() {
  166. //初始化首页数据
  167. this.CommonService.GetProductCarousel()
  168. .then(response => {
  169. let data = response.data
  170. this.bannerImageList = data
  171. this.skeletonShow = false
  172. })
  173. .catch(error => {
  174. this.$util.msg(error.msg, 2000)
  175. })
  176. },
  177. GetHomeProductList() {
  178. //初始化首页商品数据
  179. this.ProductService.QueryProductFloor()
  180. .then(response => {
  181. this.productFloor = response.data
  182. })
  183. .catch(error => {
  184. this.$util.msg(error.msg, 2000)
  185. })
  186. },
  187. NavToDetailPage(floor) {
  188. //跳转
  189. this.$api.navigateTo(`/pages/goods/good-floorMore?floorId=${floor.floorId}&title=${floor.title}`)
  190. },
  191. Details(pro) {
  192. this.$api.navigateTo(`/pages/goods/product?productId=${pro.productId}`)
  193. },
  194. handAddCarts(pro) {
  195. this.addToCart({ productId: pro.productId })
  196. },
  197. activeClick() {
  198. this.activePopupVisible = false
  199. console.log('点击了活动弹窗')
  200. },
  201. activeClosed() {
  202. this.activePopupVisible = false
  203. console.log('活动弹窗关闭')
  204. }
  205. },
  206. onPageScroll(e) {
  207. //实时获取到滚动的值
  208. if (e.scrollTop > 50) {
  209. this.inputActive = 'bgclass'
  210. } else {
  211. this.inputActive = 'bgnone'
  212. }
  213. if (e.scrollTop > 400) {
  214. this.isScrollTop = true
  215. } else {
  216. this.isScrollTop = false
  217. }
  218. },
  219. //下拉刷新
  220. onPullDownRefresh() {
  221. this.GetHomeBanner()
  222. this.GetHomeProductList()
  223. setTimeout(() => {
  224. uni.stopPullDownRefresh()
  225. }, 2000)
  226. },
  227. onShareAppMessage(res) {
  228. //分享转发
  229. if (res.from === 'button') {
  230. // 来自页面内转发按钮
  231. }
  232. return {
  233. title: '国内外知名美容院线护肤品线上商城~',
  234. path: 'pages/tabBar/index/index',
  235. imageUrl: 'https://static.caimei365.com/app/mini-hehe/icon/icon-index-share.jpg'
  236. }
  237. },
  238. onShow() {
  239. if (this.hasLogin) {
  240. this.getCartNumber()
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss">
  246. page {
  247. background-color: #ffffff;
  248. }
  249. .navbar-wrap {
  250. position: fixed;
  251. width: 100%;
  252. top: 0;
  253. z-index: 100000;
  254. box-sizing: border-box;
  255. background-image: linear-gradient(0deg, #f83c6c 0%, #fa55bf 100%);
  256. background-size: cover;
  257. border-bottom: none;
  258. &.bgnone {
  259. background: rgba(255, 255, 255, 0);
  260. }
  261. &.bgclass {
  262. background: #f94a9b;
  263. }
  264. }
  265. .navbar-text {
  266. font-size: 30rpx;
  267. color: #000000;
  268. font-weight: 500;
  269. }
  270. .navbar-text.center {
  271. text-align: center;
  272. }
  273. .navbar-text.left {
  274. text-align: left;
  275. padding-left: 45px;
  276. }
  277. .navbar-icon {
  278. position: fixed;
  279. display: flex;
  280. box-sizing: border-box;
  281. }
  282. .navbar-icon .iconfont {
  283. display: inline-block;
  284. overflow: hidden;
  285. font-size: 44rpx;
  286. padding-right: 40rpx;
  287. margin-top: 1px;
  288. }
  289. .navbar-icon .icon-iconfonticonfontsousuo1 {
  290. color: #000000;
  291. }
  292. .navbar-icon view {
  293. height: 18px;
  294. border-left: 0.5px solid rgba(0, 0, 0, 0.3);
  295. margin-top: 6px;
  296. }
  297. .navbar-loading {
  298. background: #fff;
  299. text-align: center;
  300. }
  301. .container-home {
  302. background: #f7f7f7 url(https://static.caimei365.com/app/mini-hehe/icon/icon-index-bg.png) top center no-repeat;
  303. background-size: contain;
  304. min-height: 485rpx;
  305. }
  306. .container-section {
  307. width: 100%;
  308. height: auto;
  309. background-color: #f7f7f7;
  310. box-sizing: border-box;
  311. padding: 0 24rpx;
  312. .product-list {
  313. width: 339rpx;
  314. height: 532rpx;
  315. float: left;
  316. margin-right: 24rpx;
  317. margin-bottom: 24rpx;
  318. background-color: #ffffff;
  319. border-radius: 16rpx;
  320. &:nth-child(2n + 1) {
  321. margin-right: 0;
  322. }
  323. .product-list-image {
  324. width: 100%;
  325. height: 339rpx;
  326. float: left;
  327. position: relative;
  328. .product-image {
  329. width: 100%;
  330. height: 100%;
  331. display: block;
  332. border-radius: 16rpx 16rpx 0 0;
  333. }
  334. .product-icon {
  335. width: 68rpx;
  336. height: 55rpx;
  337. display: block;
  338. position: absolute;
  339. top: 0;
  340. left: 34rpx;
  341. }
  342. }
  343. .product-list-msg {
  344. width: 100%;
  345. height: 193rpx;
  346. box-sizing: border-box;
  347. padding: 16rpx 24rpx;
  348. float: left;
  349. position: relative;
  350. .product-msg-name {
  351. width: 100%;
  352. height: 72rpx;
  353. line-height: 35rpx;
  354. text-overflow: ellipsis;
  355. overflow: hidden;
  356. display: -webkit-box;
  357. -webkit-line-clamp: 2;
  358. line-clamp: 2;
  359. -webkit-box-orient: vertical;
  360. font-size: $font-size-26;
  361. color: #333333;
  362. text-align: justify;
  363. float: left;
  364. }
  365. .product-list-tag {
  366. position: relative;
  367. z-index: 9;
  368. width: 100%;
  369. height: 30rpx;
  370. margin-top: 8rpx;
  371. float: left;
  372. .tag {
  373. display: inline-block;
  374. height: 32rpx;
  375. font-size: 22rpx;
  376. line-height: 30rpx;
  377. text-align: center;
  378. color: #f83c6c;
  379. float: left;
  380. margin-right: 10rpx;
  381. &.tag-02 {
  382. width: 80rpx;
  383. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png) top center
  384. no-repeat;
  385. background-size: contain;
  386. }
  387. &.tag-01 {
  388. width: 56rpx;
  389. color: #fff;
  390. background-color: #f83c6c;
  391. border-radius: 4rpx;
  392. }
  393. }
  394. }
  395. .product-list-pri {
  396. width: 100%;
  397. height: 44rpx;
  398. float: left;
  399. position: absolute;
  400. bottom: 16rpx;
  401. left: 0;
  402. box-sizing: border-box;
  403. padding: 0 24rpx;
  404. .price {
  405. float: left;
  406. font-size: $font-size-26;
  407. color: #f83c6c;
  408. font-weight: bold;
  409. line-height: 44rpx;
  410. }
  411. .carts {
  412. float: right;
  413. .carts-add {
  414. width: 44rpx;
  415. height: 44rpx;
  416. text-align: center;
  417. line-height: 44rpx;
  418. background-color: #ff457b;
  419. border-radius: 50%;
  420. .iconfont {
  421. font-size: 32rpx;
  422. color: #ffffff;
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429. }
  430. .search-input {
  431. width: 100%;
  432. height: 110rpx;
  433. padding: 20rpx 24rpx;
  434. box-sizing: border-box;
  435. .gosearch-btn {
  436. width: 100%;
  437. height: 100%;
  438. border-radius: 40rpx;
  439. background: #f0f0f0;
  440. margin: 0 auto;
  441. font-size: 28rpx;
  442. line-height: 70rpx;
  443. color: #8a8a8a;
  444. background: #ffffff;
  445. position: relative;
  446. box-sizing: border-box;
  447. padding-left: 80rpx;
  448. .search-icon {
  449. width: 80rpx;
  450. height: 70rpx;
  451. position: absolute;
  452. left: 0;
  453. top: 0;
  454. text-align: center;
  455. line-height: 70rpx;
  456. .icon-iconfonticonfontsousuo1 {
  457. margin: 0 6rpx;
  458. font-size: $font-size-34;
  459. color: #8a8a8a;
  460. z-index: 10;
  461. }
  462. }
  463. .search-text {
  464. font-size: $font-size-24;
  465. line-height: 70rpx;
  466. color: #8a8a8a;
  467. }
  468. }
  469. }
  470. .tui-group-name {
  471. width: 100%;
  472. height: 92rpx;
  473. padding: 20rpx 0;
  474. }
  475. .tui-group-title {
  476. width: 100%;
  477. float: left;
  478. .tui-group-l {
  479. float: left;
  480. font-size: 34rpx;
  481. font-weight: bold;
  482. text-align: left;
  483. line-height: 49rpx;
  484. color: #333;
  485. }
  486. .tui-group-r {
  487. float: right;
  488. font-size: $font-size-26;
  489. text-align: right;
  490. line-height: 49rpx;
  491. color: #999999;
  492. .icon-xiayibu {
  493. font-size: $font-size-30;
  494. color: #999999;
  495. }
  496. }
  497. }
  498. .tui-sub__desc {
  499. width: 100%;
  500. float: left;
  501. color: rgba(153, 153, 153, 0.9);
  502. font-size: $font-size-26;
  503. }
  504. </style>