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. .search-input {
  302. width: 100%;
  303. height: 110rpx;
  304. padding: 20rpx 24rpx;
  305. box-sizing: border-box;
  306. .gosearch-btn {
  307. width: 100%;
  308. height: 100%;
  309. border-radius: 40rpx;
  310. background: #f0f0f0;
  311. margin: 0 auto;
  312. font-size: 28rpx;
  313. line-height: 70rpx;
  314. color: #8a8a8a;
  315. background: #ffffff;
  316. position: relative;
  317. box-sizing: border-box;
  318. padding-left: 80rpx;
  319. .search-icon {
  320. width: 80rpx;
  321. height: 70rpx;
  322. position: absolute;
  323. left: 0;
  324. top: 0;
  325. text-align: center;
  326. line-height: 70rpx;
  327. .icon-iconfonticonfontsousuo1 {
  328. margin: 0 6rpx;
  329. font-size: $font-size-34;
  330. color: #8a8a8a;
  331. z-index: 10;
  332. }
  333. }
  334. .search-text {
  335. font-size: $font-size-24;
  336. line-height: 70rpx;
  337. color: #8a8a8a;
  338. }
  339. }
  340. }
  341. .container-home {
  342. background: #f7f7f7 url(https://static.caimei365.com/app/mini-hehe/icon/icon-index-bg.png) top center no-repeat;
  343. background-size: contain;
  344. min-height: 485rpx;
  345. }
  346. .container-section {
  347. width: 100%;
  348. height: auto;
  349. background-color: #f7f7f7;
  350. box-sizing: border-box;
  351. padding: 0 24rpx;
  352. .product-list {
  353. width: 339rpx;
  354. height: 532rpx;
  355. float: left;
  356. margin-right: 24rpx;
  357. margin-bottom: 24rpx;
  358. background-color: #ffffff;
  359. border-radius: 16rpx;
  360. &:nth-child(2n + 1) {
  361. margin-right: 0;
  362. }
  363. .product-list-image {
  364. width: 100%;
  365. height: 339rpx;
  366. float: left;
  367. position: relative;
  368. .product-image {
  369. width: 100%;
  370. height: 100%;
  371. display: block;
  372. border-radius: 16rpx 16rpx 0 0;
  373. }
  374. .product-icon {
  375. width: 68rpx;
  376. height: 55rpx;
  377. display: block;
  378. position: absolute;
  379. top: 0;
  380. left: 34rpx;
  381. }
  382. }
  383. .product-list-msg {
  384. width: 100%;
  385. height: 193rpx;
  386. box-sizing: border-box;
  387. padding: 16rpx 24rpx;
  388. float: left;
  389. position: relative;
  390. .product-msg-name {
  391. width: 100%;
  392. height: 72rpx;
  393. line-height: 35rpx;
  394. text-overflow: ellipsis;
  395. overflow: hidden;
  396. display: -webkit-box;
  397. -webkit-line-clamp: 2;
  398. line-clamp: 2;
  399. -webkit-box-orient: vertical;
  400. font-size: $font-size-26;
  401. color: #333333;
  402. text-align: justify;
  403. float: left;
  404. }
  405. .product-list-tag {
  406. position: relative;
  407. z-index: 9;
  408. width: 100%;
  409. height: 30rpx;
  410. margin-top: 8rpx;
  411. float: left;
  412. .tag {
  413. display: inline-block;
  414. height: 32rpx;
  415. font-size: 22rpx;
  416. line-height: 30rpx;
  417. text-align: center;
  418. color: #f83c6c;
  419. float: left;
  420. margin-right: 10rpx;
  421. &.tag-02 {
  422. width: 80rpx;
  423. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png) top center
  424. no-repeat;
  425. background-size: contain;
  426. }
  427. &.tag-01 {
  428. width: 56rpx;
  429. color: #fff;
  430. background-color: #f83c6c;
  431. border-radius: 4rpx;
  432. }
  433. }
  434. }
  435. .product-list-pri {
  436. width: 100%;
  437. height: 44rpx;
  438. float: left;
  439. position: absolute;
  440. bottom: 16rpx;
  441. left: 0;
  442. box-sizing: border-box;
  443. padding: 0 24rpx;
  444. .price {
  445. float: left;
  446. font-size: $font-size-26;
  447. color: #f83c6c;
  448. font-weight: bold;
  449. line-height: 44rpx;
  450. }
  451. .carts {
  452. float: right;
  453. .carts-add {
  454. width: 44rpx;
  455. height: 44rpx;
  456. text-align: center;
  457. line-height: 44rpx;
  458. background-color: #ff457b;
  459. border-radius: 50%;
  460. .iconfont {
  461. font-size: 32rpx;
  462. color: #ffffff;
  463. }
  464. }
  465. }
  466. }
  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>