home.vue 17 KB

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