From 9a4497a14aa2b80fb82c03ad319fc0b82836f5e6 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Thu, 9 May 2019 14:12:44 +0800 Subject: [PATCH] add defaultLoading --- app.json | 5 +- pages/empty/login.js | 175 +++++++++++++++++++++++++++++++++++++++++ pages/empty/login.json | 5 ++ pages/empty/login.wxml | 2 + pages/empty/login.wxss | 1 + pages/login/login.js | 50 +++++------- project.config.json | 2 + sitemap.json | 7 ++ 8 files changed, 213 insertions(+), 34 deletions(-) create mode 100644 pages/empty/login.js create mode 100644 pages/empty/login.json create mode 100644 pages/empty/login.wxml create mode 100644 pages/empty/login.wxss create mode 100644 sitemap.json diff --git a/app.json b/app.json index 4799578..8e285ba 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages": [ + "pages/empty/login", "pages/login/login", "pages/homePage/homePage", "pages/order/order", @@ -24,7 +25,6 @@ "pages/debitNoteList/debitNoteQuery/debitNoteQuery", "pages/goodaNameChooseTemplate/goodaNameChooseTemplate", "pages/sendTheDetails/creatNewCar/creatNewCar" - ], "window": { "backgroundTextStyle": "light", @@ -54,5 +54,6 @@ }, "navigateToMiniProgramAppIdList": [ "wx246fd8f3a0273f2f" - ] + ], + "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..323205b --- /dev/null +++ b/pages/empty/login.js @@ -0,0 +1,175 @@ +// 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) { + setCurrentCustomerID(); + wx.switchTab({ + url: '/pages/homePage/homePage', + }) + }); + } + }) +} +// 跳转前获取客户自己的ID 存储后在创建订单时 基本信息带出使用 +function setCurrentCustomerID() { + let method = "/MainSystem/B3MiniProgramRpc/XuRpcs/Customer/AccountRpc/GetCurrentCustomerID"; + let params = []; + network.transfer_request(method, params, function(res) { + console.log("当前客户信息==" + res.result); + app.globalData.userID = res.result; + }) +} + +// 获取cookie值 参数1、appID 2、openID +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 04b33f4..9445040 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -2,30 +2,29 @@ var network = require("../../utils/net.js"); var app = getApp(); -var openID; /** * 获取绑定客户ID及用户电话 参数1、appID 2、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) { - setCurrentCustomerID(); - 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) { +// setCurrentCustomerID(); +// wx.switchTab({ +// url: '/pages/homePage/homePage', +// }) +// }); +// } +// }) +// } // 跳转前获取客户自己的ID 存储后在创建订单时 基本信息带出使用 function setCurrentCustomerID (){ let method = "/MainSystem/B3MiniProgramRpc/XuRpcs/Customer/AccountRpc/GetCurrentCustomerID"; @@ -85,20 +84,7 @@ 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) - }) - } - }); + }, //获取企业编号 diff --git a/project.config.json b/project.config.json index 0730f2c..542c69a 100644 --- a/project.config.json +++ b/project.config.json @@ -12,6 +12,8 @@ "appid": "wx0b897783b2588147", "projectname": "%E7%95%9C%E5%AE%A2%E6%88%B7", "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