diff --git a/app.json b/app.json index f8fcfbf..2a71437 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages": [ + "pages/empty/login", "pages/login/login", "pages/homePage/homePage", "pages/message/message", @@ -28,7 +29,6 @@ "pages/waitForApproval/waitForApproval", "pages/waitForApproval/approvalDetail/approvalDetail", "pages/startImage/startImage" - ], "window": { "backgroundTextStyle": "light", @@ -54,5 +54,6 @@ "selectedIconPath": "/imgs/my.png" } ] - } + }, + "sitemapLocation": "sitemap.json" } \ No newline at end of file diff --git a/pages/empty/login.js b/pages/empty/login.js new file mode 100644 index 0000000..119ee4a --- /dev/null +++ b/pages/empty/login.js @@ -0,0 +1,164 @@ +// pages/empty/login.js +var network = require("../../utils/net.js"); +var app = getApp(); + +function requestLoading(method, params, successaction) { + wx.showLoading({ + title: "加载中", + }) + + var data = { + 'id': 1, + 'method': method, + 'params': params + }; + + wx.request({ + url: app.globalData.baseUrl, + data: data, + header: { + 'content-type': 'application/json', + 'cookie': app.globalData.cookie + }, + method: 'POST', + success: function(res) { + if (res.data.error != null) { + if (res.data.error.message == '没有对应关系,请先绑定') { + wx.navigateTo({ + url: '/pages/login/login', + }) + } else { + wx.showModal({ + showCancel: false, + title: '执行出错', + content: res.data.error.message, + }) + } + } else { + successaction(res.data) + } + }, + fail: function(res) { + console.log(res) + wx.showModal({ + title: '执行出错', + content: res, + }) + }, + complete: function(res) { + wx.hideLoading() + }, + }) +} + +function GetBindCustomer(that) { + let method = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetBindCustomer'; + let params = [app.globalData.appID, app.globalData.openID]; + 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) { + wx.switchTab({ + url: '/pages/homePage/homePage', + }) + }); + } + }) +} + +function WeixinLogin(successtion) { + let method = '/MainSystem/B3MiniProgramRpc/Rpcs/CommonRpc/WeixinLogin'; + let params = [app.globalData.appID, app.globalData.openID]; + network.transfer_request(method, params, function(res) { + app.globalData.cookie = res.result; + successtion(); + }) +} + +function load(that) { + wx.login({ + success: function(res) { + let code = res.code; + let method = '/MainSystem/B3WeChatMiniProgram/Rpcs/CommonRpc/GetMiniOpenIdByCode'; + let params = [app.globalData.appID, code]; + // 获取openID + network.requestLoading(method, params, function(res) { + app.globalData.openID = res.result; + // 获取绑定客户ID及用户电话 + GetBindCustomer(that) + }) + } + }); +} + +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function() { + load(this); + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function() { + wx.showNavigationBarLoading(); + //doSomeThing + load(this); + wx.stopPullDownRefresh(); + wx.hideNavigationBarLoading(); + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function() { + + } +}) \ No newline at end of file diff --git a/pages/empty/login.json b/pages/empty/login.json new file mode 100644 index 0000000..32a5de3 --- /dev/null +++ b/pages/empty/login.json @@ -0,0 +1,5 @@ +{ + "usingComponents": {}, + "enablePullDownRefresh": true, + "backgroundColor": "#c0c0c0" +} \ No newline at end of file diff --git a/pages/empty/login.wxml b/pages/empty/login.wxml new file mode 100644 index 0000000..454a5ff --- /dev/null +++ b/pages/empty/login.wxml @@ -0,0 +1,2 @@ + + diff --git a/pages/empty/login.wxss b/pages/empty/login.wxss new file mode 100644 index 0000000..32a02e4 --- /dev/null +++ b/pages/empty/login.wxss @@ -0,0 +1 @@ +/* pages/empty/login.wxss */ \ No newline at end of file diff --git a/pages/login/login.js b/pages/login/login.js index d6a2122..380c544 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -9,22 +9,22 @@ var openID; * 返回值globalCustomerID,WeixinUser_Phone * 成功调用获取cookie方法及判断是否绑定成功方法 */ -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.globalCustomerID = res.result.ID; - app.globalData.phoneNum = res.result.WeixinUser_Phone; - // 获取cookie值 - WeixinLogin(function (res) { - wx.switchTab({ - url: '/pages/homePage/homePage', - }) - }); - } - }) -} +// 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.globalCustomerID = res.result.ID; +// app.globalData.phoneNum = res.result.WeixinUser_Phone; +// // 获取cookie值 +// WeixinLogin(function (res) { +// wx.switchTab({ +// url: '/pages/homePage/homePage', +// }) +// }); +// } +// }) +// } // 获取cookie值 参数1、appID 2、openID function WeixinLogin(successtion) { @@ -74,20 +74,20 @@ Page({ // 页面生命周期函数 onShow: function() { - 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]; - // 获取openID - network.requestLoading(method, params, function(res) { - app.globalData.openID = res.result; - // 获取绑定客户ID及用户电话 - GetBindCustomer(that) - }) - } - }); + // 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]; + // // 获取openID + // network.requestLoading(method, params, function(res) { + // app.globalData.openID = res.result; + // // 获取绑定客户ID及用户电话 + // GetBindCustomer(that) + // }) + // } + // }); }, //获取企业编号 diff --git a/project.config.json b/project.config.json index fc2dea8..436da6c 100644 --- a/project.config.json +++ b/project.config.json @@ -18,6 +18,8 @@ "hidedInDevtools": [] }, "isGameTourist": false, + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, "condition": { "search": { "current": -1, diff --git a/sitemap.json b/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file