yuminge-app/yun-min-program-plugin-master/packageC/member/visit/InputVisit/InputVisit.js

187 lines
3.8 KiB
JavaScript

// packageC/member/visit/InputVisit/InputVisit.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
invite_code: "",
name: "",
img: "",
title: "",
fromGood: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options.fromGood) {
this.setData({
fromGood: options.fromGood
});
}
this.showName();
wx.hideHomeButton();
},
fillInCode(e){
this.setData({
invite_code:this.data.default_invite
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
inviteCodeinp(e) {
let val = e.detail.value;
this.setData({
invite_code: val
});
},
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);
}
});
},
submit() {
let that = this;
if (app._isTextEmpty(this.data.invite_code)) {
wx.showToast({
icon: 'none',
title: '请输入邀请码',
duration: 1500
});
return;
}
if (this.data.fromGood) {
let urlStr = app.getNetAddresss("member.member.refuseGoods");
app._getNetWork({
url: urlStr,
data: {
invite_code: this.data.invite_code
},
validateBol: 2,
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 {
let urlStr = app.getNetAddresss("member.member.member-invite-validate");
app._getNetWork({
url: urlStr,
data: {
invite_code: this.data.invite_code
},
validateBol: 2,
success: function (resdata) {
var res = resdata.data;
if (res.result == 1) {
that.setData({
name: res.data.has_one_member.nickname,
img: res.data.has_one_member.avatar_image
});
try {
wx.setStorageSync('isset', 1);
} catch (e) {
console.log(e);
}
wx.navigateTo({
url: '/packageA/member/editmobile/editmobile?code=' + that.data.invite_code + '&fromApp=5'
});
} else {
wx.showToast({
icon: 'none',
title: res.msg,
duration: 1500
});
}
},
fail: function (res) {
console.log(res);
}
});
}
},
});