home.vue 17 KB

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