home.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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. this.getHomeInformation()
  194. }else{
  195. this.isLogin = false;
  196. this.userID ='';
  197. let user_key = {code:response.code,tel:response.data,userID:this.userID,openid:''}
  198. this.$store.commit('updateStatus',user_key)
  199. this.getHomeInformation()
  200. // this.$store.commit('updateAllNum',0)
  201. }
  202. }
  203. )
  204. })
  205. },
  206. getHomeInformation(){
  207. this.$api.get('/home/information',{userID:this.userID,organizeID:this.userOrganizeID},
  208. response => {
  209. if(response.code =='1'){
  210. let data = response.data;
  211. this.organizeProducts = data.organizeProducts
  212. this.productsClassify = data.productsClassify
  213. this.bannerImageList = data.bannerImageList
  214. this.mallPageModules = data.mallPageModules
  215. this.$store.commit('updateAllNum',response.data.count)
  216. }
  217. this.skeletonShow = false
  218. }
  219. )
  220. },
  221. //轮播图切换修改背景色
  222. swiperChange(e) {
  223. const index = e.detail.current;
  224. this.current = index;
  225. // console.log('current',this.current)
  226. // this.titleNViewBackground = this.carouselList[index].background;
  227. },
  228. formatMoney(num){
  229. return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
  230. return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
  231. return $1 + ",";
  232. });
  233. });
  234. },
  235. //分类导航跳转
  236. navToListPage(nav){
  237. let self = this;
  238. uni.setStorage({
  239. key: 'commodity_id',
  240. data: nav.id,
  241. success: function () {
  242. self.$api.navToListPage({type:'商品分类',value:nav.classifyName,id:nav.id});
  243. }
  244. })
  245. },
  246. navToDetailPage(id) {//跳转商品详情页
  247. this.modallayer = true;
  248. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  249. },
  250. handleContact(e){
  251. console.log(e.detail.path)
  252. console.log(e.detail.query)
  253. },
  254. showTost(){
  255. this.$util.msg("正在开发中,敬请期待~",2000);
  256. },
  257. navto(url){
  258. this.$api.navigateTo(url)
  259. },
  260. telPhoneTo(){
  261. let self = this;
  262. this.$api.get('/home/afterSale',{organizeID:this.userOrganizeID},
  263. response => {
  264. console.log(response.data.contactNumber)
  265. uni.makePhoneCall({
  266. phoneNumber:response.data.contactNumber //仅为示例
  267. });
  268. }
  269. )
  270. },
  271. },
  272. onPageScroll(e){
  273. // console.log(e.scrollTop);//实时获取到滚动的值
  274. if(e.scrollTop>50){
  275. this.inputActive = 'fixed'
  276. }else{
  277. this.inputActive = 'float'
  278. }
  279. },
  280. onPullDownRefresh() {//下拉刷新
  281. this.getHomeInformation()
  282. uni.stopPullDownRefresh()
  283. },
  284. onShareAppMessage(res){//分享转发
  285. if (res.from === 'button') {
  286. // 来自页面内转发按钮
  287. console.log(res.target)
  288. }
  289. return {
  290. title: '星范Starstyle-全球医美领导品牌',
  291. path: 'pages/tabBar/home/home',
  292. imageUrl:'https://img.caimei365.com/group1/M00/03/88/Cmis214gJkOAAJBGABjUCizCahk919.png'
  293. }
  294. },
  295. onShow(){
  296. this.modallayer = false;
  297. this.getCheekeyCode()
  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: 48rpx 24rpx;
  370. background: #fff;
  371. .tabbar{
  372. margin-bottom: 26rpx;
  373. }
  374. .cate-item {
  375. width: 118rpx;
  376. margin-right:28rpx;
  377. margin-bottom:28rpx;
  378. display: flex;
  379. float: left;
  380. flex-direction: column;
  381. align-items: center;
  382. font-size: $font-size-sb;
  383. color: $text-color;
  384. line-height: 36rpx;
  385. &:last-child{
  386. margin-right: 0;
  387. }
  388. &:nth-child(5n){
  389. margin-right: 0;
  390. }
  391. image {
  392. width: 90rpx;
  393. height: 90rpx;
  394. margin-bottom: 8rpx;
  395. }
  396. }
  397. .cate-item-info {
  398. width: 160rpx;
  399. margin-right:20.666rpx;
  400. display: flex;
  401. float: left;
  402. flex-direction: column;
  403. align-items: center;
  404. font-size: $font-size-sb;
  405. color: $text-color;
  406. line-height: 36rpx;
  407. &:last-child{
  408. margin-right: 0;
  409. }
  410. image {
  411. width: 160rpx;
  412. height: 90rpx;
  413. margin-bottom: 16rpx;
  414. }
  415. button.contact-btn{
  416. width: 160rpx;
  417. height: 90rpx;
  418. margin: 0;
  419. padding: 0;
  420. display: flex;
  421. flex-direction: column;
  422. align-items: center;
  423. box-sizing: border-box;
  424. text-align: center;
  425. text-decoration: none;
  426. border-radius: 0;
  427. -webkit-tap-highlight-color: transparent;
  428. overflow: hidden;
  429. background-color:#FFFFFF;
  430. margin-bottom: 16rpx;
  431. image{
  432. width: 160rpx;
  433. height: 90rpx;
  434. margin-bottom: 0;
  435. }
  436. }
  437. }
  438. }
  439. /* 活动 */
  440. .hot-section{
  441. padding:0 24rpx 48rpx 24rpx;
  442. background: #FFFFFF;
  443. .ht-l{
  444. width: 339rpx;
  445. height: 188rpx;
  446. float: left;
  447. image{
  448. width: 339rpx;
  449. height: 188rpx;
  450. border-radius:10rpx;
  451. }
  452. }
  453. .ht-r{
  454. width: 339rpx;
  455. height: 188rpx;
  456. float: right;
  457. image{
  458. width: 339rpx;
  459. height: 188rpx;
  460. border-radius:10rpx;
  461. }
  462. }
  463. }
  464. .hotgoods-section{
  465. padding: 4rpx 0 24rpx 24rpx;
  466. background: #fff;
  467. .s-header{
  468. display:flex;
  469. align-items:center;
  470. height: 40rpx;
  471. line-height: 40rpx;
  472. .tip{
  473. flex: 4;
  474. font-size: 30rpx;
  475. color: $text-color;
  476. font-weight: bolder;
  477. }
  478. .tit{
  479. flex: 4.4;
  480. font-size: $font-size-base;
  481. color: $text-color;
  482. text-align: right;
  483. }
  484. .icon-xiayibu{
  485. flex: 0.6;
  486. color: $text-color;
  487. text-align: left;
  488. font-size: $font-size-sm;
  489. }
  490. }
  491. }
  492. .hotgoods-swiper{
  493. width: 100%;
  494. height: auto;
  495. overflow: hidden;
  496. scroll-view{
  497. padding: 26rpx 0;
  498. width: 100%;
  499. }
  500. .scoll-wrapper{
  501. display:flex;
  502. align-items: flex-start;
  503. }
  504. .floor-item{
  505. width: 210rpx;
  506. padding-right: 24rpx;
  507. font-size: $font-size-sm;
  508. color: $text-color;
  509. line-height: 36rpx;
  510. border-radius: 10rpx;
  511. image{
  512. width: 210rpx;
  513. height: 217rpx;
  514. border-radius: 10rpx;
  515. }
  516. .title{
  517. width: 210rpx;
  518. height: 72rpx;
  519. display: flex;
  520. flex-direction: column;
  521. .mclap{
  522. width: 100%;
  523. line-height: 36rpx;
  524. text-overflow:ellipsis;
  525. display: -webkit-box;
  526. word-break: break-all;
  527. -webkit-box-orient: vertical;
  528. -webkit-line-clamp: 2;
  529. overflow: hidden;
  530. font-size: 26rpx;
  531. }
  532. }
  533. .no-price{
  534. height: 36rpx;
  535. line-height: 36rpx;
  536. display: flex;
  537. margin-top: 8rpx;
  538. .p-no{
  539. font-size: $font-size-sm;
  540. color: #F8C499;
  541. margin-left: 10rpx;
  542. }
  543. image{
  544. width:30rpx;
  545. height: 36rpx;
  546. }
  547. }
  548. .price{
  549. color:#FF2A2A;
  550. line-height: 20rpx;
  551. margin-top: 18rpx;
  552. .sm{
  553. font-size: $font-size-sm;
  554. }
  555. .big{
  556. font-size: $font-size-base;
  557. }
  558. }
  559. }
  560. }
  561. .footer-section{
  562. width: 702rpx;
  563. padding: 0 24rpx 30rpx 24rpx;
  564. .s-header{
  565. display:flex;
  566. align-items:center;
  567. height: 40rpx;
  568. line-height: 40rpx;
  569. margin-bottom: 38rpx;
  570. .tip{
  571. flex: 1;
  572. font-size: 30rpx;
  573. color: $text-color;
  574. font-weight: bolder;
  575. }
  576. }
  577. .f-content{
  578. width: 100%;
  579. image{
  580. width: 100%;
  581. height: 350rpx;
  582. }
  583. }
  584. /*底部服务导航*/
  585. .f-tab-section {
  586. width: 100%;
  587. height: auto;
  588. padding: 38rpx 0;
  589. background: #fff;
  590. /*底部服务导航*/
  591. .cate-item {
  592. width: 99rpx;
  593. margin-right: 102rpx;
  594. float: left;
  595. display: flex;
  596. flex-direction: column;
  597. align-items: center;
  598. font-size: $font-size-sm;
  599. color: $text-color;
  600. &:last-child{
  601. margin-right: 0;
  602. }
  603. image {
  604. width: 75rpx;
  605. height: 75rpx;
  606. margin-bottom: 8rpx;
  607. border-radius: 50%;
  608. }
  609. }
  610. }
  611. .f-logo.s{
  612. width: 100%;
  613. display: flex;
  614. flex-direction: column;
  615. align-items: center;
  616. margin-bottom: 8rpx;
  617. image{
  618. width: 250rpx;
  619. height: 86rpx;
  620. }
  621. }
  622. .f-logo.c{
  623. width: 100%;
  624. display: flex;
  625. flex-direction: column;
  626. align-items: center;
  627. image{
  628. width: 82rpx;
  629. height: 84rpx;
  630. }
  631. }
  632. .f-text{
  633. display: flex;
  634. flex-direction: column;
  635. align-items: center;
  636. font-size: $font-size-sm;
  637. color: $text-color;
  638. line-height: 40rpx;
  639. }
  640. }
  641. </style>