import { getDictData, getWxMiniPhone, binDingPhone } from '../../api/index' Page({ /** * 页面的初始数据 */ data: { agreementFalg: false, tempPath: '', primary: '', bottomLift: 0, showModal: false, serviceHtml: '', title: '', privacyHtml: '', activeHtml: '' }, initData() { var app = getApp().globalData this.setData({ bottomLift: app.bottomLift }) getDictData({ code: 'ZBOM_CUSTOMIZED', label: 'SERVER_AGREEMENT' }).then(res => { this.setData({ serviceHtml: res.data.code }) }) getDictData({ code: 'ZBOM_CUSTOMIZED', label: 'PRIVACY_AGREEMENT' }).then(res => { this.setData({ privacyHtml: res.data.code }) }) }, handleJudge(e) { const flag = e.currentTarget.dataset.flag console.log(e); this.setData({ agreementFalg: flag, showModal: false }) }, loginIn() { const { agreementFalg } = this.data if (!agreementFalg) return wx.showToast({ title: '请先阅读并同意相关协议', icon: 'none', duration: 2000 }) }, getPhoneNumber(e) { console.log(e.detail) console.log(e.detail.iv) console.log(e.detail.encryptedData) const data = { ...e.detail } if (e.detail && e.detail.iv) { getWxMiniPhone({ encryptedData: data.encryptedData, iv: data.iv, sessionKey: wx.getStorageSync('sessionKey') || data.iv, }).then(res => { binDingPhone({ phone: res.data }).then((res) => { if (res.code == 200) { const { tempPath } = this.data wx.setStorageSync('member', res.data) if (tempPath) { if (tempPath == '/pages/webView/index') { wx.navigateTo({ url: '/pages/webView/index', success: function (res) { res.eventChannel.emit('acceptDataFromOpenerPage', { link: wx.getStorageSync('testUrl') }) } }) return } wx.redirectTo({ url: tempPath, }) } else { wx.navigateBack() } } }) }) } }, onOpen(e) { console.log('e', e); const { serviceHtml, privacyHtml } = this.data const { index } = e.target.dataset let activeHtml = index == '0' ? serviceHtml : privacyHtml this.setData({ activeHtml, showModal: true }) }, onClose() { this.setData({ showModal: false }) }, agreementChange(e) { this.setData({ agreementFalg: e.detail, }) }, onLoad(options) { var app = getApp().globalData this.setData({ primary: app.primary }) this.initData() }, onReady() { }, onShow() { const tempPath = wx.getStorageSync('tempPath') || '' this.setData({tempPath}) setTimeout(() => { wx.setStorageSync('tempPath', '') }) }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })