// pages/detail/index.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { navHeight: '', //swiper background: ['bg1', 'bg2', 'bg3'], vertical: false, autoplay: false, interval: 2000, duration: 500, current:0, //下啦 isScroll: false, //地图 markers: [{ latitude: 0, longitude: 0, }], BASEIMGURL: app.globalData.BASEIMGURL, //图片域名 currentActivity: {}, //详情 userInfo: {} }, add() { //参加活动 console.log('add'); }, async getPhoneNumber(e) { const that = this; if (e.detail.errMsg == "getPhoneNumber:ok") { let res = await app.globalData.api.bindphone({ "openid": app.globalData.userInfo.openid, "encryptedData": e.detail.encryptedData, "iv": e.detail.iv, "invitor": app.globalData.shareOpenId }) app.globalData.userInfo.phone = res.data.phone; that.setData({ userInfo: { ...this.data.userInfo, 'phone': res.data.phone } }); //参加活动 that.add(); // wx.showToast({ // title: '参加成功!', // icon: 'none' // }) } else { wx.showToast({ title: '请授权您的手机号!', icon: 'none' }) } }, change(e){ this.setData({ current: e.detail.current }) }, scroll(e){ if(e.detail.scrollTop > 1 && this.data.isScroll == false){ this.setData({ isScroll: true }) }else if(e.detail.scrollTop < 1 && this.data.isScroll == true){ this.setData({ isScroll: false }) } }, scrollView(){ this.setData({ isScroll: !this.data.isScroll }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ userInfo: app.globalData.userInfo, navHeight: app.globalData.navHeight, currentActivity: app.globalData.currentActivity, markers: [{ latitude: app.globalData.currentActivity.lat || 0, longitude: app.globalData.currentActivity.lng || 0 }] }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage() { const openid = wx.getStorageSync('openid') let param = openid && typeof openid === 'string' ? `pages/index/index?openid=${ openid }` : `pages/index/index` return { title: 'Coffee Talk', desc: '快来参加活动吧~', // imageUrl: 'https://cirraybucket.oss-cn-shanghai.aliyuncs.com/nowwa-h5/aboutUs/share.jpg', path: param } }, })