index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import {
  2. VueLikePage
  3. } from '../../utils/page'
  4. import {
  5. isPhoneX
  6. } from './../../utils/tools'
  7. import Router from '../../utils/routes'
  8. import Api from '../../apis/index'
  9. import ImApi from '../../apis/im'
  10. const app = getApp();
  11. VueLikePage([], {
  12. data: {
  13. images: [],
  14. detail: {},
  15. categoryList: [],
  16. companyList: [],
  17. currentIndex: 0,
  18. tabList: [{
  19. label: '科技珠海',
  20. route: 'exhibitionDetail',
  21. icon: '/image/4Dage/index/img_tags_situation.svg'
  22. },
  23. {
  24. label: '企业名录',
  25. route: 'exhibitionEnterprise',
  26. icon: '/image/4Dage/index/img_tags_directories.svg'
  27. },
  28. {
  29. label: '联系我们',
  30. route: 'exhibitionRegister',
  31. icon: '/image/4Dage/index/img_tags_register.svg'
  32. },
  33. ]
  34. },
  35. methods: {
  36. onLoad: function (options) {
  37. this.notAdd = true
  38. this.getActivityDetail()
  39. this.getCategoryList()
  40. this.getCompanyList()
  41. isPhoneX().then(res => {
  42. this.setData({
  43. isIphoneX: res
  44. })
  45. })
  46. },
  47. onShow () {
  48. if (this.notAdd && getApp().globalData.token && this.data.companyList.length > 0) {
  49. this.notAdd = false
  50. this.data.companyList.forEach(item => {
  51. if (item.guideId) {
  52. ImApi.addFriend(item.guideId)
  53. }
  54. })
  55. }
  56. },
  57. onShareAppMessage: function (res) {
  58. var path = '/pages/index/index'
  59. return {
  60. title: '三维数字化技术助力内循环',
  61. path: path,
  62. imageUrl: 'https://houseoss.4dkankan.com/domain/exhibition/demo/hwzff.jpg', // 分享的封面图
  63. }
  64. },
  65. toGoodsTab(e) {
  66. const { index } = e.currentTarget.dataset
  67. Router.push({
  68. url: 'goodsTabs',
  69. query: {
  70. active: index
  71. }
  72. })
  73. },
  74. toExhibitionList () {
  75. Router.push('exhibitionEnterprise')
  76. },
  77. toTabDetail (e) {
  78. const { route } = e.currentTarget.dataset
  79. Router.push(route)
  80. },
  81. toSearch () {
  82. Router.push('search')
  83. },
  84. getActivityDetail () {
  85. Api.getActivityDetail().then(res => {
  86. let detail = res.data
  87. detail.firstPageContent = JSON.parse(res.data.firstPageContent)
  88. this.setData({
  89. detail
  90. })
  91. })
  92. },
  93. getCategoryList () {
  94. Api.getCategoryList().then(res => {
  95. this.setData({
  96. categoryList: res.data.list
  97. })
  98. })
  99. },
  100. getCompanyList () {
  101. Api.getCompanyList({ pageSize: 12 }).then(res => {
  102. this.setData({
  103. companyList: res.data.list
  104. })
  105. if (this.notAdd && getApp().globalData.token) {
  106. this.notAdd = false
  107. res.data.list.forEach(item => {
  108. if (item.guideId) {
  109. ImApi.addFriend(item.guideId)
  110. }
  111. })
  112. }
  113. })
  114. },
  115. toScene (e) {
  116. const { vr_link, companyid } = e.currentTarget.dataset
  117. Api.postApiData({ companyId: companyid }).then((res) => {
  118. console.log(res)
  119. })
  120. Router.push({
  121. url: 'scene',
  122. query: {
  123. vr_link
  124. }
  125. })
  126. },
  127. imageLoad: function(e) {
  128. var $width=e.detail.width, //获取图片真实宽度
  129. $height=e.detail.height,
  130. ratio=$width/$height; //图片的真实宽高比例
  131. var viewWidth=88 * ratio, //设置图片显示宽度,左右留有16rpx边距
  132. viewHeight = 88; //计算的高度值
  133. var image=this.data.images;
  134. //将图片的datadata-index作为image对象的key,然后存储图片的宽高值
  135. image[e.target.dataset.index]={
  136. width:viewWidth,
  137. height:viewHeight
  138. }
  139. this.setData({
  140. images:image
  141. })
  142. },
  143. changeCurrentIndex (e) {
  144. this.setData({
  145. currentIndex: e.detail.current
  146. })
  147. }
  148. }
  149. })