123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- 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: {
- loginCode: '',
- detail: '',
- userName: '',
- avatarUrl: '',
- codeShow: false,
- code: '',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- userName: app.globalData.recommend.userName,
- avatarUrl: app.globalData.recommend.avatarUrl
- })
- },
- getPhoneNumber(e) {
- console.log(e);
- this.setData({
- detail: e.detail
- })
- this.getDenPhone();
- },
- getDenPhone() {
- util.request(api.GetDenPhone, {
- code: this.data.loginCode,
- encryptedData: this.data.detail.encryptedData,
- errMsg: this.data.detail.errMsg,
- iv: this.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();
- },
- showDialog() {
- this.setData({
- codeShow: true
- })
- },
- onClickHide() {
- this.setData({
- codeShow: false
- })
- },
- codeInput(e) {
- this.setData({
- code: e.detail.value
- })
- },
- confirm() {
- if (this.data.code == '') {
- wx.showToast({
- title: '请输入邀请码',
- icon: 'none',
- duration: 2000
- })
- } else {
- util.request(api.RefBcodeInfo, {
- bcode: this.data.code,
- }, "GET")
- .then((res) => {
- if (res.errno == 0) {
- app.globalData.recommend = {
- bCode: res.data.refereeCode,
- userName: res.data.refereeName,
- avatarUrl: res.data.refereeAvatar
- };
- app.globalData.rId = res.data.refereeId;
- this.setData({
- userName: res.data.refereeName,
- avatarUrl: res.data.refereeAvatar,
- codeShow: false
- })
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|