home.vue 17 KB

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