home.vue 5.3 KB

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