123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- <template>
- <view class="container home clearfix">
- <!-- 首页自定义导航栏 -->
- <view class='navbar-wrap' :style="{height:(CustomBar+55)+'px',paddingTop:StatusBar+'px'}" :class="inputActive">
- <view class="navbar-text"
- :style="{color:navbarData.textColor ? navbarData.textColor:'',lineHeight:(CustomBar - StatusBar)+'px;',fontSize:fontSizeSetting+'px;',paddingLeft:navbarData.textLeft ? '' : 12+'px'}" :class="platformClass">
- {{navbarData.title ? navbarData.title : " "}}
- </view>
- <view class="search-input">
- <view class="gosearch-btn" @click="this.$api.navigateTo(clickPath)">
- <view class="search-icon">
- <text class="iconfont icon-iconfonticonfontsousuo1"></text>
- </view>
- <view class="search-text">{{hotSearchText}}</view>
- </view>
- </view>
- </view>
- <!-- 主页内容 -->
- <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="5"></tui-skeleton>
- <view class="container-home tui-skeleton" :style="{paddingTop:CustomBar+'px'}">
- <!-- 轮播 -->
- <banner :list="bannerImageList" v-if="isNavRequest"></banner>
- </view>
- <!-- 楼层 -->
- <view class="container-section tui-skeleton">
-
- </view>
- <!-- 侧边 -->
- <scroll-top :isScrollTop="isScrollTop" :bottom="50"></scroll-top>
- </view>
- </template>
- <script>
- import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
- import authorize from '@/common/config/authorize.js'
- import btSearch from '@/components/uni-search/bt-search.vue'
- import banner from '@/components/cm-module/homeIndex/banner.vue'
- import { mapState,mapMutations} from 'vuex';
- export default {
- components:{
- tuiSkeleton,
- btSearch,
- banner,
- },
- data() {
- return {
- navbarData: {//顶部自定义导航
- showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
- showSearch: 0,
- title: '呵呵商城', // 导航栏 中间的标题
- haveBack:false,
- textLeft:this.$store.state.isIphone,
- textColor:'#FFFFFF'
- },
- inputActive:'bgnone',
- clickPath:'/search/pages/search/search',
- hotSearchText:'搜索商品',
- CustomBar:this.CustomBar,// 顶部导航栏高度
- StatusBar: this.StatusBar,
- fontSizeSetting:this.fontSizeSetting,
- screenWidth:this.screenWidth,
- capsule:this.capsule,
- platformClass:this.platformClass,
- userID:0,
- clubStatus:'',
- current:0,
- mode:'round',
- modallayer:false,
- isLogin:false,
- skeletonShow: false,
- userIdentity:'',
- flootData:[],//楼层
- bannerImageList:[
- image:'',
-
- ],//轮播
- navBarsList:[],//导航分类
- templateData:{},
- pageList:[],//楼层
- isScrollTop:false,
- isRequest:false,
- isNavRequest:false,
- isLiveRequest:false,
- }
- },
- onLoad() {
-
- },
- computed: {
- ...mapState(['hasLogin','userInfo','identity','isActivity'])
- },
- methods: {
- ...mapMutations(['login','logout']),
- GetWxAuthorize(){
- authorize.getCode('weixin').then(wechatcode =>{// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
- authorize.getUserInfo('weixin').then(getUserInfo =>{
- this.UserService.UserLoginAuthApplets({
- code:wechatcode,
- encryptedData:getUserInfo.encryptedData,
- iv:getUserInfo.iv ,
- })
- .then(response =>{
- this.isLogin = true;
- this.userID = response.data.userId;
- this.userIdentity = response.data.userIdentity;
- this.clubStatus = response.data.clubStatus;
- this.$store.commit('updateStatus',response.data)
- this.login(response.data);
- uni.setStorageSync('token',response.data.token)
- uni.setStorageSync('unionId',response.data.unionId)
- if(response.data.userIdentity ==1){
- this.$api.redirectTo('/seller/pages/index/index')
- }else if(response.data.userIdentity === 3){
- this.$api.redirectTo('/supplier/pages/index/index')
- }
- this.getHomeInformation()
- })
- .catch(error =>{
- this.isLogin = false;
- this.logout()
- uni.setStorageSync('unionId',error.data.unionId)
- this.$store.commit('updateStatus',error.data)
- this.getHomeInformation()
- })
- })
- })
- },
- async getWxAuthorize(){
- const wechatCode = await authorize.getCode('weixin');// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
- const getUserInfo = await authorize.getUserInfo('weixin');
- this.UserService.UserLoginAuthApplets({
- code:wechatCode,
- encryptedData:getUserInfo.encryptedData,
- iv:getUserInfo.iv
- })
- .then(response =>{
- this.isLogin = true;
- this.userID = response.data.userId;
- this.userIdentity = response.data.userIdentity;
- this.clubStatus = response.data.clubStatus;
- this.$store.commit('updateStatus',response.data)
- this.login(response.data);
- uni.setStorageSync('token',response.data.token)
- uni.setStorageSync('unionId',response.data.unionId)
- if(response.data.userIdentity ==1){
- this.$api.redirectTo('/seller/pages/index/index')
- }else if(response.data.userIdentity === 3){
- this.$api.redirectTo('/supplier/pages/index/index')
- }
- this.getHomeInformation()
- })
- .catch(error =>{
- this.isLogin = false;
- this.logout()
- uni.setStorageSync('unionId',error.data.unionId)
- this.$store.commit('updateStatus',error.data)
- this.getHomeInformation()
- })
- },
- GetHomeInit(){//金刚区分类
- this.CommonService.GetHomeInit({source:2}).then(response =>{
- let data = response.data
- this.navBarsList = data.topMenuList
- this.isNavRequest = true
- }).catch(error =>{
- this.$util.msg(error.msg,2000)
- })
- },
- GetHomeTopDataInfo(){//直播、活动、文章模块
- this.CommonService.GetHomeTopDataInfo({source:2}).then(response =>{
- this.templateData = response.data
- this.isLiveRequest = true
- }).catch(error =>{
- this.$util.msg(error.msg,2000)
- })
- },
- GetHomeFloorInfo(){//初始化首页楼层数据
- this.CommonService.GetHomeDataInfo({userId:this.userID,soure:2}).then(response =>{
- let data = response.data;
- this.liveList = data.liveList;
- this.pageList = data.homePageFloor;
- this.isRequest = true;
- }).catch(error =>{
- this.$util.msg(error.msg,2000)
- })
- },
- getHomeInformation(){//初始化首页数据
- this.CommonService.GetHomeModulesDataInfo({ userId:this.userID }).then(res =>{
- let data = res.data;
- this.bannerImageList = data.bannerImageList
- this.mallPageModules = data.mallPageModules
- this.$store.commit('updateAllNum',data.shoppingCartCount)
- this.skeletonShow = false;
- this.GetHomeInit()
- this.GetHomeTopDataInfo()
- this.GetHomeFloorInfo()
- }).catch(error =>{
- this.$util.msg(error.msg,2000)
- })
- },
- handleClick(data){
- this.$api.navigateTo(`/h5/pages/activity/meobohui`)
- this.$store.commit('setActivity',data)
- uni.setStorageSync('lockTime',Date.now())
- uni.setStorageSync('isActivityStatus',true)
- },
- handleCancelClick(data){
- this.$store.commit('setActivity',data)
- uni.setStorageSync('lockTime',Date.now())
- uni.setStorageSync('isActivityStatus',true)
- },
- async InitAuthorize(){ //是否已授权 0:为取消授权 1:为已授权 2:为未操作
- authorize.checkLogin()
- .then(res => {
- this.GetWxAuthorize()
- })
- .catch(err => {
- this.$api.getComStorage('userInfo').then((resolve) =>{
- this.userID = resolve.userId ? resolve.userId :0;
- this.getHomeInformation()
- }).catch(error =>{
- this.getHomeInformation()
- })
- })
- }
- },
- onPageScroll(e){//实时获取到滚动的值
- if(e.scrollTop>50){
- this.inputActive = 'bgclass'
- }else{
- this.inputActive = 'bgnone'
- }
- if(e.scrollTop>400){
- this.isScrollTop = true
- }else{
- this.isScrollTop = false
- }
- },
- onPullDownRefresh() {//下拉刷新
- this.getHomeInformation()
- uni.stopPullDownRefresh()
- },
- onShareAppMessage(res){//分享转发
- if (res.from === 'button') {
- // 来自页面内转发按钮
- }
- return {
- title: '生美医美正品采购服务平台',
- path: 'pages/tabBar/home/index',
- imageUrl:'https://static.caimei365.com/app/img/bg/min-banner.jpg'
- }
- },
- onShow(){
- this.modallayer = false
- // this.InitAuthorize()
- }
- }
- </script>
- <style lang="scss">
- page{
- background-color: #FFFFFF;
- }
- .navbar-wrap {
- position: fixed;
- width: 100%;
- top: 0;
- z-index: 100000;
- box-sizing: border-box;
- background-image: linear-gradient(0deg, #f83c6c 0%, #fa55bf 100%);
- background-size: cover;
- border-bottom:none;
- &.bgnone{
- background: rgba(255,255,255,0);
- }
- &.bgclass{
- background: #f83c6c;
- }
- }
- .navbar-text {
- font-size: 30rpx;
- color: #000000;
- font-weight: 500;
- }
- .navbar-text.center{
- text-align: center;
- }
- .navbar-text.left{
- text-align: left;
- padding-left: 45px;
- }
- .navbar-icon {
- position: fixed;
- display: flex;
- box-sizing: border-box;
- }
- .navbar-icon .iconfont {
- display: inline-block;
- overflow: hidden;
- font-size: 44rpx;
- padding-right:40rpx;
- margin-top: 1px;
- }
- .navbar-icon .icon-iconfonticonfontsousuo1 {
- color: #000000;
- }
- .navbar-icon view {
- height: 18px;
- border-left: 0.5px solid rgba(0,0,0, 0.3);
- margin-top: 6px;
- }
- .navbar-loading {
- background: #fff;
- text-align: center;
- }
- .search-input{
- width: 100%;
- height: 110rpx;
- padding: 20rpx 24rpx;
- box-sizing: border-box;
- .gosearch-btn{
- width: 100%;
- height: 100%;
- border-radius: 40rpx;
- background: #F0F0F0;
- margin: 0 auto;
- font-size: 28rpx;
- line-height: 70rpx;
- color: #8A8A8A;
- background: #FFFFFF;
- position: relative;
- box-sizing: border-box;
- padding-left: 80rpx;
- .search-icon{
- width: 80rpx;
- height: 70rpx;
- position:absolute ;
- left: 0;
- top: 2rpx;
- text-align: center;
- line-height: 70rpx;
- .icon-iconfonticonfontsousuo1{
- margin:0 6rpx;
- font-size: $font-size-34;
- color: #8A8A8A;
- z-index: 10;
- }
- }
- .search-text{
- font-size: $font-size-24;
- line-height: 70rpx;
- color: #8A8A8A;
- }
- }
- }
- .container-home{
- background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-index-bg.png)top center no-repeat;
- background-size: contain;
- min-height: 528rpx;
- }
- .container-section{
- width: 100%;
- height: auto;
- background-color: #F7F7F7;
- }
- </style>
|