diff --git a/.env b/.env
index df21f30..3b992e0 100644
--- a/.env
+++ b/.env
@@ -1,2 +1,3 @@
-VITE_API_URL=https://m1.apifoxmock.com
-VITE_AES_KEY=4e2c3d4e5f6a7b8c9d0e1f2g3h4i5j6k7l8m9n0o1p2q3r4s5t6u7v8w9x0y1z2
+VITE_API_URL=http://192.168.1.105/api
+VITE_TINYMCE_KEY=agmu6i1c6k7bcp36oenzyz7yi1yplptq7goyx88y1g6ofnqu
+VITE_AES_KEY=st123456654321st
diff --git a/package.json b/package.json
index 0ec8339..5343b6a 100644
--- a/package.json
+++ b/package.json
@@ -57,6 +57,7 @@
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-4050420250306001",
"@tailwindcss/vite": "^4.0.15",
"@uni-helper/vite-plugin-uni-tailwind": "^0.15.2",
+ "axios": "^1.9.0",
"crypto-js": "^4.2.0",
"dayjs": "^1.11.13",
"deep-pick-omit": "^1.2.1",
@@ -68,6 +69,7 @@
"tailwindcss": "^4.0.15",
"tailwindcss-rem2px-preset": "^1.0.3",
"thorui-uni": "^3.0.0",
+ "uniapp-axios-adapter": "^0.3.2",
"uqrcodejs": "^4.0.7",
"uuid": "^11.1.0",
"vue": "^3.5.13",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ba1bff0..e3cd525 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -62,6 +62,9 @@ importers:
'@uni-helper/vite-plugin-uni-tailwind':
specifier: ^0.15.2
version: 0.15.2(rollup@4.37.0)(tailwindcss@4.1.5)(vite@6.3.5(@types/node@22.13.11)(jiti@2.4.2)(lightningcss@1.29.2)(sass-embedded@1.86.0)(terser@5.39.0)(yaml@2.7.1))
+ axios:
+ specifier: ^1.9.0
+ version: 1.9.0
crypto-js:
specifier: ^4.2.0
version: 4.2.0
@@ -95,6 +98,9 @@ importers:
thorui-uni:
specifier: ^3.0.0
version: 3.0.0
+ uniapp-axios-adapter:
+ specifier: ^0.3.2
+ version: 0.3.2(axios@1.9.0)
uqrcodejs:
specifier: ^4.0.7
version: 4.0.7
@@ -2257,6 +2263,9 @@ packages:
peerDependencies:
postcss: ^8.1.0
+ axios@1.9.0:
+ resolution: {integrity: sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==}
+
babel-jest@27.5.1:
resolution: {integrity: sha512-cdQ5dXjGRd0IBRATiQ4mZGlGlRE8kJpjPOixdNRdT+m3UcNqmYWN6rK6nvtXYfY3D76cb8s/O1Ss8ea24PIwcg==}
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
@@ -2904,6 +2913,10 @@ packages:
resolution: {integrity: sha512-q5YBMeWy6E2Un0nMGWMgI65MAKtaylxfNJGJxpGh45YDciZB4epbWpaAfImil6CPAPTYB4sh0URQNDRIZG5F2w==}
engines: {node: '>= 6'}
+ form-data@4.0.2:
+ resolution: {integrity: sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==}
+ engines: {node: '>= 6'}
+
forwarded@0.2.0:
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
engines: {node: '>= 0.6'}
@@ -4163,6 +4176,9 @@ packages:
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
engines: {node: '>= 0.10'}
+ proxy-from-env@1.1.0:
+ resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
+
psl@1.15.0:
resolution: {integrity: sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==}
@@ -4729,6 +4745,11 @@ packages:
undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
+ uniapp-axios-adapter@0.3.2:
+ resolution: {integrity: sha512-Wbq8tkjxTw80KaWqpBbrzB575FlJ0YZ+i/EhPFqJmP8iL/x8yzf04RgdrKP7KlI9VArTpEO5PcSe44ciRzTJ8Q==}
+ peerDependencies:
+ axios: '*'
+
unicode-canonical-property-names-ecmascript@2.0.1:
resolution: {integrity: sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==}
engines: {node: '>=4'}
@@ -7960,6 +7981,14 @@ snapshots:
postcss: 8.5.3
postcss-value-parser: 4.2.0
+ axios@1.9.0:
+ dependencies:
+ follow-redirects: 1.15.9
+ form-data: 4.0.2
+ proxy-from-env: 1.1.0
+ transitivePeerDependencies:
+ - debug
+
babel-jest@27.5.1(@babel/core@7.26.10):
dependencies:
'@babel/core': 7.26.10
@@ -8670,6 +8699,13 @@ snapshots:
es-set-tostringtag: 2.1.0
mime-types: 2.1.35
+ form-data@4.0.2:
+ dependencies:
+ asynckit: 0.4.0
+ combined-stream: 1.0.8
+ es-set-tostringtag: 2.1.0
+ mime-types: 2.1.35
+
forwarded@0.2.0: {}
fraction.js@4.3.7: {}
@@ -10187,6 +10223,8 @@ snapshots:
forwarded: 0.2.0
ipaddr.js: 1.9.1
+ proxy-from-env@1.1.0: {}
+
psl@1.15.0:
dependencies:
punycode: 2.3.1
@@ -10748,6 +10786,10 @@ snapshots:
undici-types@6.20.0: {}
+ uniapp-axios-adapter@0.3.2(axios@1.9.0):
+ dependencies:
+ axios: 1.9.0
+
unicode-canonical-property-names-ecmascript@2.0.1: {}
unicode-match-property-ecmascript@2.0.0:
diff --git a/src/api/system/index.js b/src/api/system/index.js
index 516bbb6..f660691 100644
--- a/src/api/system/index.js
+++ b/src/api/system/index.js
@@ -8,7 +8,48 @@ const system = {
url: "/m1/5995958-5684445-default/getList",
data: data,
});
- }
+ },
+ getBarrageList: async () => {
+ return request({
+ method: MethodsENUM.POST,
+ url: "/index/getBarrageList",
+ });
+ },
+ sendSms: async (data) => {
+ return request({
+ method: MethodsENUM.POST,
+ url: "/login/sendSms",
+ data: data,
+ });
+ },
+ register: async (data) => {
+ return request({
+ method: MethodsENUM.POST,
+ url: "/login/register",
+ data: data,
+ });
+ },
+ smsLogin: async (data) => {
+ return request({
+ method: MethodsENUM.POST,
+ url: "/login/smsLogin",
+ data: data,
+ });
+ },
+ accountLogin: async (data) => {
+ return request({
+ method: MethodsENUM.POST,
+ url: "/login/login",
+ data: data,
+ });
+ },
+ editPassword: async (data) => {
+ return request({
+ method: MethodsENUM.POST,
+ url: "/login/editPassword",
+ data: data,
+ });
+ },
}
export default system;
diff --git a/src/components/SendMsg.vue b/src/components/SendMsg.vue
index 37bc31e..675ab40 100644
--- a/src/components/SendMsg.vue
+++ b/src/components/SendMsg.vue
@@ -1,14 +1,49 @@
- 发送验证码
+ {{
+ timer ? `${timer}秒后重试` : `发送验证码`
+ }}
+
diff --git a/src/components/XInput.vue b/src/components/XInput.vue
index 0f9e460..522fb53 100644
--- a/src/components/XInput.vue
+++ b/src/components/XInput.vue
@@ -27,7 +27,7 @@ const modelValue = defineModel();
height: v-bind(height);
:deep(input) {
- background-color: rgba(0,0,0,0);
+ background-color: rgba(0, 0, 0, 0);
flex-grow: 1;
}
}
diff --git a/src/pages/forgotPassword/index.vue b/src/pages/forgotPassword/index.vue
index 809766f..9d59eff 100644
--- a/src/pages/forgotPassword/index.vue
+++ b/src/pages/forgotPassword/index.vue
@@ -3,12 +3,21 @@ import {reactive} from "vue";
import XNav from "../../components/XNav.vue";
import XLink from "../../components/XLink.vue";
import XInput from "../../components/XInput.vue";
+import Api from "../../api/index.js";
+import {backPage, showToast} from "../../utils/uils.js";
+import SendMsg from "../../components/SendMsg.vue";
const form = reactive({
- phone: null,
- verificationCode: null,
+ mobile: null,
+ captcha: null,
password: null,
});
+
+const success = async () => {
+ const {msg} = await Api.system.editPassword(form);
+ showToast(msg);
+ backPage();
+}
@@ -22,19 +31,21 @@ const form = reactive({
-
-
-
- 发送验证码
-
-
-
+
+
+
- 确定修改
+ 确定修改
+
+
diff --git a/src/pages/login/PhoneLogin.vue b/src/pages/login/PhoneLogin.vue
index b2ab532..6646625 100644
--- a/src/pages/login/PhoneLogin.vue
+++ b/src/pages/login/PhoneLogin.vue
@@ -1,27 +1,32 @@
-
-
+
+
登录
diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue
index 7389c30..7f04071 100644
--- a/src/pages/login/index.vue
+++ b/src/pages/login/index.vue
@@ -1,4 +1,5 @@
@@ -23,10 +26,10 @@ const success = () => {
-
-
+
欢迎注册
@@ -34,13 +37,13 @@ const success = () => {
-
+
-
-
-
+
+
+
-
+
确认注册
diff --git a/src/pinia/UserStore/index.js b/src/pinia/UserStore/index.js
index ac58611..3d9b870 100644
--- a/src/pinia/UserStore/index.js
+++ b/src/pinia/UserStore/index.js
@@ -1,22 +1,20 @@
import {defineStore} from "pinia";
-import {ref} from "vue";
+import {ref, reactive} from "vue";
export const useUserStore = defineStore('UserStore', () => {
const isLogin = ref(false);
- const userInfo = ref(null);
-
- const login = () => {
- isLogin.value = true;
- }
+ const token = ref(null);
+ const userInfo = reactive({});
return {
isLogin,
userInfo,
- login,
+ token,
}
}, {
persist: {
key: 'UserStore',
+ pick: ['isLogin', 'userInfo', 'token'],
storage: {
getItem(key) {
return uni.getStorageSync(key);
@@ -25,6 +23,5 @@ export const useUserStore = defineStore('UserStore', () => {
uni.setStorageSync(key, value);
}
},
- pick: ['isLogin', 'userInfo']
}
});
diff --git a/src/utils/AESCrypto.js b/src/utils/AESCrypto.js
index b8f0a0d..3c9595f 100644
--- a/src/utils/AESCrypto.js
+++ b/src/utils/AESCrypto.js
@@ -1,29 +1,58 @@
-import AES from 'crypto-js/aes.js';
-import utf8 from 'crypto-js/enc-utf8.js';
+import Crypto from 'crypto-js';
class AESCrypto {
/**
* 密钥
* @type {string}
*/
- static #AES_KEY = import.meta.env.VITE_AES_KEY;
+ static _AES_KEY = import.meta.env.VITE_AES_KEY;
/**
* AES加密
* @param context {string} 加密内容
*/
static encrypt = (context) => {
- return AES.encrypt(context, this.#AES_KEY).toString();
+ const IV = this.createIV();
+ return {
+ context: Crypto.AES.encrypt(
+ context,
+ Crypto.enc.Utf8.parse(this._AES_KEY),
+ {
+ iv: Crypto.enc.Utf8.parse(IV),
+ mode: Crypto.mode.CBC,
+ padding: Crypto.pad.Pkcs7
+ }
+ ).toString(),
+ iv: IV,
+ };
}
/**
* AES解密
* @param context {string}
+ * @param iv {string}
* @return {string}
*/
- static decrypt = (context) => {
- const bytes = AES.decrypt(context, this.#AES_KEY);
- return bytes.toString(utf8);
+ static decrypt = (context, iv) => {
+ return Crypto.AES.decrypt(
+ context,
+ Crypto.enc.Utf8.parse(this._AES_KEY),
+ {
+ iv: Crypto.enc.Utf8.parse(iv),
+ mode: Crypto.mode.CBC,
+ padding: Crypto.pad.Pkcs7
+ }
+ ).toString(Crypto.enc.Utf8);
+ };
+
+ static createIV = (length = 16) => {
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ let result = '';
+ for (let i = 0; i < length; i++) {
+ const randomIndex = Math.floor(Math.random() * characters.length);
+ result += characters[randomIndex];
+ }
+ return result;
}
}
diff --git a/src/utils/request.js b/src/utils/request.js
index f06d16d..73b973f 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,26 +1,69 @@
+import axios from "axios";
+import {UniAdapter} from "uniapp-axios-adapter";
import {showToast} from "./uils.js";
+import AESCrypto from "./AESCrypto.js";
+import {useUserStore} from "../pinia/UserStore/index.js";
-const request = (options) => {
- return new Promise((resolve, reject) => {
- const {url, method, data, params} = options;
+export const BASEURL = import.meta.env.MODE === 'development' ? '/baseApi/api' : import.meta.env.VITE_API_URL;
- uni.request({
- method: method,
- data: data,
- params: params,
- url: `${import.meta.env.VITE_API_URL}${url}`,
- success: ({data}) => {
- if (data.code !== 0) {
- showToast(data.msg);
- reject(data.msg);
- }
- resolve(data);
- },
- fail: (err) => {
- reject(err);
- }
- });
- });
-}
+const request = axios.create({
+ baseURL: BASEURL,
+ timeout: '6000',
+ adapter: UniAdapter,
+});
+
+request.interceptors.request.use(
+ (config) => {
+ const {token} = useUserStore();
+
+ // 如果 token 存在,则将其添加到请求头中
+ if (token) {
+ config.headers['Access-Token'] = token;
+ }
+
+ console.log('请求拦截器', config.data);
+
+ if (!config.UN_AES) {
+ const {context, iv} = AESCrypto.encrypt(JSON.stringify(config.data));
+
+ config.data = {
+ requestData: context, iv: iv,
+ };
+ }
+
+ return config;
+ },
+ (error) => {
+ // 处理请求错误
+ return Promise.reject(error);
+ }
+);
+
+// 响应拦截器
+request.interceptors.response.use((response) => {
+ const {data: {msg, code, data}, config: {url}} = response;
+ console.log('接口返回', response)
+ if (code === 401) {
+ const {logout} = useUserStore();
+ logout();
+ }
+ if (code !== 1) {
+ showToast(msg);
+ return Promise.reject(msg);
+ }
+ if (!data.data) {
+ return {msg, code, data}
+ } else {
+ const resp = JSON.parse(AESCrypto.decrypt(data.data, data.iv));
+ console.log(`接口${url}返回`, resp);
+ return {data: resp};
+ }
+}, (error) => {
+ if (error.response) {
+ return Promise.reject(error.response.data); // 返回错误信息
+ } else { // 网络错误
+ return Promise.reject(error.message);
+ }
+});
export default request;
diff --git a/vite.config.js b/vite.config.js
index d76e1a3..cc47199 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -4,22 +4,25 @@ import {UnifiedViteWeappTailwindcssPlugin} from 'weapp-tailwindcss/vite';
import tailwindcss from '@tailwindcss/postcss'
export default defineConfig({
- plugins: [
- uni.default(),
- UnifiedViteWeappTailwindcssPlugin({
- rem2rpx: true,
- })
- ],
- css: {
+ plugins: [uni.default({
+ script: {
+ defineModel: true,
+ }
+ }), UnifiedViteWeappTailwindcssPlugin({
+ rem2rpx: true,
+ })], css: {
postcss: {
- plugins: [
- tailwindcss()
- ]
- },
- preprocessorOptions: {
+ plugins: [tailwindcss()]
+ }, preprocessorOptions: {
scss: {
silenceDeprecations: ['legacy-js-api'],
}
},
- },
+ }, server: {
+ proxy: {
+ '/baseApi': {
+ target: 'http://192.168.1.105', changeOrigin: true, rewrite: (path) => path.replace(/^\/baseApi/, ''),
+ }
+ }
+ }
})