index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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" 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. webviewStyles: {
  47. progress: {
  48. color: '#FF3333'
  49. }
  50. },
  51. nvabarData: {//顶部自定义导航
  52. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  53. showSearch: 0,
  54. title: '采美采购商城', // 导航栏 中间的标题
  55. haveBack:false,
  56. textLeft:this.$store.state.isIphone,
  57. textColor:'#FFFFFF'
  58. },
  59. CustomBar:this.CustomBar,// 顶部导航栏高度
  60. userID:0,
  61. clubStatus:'',
  62. current:0,
  63. mode:'round',
  64. modallayer:false,
  65. isLogin:false,
  66. skeletonShow: true,
  67. userIdentity:'',
  68. flootData:[],//楼层
  69. bannerImageList:[],//轮播
  70. navBarsList:[],//导航分类
  71. templateData:[],
  72. pageList:[],//楼层
  73. supplierObj:{},//供应商列表
  74. isScrollTop:false,
  75. isRequest:false,
  76. }
  77. },
  78. onLoad() {
  79. },
  80. computed: {
  81. ...mapState(['hasLogin','userInfo','identity'])
  82. },
  83. methods: {
  84. ...mapMutations(['login','logout']),
  85. getWxAuthorize(){
  86. authorize.getCode('weixin').then(wechatcode =>{// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  87. authorize.getUserInfo('weixin').then(wxResponse =>{
  88. userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
  89. this.isLogin = true;
  90. this.userID = response.data.userID;
  91. this.userIdentity = response.data.userIdentity;
  92. this.clubStatus = response.data.clubStatus;
  93. this.$store.commit('updateStatus',response.data)
  94. this.login(response.data);
  95. uni.setStorageSync('token',response.data.token)
  96. uni.removeStorageSync('sessionid')
  97. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  98. if(response.data.userIdentity ==1){
  99. this.$api.redirectTo('/seller/pages/index/index')
  100. }else if(response.data.userIdentity === 3){
  101. this.$api.redirectTo('/supplier/pages/index/index')
  102. }
  103. this.getHomeInformation()
  104. }).catch(error =>{
  105. this.isLogin = false;
  106. this.logout()
  107. uni.removeStorageSync('sessionid')
  108. uni.setStorageSync('sessionid','JSESSIONID='+error.data)
  109. this.$store.commit('updateStatus',error.data)
  110. this.getHomeInformation()
  111. })
  112. })
  113. })
  114. },
  115. GetHomeInit(){//金刚区分类
  116. this.CommonService.GetHomeInit({source:2}).then(response =>{
  117. let data = response.data
  118. this.navBarsList = data.topMenuList
  119. }).catch(error =>{
  120. this.$util.msg(error.msg,2000)
  121. })
  122. },
  123. GetHomeTopDataInfo(){//金刚区分类
  124. this.CommonService.GetHomeTopDataInfo({source:2}).then(response =>{
  125. this.templateData = response.data
  126. console.log(this.templateData)
  127. }).catch(error =>{
  128. this.$util.msg(error.msg,2000)
  129. })
  130. },
  131. GetHomeFloorInfo(){//初始化首页楼层数据
  132. this.CommonService.GetHomeDataInfo({userId:this.userID,soure:2}).then(response =>{
  133. let data = response.data;
  134. this.liveList = data.liveList;
  135. this.pageList = data.homePageFloor;
  136. this.supplierObj = data.supplierImage;
  137. console.log(this.pageList)
  138. this.skeletonShow = false;
  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.GetHomeInit()
  151. this.GetHomeFloorInfo()
  152. this.GetHomeTopDataInfo()
  153. }).catch(error =>{
  154. this.$util.msg(error.msg,2000)
  155. })
  156. },
  157. handleClick(data){
  158. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  159. this.$store.commit('setActivity',data)
  160. },
  161. handleCancelClick(data){
  162. this.$store.commit('setActivity',data)
  163. },
  164. },
  165. onPageScroll(e){//实时获取到滚动的值
  166. if(e.scrollTop>50){
  167. this.inputActive = 'fixed'
  168. }else{
  169. this.inputActive = 'float'
  170. }
  171. if(e.scrollTop>400){
  172. this.isScrollTop = true
  173. }else{
  174. this.isScrollTop = false
  175. }
  176. },
  177. onPullDownRefresh() {//下拉刷新
  178. this.getHomeInformation()
  179. uni.stopPullDownRefresh()
  180. },
  181. onShareAppMessage(res){//分享转发
  182. if (res.from === 'button') {
  183. // 来自页面内转发按钮
  184. }
  185. return {
  186. title: '采美采购商城-生美/医美采购服务平台',
  187. path: 'pages/tabBar/home/index',
  188. imageUrl:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAWWkhAAXDP4-6m_c397.png'
  189. }
  190. },
  191. onShow(){
  192. this.modallayer = false
  193. authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  194. if(res == 1){
  195. this.getWxAuthorize()
  196. }else{
  197. this.$api.getComStorage('userInfo').then((resolve) =>{
  198. this.userID = resolve.userID ? resolve.userID :0;
  199. this.getHomeInformation()
  200. }).catch(error =>{
  201. this.getHomeInformation()
  202. })
  203. }
  204. })
  205. }
  206. }
  207. </script>
  208. <style lang="scss">
  209. page{
  210. background-color: #FFFFFF;
  211. }
  212. .container-section{
  213. width: 100%;
  214. height: auto;
  215. background-color: #F7F7F7;
  216. }
  217. </style>