// pages/agreement/index.js Page({ /** * 页面的初始数据 */ data: { stage: "first", q: "", e: "", s: "", }, toStage2() { this.setData({ stage: "second" }); }, async agree() { wx.showLoading(); const app = getApp(); const openid = app.globalData.openid; const db = wx.cloud.database(); try { await db.collection("agreement").add({ data: { _id: openid } }); wx.hideLoading(); app.globalData.agreed = true; const { q, e, s } = this.data; wx.redirectTo({ url: `/pages/h5map/index?q=${q}&e=${e}&s=${s}`, }); } catch (error) { console.log(error); wx.hideLoading(); } }, exit() { wx.exitMiniProgram(); }, toPrivacy() { wx.navigateTo({ url: "/pages/privacy/index", }); }, /** * 生命周期函数--监听页面加载 */ onLoad({ q, e, s }) { q && this.setData({ q }); e && this.setData({ e }); s && this.setData({ s }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () {}, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () {}, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, });