home.vue 5.8 KB

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