home.vue 17 KB

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