- db.collection-----这个是什么原理
const db = wx.cloud.database({}); let blogId = app.globalData.test.detailId; db.collection('test').doc(blogId).get().then(res => { console.log('db读取成功', res.data); let data = res.data; this.setData({ cover: data.cover, title: data.title, content: data.content }); }) .catch(e => { wx.showToast({ title: 'db读取失败', icon: 'none' }); }); 有没有大神可以说说各行代表的意思吗?为什么读不到数据
2019-03-04 - server.getJSON这个函数的怎么一回事!
[代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]var[代码] [代码]self = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]wx.getLocation({[代码][代码] [代码][代码]type: [代码][代码]'gcj02'[代码][代码],[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]var[代码] [代码]latitude = res.latitude;[代码][代码] [代码][代码]var[代码] [代码]longitude = res.longitude;[代码][代码] [代码][代码]server.getJSON([代码][代码]'/waimai/api/location.php'[代码][代码], {[代码][代码] [代码][代码]latitude: latitude,[代码][代码] [代码][代码]longitude: longitude[代码][代码] [代码][代码]}, [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]if[代码] [代码](res.data.status != -1) {[代码][代码] [代码][代码]self.setData({[代码][代码] [代码][代码]address: res.data.result.address_component.street_number[代码][代码] [代码][代码]});[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]self.setData({[代码][代码] [代码][代码]address: [代码][代码]'定位失败'[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onShow: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onScroll: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]if[代码] [代码](e.detail.scrollTop > 100 && ![代码][代码]this[代码][代码].data.scrollDown) {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]scrollDown: [代码][代码]true[代码][代码] [代码][代码]});[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]if[代码] [代码](e.detail.scrollTop < 100 && [代码][代码]this[代码][代码].data.scrollDown) {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]scrollDown: [代码][代码]false[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]tapSearch: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]wx.navigateTo({url: [代码][代码]'search'[代码][代码]});[代码][代码] [代码][代码]},[代码][代码] [代码][代码]toNearby: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]var[代码] [代码]self = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]self.setData({[代码][代码] [代码][代码]scrollIntoView: [代码][代码]'nearby'[代码][代码] [代码][代码]});[代码][代码] [代码][代码]self.setData({[代码][代码] [代码][代码]scrollIntoView: [代码][代码]null[代码][代码] [代码][代码]});[代码][代码] [代码][代码]},[代码][代码] [代码][代码]tapFilter: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]switch[代码] [代码](e.target.dataset.id) {[代码][代码] [代码][代码]case[代码] [代码]'1'[代码][代码]:[代码][代码] [代码][代码]this[代码][代码].data.shops.sort([代码][代码]function[代码] [代码](a, b) {[代码][代码] [代码][代码]return[代码] [代码]a.id > b.id;[代码][代码] [代码][代码]});[代码][代码] [代码][代码]break[代码][代码];[代码][代码] [代码][代码]case[代码] [代码]'2'[代码][代码]:[代码][代码] [代码][代码]this[代码][代码].data.shops.sort([代码][代码]function[代码] [代码](a, b) {[代码][代码] [代码][代码]return[代码] [代码]a.sales < b.sales;[代码][代码] [代码][代码]});[代码][代码] [代码][代码]break[代码][代码];[代码][代码] [代码][代码]case[代码] [代码]'3'[代码][代码]:[代码][代码] [代码][代码]this[代码][代码].data.shops.sort([代码][代码]function[代码] [代码](a, b) {[代码][代码] [代码][代码]return[代码] [代码]a.distance > b.distance;[代码][代码] [代码][代码]});[代码][代码] [代码][代码]break[代码][代码];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]filterId: e.target.dataset.id,[代码][代码] [代码][代码]shops: [代码][代码]this[代码][代码].data.shops[代码][代码] [代码][代码]});[代码][代码] [代码][代码]},[代码][代码] [代码][代码]tapBanner: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]var[代码] [代码]name = [代码][代码]this[代码][代码].data.banners[e.target.dataset.id].name;[代码][代码] [代码][代码]wx.showModal({[代码][代码] [代码][代码]title: [代码][代码]'提示'[代码][代码],[代码][代码] [代码][代码]content: [代码][代码]'您点击了“'[代码] [代码]+ name + [代码][代码]'”活动链接,活动页面暂未完成!'[代码][代码],[代码][代码] [代码][代码]showCancel: [代码][代码]false[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码]});[代码]
2019-02-06