diff --git a/.env b/.env new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8c7dae1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +node_modules +dist +*.local +.history +.idea +dist/ +.hbuilderx +keys \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..5bc08f0 --- /dev/null +++ b/index.html @@ -0,0 +1,27 @@ + + + + + + + + + + + +
+ + + diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..730626d --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "types": [ + "@dcloudio/types", + "miniprogram-api-typings", + "mini-types" + ] + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..c79310d --- /dev/null +++ b/package.json @@ -0,0 +1,67 @@ +{ + "name": "uni-preset-vue", + "version": "0.0.0", + "scripts": { + "dev:app": "uni -p app", + "dev:app-android": "uni -p app-android", + "dev:app-ios": "uni -p app-ios", + "dev:custom": "uni -p", + "dev:h5": "uni", + "dev:h5:ssr": "uni --ssr", + "dev:mp-alipay": "uni -p mp-alipay", + "dev:mp-baidu": "uni -p mp-baidu", + "dev:mp-kuaishou": "uni -p mp-kuaishou", + "dev:mp-lark": "uni -p mp-lark", + "dev:mp-qq": "uni -p mp-qq", + "dev:mp-toutiao": "uni -p mp-toutiao", + "dev:mp-weixin": "uni -p mp-weixin", + "dev:quickapp-webview": "uni -p quickapp-webview", + "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei", + "dev:quickapp-webview-union": "uni -p quickapp-webview-union", + "build:app": "uni build -p app", + "build:app-android": "uni build -p app-android", + "build:app-ios": "uni build -p app-ios", + "build:custom": "uni build -p", + "build:h5": "uni build", + "build:h5:ssr": "uni build --ssr", + "build:mp-alipay": "uni build -p mp-alipay", + "build:mp-baidu": "uni build -p mp-baidu", + "build:mp-kuaishou": "uni build -p mp-kuaishou", + "build:mp-lark": "uni build -p mp-lark", + "build:mp-qq": "uni build -p mp-qq", + "build:mp-toutiao": "uni build -p mp-toutiao", + "build:mp-weixin": "uni build -p mp-weixin", + "build:quickapp-webview": "uni build -p quickapp-webview", + "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei", + "build:quickapp-webview-union": "uni build -p quickapp-webview-union" + }, + "dependencies": { + "@amap/amap-jsapi-loader": "^1.0.1", + "@dcloudio/uni-app": "3.0.0-3060520221121001", + "@dcloudio/uni-app-plus": "3.0.0-3060520221121001", + "@dcloudio/uni-components": "3.0.0-3060520221121001", + "@dcloudio/uni-h5": "3.0.0-3060520221121001", + "@dcloudio/uni-mp-alipay": "3.0.0-3060520221121001", + "@dcloudio/uni-mp-baidu": "3.0.0-3060520221121001", + "@dcloudio/uni-mp-kuaishou": "3.0.0-3060520221121001", + "@dcloudio/uni-mp-lark": "3.0.0-3060520221121001", + "@dcloudio/uni-mp-qq": "3.0.0-3060520221121001", + "@dcloudio/uni-mp-toutiao": "3.0.0-3060520221121001", + "@dcloudio/uni-mp-weixin": "3.0.0-3060520221121001", + "@dcloudio/uni-quickapp-webview": "3.0.0-3060520221121001", + "@dcloudio/uni-ui": "^1.4.23", + "@gykeji/jsutil": "^2.0.2", + "vue": "^3.2.37", + "vue-i18n": "^9.1.9", + "vuex": "^4.1.0" + }, + "devDependencies": { + "@dcloudio/types": "^3.0.13", + "@dcloudio/uni-automator": "3.0.0-3060520221121001", + "@dcloudio/uni-cli-shared": "3.0.0-3060520221121001", + "@dcloudio/uni-stacktracey": "3.0.0-3060520221121001", + "@dcloudio/vite-plugin-uni": "3.0.0-3060520221121001", + "sass": "^1.56.2", + "vite": "^2.9.14" + } +} diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..b5f7a25 --- /dev/null +++ b/src/App.vue @@ -0,0 +1,48 @@ + + + diff --git a/src/api/city.js b/src/api/city.js new file mode 100644 index 0000000..354c6ee --- /dev/null +++ b/src/api/city.js @@ -0,0 +1,47 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-12-28 14:42:03 + * @LastEditors: ch + * @LastEditTime: 2022-12-28 14:54:32 + * @Description: file content + */ + +import { _ToAsyncAwait } from '@gykeji/jsutil'; +import MAP_CON from '../config/gdMapConf'; +const formatCity = (data)=>{ + let arr = []; + data.forEach(i => { + if(i.citycode.length){ + arr.push(i); + } + if(i.districts.length){ + arr = arr.concat(formatCity(i.districts)) + } + }); + return arr; +} +/** + * @Description: 获取城市列表,直接使用高德API + * @return {*} + */ +const ApiGetCityList = () => _ToAsyncAwait( + new Promise((res, rej) => { + uni.request({ + method: 'GET', + url: `${MAP_CON.cityApiUrl}?subdistrict=2&key=${MAP_CON.cityKey}`, + success(result){ + res( + formatCity(result.data.districts[0].districts).sort((a,b)=>{ + return a.name.localeCompare(b.name, 'zh-CN'); + }) + ); + }, + error(e){ + rej(e) + } + }) + }) +) +export { + ApiGetCityList +} \ No newline at end of file diff --git a/src/api/order.js b/src/api/order.js new file mode 100644 index 0000000..589ba31 --- /dev/null +++ b/src/api/order.js @@ -0,0 +1,72 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-12-19 15:33:58 + * @LastEditors: ch + * @LastEditTime: 2022-12-30 16:48:20 + * @Description: file content + */ +import { MsbRequest } from "../plugins/requset"; + +const ApiGetUserProgressOrder = () => MsbRequest.get("/UserProgressOrder"); + +/** + * @Description: 获取价格 + * @param {*} + * @return {*} + */ +const ApiGetPrice = ( + params = { + depLongitude, //城市编码 + depLatitude, //出发地纬度 + destLongitude, //目的地纬度 + destLatitude, //目的地纬度 + cityCode, //城市编码 + vehicleType, //车辆类型 + } +) => MsbRequest.post("/forecast-price", params); + +/** + * @Description:乘客下单 + * @return {*} + */ +const ApiPostOrderAdd = ( + data = { + address, + departTime, + orderTime, + departure, + depLongitude, + depLatitude, + destination, + destLongitude, + destLatitude, + encrypt, + fareType, + fareVersion, + passengerId, + passengerPhone, + vehicleType, + } +) => MsbRequest.post("/order/add", data); + +/** + * @Description: 乘客取消订单 + * @param {*} orderId + * @return {*} + */ +const ApiPostOrderCancel = ({orderId}) => MsbRequest.post('/order/cancel',{orderId},{ + 'content-type':'application/x-www-form-urlencoded' +}); +/** + * @Description: 查询当前用户正在进行的订单 + * @return {*} + */ +const ApiGetCurrentOrder = () => MsbRequest.get('/order/current'); + +export { + ApiGetUserProgressOrder, + ApiGetPrice, + ApiPostOrderAdd, + ApiPostOrderCancel, + ApiGetCurrentOrder +}; diff --git a/src/api/user.js b/src/api/user.js new file mode 100644 index 0000000..1653567 --- /dev/null +++ b/src/api/user.js @@ -0,0 +1,38 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-12-19 11:30:32 + * @LastEditors: ch + * @LastEditTime: 2022-12-30 18:19:04 + * @Description: file content + */ +import { MsbRequest } from '../plugins/requset'; + +/** + * @Description: 获取验证码 + * @param {*} passengerPhone + * @return {*} + */ +const ApiGetVerifyCode = ({passengerPhone}) => MsbRequest.post('/verification-code',{ + passengerPhone +},{notVerifyToken:true}) +/** + * @Description: 验证验证码 + * @param {*} passengerPhone + * @param {*} verificationCode + * @return {*} + */ +const ApiPostVerifyCodeCheck = ({passengerPhone,verificationCode}) => MsbRequest.post('/verification-code-check',{ + passengerPhone, + verificationCode, +},{notVerifyToken:true}) +/** + * @Description: 根据token获取乘客信息 + * @return {*} + */ +const ApiGetUserInfo = () => MsbRequest.get('/users/'); + +export { + ApiGetVerifyCode, + ApiPostVerifyCodeCheck, + ApiGetUserInfo +} \ No newline at end of file diff --git a/src/component/BMap.vue b/src/component/BMap.vue new file mode 100644 index 0000000..7abac14 --- /dev/null +++ b/src/component/BMap.vue @@ -0,0 +1,191 @@ + + + + + + + + \ No newline at end of file diff --git a/src/component/BSseMessage.vue b/src/component/BSseMessage.vue new file mode 100644 index 0000000..077702f --- /dev/null +++ b/src/component/BSseMessage.vue @@ -0,0 +1,26 @@ + + \ No newline at end of file diff --git a/src/config/dicts.js b/src/config/dicts.js new file mode 100644 index 0000000..acafcf7 --- /dev/null +++ b/src/config/dicts.js @@ -0,0 +1,31 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-12-27 14:52:17 + * @LastEditors: ch + * @LastEditTime: 2022-12-30 16:33:24 + * @Description: 字典表 + */ +const ORDER_STATUS = { + // 乘客发起订单 + orderStart : 1, + // 司机接单 + driverReceive: 2, + // 司机去接乘客 + driverToPickUp: 3, + // 司机到底上车点 + driverArriveStartPoint: 4, + // 行程开始,乘客上车 + tripStart: 5, + // 行程结束,到达目的地 + tripFinish: 6, + // 发起收款,待支付 + awaitPay: 7, + // 付款完成,订单完成 + orderFinish: 8, + // 订单取消 + orderCancel: 9, + +} +export { + ORDER_STATUS +} \ No newline at end of file diff --git a/src/config/gdMapConf.js b/src/config/gdMapConf.js new file mode 100644 index 0000000..9108ae1 --- /dev/null +++ b/src/config/gdMapConf.js @@ -0,0 +1,24 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-12-28 14:39:29 + * @LastEditors: ch + * @LastEditTime: 2022-12-30 16:35:53 + * @Description: 高德地图配置,需要自行去高德开放平台申请 + */ +export default { + // 高德地图JS Api key + key:'accb4fe7de2b5efd04f187dc0f978777', + // 高德地图JS Api key对应的秘钥,正式环境最好不要放前端 + securityJsCode : '617eba916a16270f5fa3203a4ee2e2a6', + // 城市获取key + cityKey : 'fe5524e832a0fc6e2bcaf1bb781ac830', + // 高德城市请求地址 + cityApiUrl : 'https://restapi.amap.com/v3/config/district', + // 默认选中城市 + city: { + adcode: "110000", + center: "116.407387,39.904179", + citycode: "010", + name: "北京市" + } +} \ No newline at end of file diff --git a/src/config/serverConf.js b/src/config/serverConf.js new file mode 100644 index 0000000..3f64f0e --- /dev/null +++ b/src/config/serverConf.js @@ -0,0 +1,27 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-12-30 14:47:25 + * @LastEditors: ch + * @LastEditTime: 2022-12-30 15:42:42 + * @Description: 服务端配置 + */ + +export default { + // #ifdef H5 + // 支付服务 + pay: '/payApi', + // sse服务 + sse: '/sseApi', + // 其他接口服务 + other: '/api', + // #endif + + // #ifdef APP-PLUS ||MP + // 支付服务 + pay: 'http://192.168.40.193:9001', + // sse服务 + sse: 'http://192.168.40.193:60001', + // 其他接口服务 + other: 'http://192.168.40.193:8081' + // #endif +} \ No newline at end of file diff --git a/src/config/storageKey.js b/src/config/storageKey.js new file mode 100644 index 0000000..802c21a --- /dev/null +++ b/src/config/storageKey.js @@ -0,0 +1,13 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-12-19 10:58:26 + * @LastEditors: ch + * @LastEditTime: 2022-12-30 14:51:56 + * @Description: 本地存储key管理 + */ +const STORAGE_KEY = { + token : 'tk', + userInfo : 'u_i', + serverConf: 's_c' +} +export default STORAGE_KEY; \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..9733527 --- /dev/null +++ b/src/main.js @@ -0,0 +1,19 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-11-21 17:23:51 + * @LastEditors: ch + * @LastEditTime: 2022-12-13 17:41:14 + * @Description: file content + */ +import { + createSSRApp +} from "vue"; +import App from "./App.vue"; +import store from './store' +export function createApp() { + const app = createSSRApp(App); + app.use(store) + return { + app, + }; +} diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..e9002f9 --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,76 @@ +{ + "name" : "飞滴出行", + "appid" : "__UNI__390779D", + "description" : "", + "versionName" : "1.0.0", + "versionCode" : "100", + "transformPx" : false, + /* 5+App特有相关 */ + "app-plus" : { + "usingComponents" : true, + "nvueStyleCompiler" : "uni-app", + "compilerVersion" : 3, + "splashscreen" : { + "alwaysShowBeforeRender" : true, + "waiting" : true, + "autoclose" : true, + "delay" : 0 + }, + /* 模块配置 */ + "modules" : {}, + /* 应用发布信息 */ + "distribute" : { + /* android打包配置 */ + "android" : { + "permissions" : [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + /* ios打包配置 */ + "ios" : {}, + /* SDK配置 */ + "sdkConfigs" : { + "maps" : {}, + "payment" : { + "alipay" : { + "__platform__" : [ "ios", "android" ] + } + } + } + } + }, + /* 快应用特有相关 */ + "quickapp" : {}, + /* 小程序特有相关 */ + "mp-weixin" : { + "appid" : "", + "setting" : { + "urlCheck" : false + }, + "usingComponents" : true + }, + "mp-alipay" : { + "usingComponents" : true + }, + "mp-baidu" : { + "usingComponents" : true + }, + "mp-toutiao" : { + "usingComponents" : true + }, + "uniStatistics" : { + "enable" : false + }, + "vueVersion" : "3" +} diff --git a/src/pages.json b/src/pages.json new file mode 100644 index 0000000..d86db06 --- /dev/null +++ b/src/pages.json @@ -0,0 +1,60 @@ +{ + "pages": [ + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "飞滴出行", + "titleImage":"/static/logo.png" + } + }, + { + "path": "pages/city", + "style": { + "navigationBarTitleText": "飞滴出行", + "titleImage":"/static/logo.png" + } + }, + { + "path": "pages/createOrder", + "style": { + // "navigationBarTitleText": "飞滴出行", + "titleImage":"/static/logo.png" + } + }, + { + "path": "pages/orderDetail", + "style": { + // "navigationBarTitleText": "飞滴出行", + "titleImage":"/static/logo.png" + } + }, + { + "path": "pages/pay", + "style": { + // "navigationBarTitleText": "飞滴出行", + "titleImage":"/static/logo.png" + } + }, + { + "path": "pages/login", + "style": { + // "navigationBarTitleText": "飞滴出行", + "titleImage":"/static/logo.png" + } + }, + { + "path": "pages/account", + "style": { + // "navigationBarTitleText": "飞滴出行", + "titleImage":"/static/logo.png" + } + } + + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "uni-app", + "navigationBarBackgroundColor": "#F8F8F8", + "backgroundColor": "#F8F8F8" + } +} diff --git a/src/pages/account.vue b/src/pages/account.vue new file mode 100644 index 0000000..70e333e --- /dev/null +++ b/src/pages/account.vue @@ -0,0 +1,76 @@ + + + \ No newline at end of file diff --git a/src/pages/city.vue b/src/pages/city.vue new file mode 100644 index 0000000..052dec1 --- /dev/null +++ b/src/pages/city.vue @@ -0,0 +1,87 @@ + + + diff --git a/src/pages/createOrder.vue b/src/pages/createOrder.vue new file mode 100644 index 0000000..89688a4 --- /dev/null +++ b/src/pages/createOrder.vue @@ -0,0 +1,194 @@ + + + \ No newline at end of file diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue new file mode 100644 index 0000000..c315e9a --- /dev/null +++ b/src/pages/index/index.vue @@ -0,0 +1,97 @@ + + + \ No newline at end of file diff --git a/src/pages/index/modules/PointList.vue b/src/pages/index/modules/PointList.vue new file mode 100644 index 0000000..0b61c54 --- /dev/null +++ b/src/pages/index/modules/PointList.vue @@ -0,0 +1,105 @@ + + + \ No newline at end of file diff --git a/src/pages/index/modules/SelectPoint.vue b/src/pages/index/modules/SelectPoint.vue new file mode 100644 index 0000000..3db8459 --- /dev/null +++ b/src/pages/index/modules/SelectPoint.vue @@ -0,0 +1,104 @@ + + + \ No newline at end of file diff --git a/src/pages/login.vue b/src/pages/login.vue new file mode 100644 index 0000000..957793d --- /dev/null +++ b/src/pages/login.vue @@ -0,0 +1,123 @@ + + + + + \ No newline at end of file diff --git a/src/pages/orderDetail.vue b/src/pages/orderDetail.vue new file mode 100644 index 0000000..f89f8cf --- /dev/null +++ b/src/pages/orderDetail.vue @@ -0,0 +1,129 @@ + + + \ No newline at end of file diff --git a/src/pages/pay.vue b/src/pages/pay.vue new file mode 100644 index 0000000..33ee953 --- /dev/null +++ b/src/pages/pay.vue @@ -0,0 +1,17 @@ + + \ No newline at end of file diff --git a/src/plugins/Base64Markers.js b/src/plugins/Base64Markers.js new file mode 100644 index 0000000..c0fa4c7 --- /dev/null +++ b/src/plugins/Base64Markers.js @@ -0,0 +1,9 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-12-12 15:13:46 + * @LastEditors: ch + * @LastEditTime: 2022-12-12 15:14:01 + * @Description: file content + */ + +export const MarkerIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0I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7kQiNxEAEliINJ0ZDcQUAJ4k4uNBIHEfg/7IRlBdYE9YkAAAAASUVORK5CYII=" \ No newline at end of file diff --git a/src/plugins/msbUniRequest.js b/src/plugins/msbUniRequest.js new file mode 100644 index 0000000..4070b80 --- /dev/null +++ b/src/plugins/msbUniRequest.js @@ -0,0 +1,123 @@ +/* + * @Author: ch + * @Date: 2022-03-17 16:36:59 + * @LastEditors: ch + * @LastEditTime: 2023-01-03 11:23:23 + * @Description: 针对uniapp request请求做了一次封装,使用思维参考axios + * + * + * 方法 + * method(option) 自定义请求,同uni.request + * get(url, params, header) url 请求地址 params 请求参数 + * header 请求头会针对当前请求头设置特定的请求头。传了此参数request拦截器会失效 + * post(url, data, header) 同上 + * put(url, data, header) 同上 + * delete(url, data, header) 同上 + * use(hookName, callback) 注入hook拦截器 hookName 拦截器名(request/response/error) callback拦截器具体见拦截器说明 + * + * 属性 + * baseUrl 请求地址前缀 + * + * 拦截器 + * request 请求前拦截,在这可统一设置请求头,请求体等参数。uni.request的第一个参数option都可以重置 + * success 请求成功结果拦截 + * error 请求错误拦截 + * + * 示例 + * const myReq = new MsbUniRequest(); + * myReq.baseUrl = 'xxxx' + * myReq.use('request', (option)=>{ + * // option 返回请求配置 + * .....这里可以对option做一系列操作 + * return option //最后返回一个正确的请求配置 + * }) + * myReq.use('success', (res)=>{ + * //res 返回请求结果 + * let newRes = ..... //这里可以对请求结果做统一处理 + * return newRes + * }) + * + * myReq.use('error', (error)=>{ + * //error 返回错误结果 + * let newError = ..... //这里可以对请求错误做统一处理 + * return newError + * }) + */ +class MsbUniRequest { + constructor (option){ + this.baseUrl = ''; + this.header = { + repeat : true + } + this.hook = { + request : null, + success : null, + error : null + } + + } + method(option){ + option.header = {...this.header,...option.header}; + option.url = this.baseUrl ? this.baseUrl + option.url : option.url; + if(this.hook.request){ + option = this.hook.request(option); + }; + + if(!option){ + throw new Error('没有请求配置,或是request拦截未做return'); + } + if(option.constructor === Promise){ + return option + } + return new Promise((resolve, reject)=>{ + uni.request({ + ...option, + success: res => { + const response = res || res[1]; + // 200 - 399状态为正常 + if(response.statusCode >= 200 && response.statusCode < 400){ + if(!this.hook.success){ + resolve(response); + }else{ + let newRes = this.hook.success(response, option); + // 业务结果处理可能为一个Promise对象,根据结果调用错误或正确状态 + if(newRes && newRes.constructor === Promise){ + newRes.then(res => { + resolve(res); + }, error =>{ + reject(error); + }) + }else{ + resolve(newRes); + } + } + return false; + } + reject(this.hook.error ? this.hook.error(response, option) : response); + + }, + fail: error =>{ + reject(this.hook.error ? this.hook.error(error, option) : error); + + } + }); + }); + } + use(hookName, cb){ + this.hook[hookName] = cb; + } + get(url, data, header){ + return this.method({method : 'GET', url, data, header}); + } + post(url, data, header){ + return this.method({method : 'POST', url, data, header}); + } + put(url, data, header){ + return this.method({method : 'PUT', url, data, header}); + } + delete(url, data, header){ + return this.method({method : 'DELETE', url, data, header}); + } +} + +export default MsbUniRequest; \ No newline at end of file diff --git a/src/plugins/requset.js b/src/plugins/requset.js new file mode 100644 index 0000000..3cd887e --- /dev/null +++ b/src/plugins/requset.js @@ -0,0 +1,125 @@ +/* + * @Author: ch + * @Date: 2022-03-17 17:42:32 + * @LastEditors: ch + * @LastEditTime: 2022-12-30 15:44:40 + * @Description: 项目接口请求统一处理器,返回一个需要token和不需要token的请求封装方法 + */ + +import MsbUniRequest from './msbUniRequest'; +import $store from '@/store'; +import { _ToAsyncAwait } from '@gykeji/jsutil'; +// const ENV = process.env; + +/** + * 接口返回成功结果统一处理 + * @param {*} response + * @param {*} option + */ +const successIntercept = (response, option) =>{ + clearRepeat(option); + if(response.statusCode === 200){ + const result = response.data; + if(result.code === 1){ + return result.data; + } + if(result.code === 0){ + uni.navigateTo({url : '/login'}); + $store.commit('setToken', ''); + return result; + } + return Promise.reject(result); + } + return response; +} +/** + * 接口返回错误结果统一处理 + * @param {*} error + * @param {*} option + */ +const errorIntercept = (error, option) =>{ + clearRepeat(option); + if(error.statusCode === 404){ + error.errMsg = '404 请求地址未找到'; + } + return {message:error.errMsg,code:error.statusCode} +} + +//正在执行的请求标识 +let repeatFlag = []; +/** + * 验证是否重复请求,没有则添加一条到标记 + * @param {*} option + */ +const repeatVerify = (option)=>{ + let flag = { + url : option.url, + method : option.method, + data : option.data + } + if(repeatFlag.includes(JSON.stringify(flag))){ + return Promise.reject({message:'请勿频繁操作'}); + } + repeatFlag.push(JSON.stringify(flag)); + return false; +}; +/** + * 清除请求标记 + * @param {*} option + */ +const clearRepeat = (option) =>{ + repeatFlag = repeatFlag.filter( i => { + return i !== JSON.stringify({ + url : option.url, + method : option.method, + data : option.data + }) + }); +} + + + +// 接口封装 +const Request = new MsbUniRequest(); + +Request.baseUrl = $store.state.serverConf.other; + + +Request.use('request', (option) => { + const token = $store.state.token; + if(!token && !option.header.notVerifyToken){ + // 登录状态处理,没有token直接跳转至登录 + uni.redirectTo({ + url: '/pages/login' + }); + return Promise.reject({message:'要先登录才能操作哦~'}); + } + if(!option.header.notVerifyToken){ + option.header = {...option.header, Authorization:token}; + } + + + if(option.header.repeat){ + // 如果当前请求不允许重复调用,则检查重复请求,当前接口有正在请求则不发起请求 + const isRepeatVerify = repeatVerify(option); + if(isRepeatVerify){ + return isRepeatVerify; + } + } + delete option.header.repeat + delete option.header.notVerifyToken + return option; +}) +Request.use('success', successIntercept); +Request.use('error', errorIntercept); + +const MsbRequest = { + get : (...args) => _ToAsyncAwait(Request.get(...args)), + post: (...args) => _ToAsyncAwait(Request.post(...args)), + put: (...args) => _ToAsyncAwait(Request.put(...args)), + delete: (...args) => _ToAsyncAwait(Request.delete(...args)), +} +export { + MsbRequest +} + diff --git a/src/static/logo.png b/src/static/logo.png new file mode 100644 index 0000000..a32d63d Binary files /dev/null and b/src/static/logo.png differ diff --git a/src/static/sseMessage.html b/src/static/sseMessage.html new file mode 100644 index 0000000..ae86e3a --- /dev/null +++ b/src/static/sseMessage.html @@ -0,0 +1,67 @@ + + + + + + + + - + + + + diff --git a/src/static/uniwebview.js b/src/static/uniwebview.js new file mode 100644 index 0000000..c4bfbca --- /dev/null +++ b/src/static/uniwebview.js @@ -0,0 +1,8 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-12-19 17:44:42 + * @LastEditors: ch + * @LastEditTime: 2022-12-19 17:47:42 + * @Description: file content + */ +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).uni=n()}(this,(function(){"use strict";try{var e={};Object.defineProperty(e,"passive",{get:function(){!0}}),window.addEventListener("test-passive",null,e)}catch(e){}var n=Object.prototype.hasOwnProperty;function i(e,i){return n.call(e,i)}var t=[];function r(){return window.__dcloud_weex_postMessage||window.__dcloud_weex_}var o=function(e,n){var i={options:{timestamp:+new Date},name:e,arg:n};if(r()){if("postMessage"===e){var o={data:[n]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(o):window.__dcloud_weex_.postMessage(JSON.stringify(o))}var a={type:"WEB_INVOKE_APPSERVICE",args:{data:i,webviewIds:t}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(a):window.__dcloud_weex_.postMessageToService(JSON.stringify(a))}if(!window.plus)return window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:i,pageId:""},"*");if(0===t.length){var d=plus.webview.currentWebview();if(!d)throw new Error("plus.webview.currentWebview() is undefined");var s=d.parent(),w="";w=s?s.id:d.id,t.push(w)}if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:i,webviewIds:t}},"__uniapp__service");else{var u=JSON.stringify(i);plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat("WEB_INVOKE_APPSERVICE",'",').concat(u,",").concat(JSON.stringify(t),");"))}},a={navigateTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;o("navigateTo",{url:encodeURI(n)})},navigateBack:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.delta;o("navigateBack",{delta:parseInt(n)||1})},switchTab:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;o("switchTab",{url:encodeURI(n)})},reLaunch:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;o("reLaunch",{url:encodeURI(n)})},redirectTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;o("redirectTo",{url:encodeURI(n)})},getEnv:function(e){r()?e({nvue:!0}):window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o("postMessage",e.data||{})}},d=/uni-app/i.test(navigator.userAgent),s=/Html5Plus/i.test(navigator.userAgent),w=/complete|loaded|interactive/;var u=window.my&&navigator.userAgent.indexOf(["t","n","e","i","l","C","y","a","p","i","l","A"].reverse().join(""))>-1;var g=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var v=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var c=window.tt&&window.tt.miniProgram&&/toutiaomicroapp/i.test(navigator.userAgent);var m=window.wx&&window.wx.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var p=window.qa&&/quickapp/i.test(navigator.userAgent);var f=window.ks&&window.ks.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var l=window.tt&&window.tt.miniProgram&&/Lark|Feishu/i.test(navigator.userAgent);var _=window.jd&&window.jd.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var E=window.xhs&&window.xhs.miniProgram&&/xhsminiapp/i.test(navigator.userAgent);for(var h,P=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},b=[function(e){if(d||s)return window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",e):window.plus&&w.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),a},function(e){if(m)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(v)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(u){document.addEventListener("DOMContentLoaded",e);var n=window.my;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(g)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(c)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(p){window.QaJSBridge&&window.QaJSBridge.invoke?setTimeout(e,0):document.addEventListener("QaJSBridgeReady",e);var n=window.qa;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(f)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.ks.miniProgram},function(e){if(l)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(_)return window.JDJSBridgeReady&&window.JDJSBridgeReady.invoke?setTimeout(e,0):document.addEventListener("JDJSBridgeReady",e),window.jd.miniProgram},function(e){if(E)return window.xhs.miniProgram},function(e){return document.addEventListener("DOMContentLoaded",e),a}],y=0;y{ + let result = false; + if (error) { + const tip = name ? `${name}错误:` : ''; + ShowToast(error.message ? `${tip}${error.message}` : `请求失败: ${error}`); + result = true; + } + return result; +} +const ShowToast = (str) =>{ + uni.showToast({title:str,duration:3000, icon:'none'}); +} +export { + HandleApiError, + ShowToast +} \ No newline at end of file diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..0f2178a --- /dev/null +++ b/vite.config.js @@ -0,0 +1,38 @@ +/* + * @Author: ch cwl_ch@163.com + * @Date: 2022-11-21 17:23:51 + * @LastEditors: ch + * @LastEditTime: 2022-12-30 16:32:05 + * @Description: file content + */ +import { defineConfig } from 'vite' +import uni from '@dcloudio/vite-plugin-uni' +import fs from 'fs'; +import path from 'path'; +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [ + uni(), + ], + server: { + // 浏览器本地开发代理配置 + proxy: { + "/api": { + target: "http://192.168.40.193:8081", + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, "/") + }, + "/sseApi": { + target: "http://192.168.40.193:60001", + changeOrigin: true, + rewrite: (path) => path.replace(/^\/sseApi/, "/") + }, + + "/payApi": { + target: "http://192.168.40.193:9001", + changeOrigin: true, + rewrite: (path) => path.replace(/^\/payApi/, "/") + }, + }, + }, +})