123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- 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 () {
- }
- })
|