Commit e133a83de5671076a467897b2a501b6bde92f629
1 parent
afcf948d
add 接口文档更新
Showing
6 changed files
with
189 additions
and
211 deletions
common/common.js
1 | 1 | import md5 from './md5.min.js'; |
2 | 2 | |
3 | - | |
4 | - | |
5 | -// const serverUrl = ""; | |
6 | -// var serverUrl = "https://pay.service.huangshiparking.com"; | |
7 | - | |
8 | -// 黄石正式地址 | |
9 | -// var serverUrl = "https://pay.service.huangshiparking.com"; | |
10 | -// var serverUrl = "https://pay.service.renniting.cwxbee319d15de03201n/v1/"; | |
11 | - | |
12 | -// 正式 | |
13 | -// var serverUrl = "https://pay.huangshiparking.com"; | |
14 | -// 测式 | |
15 | - | |
16 | 3 | // 江阴正式环境 |
17 | 4 | var serverUrl = "https://bus.jycrtc.com"; |
18 | 5 | |
19 | -// var serverUrl = "http://39.98.54.240:8090"; | |
20 | - | |
21 | - | |
22 | - | |
23 | - | |
24 | -// const app_id = '0eca8f5373ca4866aec2f8e9d9367104'; | |
25 | -// const deviceInfo = 'BC0703A4-AFB0-4B51-9089-9B7487C0CC6E'; | |
26 | - | |
27 | 6 | //江阴微信小程序appid |
28 | -const hs_wxPay_appId = 'wxfdc1af620d3ab750'; // 江阴慧停车 wxfdc1af620d3ab750 | |
29 | - | |
7 | +const hs_wxPay_appId = 'wxfdc1af620d3ab750'; | |
30 | 8 | |
31 | 9 | // 江阴慧停车orgId |
32 | 10 | const public_orgId = '10107'; |
33 | - | |
34 | -//黄石微信小程序appid | |
35 | - | |
36 | -// 测试环境 wx1e9b2b7f35d7da83 | |
37 | -// 正式环境 wxbee319d15de03201 | |
38 | -// const hs_wxPay_appId = 'wxbee319d15de03201'; | |
39 | - | |
40 | -// 黄石orgId | |
41 | -// const public_orgId = '10079'; | |
42 | -// 无锡orgId | |
43 | -// const public_orgId = '10005'; | |
44 | - | |
45 | -// "orgId": "10003", | |
46 | -// "orgName": "赤峰", | |
47 | - | |
48 | -// "orgId": "10081", | |
49 | -// "orgName": "兰州", | |
50 | - | |
51 | 11 | const appName = '江阴慧停车'; |
52 | 12 | const ACompany = '©江阴慧停车管理有限公司'; |
53 | 13 | const BCompany = '由中兴智能交通股份有限公司提供技术支持'; |
54 | - | |
55 | 14 | const appVerson = '1.0.0'; |
56 | 15 | |
57 | 16 | const SetToken = uni.getStorageSync("globalUser").token; |
58 | -// const SetToken = 'a0050ae361a64a968ea4412723bbe0c7'; | |
59 | - | |
60 | -// const SetToken = '17d135c3af364ad890772eeebda97096'; | |
61 | 17 | |
62 | 18 | // ----江阴项目 接口---- |
63 | 19 | // 商户登录 |
... | ... | @@ -69,8 +25,6 @@ const userLoginout = serverUrl + "/business/h5/index/logout"; |
69 | 25 | // 商户关于我们 |
70 | 26 | const useraboutUs = serverUrl + "/business/h5/index/aboutUs"; |
71 | 27 | |
72 | - | |
73 | - | |
74 | 28 | // |
75 | 29 | const requestSign = function(inputData) { |
76 | 30 | |
... | ... | @@ -147,10 +101,8 @@ var getGlobalUser = function(key) { |
147 | 101 | } |
148 | 102 | } |
149 | 103 | |
150 | - | |
151 | - | |
152 | 104 | export default { |
153 | - | |
105 | + | |
154 | 106 | // deviceInfo, |
155 | 107 | hs_wxPay_appId, |
156 | 108 | public_orgId, |
... | ... | @@ -160,7 +112,7 @@ export default { |
160 | 112 | appVerson, |
161 | 113 | SetToken, |
162 | 114 | requestSign, |
163 | - | |
115 | + | |
164 | 116 | // 接口 |
165 | 117 | userLogin, |
166 | 118 | userLoginout, | ... | ... |
common/requestServer.js
1 | 1 | import common from "./common.js"; |
2 | 2 | |
3 | -//js中处理数据 | |
4 | -const searchOrderWithCarNum = function nameCanHidden(CarNum, parkState) { | |
5 | - return new Promise(resolve => { | |
6 | - // setTimeout(() => { | |
7 | - // resolve('resolved1111111111'); | |
8 | - // }, 2000); | |
9 | - var me = this; | |
10 | - uni.showLoading({ | |
11 | - mask: true, | |
12 | - title: "请稍后..." | |
13 | - }); | |
14 | - uni.showNavigationBarLoading(); | |
15 | - | |
16 | - var ParkingrecoderUrl = common.ParkingrecoderUrl; | |
17 | - | |
18 | - var jsondata = { | |
19 | - carNumber: CarNum, | |
20 | - terminalSource: '11', | |
21 | - pageNum: '1', | |
22 | - pageSize: '500', | |
23 | - parkState: parkState | |
24 | - } | |
25 | - | |
3 | +export const myRequest = (options) => { | |
4 | + // 调接口加载 | |
5 | + uni.showLoading({ | |
6 | + title: "加载中", | |
7 | + mask: true, | |
8 | + }); | |
9 | + return new Promise((resolve, reject) => { | |
26 | 10 | uni.request({ |
27 | - url: ParkingrecoderUrl, | |
28 | - data: JSON.stringify(common.requestSign(jsondata)), | |
11 | + url: common, | |
12 | + //默认参数 | |
13 | + data: options.data || {}, | |
14 | + // 配置请求头参数-例如token | |
15 | + header: { | |
16 | + 'content-type': 'application/json', | |
17 | + Token: common.SetToken, | |
18 | + // Accept: 'application/json', | |
19 | + // 'Content-Type': 'application/json', | |
20 | + // 'X-Requested-With': 'XMLHttpRequest' | |
21 | + }, | |
22 | + dataType: "json", | |
23 | + method: options.method || 'GET', | |
24 | + // sslVerify: true, | |
29 | 25 | |
30 | - header: { 'content-type': 'application/json' }, | |
31 | - dataType: "json", | |
32 | - method: "POST", | |
26 | + // 接口请求成功 | |
33 | 27 | success: (res) => { |
34 | - console.log(JSON.stringify(res.data)); | |
35 | - uni.hideNavigationBarLoading(); | |
28 | + // 关闭加载 | |
36 | 29 | uni.hideLoading(); |
37 | - if (res.data.code == 0) { | |
38 | - resolve(res.data); | |
39 | - } | |
40 | - else if (res.data.code == -10000) { | |
41 | - uni.showModal({ | |
42 | - title: '提示', | |
43 | - content: res.data.message, | |
44 | - showCancel: false, | |
45 | - success: function (res) { | |
46 | - if (res.confirm) { | |
47 | - console.log('登录失效'); | |
48 | - uni.clearStorageSync(); | |
49 | - } | |
50 | - } | |
51 | - }); | |
30 | + console.log('接口所有参数', res); | |
31 | + if (res.statusCode !== 200) { | |
32 | + // 不同报错信息的提示和配置 | |
33 | + if (res.statusCode == 500) { | |
34 | + return uni.showToast({ | |
35 | + title: '服务器重启中...', | |
36 | + icon: "none", | |
37 | + mask: true, | |
38 | + }) | |
39 | + } else { | |
40 | + return uni.showToast({ | |
41 | + title: '获取数据失败', | |
42 | + icon: "none", | |
43 | + mask: true, | |
44 | + }) | |
45 | + } | |
52 | 46 | } |
47 | + // 调用成功且有数据 返回数据 组件内通过 .then() 或者async await 接受异步返回数据 | |
48 | + //resolve(res.data) | |
49 | + //在接口200 调用成功后 才能进行判断接口内的状态码 return_code 以此判定作何操作和提示 | |
50 | + const { statusCode, data } = res | |
51 | + let return_code = res.data.return_code | |
52 | + let return_message = res.data.return_message | |
53 | + switch (return_code) { | |
54 | + case '0': | |
55 | + // 成功的数据data状态码 则直接返回数据 | |
56 | + resolve(res.data) | |
57 | + break | |
58 | + case '4011': | |
59 | + uni.clearStorage() | |
60 | + if (hasUserInfo && !isExisited && !checkToken) { | |
61 | + isExisited = true | |
62 | + uni.showModal({ | |
63 | + title: '提示', | |
64 | + content: '身份失效,请重新登录!', | |
65 | + complete: () => { | |
66 | + uni.reLaunch({ url: '/pages/index/index' }) | |
67 | + }, | |
68 | + }) | |
69 | + } else { | |
70 | + reject(res.data) | |
71 | + } | |
72 | + break | |
73 | + default: | |
74 | + // 其他的如无特定要求 则做提示 | |
75 | + // reject(res.data) | |
76 | + return uni.showToast({ | |
77 | + title: return_message || '请求失败', | |
78 | + duration: 2000, | |
79 | + icon: 'none', | |
80 | + }) | |
81 | + } | |
53 | 82 | }, |
54 | - complete: () => { | |
55 | 83 | |
56 | - uni.hideNavigationBarLoading(); | |
84 | + // 接口接口失败 | |
85 | + fail: (error) => { | |
86 | + // 关闭加载 | |
57 | 87 | uni.hideLoading(); |
88 | + console.log(2, error); | |
89 | + uni.showToast({ | |
90 | + title: '请求接口失败', | |
91 | + icon: "none", | |
92 | + mask: true, | |
93 | + }) | |
94 | + // 失败数据 | |
95 | + reject(error) | |
58 | 96 | } |
59 | - }); | |
60 | - | |
61 | - }); | |
62 | - | |
63 | -} | |
64 | - | |
65 | -//js中处理数据 | |
66 | -// const requestSs =function nameCanHidden() { | |
67 | -// return new Promise(resolve => { | |
68 | -// setTimeout(() => { | |
69 | -// resolve('resolved1111111111'); | |
70 | -// }, 2000); | |
71 | -// }); | |
72 | -// } | |
73 | - | |
74 | -//vue中接收处理后的数据 | |
75 | -// async function asyncCall() { | |
76 | -// console.log('calling'); | |
77 | -// var result = await requestServer.requestSs(); | |
78 | -// console.log(result); | |
79 | -// // expected output: 'resolved' | |
80 | -// } | |
81 | -// asyncCall(); | |
82 | - | |
83 | -export default { | |
84 | - searchOrderWithCarNum | |
85 | -} | |
97 | + }) | |
98 | + }) | |
99 | +} | |
86 | 100 | \ No newline at end of file | ... | ... |
main.js
manifest.json
pages.json
... | ... | @@ -14,19 +14,19 @@ |
14 | 14 | "pages": [ |
15 | 15 | // pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages |
16 | 16 | |
17 | - | |
18 | 17 | { |
19 | - "path": "pages/businessCard/cardPrint", | |
18 | + "path": "pages/index/index", | |
20 | 19 | "style": { |
21 | - "navigationBarTitleText": "卡券打印" | |
20 | + "navigationBarTitleText": "商户管理" | |
22 | 21 | } |
23 | 22 | }, |
24 | 23 | { |
25 | - "path": "pages/index/index", | |
24 | + "path": "pages/businessCard/cardPrint", | |
26 | 25 | "style": { |
27 | - "navigationBarTitleText": "商户管理" | |
26 | + "navigationBarTitleText": "卡券打印" | |
28 | 27 | } |
29 | 28 | }, |
29 | + | |
30 | 30 | { |
31 | 31 | "path": "pages/businessCard/printCard", |
32 | 32 | "style": { |
... | ... | @@ -127,7 +127,7 @@ |
127 | 127 | "navigationBarTitleText": "账单详情" |
128 | 128 | } |
129 | 129 | }, |
130 | - { | |
130 | + { | |
131 | 131 | "path": "pages/login/login", |
132 | 132 | "style": { |
133 | 133 | "navigationBarTitleText": "商户中心", |
... | ... | @@ -198,71 +198,57 @@ |
198 | 198 | "enablePullDownRefresh": false |
199 | 199 | } |
200 | 200 | |
201 | - } | |
202 | - ,{ | |
203 | - "path" : "pages/invoiceInformation/invoiceInformation", | |
204 | - "style" : | |
205 | - { | |
206 | - "navigationBarTitleText": "开票信息确认", | |
207 | - "enablePullDownRefresh": false | |
208 | - } | |
201 | + }, { | |
202 | + "path": "pages/invoiceInformation/invoiceInformation", | |
203 | + "style": { | |
204 | + "navigationBarTitleText": "开票信息确认", | |
205 | + "enablePullDownRefresh": false | |
206 | + } | |
209 | 207 | |
210 | - } | |
211 | - ,{ | |
212 | - "path" : "pages/invoiceTitle/invoiceTitle", | |
213 | - "style" : | |
214 | - { | |
215 | - "navigationBarTitleText": "发票抬头", | |
216 | - "enablePullDownRefresh": false | |
217 | - } | |
208 | + }, { | |
209 | + "path": "pages/invoiceTitle/invoiceTitle", | |
210 | + "style": { | |
211 | + "navigationBarTitleText": "发票抬头", | |
212 | + "enablePullDownRefresh": false | |
213 | + } | |
218 | 214 | |
219 | - } | |
220 | - ,{ | |
221 | - "path" : "pages/companyMsg/companyMsg", | |
222 | - "style" : | |
223 | - { | |
224 | - "navigationBarTitleText": "详情", | |
225 | - "enablePullDownRefresh": false | |
226 | - } | |
215 | + }, { | |
216 | + "path": "pages/companyMsg/companyMsg", | |
217 | + "style": { | |
218 | + "navigationBarTitleText": "详情", | |
219 | + "enablePullDownRefresh": false | |
220 | + } | |
227 | 221 | |
228 | - } | |
229 | - ,{ | |
230 | - "path" : "pages/addTitle/addTitle", | |
231 | - "style" : | |
232 | - { | |
233 | - "navigationBarTitleText": "添加抬头", | |
234 | - "enablePullDownRefresh": false | |
235 | - } | |
222 | + }, { | |
223 | + "path": "pages/addTitle/addTitle", | |
224 | + "style": { | |
225 | + "navigationBarTitleText": "添加抬头", | |
226 | + "enablePullDownRefresh": false | |
227 | + } | |
236 | 228 | |
237 | - } | |
238 | - ,{ | |
239 | - "path" : "pages/editTitle/editTitle", | |
240 | - "style" : | |
241 | - { | |
242 | - "navigationBarTitleText": "编辑抬头", | |
243 | - "enablePullDownRefresh": false | |
244 | - } | |
229 | + }, { | |
230 | + "path": "pages/editTitle/editTitle", | |
231 | + "style": { | |
232 | + "navigationBarTitleText": "编辑抬头", | |
233 | + "enablePullDownRefresh": false | |
234 | + } | |
245 | 235 | |
246 | - } | |
247 | - ,{ | |
248 | - "path" : "pages/creditRating/creditRating", | |
249 | - "style" : | |
250 | - { | |
251 | - "navigationBarTitleText": "信用等级", | |
252 | - "enablePullDownRefresh": false | |
253 | - } | |
236 | + }, { | |
237 | + "path": "pages/creditRating/creditRating", | |
238 | + "style": { | |
239 | + "navigationBarTitleText": "信用等级", | |
240 | + "enablePullDownRefresh": false | |
241 | + } | |
254 | 242 | |
255 | - } | |
256 | - ,{ | |
257 | - "path" : "pages/nameAuthentication/nameAuthentication", | |
258 | - "style" : | |
259 | - { | |
260 | - "navigationBarTitleText": "实名认证", | |
261 | - "enablePullDownRefresh": false | |
262 | - } | |
243 | + }, { | |
244 | + "path": "pages/nameAuthentication/nameAuthentication", | |
245 | + "style": { | |
246 | + "navigationBarTitleText": "实名认证", | |
247 | + "enablePullDownRefresh": false | |
248 | + } | |
263 | 249 | |
264 | - } | |
265 | - ], | |
250 | + } | |
251 | + ], | |
266 | 252 | "globalStyle": { |
267 | 253 | "navigationBarTextStyle": "black", |
268 | 254 | "navigationBarTitleText": "江阴慧停车", |
... | ... | @@ -278,5 +264,5 @@ |
278 | 264 | "navigationBarBackgroundColor": "#F1F1F1" |
279 | 265 | } |
280 | 266 | } |
281 | - | |
267 | + | |
282 | 268 | } | ... | ... |
pages/index/index.vue
... | ... | @@ -16,13 +16,13 @@ |
16 | 16 | <input class="uni-input" password type="text" v-model="password" placeholder="请输入密码" /> |
17 | 17 | </view> |
18 | 18 | </view> |
19 | - | |
19 | + | |
20 | 20 | <view class="paddinglr30 uni-common-mt"> |
21 | 21 | <button type="primary" @click="login">登录</button> |
22 | 22 | </view> |
23 | 23 | <view class="uni-common-mt login-foot"> |
24 | 24 | 点击”登录“,即表示你同意《商户用户协议》 |
25 | - </view> | |
25 | + </view> | |
26 | 26 | </view> |
27 | 27 | <view class="bg-white" v-if="userIsLogin"> |
28 | 28 | <view class="index-top"> |
... | ... | @@ -32,7 +32,7 @@ |
32 | 32 | class="face"></image> |
33 | 33 | <view class="username">张三</view> |
34 | 34 | </view> |
35 | - | |
35 | + | |
36 | 36 | </view> |
37 | 37 | <view class="set-wapper"> |
38 | 38 | <image src="../../static/me/settings.png" class="settings" @tap="toSetting"></image> |
... | ... | @@ -40,7 +40,7 @@ |
40 | 40 | </view> |
41 | 41 | <view class="index-menu"> |
42 | 42 | <view class="uni-padding-wrap uni-common-mt"> |
43 | - | |
43 | + | |
44 | 44 | <view class="uni-flex uni-row"> |
45 | 45 | <view class="flex-item"> |
46 | 46 | <view class=""> |
... | ... | @@ -60,7 +60,7 @@ |
60 | 60 | </view> |
61 | 61 | <view class="index-title">我的钱包</view> |
62 | 62 | </view> |
63 | - | |
63 | + | |
64 | 64 | </view> |
65 | 65 | <view class="uni-flex uni-row"> |
66 | 66 | <view class="flex-item"> |
... | ... | @@ -84,32 +84,53 @@ |
84 | 84 | </view> |
85 | 85 | </view> |
86 | 86 | </view> |
87 | - | |
87 | + | |
88 | 88 | </view> |
89 | 89 | </view> |
90 | - | |
90 | + | |
91 | 91 | </template> |
92 | 92 | |
93 | 93 | <script> |
94 | 94 | import common from "../../common/common.js"; |
95 | 95 | |
96 | - | |
97 | 96 | export default { |
98 | 97 | data() { |
99 | 98 | return { |
100 | 99 | userIsLogin: false, |
101 | 100 | appName: '江阴慧停车', |
102 | 101 | apptitle: '江阴慧停车·智慧便捷', |
103 | - username:'', | |
104 | - password:'', | |
102 | + username: '', | |
103 | + password: '', | |
105 | 104 | } |
106 | 105 | }, |
107 | 106 | onLoad() { |
108 | 107 | |
109 | 108 | }, |
110 | 109 | methods: { |
111 | - login(){ | |
112 | - | |
110 | + login() { | |
111 | + let that = this; | |
112 | + if (that.username.trim() === "" || that.password.trim() === "") { | |
113 | + uni.showToast({ | |
114 | + title: '用户名密码必填', | |
115 | + icon: 'error', | |
116 | + duration: 2000 | |
117 | + }) | |
118 | + return; | |
119 | + } else { | |
120 | + that.$myRequest({ | |
121 | + url: common.userLogin, | |
122 | + method: 'POST', | |
123 | + data: { | |
124 | + userCode: that.username, | |
125 | + userPwd: that.password | |
126 | + } | |
127 | + }).then(res => { | |
128 | + console.log('使用.then()获取返回的参数', res); | |
129 | + | |
130 | + }) | |
131 | + | |
132 | + | |
133 | + } | |
113 | 134 | }, |
114 | 135 | toSetting() { |
115 | 136 | uni.navigateTo({ |
... | ... | @@ -140,36 +161,37 @@ |
140 | 161 | display: flex; |
141 | 162 | justify-content: center; |
142 | 163 | position: relative; |
143 | - | |
164 | + | |
144 | 165 | } |
145 | - | |
166 | + | |
146 | 167 | .login-content { |
147 | 168 | background-color: #f6f6f6; |
148 | 169 | text-align: center; |
149 | 170 | height: 100vh; |
150 | 171 | } |
151 | - | |
172 | + | |
152 | 173 | .logo { |
153 | 174 | height: 200upx; |
154 | 175 | width: 200upx; |
155 | 176 | margin-top: 200upx; |
156 | 177 | } |
157 | - | |
178 | + | |
158 | 179 | .title { |
159 | 180 | font-size: 32upx; |
160 | 181 | color: #000; |
161 | 182 | font-weight: 400; |
162 | 183 | } |
163 | - | |
184 | + | |
164 | 185 | .title-msg { |
165 | 186 | font-size: 26upx; |
166 | 187 | color: #8d8d8d; |
167 | 188 | } |
168 | - | |
169 | - .login-foot{ | |
189 | + | |
190 | + .login-foot { | |
170 | 191 | font-size: 26upx; |
171 | - | |
192 | + | |
172 | 193 | } |
194 | + | |
173 | 195 | // 首页 |
174 | 196 | .index-top { |
175 | 197 | height: 200upx; | ... | ... |