home.vue 16 KB

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