vr.jsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. import Taro, { Component } from '@tarojs/taro'
  2. import { View, Map } from '@tarojs/components'
  3. import { AtNoticebar, AtFloatLayout } from 'taro-ui'
  4. import './vr.scss'
  5. import { arrToObj } from '@utils'
  6. class Index extends Component {
  7. onShareAppMessage() {
  8. return {
  9. title: `南昌楼盘航拍VR,楼栋外观、周边环境一目了然`,
  10. path: `/pagesOther/map/vr`,
  11. }
  12. }
  13. onShareTimeline () {
  14. return {
  15. title: `南昌楼盘航拍VR,楼栋外观、周边环境一目了然`,
  16. path: `/pagesOther/map/vr`,
  17. }
  18. }
  19. constructor (props) {
  20. super(props)
  21. this.state = {
  22. isPopupShow: false,
  23. curObj: {},
  24. estateList: [],
  25. allDataArr: [],
  26. }
  27. }
  28. config = {
  29. navigationBarTitleText: '楼盘航拍',
  30. }
  31. componentWillUnmount () {
  32. }
  33. componentWillMount () {
  34. Taro.$AHU(this)
  35. this.getData()
  36. }
  37. getData () {
  38. Taro.api.other.apivrestateall().then(res => {
  39. let estateList = res.map((item, index) => {
  40. return ({
  41. id: index + 20000,
  42. longitude: item.longitude,
  43. latitude: item.latitude,
  44. iconPath: 'https://icon.honglouplus.com/icon_1px.png',
  45. // iconPath: item.vr_image,
  46. width: 0,
  47. height: 0,
  48. zIndex: 9,
  49. callout: {
  50. content: `${item.estate_name}`,
  51. color: '#fff',
  52. bgColor: '#369af7',
  53. display: 'ALWAYS',
  54. padding: '6px 10px',
  55. textAlign: 'center',
  56. borderRadius: '10',
  57. }
  58. })
  59. })
  60. this.setState({
  61. allDataArr: res,
  62. estateList
  63. })
  64. })
  65. }
  66. componentDidShow () { }
  67. componentDidHide () { }
  68. calloutTap (e) {
  69. const { markerId } = e.detail
  70. if (markerId > 9999) {
  71. // Taro.showLoading({
  72. // mask: true,
  73. // title: '正在跳转~'
  74. // })
  75. // setTimeout(() => {
  76. // Taro.hideLoading()
  77. // }, 3000)
  78. if (markerId > 19999 && markerId < 30000) { // 楼盘
  79. const { allDataArr } = this.state
  80. const curItem = allDataArr[markerId - 20000]
  81. this.setState({
  82. curObj: curItem
  83. }, () => {
  84. this.openPopup()
  85. })
  86. // console.log(curItem)
  87. // Taro.navigateTo({url: `/pagesHouse/vr?id=${curItem.vr_key}&estateName=${curItem.estate_name}`})
  88. }
  89. }
  90. }
  91. markerTap (e) {}
  92. renderShare () {
  93. const iconShare = require('@img/images/icon_g_share6.png')
  94. return (
  95. <Button className="g-icon-share btn-to-div" openType="share">
  96. <Image className="img" src={iconShare} />
  97. </Button>
  98. )
  99. }
  100. renderHeader () {
  101. return (
  102. <View className="scoped-header">
  103. <AtNoticebar>
  104. 点击楼盘查看航拍VR,楼栋外观、周边环境一目了然
  105. </AtNoticebar>
  106. </View>
  107. )
  108. }
  109. renderSign () {
  110. const img = require('@img/sigin_sy.png')
  111. return (
  112. <View className="scoped-sign">
  113. <View className="bg"></View>
  114. <Image className="img" src={img} />
  115. </View>
  116. )
  117. }
  118. renderSign2 () {
  119. const img = require('@img/sigin_sy.png')
  120. return (
  121. <View className="scoped-sign2">
  122. <Image className="img" src={img} />
  123. </View>
  124. )
  125. }
  126. closePopup () {
  127. this.setState({
  128. isPopupShow: false
  129. })
  130. }
  131. openPopup () {
  132. this.setState({
  133. isPopupShow: true
  134. })
  135. }
  136. linkVr () {
  137. const { curObj } = this.state
  138. Taro.navigateTo({url: `/pagesHouse/vr?id=${curObj.vr_key}&estateName=${curObj.estate_name}`})
  139. }
  140. render () {
  141. let { estateList, isPopupShow, curObj } = this.state
  142. const hpI1 = require('@img/icon_hp_1.png')
  143. const hpI2 = require('@img/icon_hp_2.gif')
  144. return (
  145. <View className="l-box">
  146. {this.renderHeader()}
  147. <Map
  148. enable-satellite="true"
  149. longitude='115.851699'
  150. latitude='28.644161'
  151. enable-poi={false}
  152. scale='14'
  153. markers={estateList}
  154. min-scale="11"
  155. max-scale="20"
  156. subkey="Y7PBZ-FPZRP-4DXDL-VXQ3B-7DFL7-UXBK4"
  157. onCalloutTap={this.calloutTap.bind(this)}
  158. className="scoped-map"/>
  159. {this.renderShare()}
  160. {/* {this.renderSign()}
  161. {this.renderSign2()} */}
  162. <AtFloatLayout isOpened={isPopupShow} title={curObj.estate_name} onClose={this.closePopup.bind(this)}>
  163. <View className="scoped-vr-img" onClick={this.linkVr.bind(this)} >
  164. <View className="icon">
  165. <Image src={hpI1} className="i i1" />
  166. <Image src={hpI2} className="i i2" />
  167. </View>
  168. <Image src={curObj.vr_image} className="img" mode="aspectFit"/>
  169. </View>
  170. </AtFloatLayout>
  171. </View>
  172. )
  173. }
  174. }
  175. export default Index