home.vue 17 KB

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