home.vue 17 KB

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