diff --git a/app.json b/app.json index a35c8e1..62df136 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages": [ + "pages/navigation/navigation", "pages/selectCustomer/selctCustomer", "pages/index/index", "pages/logs/logs", diff --git a/pages/index/index.js b/pages/index/index.js index bb74b41..99f5224 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -19,18 +19,7 @@ function WeixinLogin() { app.globalData.DecryptCookie = res.result; }) } - -function IsBinded() { - let method = isBindedPath - let params = [app.globalData.OpenId]; - network.transfer_request(method, params, function(res) { - if (res.result != "") { - app.globalData.PhoneNum = res.result; - IsBindWeixinMP(app.globalData.PhoneNum) - } - }) -} - + function IsBindWeixinMP(phone) { let method = isBindWeixinPath @@ -38,6 +27,9 @@ function IsBindWeixinMP(phone) { network.requestLoading(method, params, function(res) { res.result = true; if (res.result == true) { + + WeixinLogin() + wx.switchTab({ url: '/pages/main/main', }) @@ -91,14 +83,7 @@ Page({ }, onShow: function() { - - //未进行中转服务器绑定 - if (app.globalData.PhoneNum == '') { - - } else { - WeixinLogin() - IsBinded() - } + }, /** diff --git a/pages/navigation/navigation.js b/pages/navigation/navigation.js new file mode 100644 index 0000000..bf3ecb9 --- /dev/null +++ b/pages/navigation/navigation.js @@ -0,0 +1,135 @@ +// pages/navigation/navigation.js +var network = require("../../utils/net.js") +var app = getApp() + +var getBindCustomer = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetBindCustomer'; +var getMiniOpenId = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetMiniOpenIdByCode'; +var isBindedPath = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/AccountRpc/IsBinded'; + +function GetBindCustomer(that) { + let method = getBindCustomer; + let params = [app.globalData.AppId, app.globalData.OpenId]; + network.requestLoading(method, params, function(res) { + if (res.result != null) { + app.globalData.CustomerId = res.result.ID; + app.globalData.PhoneNum = res.result.WeixinUser_Phone; + IsBinded(); + } + }, function(res) { + wx.redirectTo({ + url: '/pages/selectCustomer/selctCustomer', + }) + }) + +} + +function WeixinLogin() { + let method = app.globalData.LoginPath; + let params = [app.globalData.AppId, app.globalData.OpenId]; + + network.transfer_request(method, params, function(res) { + app.globalData.DecryptCookie = res.result; + }) +} + + +function IsBinded() { + let method = isBindedPath + let params = [app.globalData.OpenId]; + network.transfer_request(method, params, function(res) { + if (res.result != "") { + app.globalData.PhoneNum = res.result; + + WeixinLogin(); + wx.switchTab({ + url: '/pages/main/main', + }) + + } else { + wx.redirectTo({ + url: '/pages/index/index', + }) + } + }) +} + + +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function(options) { + var that = this; + + wx.login({ + success: function(res) { + let code = res.code; + let method = getMiniOpenId; + let params = [app.globalData.AppId, code]; + + network.requestLoading(method, params, function(res) { + app.globalData.OpenId = res.result; + GetBindCustomer(that) + }) + } + }) + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function() { + + } +}) \ No newline at end of file diff --git a/pages/navigation/navigation.json b/pages/navigation/navigation.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/pages/navigation/navigation.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/pages/navigation/navigation.wxml b/pages/navigation/navigation.wxml new file mode 100644 index 0000000..3b2b08f --- /dev/null +++ b/pages/navigation/navigation.wxml @@ -0,0 +1,2 @@ + + diff --git a/pages/navigation/navigation.wxss b/pages/navigation/navigation.wxss new file mode 100644 index 0000000..35745b6 --- /dev/null +++ b/pages/navigation/navigation.wxss @@ -0,0 +1 @@ +/* pages/navigation/navigation.wxss */ \ No newline at end of file diff --git a/pages/saleForecastList/newBill/newBill.js b/pages/saleForecastList/newBill/newBill.js index 735e1fe..1bc0850 100644 --- a/pages/saleForecastList/newBill/newBill.js +++ b/pages/saleForecastList/newBill/newBill.js @@ -516,7 +516,7 @@ Page({ if (res.result != null) { wx.showModal({ title: '新建订单No.' + res.result, - content: '新建成功,是否返回首页', + content: '新建成功,是否返回上级列表', success: function(res) { if (res.cancel) {} else { wx.navigateBack({ diff --git a/pages/selectCustomer/selctCustomer.js b/pages/selectCustomer/selctCustomer.js index 70c4ab8..550fa4c 100644 --- a/pages/selectCustomer/selctCustomer.js +++ b/pages/selectCustomer/selctCustomer.js @@ -1,21 +1,6 @@ var network = require("../../utils/net.js") var app = getApp() - -function GetBindCustomer(that) { - let method = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetBindCustomer'; - let params = [app.globalData.AppId, app.globalData.OpenId]; - - network.requestLoading(method, params, function(res) { - if (res.result != null) { - app.globalData.CustomerId = res.result.ID; - app.globalData.PhoneNum = res.result.WeixinUser_Phone; - wx.redirectTo({ - url: '/pages/index/index', - }) - } - - }) -} + Page({ @@ -31,21 +16,8 @@ Page({ */ onLoad: function(options) { var that = this; - - wx.login({ - success: function(res) { - let code = res.code; - let method = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetMiniOpenIdByCode'; - let params = [app.globalData.AppId, code]; - - network.requestLoading(method, params, function(res) { - app.globalData.OpenId = res.result; - GetBindCustomer(that) - }) - } - }) - - + + let method = '/MainSystem/B3WeChatMiniProgram/Rpcs/CustomerRpc/GetList'; let params = []; diff --git a/utils/net.js b/utils/net.js index 10c91cf..1da5e63 100644 --- a/utils/net.js +++ b/utils/net.js @@ -12,7 +12,7 @@ function request(url, params, success, fail) { // message:进度条的提示信息 // success:成功的回调函数 // fail:失败的回调 -function requestLoading(method, params, successaction) { +function requestLoading(method, params, successaction, erroraction) { wx.showLoading({ title: "加载中", @@ -36,12 +36,16 @@ function requestLoading(method, params, successaction) { method: 'POST', success: function(res) { // console.log(res) - if (res.data.error != null) { - wx.showModal({ - showCancel: false, - title: '执行出错', - content: res.data.error.message, - }) + if (res.data.error != null) { + if (erroraction != null) { + erroraction(res.data.error) + } else { + wx.showModal({ + showCancel: false, + title: '执行出错:', + content: res.data.error.message, + }) + } } else { successaction(res.data) } @@ -81,7 +85,7 @@ function transfer_request(method, params, successaction) { url: baseUrl, data: data, header: { - 'content-type': 'application/json' + 'content-type': 'application/json' }, method: 'POST', success: function(res) {