home.vue 17 KB

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