Commit f7e9351ebeba76645114c42d82fd502ecdd2161e
1 parent
e6c7d1db
add 接口文档更新
Showing
3 changed files
with
39 additions
and
18 deletions
common/common.js
@@ -19,6 +19,9 @@ const SetToken = uni.getStorageSync("globalUser").token; | @@ -19,6 +19,9 @@ const SetToken = uni.getStorageSync("globalUser").token; | ||
19 | // 商户登录 | 19 | // 商户登录 |
20 | const userLogin = serverUrl + "/business/h5/index/login"; | 20 | const userLogin = serverUrl + "/business/h5/index/login"; |
21 | 21 | ||
22 | +// 获取已登录商户用户信息 | ||
23 | +const indexInfo = serverUrl + "/business/h5/index/info"; | ||
24 | + | ||
22 | // 商户退出登录 | 25 | // 商户退出登录 |
23 | const userLoginout = serverUrl + "/business/h5/index/logout"; | 26 | const userLoginout = serverUrl + "/business/h5/index/logout"; |
24 | 27 | ||
@@ -116,6 +119,7 @@ export default { | @@ -116,6 +119,7 @@ export default { | ||
116 | 119 | ||
117 | // 接口 | 120 | // 接口 |
118 | userLogin, | 121 | userLogin, |
122 | + indexInfo, | ||
119 | userLoginout, | 123 | userLoginout, |
120 | useraboutUs, | 124 | useraboutUs, |
121 | } | 125 | } |
common/requestServer.js
@@ -13,7 +13,6 @@ export const myRequest = (options) => { | @@ -13,7 +13,6 @@ export const myRequest = (options) => { | ||
13 | // 配置请求头参数-例如token | 13 | // 配置请求头参数-例如token |
14 | header: { | 14 | header: { |
15 | 'content-type': 'application/json', | 15 | 'content-type': 'application/json', |
16 | - Token: common.SetToken, | ||
17 | // Accept: 'application/json', | 16 | // Accept: 'application/json', |
18 | // 'Content-Type': 'application/json', | 17 | // 'Content-Type': 'application/json', |
19 | // 'X-Requested-With': 'XMLHttpRequest' | 18 | // 'X-Requested-With': 'XMLHttpRequest' |
@@ -30,31 +29,28 @@ export const myRequest = (options) => { | @@ -30,31 +29,28 @@ export const myRequest = (options) => { | ||
30 | //在接口200 调用成功后 才能进行判断接口内的状态码 return_code 以此判定作何操作和提示 | 29 | //在接口200 调用成功后 才能进行判断接口内的状态码 return_code 以此判定作何操作和提示 |
31 | let result = res.data | 30 | let result = res.data |
32 | console.log(result); | 31 | console.log(result); |
33 | - console.log(result.code) | 32 | + |
34 | if (result.code == 0) { | 33 | if (result.code == 0) { |
35 | resolve(res.data) | 34 | resolve(res.data) |
36 | } else { | 35 | } else { |
37 | uni.hideLoading(); | 36 | uni.hideLoading(); |
38 | uni.showToast({ | 37 | uni.showToast({ |
39 | - title: res.data.message, | ||
40 | - icon: 'none', | 38 | + title: result.message, |
39 | + icon: 'error', | ||
41 | duration: 2000 | 40 | duration: 2000 |
42 | }); | 41 | }); |
43 | } | 42 | } |
44 | - // let return_code = result.data.code | ||
45 | - // let return_message = result.data.message | ||
46 | - // console.log(typeof return_code) | ||
47 | - // console.log(return_code) | 43 | + |
48 | }, | 44 | }, |
49 | // 接口接口失败 | 45 | // 接口接口失败 |
50 | fail: (error) => { | 46 | fail: (error) => { |
51 | // 关闭加载 | 47 | // 关闭加载 |
52 | uni.hideLoading(); | 48 | uni.hideLoading(); |
53 | - console.log(2, error); | 49 | + console.log("请求失败", error); |
54 | uni.showToast({ | 50 | uni.showToast({ |
55 | - title: '请求接口失败', | ||
56 | - icon: "none", | ||
57 | - mask: true, | 51 | + title: error.message, |
52 | + icon: 'error', | ||
53 | + duration: 2000 | ||
58 | }) | 54 | }) |
59 | // 失败数据 | 55 | // 失败数据 |
60 | reject(error) | 56 | reject(error) |
pages/index/index.vue
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | </view> | 10 | </view> |
11 | <view class="uni-common-mt paddinglr30"> | 11 | <view class="uni-common-mt paddinglr30"> |
12 | <view class="uni-form-item uni-column"> | 12 | <view class="uni-form-item uni-column"> |
13 | - <input class="uni-input" type="text" v-model="username" placeholder="请输入用户名" /> | 13 | + <input class="uni-input" type="text" v-model="userCode" placeholder="请输入用户名" /> |
14 | </view> | 14 | </view> |
15 | <view class="uni-form-item uni-column"> | 15 | <view class="uni-form-item uni-column"> |
16 | <input class="uni-input" password type="text" v-model="password" placeholder="请输入密码" /> | 16 | <input class="uni-input" password type="text" v-model="password" placeholder="请输入密码" /> |
@@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
30 | <view style="z-index: 2;"> | 30 | <view style="z-index: 2;"> |
31 | <image src="http://122.152.205.72:88/group1/M00/00/05/CpoxxFw_-5-AFyVyAABLIH8xBTw233.png" | 31 | <image src="http://122.152.205.72:88/group1/M00/00/05/CpoxxFw_-5-AFyVyAABLIH8xBTw233.png" |
32 | class="face"></image> | 32 | class="face"></image> |
33 | - <view class="username">张三</view> | 33 | + <view class="username">{{userName}}</view> |
34 | </view> | 34 | </view> |
35 | 35 | ||
36 | </view> | 36 | </view> |
@@ -98,8 +98,9 @@ | @@ -98,8 +98,9 @@ | ||
98 | userIsLogin: true, | 98 | userIsLogin: true, |
99 | appName: '江阴慧停车', | 99 | appName: '江阴慧停车', |
100 | apptitle: '江阴慧停车·智慧便捷', | 100 | apptitle: '江阴慧停车·智慧便捷', |
101 | - username: '', | 101 | + userCode: '', |
102 | password: '', | 102 | password: '', |
103 | + userName:'', | ||
103 | } | 104 | } |
104 | }, | 105 | }, |
105 | onLoad() { | 106 | onLoad() { |
@@ -109,10 +110,10 @@ | @@ -109,10 +110,10 @@ | ||
109 | login() { | 110 | login() { |
110 | let that = this; | 111 | let that = this; |
111 | let data = { | 112 | let data = { |
112 | - userCode: that.username, | 113 | + userCode: that.userCode, |
113 | userPwd: that.password | 114 | userPwd: that.password |
114 | }; | 115 | }; |
115 | - if (that.username.trim() === "" || that.password.trim() === "") { | 116 | + if (that.userCode.trim() === "" || that.password.trim() === "") { |
116 | uni.showToast({ | 117 | uni.showToast({ |
117 | title: '用户名密码必填', | 118 | title: '用户名密码必填', |
118 | icon: 'error', | 119 | icon: 'error', |
@@ -127,11 +128,31 @@ | @@ -127,11 +128,31 @@ | ||
127 | data: that.$common.requestSign(data) | 128 | data: that.$common.requestSign(data) |
128 | }).then(res => { | 129 | }).then(res => { |
129 | console.log(res) | 130 | console.log(res) |
130 | - var userInfo = res.data; | 131 | + let userInfo = res.data; |
131 | console.log(res.data) | 132 | console.log(res.data) |
133 | + | ||
132 | // 保存用户信息到全局的缓存中 | 134 | // 保存用户信息到全局的缓存中 |
133 | uni.setStorageSync("globalUser", userInfo); | 135 | uni.setStorageSync("globalUser", userInfo); |
136 | + | ||
137 | + // 登陆成功 展示首页 | ||
134 | that.userIsLogin = false; | 138 | that.userIsLogin = false; |
139 | + | ||
140 | + // 首页信息获取 接口 | ||
141 | + that.$myRequest({ | ||
142 | + url:that.$common.indexInfo, | ||
143 | + method: 'POST', | ||
144 | + data: that.$common.requestSign() | ||
145 | + }).then(res => { | ||
146 | + console.log(res) | ||
147 | + var indexInfo = res.data; | ||
148 | + console.log(indexInfo) | ||
149 | + that.userName=indexInfo.indexInfo; | ||
150 | + | ||
151 | + | ||
152 | + | ||
153 | + | ||
154 | + }) | ||
155 | + | ||
135 | 156 | ||
136 | }) | 157 | }) |
137 | 158 |