home.vue 5.9 KB

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