|
| 1 | +//index.js |
| 2 | + |
| 3 | +var cat_id = "1"; |
| 4 | + |
| 5 | +Page({ |
| 6 | + data: { |
| 7 | + cat: {}, |
| 8 | + markers: [], |
| 9 | + photoscr: "", |
| 10 | + }, |
| 11 | + |
| 12 | + /** |
| 13 | + * 生命周期函数--监听页面加载 |
| 14 | + */ |
| 15 | + onLoad: function (options) { |
| 16 | + cat_id = options.cat_id; |
| 17 | + const that = this; |
| 18 | + console.log("加载detail页码"); |
| 19 | + // console.log(cat_id); |
| 20 | + const db = wx.cloud.database(); |
| 21 | + db.collection('cat').doc(cat_id).get().then(res => { |
| 22 | + console.log(res); |
| 23 | + |
| 24 | + this.setData({ |
| 25 | + cat: res.data, |
| 26 | + photoscr: "https://6369-circle-test-zdk23-1259206269.tcb.qcloud.la/%E4%BC%9A%E5%BE%BD/" + res.data.name + ".png" |
| 27 | + }); |
| 28 | + }).then(res => { |
| 29 | + var number = 0 |
| 30 | + for (var i in this.data.cat.markers) { |
| 31 | + var marker = [ |
| 32 | + { |
| 33 | + iconPath: "https://6369-circle-test-zdk23-1259206269.tcb.qcloud.la/%E4%BC%9A%E5%BE%BD/" + encodeURIComponent(this.data.cat.name) + ".png", |
| 34 | + latitude: this.data.cat.markers[i].latitude, |
| 35 | + longitude: this.data.cat.markers[i].longitude, |
| 36 | + width: 50, |
| 37 | + height: 50, |
| 38 | + id: number, |
| 39 | + } |
| 40 | + ] |
| 41 | + this.setData({ |
| 42 | + markers: this.data.markers.concat(marker), |
| 43 | + }); |
| 44 | + // console.log(this.data.markers) |
| 45 | + number++ |
| 46 | + } |
| 47 | + }); |
| 48 | + |
| 49 | + }, |
| 50 | + |
| 51 | + includePointsOne() { |
| 52 | + const mapCtx = wx.createMapContext('map', this); |
| 53 | + mapCtx.includePoints({ |
| 54 | + padding: [60, 36, 0, 36], |
| 55 | + points: this.data.markers, |
| 56 | + success: res => { |
| 57 | + console.log('includePoints success'); |
| 58 | + }, |
| 59 | + fail: err => { |
| 60 | + console.log('includePoints fail', err); |
| 61 | + } |
| 62 | + }); |
| 63 | + }, |
| 64 | + |
| 65 | + |
| 66 | + onShow: function (options) { |
| 67 | + |
| 68 | + }, |
| 69 | + |
| 70 | + |
| 71 | + regionchange(e) { |
| 72 | + console.log(e.type) |
| 73 | + }, |
| 74 | + markertap(e) { |
| 75 | + console.log(e.detail.markerId) |
| 76 | + }, |
| 77 | + controltap(e) { |
| 78 | + console.log(e.detail.controlId) |
| 79 | + }, |
| 80 | + |
| 81 | + onShareAppMessage: function (res) { |
| 82 | + if (res.from === 'button') { |
| 83 | + // 来自页面内转发按钮 |
| 84 | + console.log(res.target) |
| 85 | + } |
| 86 | + return { |
| 87 | + title: this.data.cat.name, |
| 88 | + path: '/pages/catDetail/catDetail?cat_id=' + this.data.cat._id, |
| 89 | + success: function (res) { |
| 90 | + // 转发成功 |
| 91 | + }, |
| 92 | + fail: function (res) { |
| 93 | + // 转发失败 |
| 94 | + } |
| 95 | + } |
| 96 | + }, |
| 97 | + |
| 98 | + onShareTimeline: function (res) { |
| 99 | + if (res.from === 'button') { |
| 100 | + // 来自页面内转发按钮 |
| 101 | + console.log(res.target) |
| 102 | + } |
| 103 | + return { |
| 104 | + title: this.data.cat.name, |
| 105 | + path: '/pages/catDetail/catDetail?cat_id=' + this.data.cat._id, |
| 106 | + success: function (res) { |
| 107 | + // 转发成功 |
| 108 | + }, |
| 109 | + fail: function (res) { |
| 110 | + // 转发失败 |
| 111 | + } |
| 112 | + } |
| 113 | + }, |
| 114 | + onPullDownRefresh: function () { |
| 115 | + wx.stopPullDownRefresh() |
| 116 | + }, |
| 117 | + copyBili: function (e) { |
| 118 | + var self = this; |
| 119 | + wx.setClipboardData({ |
| 120 | + data: this.data.cat.officialAccount['bili'],//需要复制的内容 |
| 121 | + success: function (res) { |
| 122 | + console.log("复制成功") |
| 123 | + } |
| 124 | + }) |
| 125 | + }, |
| 126 | + |
| 127 | + naviToMini: function (e) { |
| 128 | + wx.navigateToMiniProgram({ |
| 129 | + appId: this.data.cat.officialAccount['miniprogram'], |
| 130 | + // path: 'pages/index/index', |
| 131 | + envVersion: 'release', |
| 132 | + success(res) { |
| 133 | + // 打开成功 |
| 134 | + } |
| 135 | + }) |
| 136 | + }, |
| 137 | + naviToMini1: function (e) { |
| 138 | + wx.navigateToMiniProgram({ |
| 139 | + appId: this.data.cat.officialAccount['miniprogram1'], |
| 140 | + // path: 'pages/index/index', |
| 141 | + envVersion: 'release', |
| 142 | + success(res) { |
| 143 | + // 打开成功 |
| 144 | + } |
| 145 | + }) |
| 146 | + } |
| 147 | + |
| 148 | +}) |
| 149 | + |
| 150 | + |
0 commit comments