home.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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" />
  6. <view class="container-home tui-skeleton">
  7. <!-- 轮播 -->
  8. <banner :list="bannerImageList" v-if="isNavRequest" />
  9. <!-- 金刚区菜单 -->
  10. <navbars :list="navBarsList" v-if="isNavRequest" />
  11. <!-- 快捷运营 -->
  12. <quick-opera :list="shortcutList" v-if="isNavRequest && shortcutList.length > 0"/>
  13. <!-- 直播 -->
  14. <page-special :templateData="templateData" v-if="isLiveRequest" />
  15. <!-- 新品橱窗 -->
  16. <hot-floor :list="hotListPageFloor" :usserIdentity="userIdentity" v-if="isRequest" />
  17. </view>
  18. <!-- 楼层 -->
  19. <view class="container-section tui-skeleton">
  20. <page-floor :list="pageList" :userIdentity="userIdentity" :pageType='1' v-if="isRequest" />
  21. <supplier-list :supplierObj="supplierObj" v-if="isRequest" />
  22. </view>
  23. <!-- 资质证书 -->
  24. <Certificate v-if="isRequest" />
  25. <!-- 活动弹窗 -->
  26. <activityAlert :show="isActivity" @click="handleClick" @cancel="handleCancelClick" />
  27. <!-- 侧边 -->
  28. <scroll-top :isScrollTop="isScrollTop" :isShowSupplier="true" :isShowKefu='false' :bottom="130" />
  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 hotFloor from '@/components/cm-module/homeIndex/hotFloor.vue'
  37. import pageFloor from '@/components/cm-module/homeIndex/pageFloor.vue'
  38. import Certificate from '@/components/cm-module/homeIndex/certificate.vue'
  39. import pageSpecial from '@/components/cm-module/homeIndex/pageSpecial.vue'
  40. import supplierList from '@/components/cm-module/homeIndex/supplierList.vue'
  41. import quickOpera from '@/components/cm-module/homeIndex/quickOperation.vue'
  42. import { mapState,mapMutations} from 'vuex'
  43. export default {
  44. components:{
  45. customer,
  46. banner,
  47. navbars,
  48. hotFloor,
  49. pageFloor,
  50. Certificate,
  51. pageSpecial,
  52. supplierList,
  53. quickOpera
  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. shortcutList: [], // 快捷运营
  87. isScroll: 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.shortcutList = data.shortcutList || [] // 快捷运营
  136. this.isNavRequest = true
  137. this.GetHomeTopDataInfo()
  138. this.GetHomeFloorInfo()
  139. }).catch(error =>{
  140. this.$util.msg(error.msg,2000)
  141. })
  142. },
  143. handleClick(data){
  144. this.$api.navigateTo('/pages/h5/activity/meobohui')
  145. this.$store.commit('setActivity',data)
  146. },
  147. handleCancelClick(data){
  148. this.$store.commit('setActivity',data)
  149. }
  150. },
  151. onPageScroll(e){//实时获取到滚动的值
  152. if (e.scrollTop > 0) {
  153. this.isScroll = true
  154. } else {
  155. this.isScroll = false
  156. }
  157. if(e.scrollTop>50){
  158. this.inputActive = 'fixed'
  159. }else{
  160. this.inputActive = 'float'
  161. }
  162. if(e.scrollTop>400){
  163. this.isScrollTop = true
  164. }else{
  165. this.isScrollTop = false
  166. }
  167. },
  168. onPullDownRefresh() {//下拉刷新
  169. this.getHomeInformation()
  170. uni.stopPullDownRefresh()
  171. },
  172. onShareAppMessage(res){//分享转发
  173. if (res.from === 'button') {
  174. // 来自页面内转发按钮
  175. }
  176. return {
  177. title: '生美医美正品采购服务平台',
  178. path: 'pages/tabBar/home/index',
  179. imageUrl:'https://static.caimei365.com/app/img/bg/min-banner.jpg'
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss">
  185. page{
  186. background-color: #ff5b00;
  187. }
  188. .container-section{
  189. width: 100%;
  190. height: auto;
  191. background-color: #F7F7F7;
  192. }
  193. </style>