home.vue 17 KB

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