wangguoyu hace 6 meses
padre
commit
0c4f4855d7
Se han modificado 7 ficheros con 88 adiciones y 276 borrados
  1. 10 0
      common/prototype.js
  2. 4 0
      main.js
  3. 49 20
      package.json
  4. 21 5
      unpackage/dist/cache/.vite/deps/_metadata.json
  5. 4 0
      utils/global.js
  6. 0 178
      utils/request copy 1.js
  7. 0 73
      utils/request copy.js

+ 10 - 0
common/prototype.js

@@ -0,0 +1,10 @@
+/**
+ * @全局挂载
+ * @API 全局事件
+ */
+import global from '../utils/global'
+export default {
+    install(app) {
+        app.config.globalProperties.$global = global
+    }
+}

+ 4 - 0
main.js

@@ -3,9 +3,13 @@ import App from './App.vue'
 //import plugins from './plugins' // plugins
 //import './permission' // permission
 import { createPinia } from 'pinia'
+import uviewPlus from 'uview-plus'
+import prototype from './common/prototype.js'//全局挂载
+const pinia = createPinia()
 // 创建Vue应用实例
 const app = createApp(App)
 //app.use(plugins)
 app.use(createPinia())
+app.use(uviewPlus)
 // 挂载Vue应用实例
 app.mount('#app')

+ 49 - 20
package.json

@@ -1,22 +1,51 @@
 {
-  "name": "hbproject",
-  "version": "1.0.0",
-  "description": "",
-  "main": "main.js",
-  "dependencies": {
-    "axios": "^1.7.2",
-    "jsencrypt": "^3.3.2",
-    "pinia": "^2.1.7",
-    "ts-md5": "^1.3.1"
-  },
-  "devDependencies": {},
-  "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1112"
-  },
-  "repository": {
-    "type": "git",
-    "url": "https://gogs.mtavip.com/wangguoyu/uniProject.git"
-  },
-  "author": "",
-  "license": "ISC"
+	"name": "hbproject",
+	"version": "1.0.0",
+	"description": "",
+	"main": "main.js",
+	"dependencies": {
+		"axios": "^1.7.2",
+		"jsencrypt": "^3.3.2",
+		"pinia": "^2.1.7",
+		"ts-md5": "^1.3.1",
+		"uview-plus": "^3.3.42",
+		"vue": "^3.5.13"
+	},
+	"devDependencies": {},
+	"uni-app": {
+		"scripts": {
+			"dev-h5": {
+				"title": "开发环境H5",
+				"BROWSER": "chrome",
+				"env": {
+					"UNI_PLATFORM": "h5",
+					"UNI_APP_URL": "https://www.wgy.com",
+					"UNI_BASE_URL": "https://www.wgy.com"
+				},
+				"define": {
+					"DEV-H5": true
+				}
+			},
+			"prod-h5": {
+				"title": "生产环境H5",
+				"BROWSER": "chrome",
+				"env": {
+					"UNI_PLATFORM": "h5",
+					"UNI_APP_URL": "https://www.wgy.com"
+				},
+				"define": {
+					"PROD-H5": true
+				}
+			}
+		}
+	},
+	"scripts": {
+		"dev:h5": "uni"
+	},
+	"repository": {
+		"type": "git",
+		"url": "https://gogs.mtavip.com/wangguoyu/uniProject.git"
+	},
+	"author": "",
+	"license": "ISC"
 }

+ 21 - 5
unpackage/dist/cache/.vite/deps/_metadata.json

@@ -1,15 +1,31 @@
 {
-  "hash": "88503f0e",
-  "configHash": "ea4e468c",
+  "hash": "2a404f3e",
+  "configHash": "088a760f",
   "lockfileHash": "e3b0c442",
-  "browserHash": "38e76d38",
+  "browserHash": "ffd0a475",
   "optimized": {
+    "jsencrypt": {
+      "src": "../../../../../node_modules/jsencrypt/lib/index.js",
+      "file": "jsencrypt.js",
+      "fileHash": "03d4dde8",
+      "needsInterop": false
+    },
     "ts-md5/dist/md5": {
       "src": "../../../../../node_modules/ts-md5/dist/md5.js",
       "file": "ts-md5_dist_md5.js",
-      "fileHash": "c0f874e9",
+      "fileHash": "edc4dd39",
       "needsInterop": true
+    },
+    "uview-plus": {
+      "src": "../../../../../node_modules/uview-plus/index.js",
+      "file": "uview-plus.js",
+      "fileHash": "111ff084",
+      "needsInterop": false
     }
   },
-  "chunks": {}
+  "chunks": {
+    "chunk-Y2F7D3TJ": {
+      "file": "chunk-Y2F7D3TJ.js"
+    }
+  }
 }

+ 4 - 0
utils/global.js

@@ -0,0 +1,4 @@
+export default {
+
+
+}

+ 0 - 178
utils/request copy 1.js

@@ -1,178 +0,0 @@
-import axios     from 'axios';
-import { Md5 }   from 'ts-md5/dist/md5';
-import config from '@/config'
-let noTimeoutLimitArr = [
-
-];
-
-// create an axios instance
-const service = axios.create({
-                                 baseURL:         config.baseUrl, // url = base url + request url
-                                 withCredentials: false, // send cookies when cross-domain requests
-                                 timeout:         20000, // request timeout
-                             });
-
-export let needLoadingRequestCount = 0;
-export function showFullScreenLoading(config) {
-    if (needLoadingRequestCount === 0) {
-        store.state.isLoading = true
-    }
-    needLoadingRequestCount++;
-}
-
-export function tryHideFullScreenLoading() {
-    if (needLoadingRequestCount <= 0) {
-        return;
-    }
-
-    needLoadingRequestCount--;
-    if (needLoadingRequestCount === 0) {
-        store.state.isLoading = false
-    }
-}
-// request interceptor
-service.interceptors.request.use(
-    config => {
-        // do something before request is sent
-        // console.log(config);
-
-        function setTimeoutunlimit(config) {
-            // if (_.indexOf(noTimeoutLimitArr, config.url) > -1) {
-            //     config.timeout = 9999999999;
-            // }
-        }
-
-        function mixSignAndToken(config) {
-		//	debugger
-            // console.log(config.data, process.env.VUE_APP_BASE_API, process.env.VUE_APP_SECRET_KEY);
-            const checkurl = function (url) {
-                if (url === '/common/active') {
-                    return false;
-                }
-                // 用户端白名单
-                if (url.indexOf('/common') > -1) {
-                    return true;
-                }
-                // 管理端白名单
-                if (url === '/admin/user/auth') {
-                    return true;
-                }
-                // 短信服务白名单
-                if (url === 'sms/sendCode') {
-                    return true;
-                }
-                return false;
-            };
-			
-            if (checkurl(config.url)) {
-                if(config.url.indexOf('/open' >-1)){
-                }else {
-                    config.headers['X-AUTH-SIGN'] = Md5.hashStr(JSON.stringify(config.data) + '123');
-                }
-            } else {
-                if (store.state.auth) {
-                    config.headers['X-AUTH-SIGN'] = Md5.hashStr(JSON.stringify(config.data) + store.state.auth.secret);
-                    config.headers['X-AUTH-TOKEN'] = store.state.auth.token;
-                } else {
-                    // 非登录操作,但没有auth,跳转登录
-                    router.push('/' + store.state.tenantCode + '/login');
-                }
-            }
-
-        }
-        // if (!JSON.stringify(config.data.customLoadingSwitch)) {
-        //     //  如不需要在data中 LoadingSwitch:false
-        //     console.log('有loading');
-        //     showFullScreenLoading(config);
-        // }
-        mixSignAndToken(config);
-        setTimeoutunlimit(config);
-
-        /*if (store.getters.token) {
-            // let each request carry token
-            // ['X-Token'] is a custom headers key
-            // please modify it according to the actual situation
-            config.headers['X-Token'] = getToken();
-        }*/
-        return config;
-    },
-    error => {
-        // do something with request error
-        // console.log(error); // for debug
-        return Promise.reject(error);
-    },
-);
-
-
-
-// response interceptor
-service.interceptors.response.use(
-    /**
-     * If you want to get http information such as headers or status
-     * Please return  response => response
-     */
-
-    /**
-     * Determine the request status by custom code
-     * Here is just an example
-     * You can also judge the status by HTTP Status Code
-     */
-    response => {
-        const res = response.data;
-
-        // if the custom code is not 20000, it is judged as an error.
-        if (res.code !== 0) {
-    
-            // 401:登录超时
-            if (res.code === 401) {
-                setTimeout(function () {
-                    if (window.loading) {
-                        window.loading.close();
-                    }
-                    // console.log(router);
-                    /*if (router.app.$route.path.indexOf('/c/') === 0) {
-                        router.push('/c/' + store.state.tenantCode + '/login');
-                    } else {
-                        router.push('/a/' + store.state.tenantCode + '/login');
-                    }*/
-                    store.state.showBottomNav = true;
-                    router.push('/login');
-                }, 2000);
-            }
-            if (res.code === 405) {
-                setTimeout(function () {
-                    if (window.loading) {
-                        window.loading.close();
-                    }
-                    store.state.showBottomNav = true;
-                    router.push('/login');
-                }, 2000);
-            }
-
-            if (res.code === 502) {
-            //    Toast.fail('bad gateway');
-            }
-            if (res.code === 500 || res.code === 1001|| res.code ===1002) {
-                tryHideFullScreenLoading();
-                return Promise.reject('error' + res.code + '-' + (res.message === undefined ? 'nomessage': res.message));
-            }
-            tryHideFullScreenLoading();
-            return Promise.reject(res.message || 'error');
-        } else {
-            tryHideFullScreenLoading();
-            return res;
-        }
-    },
-    error => {
-
-        if (error == 'Error: Network Error') {
-        //    Toast.fail('网络断开,请检查网络');
-        } else {
-         //   Toast.fail('其他错误,请联系管理员');
-        }
-        tryHideFullScreenLoading();
-        return Promise.reject(error);
-    },
-);
-
-export default service;

+ 0 - 73
utils/request copy.js

@@ -1,73 +0,0 @@
-import store from '@/store'
-import config from '@/config'
-import { getToken } from '@/utils/auth'
-import errorCode from '@/utils/errorCode'
-import { toast, showConfirm, tansParams } from '@/utils/common'
-
-let timeout = 10000
-const baseUrl = config.baseUrl
-
-const request = config => {
-  // 是否需要设置 token
-  const isToken = (config.headers || {}).isToken === false
-  config.header = config.header || {}
-  if (getToken() && !isToken) {
-    config.header['Authorization'] = 'Bearer ' + getToken()
-  }
-  // get请求映射params参数
-  if (config.params) {
-    let url = config.url + '?' + tansParams(config.params)
-    url = url.slice(0, -1)
-    config.url = url
-  }
-  return new Promise((resolve, reject) => {
-    uni.request({
-        method: config.method || 'get',
-        timeout: config.timeout ||  timeout,
-        url: config.baseUrl || baseUrl + config.url,
-        data: config.data,
-        header: config.header,
-        dataType: 'json'
-      }).then(response => {
-        let [error, res] = response
-        if (error) {
-          toast('后端接口连接异常')
-          reject('后端接口连接异常')
-          return
-        }
-        const code = res.data.code || 200
-        const msg = errorCode[code] || res.data.msg || errorCode['default']
-        if (code === 401) {
-          showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
-            if (res.confirm) {
-              store.dispatch('LogOut').then(res => {
-                uni.reLaunch({ url: '/pages/login' })
-              })
-            }
-          })
-          reject('无效的会话,或者会话已过期,请重新登录。')
-        } else if (code === 500) {
-          toast(msg)
-          reject('500')
-        } else if (code !== 200) {
-          toast(msg)
-          reject(code)
-        }
-        resolve(res.data)
-      })
-      .catch(error => {
-        let { message } = error
-        if (message === 'Network Error') {
-          message = '后端接口连接异常'
-        } else if (message.includes('timeout')) {
-          message = '系统接口请求超时'
-        } else if (message.includes('Request failed with status code')) {
-          message = '系统接口' + message.substr(message.length - 3) + '异常'
-        }
-        toast(message)
-        reject(error)
-      })
-  })
-}
-
-export default request