information.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="container">
  3. <home-deco :deco_info="deco_data" :width='width' :height='height' :home_page_img='home_page_img' :is_show_top="false" type="information"></home-deco>
  4. </view>
  5. </template>
  6. <script>
  7. import HomeDeco from '@/components/home_deco.vue'
  8. export default {
  9. data() {
  10. return {
  11. deco_data:[],
  12. home_page_img:[],
  13. width:'',
  14. height:'',
  15. client:'' //客户端类型
  16. };
  17. },
  18. components: {
  19. HomeDeco
  20. },
  21. onLoad(option) {
  22. this.loadData(this.topic_id);
  23. },
  24. onBackPress(e){
  25. uni.navigateTo({
  26. url:"/pages/details/details?type=2"
  27. })
  28. // 此处一定姚要return为true,否则页面不会返回到指定路径
  29. return true;
  30. },
  31. methods: {
  32. /**
  33. * 请求静态数据只是为了代码不那么乱
  34. * 分次请求未作整合
  35. */
  36. async loadData(id) {
  37. uni.showLoading({
  38. title:this.$L('加载中...'),
  39. })
  40. // #ifdef H5
  41. this.client = 'h5'
  42. // #endif
  43. // #ifdef APP-PLUS
  44. switch(uni.getSystemInfoSync().platform){
  45. case 'android':
  46. this.client = 'android'
  47. break;
  48. case 'ios':
  49. this.client = 'ios'
  50. break;
  51. default:
  52. break;
  53. }
  54. // #endif
  55. // #ifdef MP
  56. this.client = 'weixinXcx'
  57. // #endif
  58. let param = {}
  59. param.url = 'v3/system/front/deco/information?os='+this.client
  60. param.method = 'GET'
  61. this.$request(param).then(res => {
  62. if (res.state == 200) {
  63. if(res.data&&res.data.data){
  64. this.deco_data = JSON.parse(res.data.data)
  65. }
  66. uni.hideLoading()
  67. if(res.data.showTip != null){
  68. this.home_page_img = JSON.parse(res.data.showTip)
  69. const {windowWidth,windowHeight} = uni.getSystemInfoSync();
  70. this.width = this.home_page_img[0].width || windowWidth*0.75 * 1.8;
  71. this.height = this.home_page_img[0].height || windowHeight*0.56 * 1.8;
  72. }else{
  73. this.home_page_img = []
  74. }
  75. }
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss">
  82. </style>