// pages/index/index.js import * as UTIL from '../../../utils/util.js'; import * as API from '../../../utils/API.js'; import * as STORAGE from '../../../utils/storage' const APP = getApp(); Page({ /** * 页面的初始数据 */ data: { isIPhoneX:false, privacyCheck:true //用户协议 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ isIPhoneX:UTIL.isIPhoneX() }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, checkboxChange: function(res) { let checkStatus = false; if(res.detail.value.length!=0){ checkStatus = true; }else{ checkStatus = false; } this.setData({ privacyCheck:checkStatus }) }, getPhoneNumber: function(res) { let that = this; let { detail } = res; if (!detail.encryptedData) { //允许授权 APP.showToast("未获取到手机号码,注册失败!"); return; }else if(this.data.privacyCheck == false){ APP.showToast("请阅读并同意用户协议和隐私政策!"); return; } let sendData = { sessionKey:STORAGE.getSessionKey(), iv:detail.iv, encryptedData:detail.encryptedData } UTIL.httpRequest(API.URL_POST_DECRYPTEDWXDATA, sendData,{ success: (res) => { if (res._code == API.SUCCESS_CODE) { // UTIL.showToastNoneIcon("数据共:" + res._data.length + "条"); } else { //待删 wx.navigateTo({ url: '/pages/index/index', }) UTIL.showToastNoneIcon(res.msg) } }, fail: (res) => { UTIL.showToastNoneIcon(API.MSG_FAIL_HTTP) }, complete: (res) => { } }); //     if (res.detail.userInfo) { //       //用户按了允许授权按钮 //       var that = this; //       // 获取到用户的信息了,打印到控制台上看下 //       console.log("用户的信息如下:"); //       console.log(res.detail); //       //授权成功后,通过改变 isHide 的值,让实现页面显示出来,把授权页面隐藏起来 //       that.setData({ //         isHide: false //       }); //     } else { //       //用户按了拒绝按钮 //       wx.showModal({ //         title: '警告', //         content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!!!', //         showCancel: false, //         confirmText: '返回授权', //         success: function(res) { //           // 用户没有授权成功,不需要改变 isHide 的值 //           if (res.confirm) { //             console.log('用户点击了“返回授权”'); //           } //         } //       }); //     } } })