diff --git a/mySlwl/app.js b/mySlwl/app.js
index 397cc073bfea68ec009e131e0c5c755ca7d0b4cd..8a2bc51d52e5ff07399779122c1fcbfaceb5b98e 100644
--- a/mySlwl/app.js
+++ b/mySlwl/app.js
@@ -3,23 +3,24 @@ import './utils/http'
App({
globalData: {
- navBarHeight: 0, // 导航栏高度
- menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
- menuTop: 0, // 胶囊距顶部间距
- menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
+ navBarHeight: 0, // 导航栏高度
+ menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
+ menuTop: 0, // 胶囊距顶部间距
+ menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
+ token: ''
},
- onLaunch: function(options) {
- const that = this;
- // 获取系统信息
- const systemInfo = wx.getSystemInfoSync();
- // 胶囊按钮位置信息
- const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
- console.log(systemInfo)
- console.log(menuButtonInfo)
- // 导航栏高度 = 状态栏高度 + 44(所有机型都适用)
- that.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
- that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
- that.globalData.menuTop = menuButtonInfo.top;
- that.globalData.menuHeight = menuButtonInfo.height;
+ onLaunch: function (options) {
+ const that = this;
+ // 获取系统信息
+ const systemInfo = wx.getSystemInfoSync();
+ // 胶囊按钮位置信息
+ const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
+ console.log(systemInfo)
+ console.log(menuButtonInfo)
+ // 导航栏高度 = 状态栏高度 + 44(所有机型都适用)
+ that.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
+ that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
+ that.globalData.menuTop = menuButtonInfo.top;
+ that.globalData.menuHeight = menuButtonInfo.height;
}
-})
+})
\ No newline at end of file
diff --git a/mySlwl/pages/login/index.js b/mySlwl/pages/login/index.js
index 3405b40fff9e1034152abab83d84da9975799f46..c3257589327104ad52d40e9ed895062a576d620a 100644
--- a/mySlwl/pages/login/index.js
+++ b/mySlwl/pages/login/index.js
@@ -1,30 +1,38 @@
Page({
- /* 页面的初始数据 */
- data: {
- account: '', //账号
- password: '' //密码
- },
- /* 点击登录 */
- getLogin() {
- if (!this.data.account) return wx.utils.toast('账号不能为空')
- if (!/^\d{4,9}$/.test(this.data.account)) return wx.utils.toast('请输入4-9长度的账号')
- if (!this.data.password) return wx.utils.toast('密码不能为空')
- if (!/^\d{4,9}$/.test(this.data.password)) return wx.utils.toast('请输入4-9长度的密码')
- },
- /* 生命周期函数--监听页面加载 */
- onLoad(options) {},
- /* 生命周期函数--监听页面初次渲染完成 */
- onReady: function () {},
- /* 生命周期函数--监听页面显示 */
- onShow: function () {},
- /* 生命周期函数--监听页面隐藏 */
- onHide: function () {},
- /* 生命周期函数--监听页面卸载 */
- onUnload: function () {},
- /* 页面相关事件处理函数--监听用户下拉动作 */
- onPullDownRefresh: function () {},
- /* 页面上拉触底事件的处理函数 */
- onReachBottom: function () {},
- /* 用户点击右上角分享 */
- onShareAppMessage: function () {}
-})
+ /* 页面的初始数据 */
+ data: {
+ account: 'shenling', //账号
+ password: '123456' //密码
+ },
+ /* 生命周期函数--监听页面加载 */
+ onLoad(options) {},
+ /* 点击登录 */
+ async getLogin() {
+ if (!this.data.account) return wx.utils.toast('账号不能为空')
+ // if (!/^\d{4,9}$/.test(this.data.account)) return wx.utils.toast('请输入4-9长度的账号')
+ if (!this.data.password) return wx.utils.toast('密码不能为空')
+ if (!/^\d{4,9}$/.test(this.data.password)) return wx.utils.toast('请输入4-9长度的密码')
+ const res = await wx.http.post('/driver/login/account', this.data)
+ const app = getApp()
+ app.globalData.token = res.data
+ console.log(app.globalData.token);
+ wx.setStorage({
+ key: "token",
+ data: res.data
+ })
+ },
+ /* 生命周期函数--监听页面初次渲染完成 */
+ onReady: function () {},
+ /* 生命周期函数--监听页面显示 */
+ onShow: function () {},
+ /* 生命周期函数--监听页面隐藏 */
+ onHide: function () {},
+ /* 生命周期函数--监听页面卸载 */
+ onUnload: function () {},
+ /* 页面相关事件处理函数--监听用户下拉动作 */
+ onPullDownRefresh: function () {},
+ /* 页面上拉触底事件的处理函数 */
+ onReachBottom: function () {},
+ /* 用户点击右上角分享 */
+ onShareAppMessage: function () {}
+})
\ No newline at end of file
diff --git a/mySlwl/pages/login/index.scss b/mySlwl/pages/login/index.scss
index f15186119b3c8a5ff8bf5039faff418b66acd82f..2487e4c051aecdd896635fc083f2748f7810bf49 100644
--- a/mySlwl/pages/login/index.scss
+++ b/mySlwl/pages/login/index.scss
@@ -44,4 +44,4 @@
line-height: 90rpx;
width: 90%;
}
-}
+}
\ No newline at end of file
diff --git a/mySlwl/pages/login/index.wxml b/mySlwl/pages/login/index.wxml
index 97b63a6df1cec3501b7708f2193a1a8c98803583..1d7ee10654fe7f42e7d0b5cc72de959eb2469c5b 100644
--- a/mySlwl/pages/login/index.wxml
+++ b/mySlwl/pages/login/index.wxml
@@ -9,10 +9,16 @@
-
-
+
+
+
+
+
+
+
登录
-
+
\ No newline at end of file
diff --git a/mySlwl/utils/http.js b/mySlwl/utils/http.js
index b7deae038c50e4e812c390425c6d5b3b855bc9f2..f72c4bccc3f5b499799cbafbc9f31c6a67ca8795 100644
--- a/mySlwl/utils/http.js
+++ b/mySlwl/utils/http.js
@@ -1,23 +1,23 @@
import http from 'wechat-http'
// 接口基础地址
-http.baseURL = 'https://your.host.com'
+http.baseURL = 'https://slwl-api.itheima.net'
// 请求拦截器
http.intercept.request = (options) => {
- return options
+ return options
}
// 响应拦截器
http.intercept.response = ({
- statusCode,
- data,
- config
+ statusCode,
+ data,
+ config
}) => {
- console.log(statusCode) // http 响应状态码
- console.log(config) // 发起请求时的参数
- // 拦截器处理后的响应结果
- return data
+ console.log(statusCode) // http 响应状态码
+ console.log(config) // 发起请求时的参数
+ // 拦截器处理后的响应结果
+ return data
}
// 挂载到 wx 全局命名空间