home.vue 17 KB

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