diff --git a/app.js b/app.js index 673f993..7251fe3 100644 --- a/app.js +++ b/app.js @@ -38,8 +38,8 @@ App({ cookie: "", decryptCookie: '', userInfo: null, - baseUrl: "https://miniprogram.food988.com/Rest.aspx", - tranferBaseUrl: 'https://miniprogram.food988.com/RequestTransfer.aspx', + baseUrl: "https://miniprotest.food988.com/Rest.aspx", + tranferBaseUrl: "https://miniprotest.food988.com/RequestTransfer.aspx", globalCustomerID: 0, selectCustomer_ID: null, selectStartDate: null, diff --git a/app.json b/app.json index af810c1..f8fcfbf 100644 --- a/app.json +++ b/app.json @@ -34,7 +34,7 @@ "backgroundTextStyle": "light", "navigationBarTitleText": "畜业务员易", "navigationBarBackgroundColor": "#2689f8", - "navigationBarTextStyle": "#FFFFFF" + "navigationBarTextStyle": "white" }, "tabBar": { "borderStyle": "white", diff --git a/pages/login/login.js b/pages/login/login.js index c71d2d0..ec7584e 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -4,84 +4,45 @@ var network = require("../../utils/net.js"); var app = getApp(); var openID; -var isBindedPath = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/AccountRpc/IsBinded'; -var bindByPhone = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/AccountRpc/XuBindByPhone'; -var isBindWeixinPath = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/IsBindWeixinMP'; -var getOpenIdByCode = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetMiniOpenIdByCode'; -var bindPath = "/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/Bind"; -var getBindCustomer = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetBindCustomer'; -var getCookie = '/MainSystem/MainSystem/Auth/WeixinLogin' -var getCustomerList = '/MainSystem/B3WeChatMiniProgram/Rpcs/CustomerRpc/GetList'; /** * 获取绑定客户ID及用户电话 参数1、appID 2、openID * 返回值globalCustomerID,WeixinUser_Phone * 成功调用获取cookie方法及判断是否绑定成功方法 */ function GetBindCustomer(that) { - let method = getBindCustomer; + let method = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetBindCustomer'; let params = [app.globalData.appID, app.globalData.openID]; - network.requestLoading(method, params, function(res) { + network.requestLoading(method, params, function (res) { if (res.result != null) { app.globalData.globalCustomerID = res.result.ID; app.globalData.phoneNum = res.result.WeixinUser_Phone; // 获取cookie值 - WeixinLogin(function(res) { - // 判断是否绑定成功 参数openid 返回值phoneNum - IsBinded(app.globalData.openID); + WeixinLogin(function (res) { + wx.switchTab({ + url: '/pages/homePage/homePage', + }) }); } }) } -/** - * 判断是否绑定成功 参数openid - * 返回值phoneNum - * 成功调用是否关注公众号方法 - */ -function IsBinded(openid) { - let method = isBindedPath; - let params = [openid]; - network.transfer_request(method, params, function(res) { - if (res.result != "") { - app.globalData.phoneNum = res.result; - // 判断是否关注公众号 - IsBindWeixinMP(app.globalData.phoneNum) - } - }) -} -// 判断是否关注公众号 参数phone 返回值bool 成功进入首页 -function IsBindWeixinMP(phone) { - let method = isBindWeixinPath; - let params = [phone]; - network.requestLoading(method, params, function(res) { - // res.result = false; - if (res.result == true) { - wx.switchTab({ - url: '/pages/homePage/homePage', - }) - } else { - wx.showModal({ - title: '提示', - content: '请关注公众号', - showCancel: false, - }) - } - }) -} + // 获取cookie值 参数1、appID 2、openID function WeixinLogin(successtion) { - let method = getCookie; + let method = '/MainSystem/B3MiniProgramRpc/Rpcs/CommonRpc/WeixinLogin'; let params = [app.globalData.appID, app.globalData.openID]; - network.transfer_request(method, params, function(res) { + network.transfer_request(method, params, function (res) { app.globalData.cookie = res.result; successtion(); }) } -//绑定中转服务器客户对应信息 成功判断是否关注公众号 -function Bind(that) { + +//2次绑定第二次 绑定客户 要有先后 +function XuBindByPhone(that) { let userInfos = app.globalData.userInfo - let method2 = bindPath; + let method2 = "/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/AccountRpc/XuBindByPhone"; let params2 = [{ - "AppId": app.globalData.appID, + "UserName": that.data.userName, + "Password": that.data.psw, "OpenId": app.globalData.openID, "Phone": that.data.phoneNum, "NickName": userInfos.nickName, @@ -91,31 +52,24 @@ function Bind(that) { "Country": userInfos.country, "HeadImgUrl": userInfos.avatarUrl, "UnionId": "", - "CustomerId": app.globalData.globalCustomerID }]; - network.requestLoading(method2, params2, function(res) { - if (res.result == true) { - IsBindWeixinMP(app.globalData.phoneNum) + network.transfer_request(method2, params2, function (res) { + if (res.result != null) { + WeixinLogin(function () { + wx.switchTab({ + url: '/pages/homePage/homePage', + }) + }) } }) } Page({ data: { + code: "", + userName: "", + psw: "", phoneNum: "", - index: 0, - customerArray: [{ - ID: 0, - Name: "请选择所属客户" - }], - }, - - // 客户列表变更选项信息 - listenerPickerSelected: function(e) { - this.setData({ - index: e.detail.value, - }); - app.globalData.globalCustomerID = this.data.customerArray[this.data.index].ID; }, // 页面生命周期函数 @@ -124,7 +78,7 @@ Page({ wx.login({ success: function(res) { let code = res.code; - let method = getOpenIdByCode; + let method = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetMiniOpenIdByCode'; let params = [app.globalData.appID, code]; // 获取openID network.requestLoading(method, params, function(res) { @@ -134,23 +88,22 @@ Page({ }) } }); - - // 获取客户列表 - let method = getCustomerList; - let params = []; - network.requestLoading(method, params, function(res) { - if (res.result.length > 0) { - var lastArr = that.data.customerArray.concat(res.result) - that.setData({ - customerArray: lastArr, - }) - } - }) - }, + //获取企业编号 + getCode: function (e) { + this.data.code = e.detail.value; + }, + //获取用户名 + getUserName: function (e) { + this.data.userName = e.detail.value; + }, + //获取密码 + getPSW: function (e) { + this.data.psw = e.detail.value; + }, // 电话输入框 - getPhone: function(e) { + getPhone: function (e) { let val = e.detail.value; this.data.phoneNum = val; }, @@ -160,12 +113,24 @@ Page({ var that = this; if (e.detail.userInfo != null) { app.globalData.userInfo = e.detail.userInfo - if (that.data.customerArray[that.data.index].ID == 0) { + if (this.data.code == "") { + wx.showToast({ + title: '请输入企业编码', + }) + return false; + } + if (this.data.userName == "") { wx.showToast({ - title: '请选择所属客户', + title: '请输入用户名', }) return false; } + // if (this.data.psw == "") { + // wx.showToast({ + // title: '请输入密码', + // }) + // return false; + // } if (this.data.phoneNum == "") { wx.showToast({ title: '请输入手机号码', @@ -178,8 +143,10 @@ Page({ return false; } let userInfos = app.globalData.userInfo - let method = bindByPhone; + let method = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/BindCustomerCode'; let params = [{ + "AppId": app.globalData.appID, + "CustomerCode": this.data.code, "OpenId": app.globalData.openID, "Phone": this.data.phoneNum, "NickName": userInfos.nickName, @@ -190,11 +157,10 @@ Page({ "HeadImgUrl": userInfos.avatarUrl, "UnionId": "" }]; - network.transfer_request(method, params, function(res) { + network.requestLoading(method, params, function(res) { if (res.result != null) { - app.globalData.phoneNum = that.data.phoneNum; - // 判断是否绑定成功 - Bind(that) + app.globalData.globalCustomerID = res.result; + XuBindByPhone(that); } }) } else { diff --git a/pages/login/login.wxml b/pages/login/login.wxml index 0a17aa7..a255f41 100644 --- a/pages/login/login.wxml +++ b/pages/login/login.wxml @@ -2,6 +2,30 @@ + 企业编码 + + + + + + + + 用户名 + + + + + + + + 密码 + + + + + + + 手机号码 diff --git a/pages/login/login.wxss b/pages/login/login.wxss index d624eb7..2db05cd 100644 --- a/pages/login/login.wxss +++ b/pages/login/login.wxss @@ -2,8 +2,8 @@ .containerView{ margin-left: 30rpx; margin-right: 30rpx; - height: 240rpx; - margin-top: 40%; + height: 480rpx; + margin-top: 30%; display: flex; flex-direction: column; diff --git a/project.config.json b/project.config.json index 7be88d8..fc2dea8 100644 --- a/project.config.json +++ b/project.config.json @@ -4,7 +4,7 @@ "ignore": [] }, "setting": { - "urlCheck": true, + "urlCheck": false, "es6": true, "postcss": true, "minified": true, diff --git a/utils/net.js b/utils/net.js index 39e8696..fa25ec3 100644 --- a/utils/net.js +++ b/utils/net.js @@ -39,7 +39,7 @@ function requestLoading(method, params, successaction) { url: app.globalData.baseUrl, data: { 'id': 1, - 'method': "/MainSystem/MainSystem/Auth/WeixinLogin", + 'method': "/MainSystem/B3MiniProgramRpc/Rpcs/CommonRpc/WeixinLogin", 'params': [app.globalData.appID, app.globalData.openID] }, header: { @@ -102,7 +102,6 @@ function transfer_request(method, params, successaction) { }, method: 'POST', success: function (res) { - // console.log(res) if (res.data.error != null) { if (res.data.error.code == 401) { wx.request({ @@ -110,7 +109,7 @@ function transfer_request(method, params, successaction) { data: { "DecryptCookie": app.globalData.cookie, "CustomerId": app.globalData.globalCustomerID, - "Method": "/MainSystem/MainSystem/Auth/WeixinLogin", + "Method": "/MainSystem/B3MiniProgramRpc/Rpcs/CommonRpc/WeixinLogin", "Data": [app.globalData.appID, app.globalData.openID] }, header: {