home.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class="container home clearfix" :style="{paddingTop:CustomBar+'px'}">
  3. <customer ref="customer" :navbar-data='nvabarData'></customer>
  4. <!-- 主页内容 -->
  5. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="5"></tui-skeleton>
  6. <view class="container-home tui-skeleton">
  7. <!-- 轮播 -->
  8. <banner :list="bannerImageList" v-if="isNavRequest"></banner>
  9. <!-- 金刚区菜单 -->
  10. <navbars :list="navBarsList" v-if="isNavRequest"></navbars>
  11. <!-- 直播 -->
  12. <page-special :templateData="templateData" v-if="isLiveRequest"></page-special>
  13. </view>
  14. <!-- 楼层 -->
  15. <view class="container-section tui-skeleton">
  16. <page-floor :list="pageList" :userIdentity="userIdentity" :pageType='1' v-if="isRequest"></page-floor>
  17. <supplier-list :supplierObj="supplierObj" v-if="isRequest"></supplier-list>
  18. </view>
  19. <!-- 活动弹窗 -->
  20. <activityAlert :show="isActivity" @click="handleClick" @cancel="handleCancelClick"></activityAlert>
  21. <!-- 侧边 -->
  22. <scroll-top :isScrollTop="isScrollTop" :bottom="50"></scroll-top>
  23. </view>
  24. </template>
  25. <script>
  26. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  27. import authorize from '@/common/config/authorize.js'
  28. import customer from '@/components/cm-module/homeIndex/customer.vue'
  29. import banner from '@/components/cm-module/homeIndex/banner.vue'
  30. import navbars from '@/components/cm-module/homeIndex/navbars.vue'
  31. import pageFloor from '@/components/cm-module/homeIndex/pageFloor.vue'
  32. import pageSpecial from '@/components/cm-module/homeIndex/pageSpecial.vue'
  33. import supplierList from '@/components/cm-module/homeIndex/supplierList.vue'
  34. import { userInfoLogin } from "@/services/use.js"
  35. import { mapState,mapMutations} from 'vuex';
  36. export default {
  37. components:{
  38. tuiSkeleton,
  39. customer,
  40. banner,
  41. navbars,
  42. pageFloor,
  43. pageSpecial,
  44. supplierList
  45. },
  46. data() {
  47. return {
  48. nvabarData: {//顶部自定义导航
  49. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  50. showSearch: 0,
  51. title: '采美采购商城', // 导航栏 中间的标题
  52. haveBack:false,
  53. textLeft:this.$store.state.isIphone,
  54. textColor:'#FFFFFF'
  55. },
  56. CustomBar:this.CustomBar,// 顶部导航栏高度
  57. userID:0,
  58. clubStatus:'',
  59. current:0,
  60. mode:'round',
  61. modallayer:false,
  62. isLogin:false,
  63. skeletonShow: true,
  64. userIdentity:'',
  65. flootData:[],//楼层
  66. bannerImageList:[],//轮播
  67. navBarsList:[],//导航分类
  68. templateData:{},
  69. pageList:[],//楼层
  70. supplierObj:{},//供应商列表
  71. isScrollTop:false,
  72. isRequest:false,
  73. isNavRequest:false,
  74. isLiveRequest:false,
  75. }
  76. },
  77. created() {
  78. this.$api.getStorage().then((resolve) =>{
  79. this.userID = resolve.userID ? resolve.userID : 0
  80. this.userIdentity = resolve.userIdentity
  81. this.getHomeInformation()
  82. })
  83. },
  84. filters: {
  85. NumFormat:function(text) {//处理金额
  86. return Number(text).toFixed(2);
  87. },
  88. },
  89. computed: {
  90. ...mapState(['hasLogin','userInfo','isActivity'])
  91. },
  92. methods: {
  93. ...mapMutations(['login','logout']),
  94. GetHomeInit(){//金刚区分类
  95. this.CommonService.GetHomeInit({source:2}).then(response =>{
  96. let data = response.data
  97. this.navBarsList = data.topMenuList
  98. this.isNavRequest = true
  99. }).catch(error =>{
  100. this.$util.msg(error.msg,2000)
  101. })
  102. },
  103. GetHomeTopDataInfo(){//直播、活动、文章模块
  104. this.CommonService.GetHomeTopDataInfo({source:2}).then(response =>{
  105. this.templateData = response.data
  106. this.isLiveRequest = true
  107. }).catch(error =>{
  108. this.$util.msg(error.msg,2000)
  109. })
  110. },
  111. GetHomeFloorInfo(){//初始化首页楼层数据
  112. this.CommonService.GetHomeDataInfo({userId:this.userID,soure:2}).then(response =>{
  113. let data = response.data;
  114. this.liveList = data.liveList;
  115. this.pageList = data.homePageFloor;
  116. this.supplierObj = data.supplierImage;
  117. this.isRequest = true;
  118. }).catch(error =>{
  119. this.$util.msg(error.msg,2000)
  120. })
  121. },
  122. getHomeInformation(){//初始化首页数据
  123. this.CommonService.GetHomeModulesDataInfo({ userId:this.userID }).then(res =>{
  124. let data = res.data;
  125. this.bannerImageList = data.bannerImageList
  126. this.mallPageModules = data.mallPageModules
  127. this.$store.commit('updateAllNum',data.shoppingCartCount)
  128. this.skeletonShow = false;
  129. this.GetHomeInit()
  130. this.GetHomeTopDataInfo()
  131. this.GetHomeFloorInfo()
  132. }).catch(error =>{
  133. this.$util.msg(error.msg,2000)
  134. })
  135. },
  136. handleClick(data){
  137. this.$api.navigateTo(`/h5/pages/activity/meobohui`)
  138. this.$store.commit('setActivity',data)
  139. },
  140. handleCancelClick(data){
  141. this.$store.commit('setActivity',data)
  142. }
  143. },
  144. onPageScroll(e){//实时获取到滚动的值
  145. if(e.scrollTop>50){
  146. this.inputActive = 'fixed'
  147. }else{
  148. this.inputActive = 'float'
  149. }
  150. if(e.scrollTop>400){
  151. this.isScrollTop = true
  152. }else{
  153. this.isScrollTop = false
  154. }
  155. },
  156. onPullDownRefresh() {//下拉刷新
  157. this.getHomeInformation()
  158. uni.stopPullDownRefresh()
  159. },
  160. onShareAppMessage(res){//分享转发
  161. if (res.from === 'button') {
  162. // 来自页面内转发按钮
  163. }
  164. return {
  165. title: '生美医美正品采购服务平台',
  166. path: 'pages/tabBar/home/index',
  167. imageUrl:'https://static.caimei365.com/app/img/bg/min-banner.jpg'
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss">
  173. page{
  174. background-color: #FFFFFF;
  175. }
  176. .container-section{
  177. width: 100%;
  178. height: auto;
  179. background-color: #F7F7F7;
  180. }
  181. </style>