|
|
|
|
|
|
|
|
|
|
|
const app = getApp();
|
|
|
|
|
|
|
|
|
|
|
|
const commonUtil = require("../../utils/commonUtil.js");
|
|
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
data: {
|
|
|
|
|
|
wxCode: '',
|
|
|
|
|
|
hasUserInfo: '',
|
|
|
|
|
|
balance: 0,
|
|
|
|
|
|
auth: 0,
|
|
|
|
|
|
},
|
|
|
|
|
|
showphone:function(){
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
iosDialog1: true
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
close:function(){
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
iosDialog1: false
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
toCollect:function(){
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: '../collect/index',
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
makePhoneCall() {
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
wx.makePhoneCall({
|
|
|
|
|
|
phoneNumber: '18039237825'
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
goMyinfo:function(){
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: '../user/myInfo/index',
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
goMoney:function(){
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: '/pages/withdraw/index',
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
goAgent:function(){
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
// url: '/pages/creatAgent/index?fromMiniApp=1',
|
|
|
|
|
|
url: '/pages/creatAgent/index?fromMiniApp=1&pmdUserId=' + app.globalData.userId,//path
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
toMakeInfo:function(){
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: '/pages/makeInfo/index',
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
toUrl: function(e) {
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: e.currentTarget.dataset.url
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
emptyMethod() {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
|
*/
|
|
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
//登录=================================start
|
|
|
|
|
|
if (app.globalData.isLogin) {
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
isLogin: app.globalData.isLogin,
|
|
|
|
|
|
hasUserInfo: app.globalData.hasUserInfo,
|
|
|
|
|
|
agencyStatus: app.globalData.agencyStatus,
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
|
|
|
// 所以此处加入 callback 以防止这种情况
|
|
|
|
|
|
app.userLoginCallback = res => {
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
isLogin: app.globalData.isLogin,
|
|
|
|
|
|
hasUserInfo: app.globalData.hasUserInfo,
|
|
|
|
|
|
agencyStatus: app.globalData.agencyStatus,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
let agencyUserId = options.agencyUserId;
|
|
|
|
|
|
if(agencyUserId) {
|
|
|
|
|
|
wx.setStorageSync('storageSyncAgencyUserId', agencyUserId);
|
|
|
|
|
|
console.log('agencyUserId', agencyUserId)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
|
*/
|
|
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
|
*/
|
|
|
|
|
|
onShow: function () {
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
if (!app.globalData.isLogin) {
|
|
|
|
|
|
this.wxLogin();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.getWalletInfo();
|
|
|
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
isLogin: app.globalData.isLogin,
|
|
|
|
|
|
hasUserInfo: app.globalData.hasUserInfo,
|
|
|
|
|
|
});
|
|
|
|
|
|
//登录=================================start
|
|
|
|
|
|
// if (app.globalData.isLogin) {
|
|
|
|
|
|
// that.setData({
|
|
|
|
|
|
// isLogin: app.globalData.isLogin,
|
|
|
|
|
|
// hasUserInfo: app.globalData.hasUserInfo,
|
|
|
|
|
|
// });
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// // 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
|
|
|
// // 所以此处加入 callback 以防止这种情况
|
|
|
|
|
|
// app.userLoginCallback = res => {
|
|
|
|
|
|
// that.wxLogin();
|
|
|
|
|
|
// that.setData({
|
|
|
|
|
|
// isLogin: app.globalData.isLogin,
|
|
|
|
|
|
// hasUserInfo: app.globalData.hasUserInfo,
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
|
*/
|
|
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
|
*/
|
|
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
|
*/
|
|
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
|
*/
|
|
|
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
getWalletInfo: function() {
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
wx.request({
|
|
|
|
|
|
url: app.globalData.ip + "/wallet/info",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
},
|
|
|
|
|
|
header: app.globalData.headers,
|
|
|
|
|
|
method: "GET",
|
|
|
|
|
|
success: function(res) {
|
|
|
|
|
|
console.log(res)
|
|
|
|
|
|
if(res.data.status == 200) {
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
//绑定成功
|
|
|
|
|
|
that.setData({
|
|
|
|
|
|
balance: commonUtil.moneyToFixed(res.data.data.balance),
|
|
|
|
|
|
auth: res.data.data.auth,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
icon: "none",
|
|
|
|
|
|
title: res.data.msg,
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: function(res) {
|
|
|
|
|
|
console.log("操作失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
|
*/
|
|
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
var path = commonUtil.getCurrentPageUrlWithArgs();
|
|
|
|
|
|
if(app.globalData.isLogin && app.globalData.agencyStatus - 0 != 0) {//当前用户是代理人
|
|
|
|
|
|
path += (path.indexOf('?') >= 0 ? '&' : '?') + 'agencyUserId=' + app.globalData.loginUserInfo.id;
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log(path)
|
|
|
|
|
|
return {
|
|
|
|
|
|
"title":'伯才',
|
|
|
|
|
|
'path': path,
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
wxLogin() {
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
wx.login({
|
|
|
|
|
|
success(res) {
|
|
|
|
|
|
if (res.code) {
|
|
|
|
|
|
that.setData({
|
|
|
|
|
|
wxCode: res.code
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.log('获取code失败!' + res.errMsg)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
makePhoneCall() {
|
|
|
|
|
|
console.log(1);
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
wx.makePhoneCall({
|
|
|
|
|
|
// number: that.data.jobDetail.assistantUserTel + ""
|
|
|
|
|
|
phoneNumber:'18039237825'
|
|
|
|
|
|
});
|
|
|
|
|
|
// var that = this;
|
|
|
|
|
|
|
|
|
|
|
|
// let res = wx.getStorageSync({
|
|
|
|
|
|
// key: "assistantUserTel"
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(res);
|
|
|
|
|
|
// console.log("缓存获取电话号:" + res.data);
|
|
|
|
|
|
|
|
|
|
|
|
// if (app.isNotEmptyCheck(res.data)) {
|
|
|
|
|
|
// wx.makePhoneCall({
|
|
|
|
|
|
// number: res.data
|
|
|
|
|
|
// });
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// wx.request({
|
|
|
|
|
|
// url: app.globalData.ip + "/store/job/getOneAssistantUser",
|
|
|
|
|
|
// method: "POST",
|
|
|
|
|
|
// header: app.globalData.headers,
|
|
|
|
|
|
// data: {},
|
|
|
|
|
|
// success: function (res) {
|
|
|
|
|
|
// console.log(res.data.data.tel);
|
|
|
|
|
|
|
|
|
|
|
|
// wx.setStorageSync({
|
|
|
|
|
|
// key: "assistantUserTel",
|
|
|
|
|
|
// data: res.data.data.tel
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// wx.makePhoneCall({
|
|
|
|
|
|
// number: res.data.data.tel + ""
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
},
|
|
|
|
|
|
getPhoneNumber(e) {
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
console.log(e)
|
|
|
|
|
|
console.log(e.detail.errMsg)
|
|
|
|
|
|
|
|
|
|
|
|
var tag = e.currentTarget.dataset.tag;
|
|
|
|
|
|
|
|
|
|
|
|
if ("getPhoneNumber:ok" == e.detail.errMsg) {//同意
|
|
|
|
|
|
var iv = e.detail.iv;
|
|
|
|
|
|
var encryptedData = e.detail.encryptedData;
|
|
|
|
|
|
wx.checkSession({
|
|
|
|
|
|
success () {
|
|
|
|
|
|
//session_key 未过期,并且在本生命周期一直有效
|
|
|
|
|
|
wx.request({
|
|
|
|
|
|
url: app.globalData.ip + '/getWechatTel',
|
|
|
|
|
|
data: {
|
|
|
|
|
|
code: that.data.wxCode,
|
|
|
|
|
|
iv: iv,
|
|
|
|
|
|
encryptedData: encryptedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
success: function (res) {
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
app.globalData.openId = res.data.data.openId;
|
|
|
|
|
|
let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null);
|
|
|
|
|
|
promise.then(res => {
|
|
|
|
|
|
that.setData({
|
|
|
|
|
|
isLogin: true
|
|
|
|
|
|
});
|
|
|
|
|
|
if (tag == 1) {
|
|
|
|
|
|
that.toCollect();
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: function (res) {
|
|
|
|
|
|
console.log("获取用户手机号错误");
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
fail () {
|
|
|
|
|
|
// session_key 已经失效,需要重新执行登录流程
|
|
|
|
|
|
wx.login({
|
|
|
|
|
|
success(res) {
|
|
|
|
|
|
if (res.code) {
|
|
|
|
|
|
console.log(res.code);
|
|
|
|
|
|
//发起网络请求
|
|
|
|
|
|
wx.request({
|
|
|
|
|
|
url: app.globalData.ip + '/getWechatTel',
|
|
|
|
|
|
data: {
|
|
|
|
|
|
code: res.code,
|
|
|
|
|
|
iv: iv,
|
|
|
|
|
|
encryptedData: encryptedData,
|
|
|
|
|
|
},
|
|
|
|
|
|
success: function (res) {
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
|
|
|
|
let promise = app.setLoginUserTokenInfo(res.data.data.phoneNumber, null);
|
|
|
|
|
|
promise.then(res => {
|
|
|
|
|
|
that.setData({
|
|
|
|
|
|
isLogin: true
|
|
|
|
|
|
});
|
|
|
|
|
|
if (tag == 1) {
|
|
|
|
|
|
that.toCollect();
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: function (res) {
|
|
|
|
|
|
console.log("获取用户手机号错误");
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.log('获取手机号失败!' + res.errMsg)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
} else {//拒绝
|
|
|
|
|
|
try {
|
|
|
|
|
|
wx.setStorageSync('comeFromPage', 'me');
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.log("0-页面跳转,设置参数错误:", e);
|
|
|
|
|
|
}
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: '/pages/login/index',
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
},
|
|
|
|
|
|
getUserInfoBtn: function(e) {
|
|
|
|
|
|
console.log(e)
|
|
|
|
|
|
let that = this;
|
|
|
|
|
|
wx.getUserProfile({
|
|
|
|
|
|
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
|
|
|
|
|
success: (res) => {
|
|
|
|
|
|
console.log(res)
|
|
|
|
|
|
//发起网络请求
|
|
|
|
|
|
wx.request({
|
|
|
|
|
|
url: app.globalData.ip + '/updateUserWechatInfo',
|
|
|
|
|
|
data: {
|
|
|
|
|
|
nickName: res.userInfo.nickName,
|
|
|
|
|
|
avatarUrl: res.userInfo.avatarUrl,
|
|
|
|
|
|
gender: res.userInfo.gender,
|
|
|
|
|
|
country: res.userInfo.country,
|
|
|
|
|
|
province: res.userInfo.province,
|
|
|
|
|
|
city: res.userInfo.city,
|
|
|
|
|
|
},
|
|
|
|
|
|
method: "POST",
|
|
|
|
|
|
header: app.globalData.headers,
|
|
|
|
|
|
success: function(res) {
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
app.globalData.hasUserInfo = 1;
|
|
|
|
|
|
that.setData({
|
|
|
|
|
|
hasUserInfo: 1
|
|
|
|
|
|
})
|
|
|
|
|
|
that.goMyinfo();
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: function(res) {
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: (res) => {
|
|
|
|
|
|
console.log(res)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|