195 lines
3.8 KiB
JavaScript
195 lines
3.8 KiB
JavaScript
// packageC/member/visit/Inviter/Inviter.js
|
|
var app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
name: "",
|
|
img: "",
|
|
mid: "",
|
|
title: "",
|
|
fromGood: '',
|
|
is_bind_invite: 0
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
if (options.fromGood) {
|
|
this.setData({
|
|
fromGood: options.fromGood
|
|
});
|
|
}
|
|
wx.hideHomeButton();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
this.getUserinfo();
|
|
this.showName();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {
|
|
|
|
},
|
|
getUserinfo() {
|
|
let that = this;
|
|
let mid = '';
|
|
try {
|
|
var value = wx.getStorageSync('mid');
|
|
if (value) {
|
|
mid = value;
|
|
// Do something with return value
|
|
}
|
|
} catch (e) {
|
|
// Do something when catch error
|
|
}
|
|
let urlStr = app.getNetAddresss("member.member.getUserInfo");
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
mid: mid
|
|
},
|
|
validateBol:2,
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
name: res.data.referral.nickname,
|
|
img: res.data.referral.avatar,
|
|
is_bind_invite: res.data.is_bind_invite,
|
|
inviteCode:res.data.inviteCode
|
|
});
|
|
}
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
showName() {
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss("member.member.getShopSet");
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: {},
|
|
validateBol:2,
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
title: res.data.shop_set_name,
|
|
default_invite: res.data.default_invite
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: res.msg,
|
|
duration: 1500
|
|
});
|
|
}
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
affirm() {
|
|
try {
|
|
wx.setStorageSync('isset', 1);
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
if (this.data.fromGood == 1) {
|
|
//商品下单判断是否需要邀请码
|
|
let urlStr = app.getNetAddresss("member.member.confirmGoods");
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: {},
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: res.msg,
|
|
duration: 1500
|
|
});
|
|
}
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
} else {
|
|
//商城登录输入邀请码
|
|
wx.navigateTo({
|
|
url: '/packageA/member/editmobile/editmobile?fromApp=3&code='+this.data.inviteCode
|
|
});
|
|
}
|
|
},
|
|
error(event) {
|
|
try {
|
|
wx.setStorageSync('isset', 1);
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
if (this.data.fromGood) {
|
|
wx.navigateTo({
|
|
url: '/packageC/member/visit/InputVisit/InputVisit?fromGood=' + this.data.fromGood
|
|
});
|
|
} else {
|
|
wx.navigateTo({
|
|
url: '/packageC/member/visit/InputVisit/InputVisit'
|
|
});
|
|
}
|
|
|
|
},
|
|
});
|