home.vue 5.7 KB

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