index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import ad from '../index/ad'
  2. const windowHeight = wx.getSystemInfoSync().windowHeight
  3. const locations = [{
  4. name: '北京',
  5. geo: [116.46, 39.92],
  6. }, {
  7. name: '上海',
  8. geo: [121.48, 31.22],
  9. }, {
  10. name: '广州',
  11. geo: [113.23, 23.16],
  12. }, {
  13. name: '深圳',
  14. geo: [114.07, 22.62],
  15. }]
  16. ad({
  17. data: {
  18. geo: locations[0].geo,
  19. locations,
  20. defaultAnchors: [100, windowHeight * .5, windowHeight * .8],
  21. },
  22. onHeightChange(e) {
  23. console.log('onHeightChange', e.detail)
  24. const { height, maxHeight } = e.detail
  25. const ratio = height / maxHeight
  26. this.setData({
  27. height: '100%',
  28. backgroundImage: `linear-gradient(rgba(124, 24, 126, ${ratio}), rgba(203, 98, 117, ${ratio}))`,
  29. })
  30. },
  31. setHeight() {
  32. const floatingPanelRef = this.selectComponent('#wux-floating-panel')
  33. floatingPanelRef.setHeight(200, { immediate: true })
  34. },
  35. onLocation(e) {
  36. console.log('onLocation', e.target.dataset)
  37. const { geo } = e.target.dataset
  38. this.setData({
  39. geo,
  40. })
  41. },
  42. })