// component/authorize/authorize.js import utils from '../../utils/util.js' const app = getApp(); Component({ /** * 组件的属性列表 */ options: { multipleSlots: true // 在组件定义时的选项中启用多slot支持 }, properties: { isMustAuthorize:{ type:Boolean, value:false } }, /** * 组件的初始数据 */ data: { // isAuthorize: true, isShowDialog:false, wxIfShowDialog:true }, lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached() { // let getLogin = Request.request({ // url: '/shopping/confirm.do?m=isLogin' // }).then((res) => { // console.log('denglu', res) // isLogin = res.isLogin // // res.isLogin ? isLogin = false : isLogin = true // // console.log('isPullTelephone2', isPullTelephone2) // }); }, // moved() { }, // detached() { }, // ready() { // } }, pageLifetimes: { // 组件所在页面的生命周期函数 // show() { // utils.isAuthorize(this); // }, // hide() { // }, }, /** * 组件的方法列表 */ methods: { preventMove: function () { // 利用catchtouchmove阻止背景滚动 不用添加任何代码 // 只适合模态层不需要滚动的场景 }, onDialogClose(){ this.setData({ isShowDialog:false }) if (!this.data.isMustAuthorize) { this.triggerEvent('authorize', { isAuthorize: false }) } }, showGetPhoneDialog(){ this.setData({ isShowDialog:true }) }, async postPhoneNumber(e){ console.log('获取电话',e) if (e.detail.errMsg == 'getPhoneNumber:ok') { let [err, res] = await utils.to( wx.$http.request({ url: '/shopping/account.do', data: { m: 'telRegByAutoReg', // ReferralsCode: this.data.UserId, // ReferralsName: this.data.Name, ReferralsCode: app.globalData.cardUserData.UserId, ReferralsName: app.globalData.cardUserData.Name, encryptedData: e.detail.encryptedData, iv: e.detail.iv, // SessionKey: app.globalData.SessionKey } }) ) if (err) { return; } console.log('/shopping/account.do', res); if (res.cltcode) { app.globalData.Cltcode = res.cltcode; this.triggerEvent('authorize', { isAuthorize: true }) this.setData({ wxIfShowDialog:false }) } } else { console.log('取消授权'); if (!this.data.isMustAuthorize) { this.triggerEvent('authorize', { isAuthorize: false }) } } }, // 点击授权 getPhoneNumber(e) { console.log('app.globalData.Cltcode',app.globalData.Cltcode) if (!app.globalData.Cltcode) { this.showGetPhoneDialog(); } else { this.setData({ wxIfShowDialog:false }) this.triggerEvent('authorize', { isAuthorize: true }) } }, } })