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