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