home.vue 16 KB

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