home.vue 7.8 KB

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