index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. <page-special :templateData="templateData" v-if="isLiveRequest"></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. <!-- 活动弹窗 -->
  22. <activityAlert :show="isActivity" @click="handleClick" @cancel="handleCancelClick"></activityAlert>
  23. </view>
  24. </template>
  25. <script>
  26. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  27. import authorize from '@/common/config/authorize.js'
  28. import customer from '@/components/cm-module/homeIndex/customer.vue'
  29. import banner from '@/components/cm-module/homeIndex/banner.vue'
  30. import navbars from '@/components/cm-module/homeIndex/navbars.vue'
  31. import pageFloor from '@/components/cm-module/homeIndex/pageFloor.vue'
  32. import pageSpecial from '@/components/cm-module/homeIndex/pageSpecial.vue'
  33. import supplierList from '@/components/cm-module/homeIndex/supplierList.vue'
  34. import activityAlert from '@/components/cm-module/activity/activity_01.vue'
  35. import { userInfoLogin } from "@/services/use.js"
  36. import { mapState,mapMutations} from 'vuex';
  37. export default {
  38. components:{
  39. tuiSkeleton,
  40. customer,
  41. banner,
  42. navbars,
  43. pageFloor,
  44. pageSpecial,
  45. supplierList,
  46. activityAlert
  47. },
  48. data() {
  49. return {
  50. nvabarData: {//顶部自定义导航
  51. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  52. showSearch: 0,
  53. title: '采美采购商城', // 导航栏 中间的标题
  54. haveBack:false,
  55. textLeft:this.$store.state.isIphone,
  56. textColor:'#FFFFFF'
  57. },
  58. CustomBar:this.CustomBar,// 顶部导航栏高度
  59. userID:0,
  60. clubStatus:'',
  61. current:0,
  62. mode:'round',
  63. modallayer:false,
  64. isLogin:false,
  65. skeletonShow: true,
  66. userIdentity:'',
  67. flootData:[],//楼层
  68. bannerImageList:[],//轮播
  69. navBarsList:[],//导航分类
  70. templateData:{},
  71. pageList:[],//楼层
  72. supplierObj:{},//供应商列表
  73. isScrollTop:false,
  74. isRequest:false,
  75. isNavRequest:false,
  76. isLiveRequest:false,
  77. }
  78. },
  79. onLoad() {
  80. },
  81. computed: {
  82. ...mapState(['hasLogin','userInfo','identity','isActivity'])
  83. },
  84. methods: {
  85. ...mapMutations(['login','logout']),
  86. getWxAuthorize(){
  87. authorize.getCode('weixin').then(wechatcode =>{// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  88. authorize.getUserInfo('weixin').then(wxResponse =>{
  89. userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
  90. this.isLogin = true;
  91. this.userID = response.data.userID;
  92. this.userIdentity = response.data.userIdentity;
  93. this.clubStatus = response.data.clubStatus;
  94. this.$store.commit('updateStatus',response.data)
  95. this.login(response.data);
  96. uni.setStorageSync('token',response.data.token)
  97. uni.removeStorageSync('sessionid')
  98. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  99. if(response.data.userIdentity ==1){
  100. this.$api.redirectTo('/seller/pages/index/index')
  101. }else if(response.data.userIdentity === 3){
  102. this.$api.redirectTo('/supplier/pages/index/index')
  103. }
  104. this.getHomeInformation()
  105. }).catch(error =>{
  106. this.isLogin = false;
  107. this.logout()
  108. uni.removeStorageSync('sessionid')
  109. uni.setStorageSync('sessionid','JSESSIONID='+error.data)
  110. this.$store.commit('updateStatus',error.data)
  111. this.getHomeInformation()
  112. })
  113. })
  114. })
  115. },
  116. GetHomeInit(){//金刚区分类
  117. this.CommonService.GetHomeInit({source:2}).then(response =>{
  118. let data = response.data
  119. this.navBarsList = data.topMenuList
  120. this.isNavRequest = true
  121. }).catch(error =>{
  122. this.$util.msg(error.msg,2000)
  123. })
  124. },
  125. GetHomeTopDataInfo(){//直播、活动、文章模块
  126. this.CommonService.GetHomeTopDataInfo({source:2}).then(response =>{
  127. this.templateData = response.data
  128. this.isLiveRequest = true
  129. }).catch(error =>{
  130. this.$util.msg(error.msg,2000)
  131. })
  132. },
  133. GetHomeFloorInfo(){//初始化首页楼层数据
  134. this.CommonService.GetHomeDataInfo({userId:this.userID,soure:2}).then(response =>{
  135. let data = response.data;
  136. this.liveList = data.liveList;
  137. this.pageList = data.homePageFloor;
  138. this.supplierObj = data.supplierImage;
  139. this.isRequest = true;
  140. }).catch(error =>{
  141. this.$util.msg(error.msg,2000)
  142. })
  143. },
  144. getHomeInformation(){//初始化首页数据
  145. this.CommonService.GetHomeModulesDataInfo({ userId:this.userID }).then(res =>{
  146. let data = res.data;
  147. this.bannerImageList = data.bannerImageList
  148. this.mallPageModules = data.mallPageModules
  149. this.$store.commit('updateAllNum',data.shoppingCartCount)
  150. this.skeletonShow = false;
  151. this.GetHomeInit()
  152. this.GetHomeTopDataInfo()
  153. this.GetHomeFloorInfo()
  154. }).catch(error =>{
  155. this.$util.msg(error.msg,2000)
  156. })
  157. },
  158. handleClick(data){
  159. this.$api.navigateTo(`/h5/pages/activity/meobohui`)
  160. this.$store.commit('setActivity',data)
  161. uni.setStorageSync('lockTime',Date.now())
  162. uni.setStorageSync('isActivityStatus',true)
  163. },
  164. handleCancelClick(data){
  165. this.$store.commit('setActivity',data)
  166. uni.setStorageSync('lockTime',Date.now())
  167. uni.setStorageSync('isActivityStatus',true)
  168. },
  169. },
  170. onPageScroll(e){//实时获取到滚动的值
  171. if(e.scrollTop>50){
  172. this.inputActive = 'fixed'
  173. }else{
  174. this.inputActive = 'float'
  175. }
  176. if(e.scrollTop>400){
  177. this.isScrollTop = true
  178. }else{
  179. this.isScrollTop = false
  180. }
  181. },
  182. onPullDownRefresh() {//下拉刷新
  183. this.getHomeInformation()
  184. uni.stopPullDownRefresh()
  185. },
  186. onShareAppMessage(res){//分享转发
  187. if (res.from === 'button') {
  188. // 来自页面内转发按钮
  189. }
  190. return {
  191. title: '生美医美正品采购服务平台',
  192. path: 'pages/tabBar/home/index',
  193. imageUrl:'https://static.caimei365.com/app/img/bg/min-banner.jpg'
  194. }
  195. },
  196. onShow(){
  197. this.modallayer = false
  198. authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  199. if(res == 1){
  200. this.getWxAuthorize()
  201. }else{
  202. this.$api.getComStorage('userInfo').then((resolve) =>{
  203. this.userID = resolve.userID ? resolve.userID :0;
  204. this.getHomeInformation()
  205. }).catch(error =>{
  206. this.getHomeInformation()
  207. })
  208. }
  209. })
  210. }
  211. }
  212. </script>
  213. <style lang="scss">
  214. page{
  215. background-color: #FFFFFF;
  216. }
  217. .container-section{
  218. width: 100%;
  219. height: auto;
  220. background-color: #F7F7F7;
  221. }
  222. </style>