home.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <view class="container home clearfix" :style="{paddingBottom:isIphoneX?'140rpx':'98rpx',paddingTop:CustomBar+'px'}">
  3. <cu-custom :navbar-data='nvabarData'></cu-custom>
  4. <!-- 头部轮播 -->
  5. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="9"></tui-skeleton>
  6. <view :class="'container-home-'+ inputActive" class="tui-skeleton">
  7. <view :class="'search-input-' + inputActive" :style="{paddingTop:inputActive == 'fixed'?(CustomBar+2)+'px':''} ">
  8. <bt-search :clickPath="clickPath" :toestText='hotSearchText'></bt-search>
  9. </view>
  10. <view class="banner-section">
  11. <!-- <uni-swiper-dot :info="bannerList" :current="current" field="content" :mode="mode" > -->
  12. <swiper class="banner tui-banner tui-skeleton-rect" circular @change="swiperChange" :autoplay="true" :interval="5000" :duration="500" :circular="false">
  13. <swiper-item v-for="(item, index) in bannerImageList" :key="index" class="banner-item">
  14. <image :src="item" />
  15. </swiper-item>
  16. </swiper>
  17. <view class="swiper__dots-box" v-if="bannerImageList.length > 1">
  18. <view v-for="(item,idx) in bannerImageList"
  19. :key="idx"
  20. :class="[idx===current?'swiper__dots-long':'none']"
  21. :data-index="current" class="swiper__dots-item" />
  22. </view>
  23. <!-- </uni-swiper-dot> -->
  24. </view>
  25. <view class="cate-section clearfix">
  26. <!-- 优选分类 -->
  27. <view class="tabbar clearfix">
  28. <view class="cate-item-info" @click.stop="this.$api.navToListPage({type:'1',value:firstModulesName})">
  29. <image class="tui-skeleton-fillet" :src="firstModulesImage"></image>
  30. <text class="tui-skeleton-fillet">{{firstModulesName}}</text>
  31. </view>
  32. <view class="cate-item-info" @click.stop="this.$api.navToListPage({type:'2',value:secondModulesName})">
  33. <image class="tui-skeleton-fillet" :src="secondModulesImage"></image>
  34. <text class="tui-skeleton-fillet">{{secondModulesName}}</text>
  35. </view>
  36. <view class="cate-item-info" @click="showTost">
  37. <image class="tui-skeleton-fillet" :src="navInforList[0].icon"></image>
  38. <text class="tui-skeleton-fillet">{{navInforList[0].text}}</text>
  39. </view>
  40. <view class="cate-item-info">
  41. <!-- #ifdef MP-WEIXIN -->
  42. <button class="contact-btn" open-type="contact" @bindcontact="handleContact">
  43. <image class="tui-skeleton-fillet" :src="navInforList[1].icon"></image>
  44. </button>
  45. <!-- #endif -->
  46. <text class="tui-skeleton-fillet">{{navInforList[1].text}}</text>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 热销商品 -->
  51. <view class="hotgoods-section">
  52. <view class="s-header tui-skeleton-fillet" @click="this.$api.navToListPage({type:'3',value:thirdModulesName})">
  53. <text class="tip">{{thirdModulesName}}</text>
  54. <text class="tit">更多</text>
  55. <text class="iconfont icon-xiayibu"></text>
  56. </view>
  57. <view class="hotgoods-swiper">
  58. <scroll-view class="floor-list" scroll-x>
  59. <view class="scoll-wrapper">
  60. <view
  61. v-for="(item, index) in organizeProducts" :key="index"
  62. class="floor-item"
  63. @click.stop="navToDetailPage(item.productID)"
  64. >
  65. <image class="tui-skeleton-fillet" :src="item.mainImage" mode="aspectFill"></image>
  66. <view class="title tui-skeleton-rect">
  67. <text class="mclap">{{item.name}}</text>
  68. </view>
  69. <view class="" v-if="hasLogin">
  70. <view class="title-none" v-if="item.price1TextFlag == '1'">
  71. <text class="p big">尚未公开价格</text>
  72. </view>
  73. <view class="price tui-skeleton-rect" v-else>
  74. <text class="p sm">¥</text>
  75. <text class="p big">{{item.retailPrice.toFixed(2)}}</text>
  76. </view>
  77. </view>
  78. <view v-else class="no-price">
  79. <text class="p-no">价格:</text>
  80. <uni-stars :stars="parseInt(item.price1Grade)"></uni-stars>
  81. </view>
  82. </view>
  83. </view>
  84. </scroll-view>
  85. </view>
  86. </view>
  87. <!-- 底部 -->
  88. <view class="footer-section ">
  89. <view class="s-header tui-skeleton-fillet">
  90. <text class="tip">医美机构正品联盟</text>
  91. </view>
  92. <view class="f-content tui-skeleton-fillet" @click="navto('/pages/service/member')">
  93. <image class="tui-banner" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AEwQlAAjGFdpI2LM357.png" mode=""></image>
  94. </view>
  95. <view class="f-tab-section">
  96. <!-- 优选分类 -->
  97. <view class="tabbar clearfix">
  98. <view class="cate-item" @click="showTost">
  99. <image class="tui-skeleton-fillet" :src="navServerList[0].icon"></image>
  100. <text class="tui-skeleton-fillet">{{navServerList[0].text}}</text>
  101. </view>
  102. <view class="cate-item" @click="navto(navServerList[1].path)">
  103. <image class="tui-skeleton-fillet" :src="navServerList[1].icon"></image>
  104. <text class="tui-skeleton-fillet">{{navServerList[1].text}}</text>
  105. </view>
  106. <view class="cate-item" @click="navto(navServerList[2].path)">
  107. <image class="tui-skeleton-fillet" :src="navServerList[2].icon"></image>
  108. <text class="tui-skeleton-fillet">{{navServerList[2].text}}</text>
  109. </view>
  110. <view class="cate-item" @click="telPhoneTo">
  111. <image class="tui-skeleton-fillet" :src="navServerList[3].icon"></image>
  112. <text class="tui-skeleton-fillet">{{navServerList[3].text}}</text>
  113. </view>
  114. </view>
  115. </view>
  116. <view class="f-text tui-skeleton-fillet">
  117. <view class="">
  118. <image class="logo" src="../../../static/logo-c@2x.png" mode=""></image>
  119. <text class="">采美365网</text>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. <!-- 透明模态层 -->
  125. <modal-layer v-if='modallayer'></modal-layer>
  126. <!-- 底部tabbar -->
  127. <cu-tabbar :active-index ="0"></cu-tabbar>
  128. </view>
  129. </template>
  130. <script>
  131. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  132. import authorize from '@/common/config/authorize.js'
  133. import modalLayer from "@/components/modal-layer"
  134. import cuTabbar from '@/components/cu-tabbar.vue'
  135. import btSearch from '@/components/uni-search/bt-search.vue'
  136. import uniStars from '@/components/uni-stars/uni-stars.vue'
  137. import { queryHomeInfo } from "@/api/use.js"
  138. import { queryPreferred } from "@/api/product.js"
  139. import { mapState,mapMutations } from 'vuex'
  140. export default {
  141. components:{
  142. tuiSkeleton,
  143. modalLayer,
  144. btSearch,
  145. uniStars,
  146. cuTabbar
  147. },
  148. data() {
  149. return {
  150. nvabarData: { //顶部自定义导航
  151. showCapsule: 0, // 是否显示左上角图标 1表示显示 0表示不显示,
  152. showSearch: 0,
  153. title: '采美采购商城', // 导航栏 中间的标题
  154. },
  155. userID:'',
  156. inputActive:'float',
  157. hotSearchText:'你想要的这里都有',
  158. clickPath:'/pages/search/search',
  159. current:0,
  160. mode:'round',
  161. isLogin:false,
  162. modallayer:false,
  163. bannerImageList:[],
  164. skeletonShow: true,
  165. isIphoneX:this.$store.state.isIphoneX,
  166. CustomBar:this.CustomBar,// 顶部导航栏高度
  167. organizeProducts:[],//常用商品
  168. firstModulesName:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAAZU0AACaPrfbB8I435.png', //优惠模块1
  169. secondModulesName:'', //优惠模块2
  170. firstModulesImage:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAAZU0AACaPrfbB8I435.png',//优惠模块icon1
  171. secondModulesImage:'',//优惠模块icon2
  172. thirdModulesName:'', //优惠模块3
  173. navInforList:[
  174. {text:'会员中心',icon:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAAZU0AACaPrfbB8I435.png'},
  175. {text:'在线客服',icon:'https://img.caimei365.com/group1/M00/03/8D/Cmis215XHXWABv0rAACt9b8scec656.png'}
  176. ],
  177. navServerList:[
  178. {text:'会员优惠',icon:'../../../static/temp/server1@2x.png',path:'/pages/service/member'},
  179. {text:'售后无忧',icon:'../../../static/temp/server2@2x.png',path:'/pages/service/aftersale'},
  180. {text:'购物须知',icon:'../../../static/temp/server3@2x.png',path:'/pages/service/shoppingnotice'},
  181. {text:'联系我们',icon:'../../../static/temp/server4@2x.png',path:''},
  182. ]
  183. }
  184. },
  185. onLoad() {
  186. },
  187. computed: {
  188. ...mapState(['hasLogin']),
  189. },
  190. methods: {
  191. getCheekeyCode(){
  192. this.getHomeInformation()
  193. this.getOrganizeProducts()
  194. },
  195. getHomeInformation(){
  196. queryHomeInfo({}).then(res =>{
  197. let data = res.data;
  198. this.bannerImageList = data.bannerImageList
  199. this.mallPageModules = data.mallPageModules
  200. this.$store.commit('updateAllNum',data.shoppingCartCount)
  201. this.firstModulesName= data.firstModulesName
  202. this.secondModulesName= data.secondModulesName
  203. this.firstModulesImage= data.firstModulesImage
  204. this.secondModulesImage= data.secondModulesImage
  205. this.thirdModulesName= data.thirdModulesName
  206. this.skeletonShow = false;
  207. })
  208. },
  209. getOrganizeProducts(){//获取模块三商品
  210. this.$api.getStorage().then((resolve) =>{
  211. this.userID = resolve.userID
  212. queryPreferred({userId:this.userID,preferredFlag:100,pageNum:1,pageSize:5}).then(res =>{
  213. this.organizeProducts = res.data.results
  214. })
  215. })
  216. },
  217. //轮播图切换修改背景色
  218. swiperChange(e) {
  219. const index = e.detail.current;
  220. this.current = index;
  221. },
  222. formatMoney(num){
  223. return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
  224. return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
  225. return $1 + ",";
  226. });
  227. });
  228. },
  229. //分类导航跳转
  230. navToListPage(nav){
  231. let self = this;
  232. uni.setStorage({
  233. key: 'commodity_id',
  234. data: nav.id,
  235. success: function () {
  236. self.$api.navToListPage({type:'商品分类',value:nav.classifyName,id:nav.id});
  237. }
  238. })
  239. },
  240. navToDetailPage(id) {//跳转商品详情页
  241. this.modallayer = true;
  242. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  243. },
  244. handleContact(e){
  245. console.log(e.detail.path)
  246. console.log(e.detail.query)
  247. },
  248. showTost(){
  249. this.$util.msg("正在开发中,敬请期待~",2000);
  250. // uni.navigateToMiniProgram({
  251. // appId: 'wx5a5cda32926f55ac',
  252. // path: '/pages/tabBar/home/home',
  253. // extraData: {
  254. // 'data1': 'test'
  255. // },
  256. // envVersion: 'develop',
  257. // success(res) {
  258. // console.log(res)
  259. // // 打开成功
  260. // }
  261. // })
  262. },
  263. navto(url){
  264. this.$api.navigateTo(url)
  265. },
  266. telPhoneTo(){
  267. let self = this;
  268. this.$api.get('/home/afterSale',{},
  269. response => {
  270. console.log(response.data.contactNumber)
  271. uni.makePhoneCall({
  272. phoneNumber:response.data.contactNumber //仅为示例
  273. });
  274. }
  275. )
  276. }
  277. },
  278. onPageScroll(e){//实时获取到滚动的值
  279. if(e.scrollTop>50){
  280. this.inputActive = 'fixed'
  281. }else{
  282. this.inputActive = 'float'
  283. }
  284. },
  285. onPullDownRefresh() {//下拉刷新
  286. this.getHomeInformation()
  287. uni.stopPullDownRefresh()
  288. },
  289. onShareAppMessage(res){//分享转发
  290. if (res.from === 'button') {
  291. // 来自页面内转发按钮
  292. console.log(res.target)
  293. }
  294. return {
  295. title: '采美采购商城-生美/医美采购服务平台',
  296. path: 'pages/tabBar/home/home',
  297. imageUrl:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAWWkhAAXDP4-6m_c397.png'
  298. }
  299. },
  300. onShow(){
  301. this.modallayer = false;
  302. this.getCheekeyCode()
  303. }
  304. }
  305. </script>
  306. <style lang="scss">
  307. page,.home{
  308. width: 100%;
  309. height: auto;
  310. }
  311. .container-home-float{
  312. padding-top: 0;
  313. }
  314. .container-home-fixed{
  315. padding-top: 100rpx;
  316. }
  317. .search-input-float{
  318. width: 100%;
  319. height:auto;
  320. }
  321. .search-input-fixed{
  322. width: 100%;
  323. height:auto;
  324. position: fixed;
  325. top: 0;
  326. left: 0;
  327. z-index: 1000;
  328. background: #FFFFFF;
  329. }
  330. .banner-section{
  331. width: 100%;
  332. height: 366rpx;
  333. position: relative;
  334. }
  335. .banner{
  336. width: 100%;
  337. height: 366rpx;
  338. image {
  339. width: 100%;
  340. height: 100%;
  341. }
  342. }
  343. .swiper__dots-box{
  344. position: absolute;
  345. bottom: 10px;
  346. left: 0;
  347. right: 0;
  348. /* #ifndef APP-NVUE */
  349. display: flex;
  350. /* #endif */
  351. flex: 1;
  352. flex-direction: row;
  353. justify-content: center;
  354. align-items: center;
  355. .swiper__dots-item{
  356. width: 8rpx;
  357. height: 8rpx;
  358. border-radius: 100%;
  359. margin-left: 6px;
  360. background-color:rgba(255,255,255,.7);
  361. }
  362. .swiper__dots-long{
  363. width: 32rpx;
  364. height: 8rpx;
  365. border-radius: 4rpx;
  366. background-color: #ffff;
  367. transition: all 0.4s;
  368. }
  369. }
  370. /* 分类 */
  371. .cate-section {
  372. width: 702rpx;
  373. height: auto;
  374. padding:34rpx 24rpx 14rpx 24rpx;
  375. background: #fff;
  376. .tabbar{
  377. margin-bottom: 26rpx;
  378. }
  379. .cate-item {
  380. width: 118rpx;
  381. margin-right:28rpx;
  382. margin-bottom:28rpx;
  383. display: flex;
  384. float: left;
  385. flex-direction: column;
  386. align-items: center;
  387. font-size: $font-size-26;
  388. color: $text-color;
  389. line-height: 36rpx;
  390. &:last-child{
  391. margin-right: 0;
  392. }
  393. &:nth-child(5n){
  394. margin-right: 0;
  395. }
  396. image {
  397. width: 90rpx;
  398. height: 90rpx;
  399. margin-bottom: 8rpx;
  400. }
  401. }
  402. .cate-item-info {
  403. width: 160rpx;
  404. margin-right:20.666rpx;
  405. display: flex;
  406. float: left;
  407. flex-direction: column;
  408. align-items: center;
  409. font-size: $font-size-26;
  410. color: $text-color;
  411. line-height: 36rpx;
  412. &:last-child{
  413. margin-right: 0;
  414. }
  415. image {
  416. width: 160rpx;
  417. height: 90rpx;
  418. margin-bottom: 16rpx;
  419. }
  420. button.contact-btn{
  421. width: 160rpx;
  422. height: 90rpx;
  423. margin: 0;
  424. padding: 0;
  425. display: flex;
  426. flex-direction: column;
  427. align-items: center;
  428. box-sizing: border-box;
  429. text-align: center;
  430. text-decoration: none;
  431. border-radius: 0;
  432. -webkit-tap-highlight-color: transparent;
  433. overflow: hidden;
  434. background-color:#FFFFFF;
  435. margin-bottom: 16rpx;
  436. image{
  437. width: 160rpx;
  438. height: 90rpx;
  439. margin-bottom: 0;
  440. }
  441. }
  442. }
  443. }
  444. /* 活动 */
  445. .hot-section{
  446. padding:0 24rpx 48rpx 24rpx;
  447. background: #FFFFFF;
  448. .ht-l{
  449. width: 339rpx;
  450. height: 188rpx;
  451. float: left;
  452. image{
  453. width: 339rpx;
  454. height: 188rpx;
  455. border-radius:10rpx;
  456. }
  457. }
  458. .ht-r{
  459. width: 339rpx;
  460. height: 188rpx;
  461. float: right;
  462. image{
  463. width: 339rpx;
  464. height: 188rpx;
  465. border-radius:10rpx;
  466. }
  467. }
  468. }
  469. .hotgoods-section{
  470. padding: 4rpx 0 24rpx 24rpx;
  471. background: #fff;
  472. .s-header{
  473. display:flex;
  474. align-items:center;
  475. height: 40rpx;
  476. line-height: 40rpx;
  477. .tip{
  478. flex: 4;
  479. font-size: 30rpx;
  480. color: $text-color;
  481. font-weight: bolder;
  482. }
  483. .tit{
  484. flex: 4.4;
  485. font-size: $font-size-28;
  486. color: $text-color;
  487. text-align: right;
  488. }
  489. .icon-xiayibu{
  490. flex: 0.6;
  491. color: $text-color;
  492. text-align: left;
  493. font-size: $font-size-24;
  494. }
  495. }
  496. }
  497. .hotgoods-swiper{
  498. width: 100%;
  499. height: auto;
  500. overflow: hidden;
  501. scroll-view{
  502. padding: 26rpx 0;
  503. width: 100%;
  504. }
  505. .scoll-wrapper{
  506. display:flex;
  507. align-items: flex-start;
  508. }
  509. .floor-item{
  510. width: 210rpx;
  511. padding-right: 24rpx;
  512. font-size: $font-size-24;
  513. color: $text-color;
  514. line-height: 36rpx;
  515. border-radius: 10rpx;
  516. image{
  517. width: 210rpx;
  518. height: 217rpx;
  519. border-radius: 10rpx;
  520. }
  521. .title-none{
  522. font-size: $font-size-26;
  523. color: #FF2A2A;
  524. line-height: 60rpx;
  525. }
  526. .title{
  527. width: 210rpx;
  528. height: 72rpx;
  529. display: flex;
  530. flex-direction: column;
  531. .mclap{
  532. width: 100%;
  533. line-height: 36rpx;
  534. text-overflow:ellipsis;
  535. display: -webkit-box;
  536. word-break: break-all;
  537. -webkit-box-orient: vertical;
  538. -webkit-line-clamp: 2;
  539. overflow: hidden;
  540. font-size: 26rpx;
  541. }
  542. }
  543. .no-price{
  544. height: 36rpx;
  545. line-height: 36rpx;
  546. display: flex;
  547. margin-top: 8rpx;
  548. .p-no{
  549. font-size: $font-size-24;
  550. color: $color-system;
  551. margin-right: 5rpx;
  552. }
  553. image{
  554. width:30rpx;
  555. height: 36rpx;
  556. }
  557. }
  558. .price{
  559. color:#FF2A2A;
  560. line-height: 20rpx;
  561. margin-top: 18rpx;
  562. .sm{
  563. font-size: $font-size-24;
  564. }
  565. .big{
  566. font-size: $font-size-28;
  567. }
  568. }
  569. }
  570. }
  571. .footer-section{
  572. width: 702rpx;
  573. padding: 0 24rpx 30rpx 24rpx;
  574. .s-header{
  575. display:flex;
  576. align-items:center;
  577. height: 40rpx;
  578. line-height: 40rpx;
  579. margin-bottom: 38rpx;
  580. .tip{
  581. flex: 1;
  582. font-size: 30rpx;
  583. color: $text-color;
  584. font-weight: bolder;
  585. }
  586. }
  587. .f-content{
  588. width: 100%;
  589. image{
  590. width: 100%;
  591. height: 350rpx;
  592. }
  593. }
  594. /*底部服务导航*/
  595. .f-tab-section {
  596. width: 100%;
  597. height: auto;
  598. padding: 38rpx 0;
  599. background: #fff;
  600. /*底部服务导航*/
  601. .cate-item {
  602. width: 99rpx;
  603. margin-right: 102rpx;
  604. float: left;
  605. display: flex;
  606. flex-direction: column;
  607. align-items: center;
  608. font-size: $font-size-24;
  609. color: $text-color;
  610. &:last-child{
  611. margin-right: 0;
  612. }
  613. image {
  614. width: 75rpx;
  615. height: 75rpx;
  616. margin-bottom: 8rpx;
  617. border-radius: 50%;
  618. }
  619. }
  620. }
  621. .f-text{
  622. .logo{
  623. width: 80rpx;
  624. height: 80rpx;
  625. float: left;
  626. margin: 0 6rpx;
  627. }
  628. display: flex;
  629. flex-direction: column;
  630. align-items: center;
  631. font-size: $font-size-24;
  632. color: $text-color;
  633. line-height: 80rpx;
  634. padding-top: 20rpx;
  635. }
  636. }
  637. </style>