Commit e133a83de5671076a467897b2a501b6bde92f629

Authored by chenbiao
1 parent afcf948d

add 接口文档更新

common/common.js
1 import md5 from './md5.min.js'; 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 var serverUrl = "https://bus.jycrtc.com"; 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 //江阴微信小程序appid 6 //江阴微信小程序appid
28 -const hs_wxPay_appId = 'wxfdc1af620d3ab750'; // 江阴慧停车 wxfdc1af620d3ab750  
29 - 7 +const hs_wxPay_appId = 'wxfdc1af620d3ab750';
30 8
31 // 江阴慧停车orgId 9 // 江阴慧停车orgId
32 const public_orgId = '10107'; 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 const appName = '江阴慧停车'; 11 const appName = '江阴慧停车';
52 const ACompany = '©江阴慧停车管理有限公司'; 12 const ACompany = '©江阴慧停车管理有限公司';
53 const BCompany = '由中兴智能交通股份有限公司提供技术支持'; 13 const BCompany = '由中兴智能交通股份有限公司提供技术支持';
54 -  
55 const appVerson = '1.0.0'; 14 const appVerson = '1.0.0';
56 15
57 const SetToken = uni.getStorageSync("globalUser").token; 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,8 +25,6 @@ const userLoginout = serverUrl + "/business/h5/index/logout";
69 // 商户关于我们 25 // 商户关于我们
70 const useraboutUs = serverUrl + "/business/h5/index/aboutUs"; 26 const useraboutUs = serverUrl + "/business/h5/index/aboutUs";
71 27
72 -  
73 -  
74 // 28 //
75 const requestSign = function(inputData) { 29 const requestSign = function(inputData) {
76 30
@@ -147,10 +101,8 @@ var getGlobalUser = function(key) { @@ -147,10 +101,8 @@ var getGlobalUser = function(key) {
147 } 101 }
148 } 102 }
149 103
150 -  
151 -  
152 export default { 104 export default {
153 - 105 +
154 // deviceInfo, 106 // deviceInfo,
155 hs_wxPay_appId, 107 hs_wxPay_appId,
156 public_orgId, 108 public_orgId,
@@ -160,7 +112,7 @@ export default { @@ -160,7 +112,7 @@ export default {
160 appVerson, 112 appVerson,
161 SetToken, 113 SetToken,
162 requestSign, 114 requestSign,
163 - 115 +
164 // 接口 116 // 接口
165 userLogin, 117 userLogin,
166 userLoginout, 118 userLoginout,
common/requestServer.js
1 import common from "./common.js"; 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 uni.request({ 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 success: (res) => { 27 success: (res) => {
34 - console.log(JSON.stringify(res.data));  
35 - uni.hideNavigationBarLoading(); 28 + // 关闭加载
36 uni.hideLoading(); 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 uni.hideLoading(); 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 \ No newline at end of file 100 \ No newline at end of file
1 import App from './App' 1 import App from './App'
2 import store from './store' 2 import store from './store'
  3 +// 引入封装的接口api
  4 +import { myRequest } from './common/requestServer.js'
  5 +// 挂在Vue属性 全局通过this.$myRequest()可以访问到
  6 +Vue.prototype.$myRequest = myRequest
3 7
4 // #ifndef VUE3 8 // #ifndef VUE3
5 import Vue from 'vue' 9 import Vue from 'vue'
manifest.json
@@ -93,7 +93,7 @@ @@ -93,7 +93,7 @@
93 "versionCode" : 100 93 "versionCode" : 100
94 }, 94 },
95 "mp-weixin" : { 95 "mp-weixin" : {
96 - "appid" : "", 96 + "appid" : "wxfdc1af620d3ab750",
97 "setting" : { 97 "setting" : {
98 "urlCheck" : false 98 "urlCheck" : false
99 }, 99 },
pages.json
@@ -14,19 +14,19 @@ @@ -14,19 +14,19 @@
14 "pages": [ 14 "pages": [
15 // pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages 15 // pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
16 16
17 -  
18 { 17 {
19 - "path": "pages/businessCard/cardPrint", 18 + "path": "pages/index/index",
20 "style": { 19 "style": {
21 - "navigationBarTitleText": "卡券打印" 20 + "navigationBarTitleText": "商户管理"
22 } 21 }
23 }, 22 },
24 { 23 {
25 - "path": "pages/index/index", 24 + "path": "pages/businessCard/cardPrint",
26 "style": { 25 "style": {
27 - "navigationBarTitleText": "商户管理" 26 + "navigationBarTitleText": "卡券打印"
28 } 27 }
29 }, 28 },
  29 +
30 { 30 {
31 "path": "pages/businessCard/printCard", 31 "path": "pages/businessCard/printCard",
32 "style": { 32 "style": {
@@ -127,7 +127,7 @@ @@ -127,7 +127,7 @@
127 "navigationBarTitleText": "账单详情" 127 "navigationBarTitleText": "账单详情"
128 } 128 }
129 }, 129 },
130 - { 130 + {
131 "path": "pages/login/login", 131 "path": "pages/login/login",
132 "style": { 132 "style": {
133 "navigationBarTitleText": "商户中心", 133 "navigationBarTitleText": "商户中心",
@@ -198,71 +198,57 @@ @@ -198,71 +198,57 @@
198 "enablePullDownRefresh": false 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 "globalStyle": { 252 "globalStyle": {
267 "navigationBarTextStyle": "black", 253 "navigationBarTextStyle": "black",
268 "navigationBarTitleText": "江阴慧停车", 254 "navigationBarTitleText": "江阴慧停车",
@@ -278,5 +264,5 @@ @@ -278,5 +264,5 @@
278 "navigationBarBackgroundColor": "#F1F1F1" 264 "navigationBarBackgroundColor": "#F1F1F1"
279 } 265 }
280 } 266 }
281 - 267 +
282 } 268 }
pages/index/index.vue
@@ -16,13 +16,13 @@ @@ -16,13 +16,13 @@
16 <input class="uni-input" password type="text" v-model="password" placeholder="请输入密码" /> 16 <input class="uni-input" password type="text" v-model="password" placeholder="请输入密码" />
17 </view> 17 </view>
18 </view> 18 </view>
19 - 19 +
20 <view class="paddinglr30 uni-common-mt"> 20 <view class="paddinglr30 uni-common-mt">
21 <button type="primary" @click="login">登录</button> 21 <button type="primary" @click="login">登录</button>
22 </view> 22 </view>
23 <view class="uni-common-mt login-foot"> 23 <view class="uni-common-mt login-foot">
24 点击”登录“,即表示你同意《商户用户协议》 24 点击”登录“,即表示你同意《商户用户协议》
25 - </view> 25 + </view>
26 </view> 26 </view>
27 <view class="bg-white" v-if="userIsLogin"> 27 <view class="bg-white" v-if="userIsLogin">
28 <view class="index-top"> 28 <view class="index-top">
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 class="face"></image> 32 class="face"></image>
33 <view class="username">张三</view> 33 <view class="username">张三</view>
34 </view> 34 </view>
35 - 35 +
36 </view> 36 </view>
37 <view class="set-wapper"> 37 <view class="set-wapper">
38 <image src="../../static/me/settings.png" class="settings" @tap="toSetting"></image> 38 <image src="../../static/me/settings.png" class="settings" @tap="toSetting"></image>
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 </view> 40 </view>
41 <view class="index-menu"> 41 <view class="index-menu">
42 <view class="uni-padding-wrap uni-common-mt"> 42 <view class="uni-padding-wrap uni-common-mt">
43 - 43 +
44 <view class="uni-flex uni-row"> 44 <view class="uni-flex uni-row">
45 <view class="flex-item"> 45 <view class="flex-item">
46 <view class=""> 46 <view class="">
@@ -60,7 +60,7 @@ @@ -60,7 +60,7 @@
60 </view> 60 </view>
61 <view class="index-title">我的钱包</view> 61 <view class="index-title">我的钱包</view>
62 </view> 62 </view>
63 - 63 +
64 </view> 64 </view>
65 <view class="uni-flex uni-row"> 65 <view class="uni-flex uni-row">
66 <view class="flex-item"> 66 <view class="flex-item">
@@ -84,32 +84,53 @@ @@ -84,32 +84,53 @@
84 </view> 84 </view>
85 </view> 85 </view>
86 </view> 86 </view>
87 - 87 +
88 </view> 88 </view>
89 </view> 89 </view>
90 - 90 +
91 </template> 91 </template>
92 92
93 <script> 93 <script>
94 import common from "../../common/common.js"; 94 import common from "../../common/common.js";
95 95
96 -  
97 export default { 96 export default {
98 data() { 97 data() {
99 return { 98 return {
100 userIsLogin: false, 99 userIsLogin: false,
101 appName: '江阴慧停车', 100 appName: '江阴慧停车',
102 apptitle: '江阴慧停车·智慧便捷', 101 apptitle: '江阴慧停车·智慧便捷',
103 - username:'',  
104 - password:'', 102 + username: '',
  103 + password: '',
105 } 104 }
106 }, 105 },
107 onLoad() { 106 onLoad() {
108 107
109 }, 108 },
110 methods: { 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 toSetting() { 135 toSetting() {
115 uni.navigateTo({ 136 uni.navigateTo({
@@ -140,36 +161,37 @@ @@ -140,36 +161,37 @@
140 display: flex; 161 display: flex;
141 justify-content: center; 162 justify-content: center;
142 position: relative; 163 position: relative;
143 - 164 +
144 } 165 }
145 - 166 +
146 .login-content { 167 .login-content {
147 background-color: #f6f6f6; 168 background-color: #f6f6f6;
148 text-align: center; 169 text-align: center;
149 height: 100vh; 170 height: 100vh;
150 } 171 }
151 - 172 +
152 .logo { 173 .logo {
153 height: 200upx; 174 height: 200upx;
154 width: 200upx; 175 width: 200upx;
155 margin-top: 200upx; 176 margin-top: 200upx;
156 } 177 }
157 - 178 +
158 .title { 179 .title {
159 font-size: 32upx; 180 font-size: 32upx;
160 color: #000; 181 color: #000;
161 font-weight: 400; 182 font-weight: 400;
162 } 183 }
163 - 184 +
164 .title-msg { 185 .title-msg {
165 font-size: 26upx; 186 font-size: 26upx;
166 color: #8d8d8d; 187 color: #8d8d8d;
167 } 188 }
168 -  
169 - .login-foot{ 189 +
  190 + .login-foot {
170 font-size: 26upx; 191 font-size: 26upx;
171 - 192 +
172 } 193 }
  194 +
173 // 首页 195 // 首页
174 .index-top { 196 .index-top {
175 height: 200upx; 197 height: 200upx;