index.vue 15 KB

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