index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view>
  3. <view class="fixed_top_status_bar"></view>
  4. <home-deco ref='home_deco' :deco_info="deco_data" :activity_open='activity_open' :width='width' :height='height' :home_page_img='home_page_img' :is_show_top="true" :home_is_show_top_cat="home_is_show_top_cat" :is_from_found="false"></home-deco>
  5. </view>
  6. </template>
  7. <script>
  8. import HomeDeco from '../components/home_deco.vue'
  9. export default {
  10. data() {
  11. return {
  12. deco_data:[] ,//首页装修数据
  13. home_is_show_top_cat:true ,//是否显示顶部分类,默认显示
  14. home_page_img:[],
  15. width:'',
  16. height:'',
  17. shareData:{},
  18. activity_open:false
  19. };
  20. },
  21. components: {
  22. HomeDeco
  23. },
  24. onLoad() {
  25. this.ifOpen()
  26. },
  27. /**
  28. * 用户点击右上角分享
  29. */
  30. onShareAppMessage: function () {
  31. const {
  32. shareData
  33. } = this;
  34. return shareData;
  35. },
  36. onReachBottom(){
  37. this.$refs.home_deco.getMoreData()
  38. },
  39. methods: {
  40. // 判断活动是否开启
  41. ifOpen(){
  42. let param = {}
  43. param.data={}
  44. param.data.names='integral_mall_is_enable'
  45. param.url = 'v3/system/front/setting/getSettings'
  46. param.method = 'GET'
  47. this.$request(param).then(res => {
  48. if (res.state == 200) {
  49. if(res.data[0]=='1'){
  50. this.activity_open=true
  51. this.loadData();
  52. }else{
  53. this.activity_open=false
  54. }
  55. }
  56. })
  57. },
  58. async loadData() {
  59. uni.showLoading({
  60. title:'加载中...'
  61. })
  62. // #ifdef H5
  63. this.client = 'h5'
  64. // #endif
  65. // #ifdef APP-PLUS
  66. switch(uni.getSystemInfoSync().platform){
  67. case 'android':
  68. this.client = 'android'
  69. break;
  70. case 'ios':
  71. this.client = 'ios'
  72. break;
  73. default:
  74. break;
  75. }
  76. // #endif
  77. // #ifdef MP
  78. this.client = 'weixinXcx'
  79. // #endif
  80. let param = {}
  81. param.data={}
  82. param.data.type='integral'
  83. param.url = 'v3/system/front/deco/index?os='+this.client
  84. param.method = 'GET'
  85. this.$request(param).then(res => {
  86. if (res.state == 200) {
  87. if(JSON.stringify(res.data) == "{}"){
  88. this.deco_data = null;
  89. uni.hideLoading();
  90. return
  91. }
  92. if(res.data.data != ''){
  93. this.deco_data = JSON.parse(res.data.data)
  94. }else{
  95. this.deco_data = null
  96. }
  97. // #ifdef MP
  98. this.shareData={
  99. title: res.data.siteName,
  100. path: '/pages/index/index',
  101. imageUrl: res.data.xcxImage
  102. }
  103. // #endif
  104. if(res.data.showTip != null){
  105. this.home_page_img = JSON.parse(res.data.showTip)
  106. const {windowWidth,windowHeight} = uni.getSystemInfoSync();
  107. this.width = this.home_page_img[0].width || windowWidth*0.75 * 1.8;
  108. this.height = this.home_page_img[0].height || windowHeight*0.56 * 1.8;
  109. }else{
  110. this.home_page_img = []
  111. }
  112. if(this.deco_data && this.deco_data.length != undefined && this.deco_data.length>0){
  113. this.home_is_show_top_cat = this.deco_data[0].type == 'top_cat_nav'?true:false;
  114. }
  115. uni.hideLoading()
  116. }else{
  117. // this.api.$msg(res.msg)
  118. uni.hideLoading();
  119. }
  120. })
  121. },
  122. },
  123. }
  124. </script>
  125. <style lang="scss">
  126. .fixed_top_status_bar {
  127. position: fixed;
  128. /* #ifdef APP-PLUS */
  129. height: var(--status-bar-height);
  130. /* #endif */
  131. /* #ifndef APP-PLUS */
  132. height: 0;
  133. /* #endif */
  134. top: 0;
  135. left: 0;
  136. right: 0;
  137. z-index: 99;
  138. background: #fff;
  139. }
  140. page{
  141. background: #F5F5F5;
  142. }
  143. </style>