Browse Source

add defaultLoading

master
yibo 6 years ago
parent
commit
9a4497a14a
8 changed files with 213 additions and 34 deletions
  1. +3
    -2
      app.json
  2. +175
    -0
      pages/empty/login.js
  3. +5
    -0
      pages/empty/login.json
  4. +2
    -0
      pages/empty/login.wxml
  5. +1
    -0
      pages/empty/login.wxss
  6. +18
    -32
      pages/login/login.js
  7. +2
    -0
      project.config.json
  8. +7
    -0
      sitemap.json

+ 3
- 2
app.json View File

@ -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"
}

+ 175
- 0
pages/empty/login.js View File

@ -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() {
}
})

+ 5
- 0
pages/empty/login.json View File

@ -0,0 +1,5 @@
{
"usingComponents": {},
"enablePullDownRefresh": true,
"backgroundColor": "#c0c0c0"
}

+ 2
- 0
pages/empty/login.wxml View File

@ -0,0 +1,2 @@
<!--pages/empty/login.wxml-->
<text></text>

+ 1
- 0
pages/empty/login.wxss View File

@ -0,0 +1 @@
/* pages/empty/login.wxss */

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

@ -2,30 +2,29 @@
var network = require("../../utils/net.js");
var app = getApp();
var openID;
/**
* 获取绑定客户ID及用户电话 参数1appID 2openID
* 返回值globalCustomerIDWeixinUser_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)
})
}
});
},
//获取企业编号


+ 2
- 0
project.config.json View File

@ -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,


+ 7
- 0
sitemap.json View File

@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}

Loading…
Cancel
Save