diff --git a/common/common.js b/common/common.js
index b1a37f7..a79a52c 100644
--- a/common/common.js
+++ b/common/common.js
@@ -1,63 +1,19 @@
import md5 from './md5.min.js';
-
-
-// const serverUrl = "";
-// var serverUrl = "https://pay.service.huangshiparking.com";
-
-// 黄石正式地址
-// var serverUrl = "https://pay.service.huangshiparking.com";
-// var serverUrl = "https://pay.service.renniting.cwxbee319d15de03201n/v1/";
-
-// 正式
-// var serverUrl = "https://pay.huangshiparking.com";
-// 测式
-
// 江阴正式环境
var serverUrl = "https://bus.jycrtc.com";
-// var serverUrl = "http://39.98.54.240:8090";
-
-
-
-
-// const app_id = '0eca8f5373ca4866aec2f8e9d9367104';
-// const deviceInfo = 'BC0703A4-AFB0-4B51-9089-9B7487C0CC6E';
-
//江阴微信小程序appid
-const hs_wxPay_appId = 'wxfdc1af620d3ab750'; // 江阴慧停车 wxfdc1af620d3ab750
-
+const hs_wxPay_appId = 'wxfdc1af620d3ab750';
// 江阴慧停车orgId
const public_orgId = '10107';
-
-//黄石微信小程序appid
-
-// 测试环境 wx1e9b2b7f35d7da83
-// 正式环境 wxbee319d15de03201
-// const hs_wxPay_appId = 'wxbee319d15de03201';
-
-// 黄石orgId
-// const public_orgId = '10079';
-// 无锡orgId
-// const public_orgId = '10005';
-
-// "orgId": "10003",
-// "orgName": "赤峰",
-
-// "orgId": "10081",
-// "orgName": "兰州",
-
const appName = '江阴慧停车';
const ACompany = '©江阴慧停车管理有限公司';
const BCompany = '由中兴智能交通股份有限公司提供技术支持';
-
const appVerson = '1.0.0';
const SetToken = uni.getStorageSync("globalUser").token;
-// const SetToken = 'a0050ae361a64a968ea4412723bbe0c7';
-
-// const SetToken = '17d135c3af364ad890772eeebda97096';
// ----江阴项目 接口----
// 商户登录
@@ -69,8 +25,6 @@ const userLoginout = serverUrl + "/business/h5/index/logout";
// 商户关于我们
const useraboutUs = serverUrl + "/business/h5/index/aboutUs";
-
-
//
const requestSign = function(inputData) {
@@ -147,10 +101,8 @@ var getGlobalUser = function(key) {
}
}
-
-
export default {
-
+
// deviceInfo,
hs_wxPay_appId,
public_orgId,
@@ -160,7 +112,7 @@ export default {
appVerson,
SetToken,
requestSign,
-
+
// 接口
userLogin,
userLoginout,
diff --git a/common/requestServer.js b/common/requestServer.js
index 353169f..8c02805 100644
--- a/common/requestServer.js
+++ b/common/requestServer.js
@@ -1,85 +1,99 @@
import common from "./common.js";
-//js中处理数据
-const searchOrderWithCarNum = function nameCanHidden(CarNum, parkState) {
- return new Promise(resolve => {
- // setTimeout(() => {
- // resolve('resolved1111111111');
- // }, 2000);
- var me = this;
- uni.showLoading({
- mask: true,
- title: "请稍后..."
- });
- uni.showNavigationBarLoading();
-
- var ParkingrecoderUrl = common.ParkingrecoderUrl;
-
- var jsondata = {
- carNumber: CarNum,
- terminalSource: '11',
- pageNum: '1',
- pageSize: '500',
- parkState: parkState
- }
-
+export const myRequest = (options) => {
+ // 调接口加载
+ uni.showLoading({
+ title: "加载中",
+ mask: true,
+ });
+ return new Promise((resolve, reject) => {
uni.request({
- url: ParkingrecoderUrl,
- data: JSON.stringify(common.requestSign(jsondata)),
+ url: common,
+ //默认参数
+ data: options.data || {},
+ // 配置请求头参数-例如token
+ header: {
+ 'content-type': 'application/json',
+ Token: common.SetToken,
+ // Accept: 'application/json',
+ // 'Content-Type': 'application/json',
+ // 'X-Requested-With': 'XMLHttpRequest'
+ },
+ dataType: "json",
+ method: options.method || 'GET',
+ // sslVerify: true,
- header: { 'content-type': 'application/json' },
- dataType: "json",
- method: "POST",
+ // 接口请求成功
success: (res) => {
- console.log(JSON.stringify(res.data));
- uni.hideNavigationBarLoading();
+ // 关闭加载
uni.hideLoading();
- if (res.data.code == 0) {
- resolve(res.data);
- }
- else if (res.data.code == -10000) {
- uni.showModal({
- title: '提示',
- content: res.data.message,
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- console.log('登录失效');
- uni.clearStorageSync();
- }
- }
- });
+ console.log('接口所有参数', res);
+ if (res.statusCode !== 200) {
+ // 不同报错信息的提示和配置
+ if (res.statusCode == 500) {
+ return uni.showToast({
+ title: '服务器重启中...',
+ icon: "none",
+ mask: true,
+ })
+ } else {
+ return uni.showToast({
+ title: '获取数据失败',
+ icon: "none",
+ mask: true,
+ })
+ }
}
+ // 调用成功且有数据 返回数据 组件内通过 .then() 或者async await 接受异步返回数据
+ //resolve(res.data)
+ //在接口200 调用成功后 才能进行判断接口内的状态码 return_code 以此判定作何操作和提示
+ const { statusCode, data } = res
+ let return_code = res.data.return_code
+ let return_message = res.data.return_message
+ switch (return_code) {
+ case '0':
+ // 成功的数据data状态码 则直接返回数据
+ resolve(res.data)
+ break
+ case '4011':
+ uni.clearStorage()
+ if (hasUserInfo && !isExisited && !checkToken) {
+ isExisited = true
+ uni.showModal({
+ title: '提示',
+ content: '身份失效,请重新登录!',
+ complete: () => {
+ uni.reLaunch({ url: '/pages/index/index' })
+ },
+ })
+ } else {
+ reject(res.data)
+ }
+ break
+ default:
+ // 其他的如无特定要求 则做提示
+ // reject(res.data)
+ return uni.showToast({
+ title: return_message || '请求失败',
+ duration: 2000,
+ icon: 'none',
+ })
+ }
},
- complete: () => {
- uni.hideNavigationBarLoading();
+ // 接口接口失败
+ fail: (error) => {
+ // 关闭加载
uni.hideLoading();
+ console.log(2, error);
+ uni.showToast({
+ title: '请求接口失败',
+ icon: "none",
+ mask: true,
+ })
+ // 失败数据
+ reject(error)
}
- });
-
- });
-
-}
-
-//js中处理数据
-// const requestSs =function nameCanHidden() {
-// return new Promise(resolve => {
-// setTimeout(() => {
-// resolve('resolved1111111111');
-// }, 2000);
-// });
-// }
-
-//vue中接收处理后的数据
-// async function asyncCall() {
-// console.log('calling');
-// var result = await requestServer.requestSs();
-// console.log(result);
-// // expected output: 'resolved'
-// }
-// asyncCall();
-
-export default {
- searchOrderWithCarNum
-}
+ })
+ })
+}
\ No newline at end of file
diff --git a/main.js b/main.js
index d314399..a600a6c 100644
--- a/main.js
+++ b/main.js
@@ -1,5 +1,9 @@
import App from './App'
import store from './store'
+// 引入封装的接口api
+import { myRequest } from './common/requestServer.js'
+// 挂在Vue属性 全局通过this.$myRequest()可以访问到
+Vue.prototype.$myRequest = myRequest
// #ifndef VUE3
import Vue from 'vue'
diff --git a/manifest.json b/manifest.json
index 1cc7009..8ca275b 100644
--- a/manifest.json
+++ b/manifest.json
@@ -93,7 +93,7 @@
"versionCode" : 100
},
"mp-weixin" : {
- "appid" : "",
+ "appid" : "wxfdc1af620d3ab750",
"setting" : {
"urlCheck" : false
},
diff --git a/pages.json b/pages.json
index 87e01e8..68d5d05 100644
--- a/pages.json
+++ b/pages.json
@@ -14,19 +14,19 @@
"pages": [
// pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
-
{
- "path": "pages/businessCard/cardPrint",
+ "path": "pages/index/index",
"style": {
- "navigationBarTitleText": "卡券打印"
+ "navigationBarTitleText": "商户管理"
}
},
{
- "path": "pages/index/index",
+ "path": "pages/businessCard/cardPrint",
"style": {
- "navigationBarTitleText": "商户管理"
+ "navigationBarTitleText": "卡券打印"
}
},
+
{
"path": "pages/businessCard/printCard",
"style": {
@@ -127,7 +127,7 @@
"navigationBarTitleText": "账单详情"
}
},
- {
+ {
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "商户中心",
@@ -198,71 +198,57 @@
"enablePullDownRefresh": false
}
- }
- ,{
- "path" : "pages/invoiceInformation/invoiceInformation",
- "style" :
- {
- "navigationBarTitleText": "开票信息确认",
- "enablePullDownRefresh": false
- }
+ }, {
+ "path": "pages/invoiceInformation/invoiceInformation",
+ "style": {
+ "navigationBarTitleText": "开票信息确认",
+ "enablePullDownRefresh": false
+ }
- }
- ,{
- "path" : "pages/invoiceTitle/invoiceTitle",
- "style" :
- {
- "navigationBarTitleText": "发票抬头",
- "enablePullDownRefresh": false
- }
+ }, {
+ "path": "pages/invoiceTitle/invoiceTitle",
+ "style": {
+ "navigationBarTitleText": "发票抬头",
+ "enablePullDownRefresh": false
+ }
- }
- ,{
- "path" : "pages/companyMsg/companyMsg",
- "style" :
- {
- "navigationBarTitleText": "详情",
- "enablePullDownRefresh": false
- }
+ }, {
+ "path": "pages/companyMsg/companyMsg",
+ "style": {
+ "navigationBarTitleText": "详情",
+ "enablePullDownRefresh": false
+ }
- }
- ,{
- "path" : "pages/addTitle/addTitle",
- "style" :
- {
- "navigationBarTitleText": "添加抬头",
- "enablePullDownRefresh": false
- }
+ }, {
+ "path": "pages/addTitle/addTitle",
+ "style": {
+ "navigationBarTitleText": "添加抬头",
+ "enablePullDownRefresh": false
+ }
- }
- ,{
- "path" : "pages/editTitle/editTitle",
- "style" :
- {
- "navigationBarTitleText": "编辑抬头",
- "enablePullDownRefresh": false
- }
+ }, {
+ "path": "pages/editTitle/editTitle",
+ "style": {
+ "navigationBarTitleText": "编辑抬头",
+ "enablePullDownRefresh": false
+ }
- }
- ,{
- "path" : "pages/creditRating/creditRating",
- "style" :
- {
- "navigationBarTitleText": "信用等级",
- "enablePullDownRefresh": false
- }
+ }, {
+ "path": "pages/creditRating/creditRating",
+ "style": {
+ "navigationBarTitleText": "信用等级",
+ "enablePullDownRefresh": false
+ }
- }
- ,{
- "path" : "pages/nameAuthentication/nameAuthentication",
- "style" :
- {
- "navigationBarTitleText": "实名认证",
- "enablePullDownRefresh": false
- }
+ }, {
+ "path": "pages/nameAuthentication/nameAuthentication",
+ "style": {
+ "navigationBarTitleText": "实名认证",
+ "enablePullDownRefresh": false
+ }
- }
- ],
+ }
+ ],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "江阴慧停车",
@@ -278,5 +264,5 @@
"navigationBarBackgroundColor": "#F1F1F1"
}
}
-
+
}
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 2e4b7b4..5f150f6 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -16,13 +16,13 @@
-
+
+
@@ -32,7 +32,7 @@
class="face">
张三
-
+
@@ -40,7 +40,7 @@
-
+