home.vue 6.4 KB

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