Browse Source

登录逻辑完成

master
chenxuhui 7 years ago
parent
commit
3a36d6a5f1
1 changed files with 32 additions and 27 deletions
  1. +32
    -27
      pages/login/login.js

+ 32
- 27
pages/login/login.js View File

@ -24,18 +24,18 @@ var bindPath = "/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/Bind";
var XuBindDriver = '/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/XuBindDriver' var XuBindDriver = '/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/XuBindDriver'
var GetDriverByIdCard = "/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/GetDriverByIdCard" var GetDriverByIdCard = "/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/GetDriverByIdCard"
var GetDriverByOpenId = '/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/GetDriverByOpenId' var GetDriverByOpenId = '/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/GetDriverByOpenId'
var isBindedPath = '/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/IsBinded';
// var isBindedPath = '/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/IsBinded';
var GetBindDriverName = '/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/GetBindDriverName' var GetBindDriverName = '/MainSystem/B3MiniProgramRpc/XuRpcs/Driver/AccountRpc/GetBindDriverName'
//获取openID 参数1、app.globalData.AppId 2、code //获取openID 参数1、app.globalData.AppId 2、code
function getOpenId(successaction) { function getOpenId(successaction) {
wx.login({ wx.login({
success: function (res) {
success: function(res) {
var code = res.code; var code = res.code;
var method = getOpenIdByCode; var method = getOpenIdByCode;
var params = [app.globalData.AppId, code]; var params = [app.globalData.AppId, code];
network.requestLoading(method, params, function (res) {
network.requestLoading(method, params, function(res) {
app.globalData.OpenId = res.result; app.globalData.OpenId = res.result;
successaction(app.globalData.OpenId) successaction(app.globalData.OpenId)
}) })
@ -47,7 +47,7 @@ function getOpenId(successaction) {
function IsBind(openid, successaction) { function IsBind(openid, successaction) {
var method = getBindCustomer; var method = getBindCustomer;
var params = [app.globalData.AppId, openid]; var params = [app.globalData.AppId, openid];
network.requestLoading(method, params, function (res) {
network.requestLoading(method, params, function(res) {
app.globalData.CustomerId = res.result.ID; app.globalData.CustomerId = res.result.ID;
successaction(res.result.WeixinUser_Phone) successaction(res.result.WeixinUser_Phone)
}) })
@ -57,7 +57,7 @@ function IsBind(openid, successaction) {
function IsBindWeixinMP(phone) { function IsBindWeixinMP(phone) {
let method = isBindWeixinPath; let method = isBindWeixinPath;
let params = [phone]; let params = [phone];
network.requestLoading(method, params, function (res) {
network.requestLoading(method, params, function(res) {
//添加假数据。方便登录测试,提交版本需更正注释 //添加假数据。方便登录测试,提交版本需更正注释
// res.result = false; // res.result = false;
if (res.result == true) { if (res.result == true) {
@ -78,8 +78,6 @@ function IsBindWeixinMP(phone) {
Page({ Page({
data: { data: {
array: [],
index: 0,
idCard: "", idCard: "",
customerList: [{ customerList: [{
ID: 0, ID: 0,
@ -90,31 +88,39 @@ Page({
// 绑定客户 // 绑定客户
listenerPickerSelected: function (e) {
listenerPickerSelected: function(e) {
this.setData({ this.setData({
customerIndex: e.detail.value, customerIndex: e.detail.value,
}); });
app.globalData.CustomerId = this.data.customerList[this.data.customerIndex].ID;
}, },
// 姓名 // 姓名
getDriverName: function (e) {
getDriverName: function(e) {
app.globalData.UserName = e.detail.value app.globalData.UserName = e.detail.value
}, },
// 手机号码 // 手机号码
getPhone: function (e) {
getPhone: function(e) {
Phone = e.detail.value; Phone = e.detail.value;
app.globalData.Phone = Phone; app.globalData.Phone = Phone;
}, },
// 身份证 // 身份证
getIDCardNum: function (e) {
var that = this
getIDCardNum: function(e) {
if (!app.globalData.CustomerId) {
wx: wx.showModal({
title: '提示',
content: '请先绑定客户',
});
return;
}
var that = this;
if (e.detail.value.length == 18) { if (e.detail.value.length == 18) {
Idcard = e.detail.value; Idcard = e.detail.value;
var method = GetDriverByIdCard; var method = GetDriverByIdCard;
var params = ["服务号", Idcard];
network.requestLoading(method, params, function (res) {
var params = [1, Idcard];
network.transfer_request(method, params, function(res) {
//res就是我们请求接口返回的数据 //res就是我们请求接口返回的数据
if (res.result != null) { if (res.result != null) {
app.globalData.UserName = res.result.Name, app.globalData.UserName = res.result.Name,
@ -129,11 +135,11 @@ Page({
}, },
// 获取所有客户列表 // 获取所有客户列表
choiceCustomer: function () {
choiceCustomer: function() {
var that = this; var that = this;
var method = getCustomerList; var method = getCustomerList;
var params = []; var params = [];
network.requestLoading(method, params, function (res) {
network.requestLoading(method, params, function(res) {
if (res.result.length > 0) { if (res.result.length > 0) {
var lastArr = that.data.customerList.concat(res.result) var lastArr = that.data.customerList.concat(res.result)
that.setData({ that.setData({
@ -143,7 +149,7 @@ Page({
}) })
}, },
getUserInfo: function (e) {
getUserInfo: function(e) {
var that = this; var that = this;
if (e.detail.userInfo != null) { if (e.detail.userInfo != null) {
app.globalData.userInfo = e.detail.userInfo; app.globalData.userInfo = e.detail.userInfo;
@ -203,10 +209,10 @@ Page({
} }
wx.login({ wx.login({
success: function (res) {
success: function(res) {
var method = XuBindDriver; var method = XuBindDriver;
var params = [{ var params = [{
"Domain_ID": that.data.array[that.data.index].ID,
// "Domain_ID": that.data.array[that.data.index].ID,
"Driver_Name": app.globalData.UserName, "Driver_Name": app.globalData.UserName,
"Phone": app.globalData.Phone, "Phone": app.globalData.Phone,
"IdCard": Idcard, "IdCard": Idcard,
@ -233,10 +239,9 @@ Page({
"AppId": app.globalData.AppId, "AppId": app.globalData.AppId,
"CustomerId": that.data.customerList[that.data.customerIndex].ID, "CustomerId": that.data.customerList[that.data.customerIndex].ID,
}]; }];
app.globalData.CustomerId = that.data.array[that.data.index].ID;
network.requestLoading(method, params, function (res) {
network.transfer_request(method, params, function(res) {
app.globalData.Phone = that.data.phoneNum; app.globalData.Phone = that.data.phoneNum;
that.bingDriverInTransferServer(transferParams, function (res) {
that.bingDriverInTransferServer(transferParams, function(res) {
IsBindWeixinMP(app.globalData.Phone) IsBindWeixinMP(app.globalData.Phone)
}); });
}) })
@ -245,21 +250,21 @@ Page({
}, },
bingDriverInTransferServer: function (params, successaction) {
bingDriverInTransferServer: function(params, successaction) {
var that = this; var that = this;
var method = bindPath; var method = bindPath;
network.requestLoading(method, params, function (res) {
network.requestLoading(method, params, function(res) {
successaction(res.result); successaction(res.result);
}); });
}, },
onShow: function () {
onShow: function() {
var that = this; var that = this;
that.choiceCustomer(); that.choiceCustomer();
getOpenId(function (res) {
getOpenId(function(res) {
openid = res; openid = res;
IsBind(openid, function (res) {
IsBind(openid, function(res) {
app.globalData.Phone = res; app.globalData.Phone = res;
if (res == "") { if (res == "") {


Loading…
Cancel
Save