home.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <template>
  2. <view class="container home clearfix" :style="{paddingBottom:isIphoneX?'140rpx':'98rpx',paddingTop:CustomBar+'px'}">
  3. <cu-custom :navbar-data='nvabarData' @navigateBack="hanldNavigateBack"></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 { 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. modallayer:false,
  162. bannerImageList:[],
  163. hotGoodsList:[],
  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. this.initData()
  187. },
  188. methods: {
  189. ...mapMutations(['hasLogin']),
  190. async initData(){
  191. this.skeletonShow = true;
  192. let hotGoodsList = await this.$util.json('hotGoodsList');
  193. this.hotGoodsList = hotGoodsList;
  194. },
  195. getCheekeyCode(){
  196. this.getHomeInformation()
  197. this.getOrganizeProducts()
  198. },
  199. getHomeInformation(){
  200. queryHomeInfo({}).then(res =>{
  201. let data = res.data;
  202. this.bannerImageList = data.bannerImageList
  203. this.mallPageModules = data.mallPageModules
  204. this.$store.commit('updateAllNum',data.shoppingCartCount)
  205. this.firstModulesName= data.firstModulesName
  206. this.secondModulesName= data.secondModulesName
  207. this.firstModulesImage= data.firstModulesImage
  208. this.secondModulesImage= data.secondModulesImage
  209. this.thirdModulesName= data.thirdModulesName
  210. this.skeletonShow = false;
  211. })
  212. },
  213. getOrganizeProducts(){//获取模块三商品
  214. queryPreferred({userId:this.userID,preferredFlag:100,pageNum:1,pageSize:5}).then(res =>{
  215. this.organizeProducts = res.data.results
  216. })
  217. },
  218. //轮播图切换修改背景色
  219. swiperChange(e) {
  220. const index = e.detail.current;
  221. this.current = index;
  222. // console.log('current',this.current)
  223. // this.titleNViewBackground = this.carouselList[index].background;
  224. },
  225. formatMoney(num){
  226. return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
  227. return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
  228. return $1 + ",";
  229. });
  230. });
  231. },
  232. //分类导航跳转
  233. navToListPage(nav){
  234. let self = this;
  235. uni.setStorage({
  236. key: 'commodity_id',
  237. data: nav.id,
  238. success: function () {
  239. self.$api.navToListPage({type:'商品分类',value:nav.classifyName,id:nav.id});
  240. }
  241. })
  242. },
  243. navToDetailPage(id) {//跳转商品详情页
  244. this.modallayer = true;
  245. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  246. },
  247. handleContact(e){
  248. console.log(e.detail.path)
  249. console.log(e.detail.query)
  250. },
  251. showTost(){
  252. this.$util.msg("正在开发中,敬请期待~",2000);
  253. // uni.navigateToMiniProgram({
  254. // appId: 'wx5a5cda32926f55ac',
  255. // path: '/pages/tabBar/home/home',
  256. // extraData: {
  257. // 'data1': 'test'
  258. // },
  259. // envVersion: 'develop',
  260. // success(res) {
  261. // console.log(res)
  262. // // 打开成功
  263. // }
  264. // })
  265. },
  266. navto(url){
  267. this.$api.navigateTo(url)
  268. },
  269. telPhoneTo(){
  270. let self = this;
  271. this.$api.get('/home/afterSale',{},
  272. response => {
  273. console.log(response.data.contactNumber)
  274. uni.makePhoneCall({
  275. phoneNumber:response.data.contactNumber //仅为示例
  276. });
  277. }
  278. )
  279. }
  280. },
  281. onPageScroll(e){
  282. // console.log(e.scrollTop);//实时获取到滚动的值
  283. if(e.scrollTop>50){
  284. this.inputActive = 'fixed'
  285. }else{
  286. this.inputActive = 'float'
  287. }
  288. },
  289. onPullDownRefresh() {//下拉刷新
  290. this.getHomeInformation()
  291. uni.stopPullDownRefresh()
  292. },
  293. onShareAppMessage(res){//分享转发
  294. if (res.from === 'button') {
  295. // 来自页面内转发按钮
  296. console.log(res.target)
  297. }
  298. return {
  299. title: '采美采购商城-生美/医美采购服务平台',
  300. path: 'pages/tabBar/home/home',
  301. imageUrl:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAWWkhAAXDP4-6m_c397.png'
  302. }
  303. },
  304. onShow(){
  305. this.modallayer = false;
  306. this.$api.getStorage().then((resolve) =>{
  307. this.userID = resolve.userID
  308. this.getCheekeyCode()
  309. })
  310. }
  311. }
  312. </script>
  313. <style lang="scss">
  314. page,.home{
  315. width: 100%;
  316. height: auto;
  317. }
  318. .container-home-float{
  319. padding-top: 0;
  320. }
  321. .container-home-fixed{
  322. padding-top: 100rpx;
  323. }
  324. .search-input-float{
  325. width: 100%;
  326. height:auto;
  327. }
  328. .search-input-fixed{
  329. width: 100%;
  330. height:auto;
  331. position: fixed;
  332. top: 0;
  333. left: 0;
  334. z-index: 1000;
  335. background: #FFFFFF;
  336. }
  337. .banner-section{
  338. width: 100%;
  339. height: 366rpx;
  340. position: relative;
  341. }
  342. .banner{
  343. width: 100%;
  344. height: 366rpx;
  345. image {
  346. width: 100%;
  347. height: 100%;
  348. }
  349. }
  350. .swiper__dots-box{
  351. position: absolute;
  352. bottom: 10px;
  353. left: 0;
  354. right: 0;
  355. /* #ifndef APP-NVUE */
  356. display: flex;
  357. /* #endif */
  358. flex: 1;
  359. flex-direction: row;
  360. justify-content: center;
  361. align-items: center;
  362. .swiper__dots-item{
  363. width: 8rpx;
  364. height: 8rpx;
  365. border-radius: 100%;
  366. margin-left: 6px;
  367. background-color:rgba(255,255,255,.7);
  368. }
  369. .swiper__dots-long{
  370. width: 32rpx;
  371. height: 8rpx;
  372. border-radius: 4rpx;
  373. background-color: #ffff;
  374. transition: all 0.4s;
  375. }
  376. }
  377. /* 分类 */
  378. .cate-section {
  379. width: 702rpx;
  380. height: auto;
  381. padding:34rpx 24rpx 14rpx 24rpx;
  382. background: #fff;
  383. .tabbar{
  384. margin-bottom: 26rpx;
  385. }
  386. .cate-item {
  387. width: 118rpx;
  388. margin-right:28rpx;
  389. margin-bottom:28rpx;
  390. display: flex;
  391. float: left;
  392. flex-direction: column;
  393. align-items: center;
  394. font-size: $font-size-26;
  395. color: $text-color;
  396. line-height: 36rpx;
  397. &:last-child{
  398. margin-right: 0;
  399. }
  400. &:nth-child(5n){
  401. margin-right: 0;
  402. }
  403. image {
  404. width: 90rpx;
  405. height: 90rpx;
  406. margin-bottom: 8rpx;
  407. }
  408. }
  409. .cate-item-info {
  410. width: 160rpx;
  411. margin-right:20.666rpx;
  412. display: flex;
  413. float: left;
  414. flex-direction: column;
  415. align-items: center;
  416. font-size: $font-size-26;
  417. color: $text-color;
  418. line-height: 36rpx;
  419. &:last-child{
  420. margin-right: 0;
  421. }
  422. image {
  423. width: 160rpx;
  424. height: 90rpx;
  425. margin-bottom: 16rpx;
  426. }
  427. button.contact-btn{
  428. width: 160rpx;
  429. height: 90rpx;
  430. margin: 0;
  431. padding: 0;
  432. display: flex;
  433. flex-direction: column;
  434. align-items: center;
  435. box-sizing: border-box;
  436. text-align: center;
  437. text-decoration: none;
  438. border-radius: 0;
  439. -webkit-tap-highlight-color: transparent;
  440. overflow: hidden;
  441. background-color:#FFFFFF;
  442. margin-bottom: 16rpx;
  443. image{
  444. width: 160rpx;
  445. height: 90rpx;
  446. margin-bottom: 0;
  447. }
  448. }
  449. }
  450. }
  451. /* 活动 */
  452. .hot-section{
  453. padding:0 24rpx 48rpx 24rpx;
  454. background: #FFFFFF;
  455. .ht-l{
  456. width: 339rpx;
  457. height: 188rpx;
  458. float: left;
  459. image{
  460. width: 339rpx;
  461. height: 188rpx;
  462. border-radius:10rpx;
  463. }
  464. }
  465. .ht-r{
  466. width: 339rpx;
  467. height: 188rpx;
  468. float: right;
  469. image{
  470. width: 339rpx;
  471. height: 188rpx;
  472. border-radius:10rpx;
  473. }
  474. }
  475. }
  476. .hotgoods-section{
  477. padding: 4rpx 0 24rpx 24rpx;
  478. background: #fff;
  479. .s-header{
  480. display:flex;
  481. align-items:center;
  482. height: 40rpx;
  483. line-height: 40rpx;
  484. .tip{
  485. flex: 4;
  486. font-size: 30rpx;
  487. color: $text-color;
  488. font-weight: bolder;
  489. }
  490. .tit{
  491. flex: 4.4;
  492. font-size: $font-size-28;
  493. color: $text-color;
  494. text-align: right;
  495. }
  496. .icon-xiayibu{
  497. flex: 0.6;
  498. color: $text-color;
  499. text-align: left;
  500. font-size: $font-size-24;
  501. }
  502. }
  503. }
  504. .hotgoods-swiper{
  505. width: 100%;
  506. height: auto;
  507. overflow: hidden;
  508. scroll-view{
  509. padding: 26rpx 0;
  510. width: 100%;
  511. }
  512. .scoll-wrapper{
  513. display:flex;
  514. align-items: flex-start;
  515. }
  516. .floor-item{
  517. width: 210rpx;
  518. padding-right: 24rpx;
  519. font-size: $font-size-24;
  520. color: $text-color;
  521. line-height: 36rpx;
  522. border-radius: 10rpx;
  523. image{
  524. width: 210rpx;
  525. height: 217rpx;
  526. border-radius: 10rpx;
  527. }
  528. .title-none{
  529. font-size: $font-size-26;
  530. color: #FF2A2A;
  531. line-height: 20rpx;
  532. margin-top: 18rpx;
  533. }
  534. .title{
  535. width: 210rpx;
  536. height: 72rpx;
  537. display: flex;
  538. flex-direction: column;
  539. .mclap{
  540. width: 100%;
  541. line-height: 36rpx;
  542. text-overflow:ellipsis;
  543. display: -webkit-box;
  544. word-break: break-all;
  545. -webkit-box-orient: vertical;
  546. -webkit-line-clamp: 2;
  547. overflow: hidden;
  548. font-size: 26rpx;
  549. }
  550. }
  551. .no-price{
  552. height: 36rpx;
  553. line-height: 36rpx;
  554. display: flex;
  555. margin-top: 8rpx;
  556. .p-no{
  557. font-size: $font-size-24;
  558. color: $color-system;
  559. margin-right: 5rpx;
  560. }
  561. image{
  562. width:30rpx;
  563. height: 36rpx;
  564. }
  565. }
  566. .price{
  567. color:#FF2A2A;
  568. line-height: 20rpx;
  569. margin-top: 18rpx;
  570. .sm{
  571. font-size: $font-size-24;
  572. }
  573. .big{
  574. font-size: $font-size-28;
  575. }
  576. }
  577. }
  578. }
  579. .footer-section{
  580. width: 702rpx;
  581. padding: 0 24rpx 30rpx 24rpx;
  582. .s-header{
  583. display:flex;
  584. align-items:center;
  585. height: 40rpx;
  586. line-height: 40rpx;
  587. margin-bottom: 38rpx;
  588. .tip{
  589. flex: 1;
  590. font-size: 30rpx;
  591. color: $text-color;
  592. font-weight: bolder;
  593. }
  594. }
  595. .f-content{
  596. width: 100%;
  597. image{
  598. width: 100%;
  599. height: 350rpx;
  600. }
  601. }
  602. /*底部服务导航*/
  603. .f-tab-section {
  604. width: 100%;
  605. height: auto;
  606. padding: 38rpx 0;
  607. background: #fff;
  608. /*底部服务导航*/
  609. .cate-item {
  610. width: 99rpx;
  611. margin-right: 102rpx;
  612. float: left;
  613. display: flex;
  614. flex-direction: column;
  615. align-items: center;
  616. font-size: $font-size-24;
  617. color: $text-color;
  618. &:last-child{
  619. margin-right: 0;
  620. }
  621. image {
  622. width: 75rpx;
  623. height: 75rpx;
  624. margin-bottom: 8rpx;
  625. border-radius: 50%;
  626. }
  627. }
  628. }
  629. .f-text{
  630. .logo{
  631. width: 80rpx;
  632. height: 80rpx;
  633. float: left;
  634. margin: 0 6rpx;
  635. }
  636. display: flex;
  637. flex-direction: column;
  638. align-items: center;
  639. font-size: $font-size-24;
  640. color: $text-color;
  641. line-height: 80rpx;
  642. padding-top: 20rpx;
  643. }
  644. }
  645. </style>