import Dialog from '@vant/weapp/dialog/dialog'; const util = require('../../../../utils/util.js'); const api = require('../../../../config/api.js'); const user = require('../../../../utils/user.js'); const app = getApp(); Page({ /** * 页面的初始数据 */ data: { rId: 0, checked: false, userName: '', loginCode: '', avatarUrl: '', bCode: '', userName: '', avatarUrl: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if (options.rId) { this.setData({ rId: options.rId }); app.globalData.rId = options.rId; this.getReferrerRidInfo(); } }, getReferrerRidInfo() { util.request(api.ReferrerRidInfo, { rId: this.data.rId, }, "GET") .then((res) => { console.info(res) if (res.errno == 0) { this.setData({ userName: res.data.applyName, avatarUrl: res.data.avatar, userName: res.data.applyName, avatarUrl: res.data.avatar, bCode: res.data.bCode }) } else { util.showErrorToast(res.errmsg); } }); }, getPhoneNumber(e) { console.info(e) this.setData({ detail: e.detail }) this.getDenPhone(); }, getDenPhone() { let that=this; util.request(api.GetDenPhone, { code: that.data.loginCode, encryptedData: that.data.detail.encryptedData, errMsg: that.data.detail.errMsg, iv: that.data.detail.iv }, "POST") .then((res) => { if (res.errno == 0) { let isNew = res.data.isNew; if (isNew) { app.globalData.recommend.phone = res.data.phone; app.globalData.recommend.unionId = res.data.unionId; app.globalData.recommend.openId = res.data.openId; app.globalData.recommend.sessionKey = res.data.sessionKey; wx.navigateTo({ url: '../register/register', }) } else { // 不是新人,则跳转到首页 Dialog.alert({ title: '引荐失败', message: '您已是鲸致商城用户,当前引荐人计划只面向新用户,敬请期待', }).then(() => { // on close wx.switchTab({ url: '/pages/index/index', }); }); } } else { util.showErrorToast(res.errmsg); this.getLoginCode(); } }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, getLoginCode() { let that = this; user.login().then(res => { that.setData({ loginCode: res.code }) }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getLoginCode(); }, onChange(e) { console.log(e); this.setData({ checked: e.detail, }); }, confirmJoin() { if (!this.data.checked) { Dialog.alert({ title: '提示', message: '请阅读《用户条款》并勾选', }).then(() => { // on close }); } else { wx.navigateTo({ url: '../confirm/confirm' }); } }, userProtocol() { wx.navigateTo({ url: '../protocol/protocol' }); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })