diff --git a/App.vue b/App.vue index 8c2b732..ac935cd 100644 --- a/App.vue +++ b/App.vue @@ -14,4 +14,5 @@ + * {} + \ No newline at end of file diff --git a/main.js b/main.js index 5f2ba1c..e08df03 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,7 @@ import App from './App' +import Card from '@/components/Card.vue' +import DictTag from '@/components/DictTag.vue' +import FormItem from '@/components/FormItem.vue' // #ifndef VUE3 import Vue from 'vue' @@ -17,6 +20,9 @@ import { } from 'vue' export function createApp() { const app = createSSRApp(App) + app.component('Card', Card) + app.component('DictTag', DictTag) + app.component('FormItem', FormItem) return { app } diff --git a/pages.json b/pages.json index 85027f0..d3b9627 100644 --- a/pages.json +++ b/pages.json @@ -1,5 +1,11 @@ { "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages + { + "path": "pages/workbench/index", + "style": { + "navigationStyle": "custom" + } + }, { "path": "pages/login/index", "style": { @@ -7,9 +13,15 @@ } }, { - "path": "pages/index/index", + "path": "pages/contract/index", "style": { - "navigationBarTitleText": "uni-app" + "navigationStyle": "custom" + } + }, + { + "path": "pages/contract/info", + "style": { + "navigationStyle": "custom" } } ], diff --git a/pages/login/index.vue b/pages/login/index.vue index 9e8a98f..24bc69e 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -4,12 +4,12 @@ - - 登 录 @@ -32,16 +32,18 @@ loginApi } from '@/api/login' const loginForm = ref({}) - const usernameInput = (event) => { - loginForm.value.username = event.detail.value - } - const passwordInput = (event) => { - loginForm.value.password = event.detail.value - } const login = async () => { const data = await loginApi(loginForm.value) if (data) { - setGlobalData('token', data.data.access_token) + uni.setStorageSync('token', data.data.access_token) + uni.showToast({ + title: '登录成功', + icon: 'success', + duration: 2000 + }) + uni.redirectTo({ + url: '/pages/workbench/index' + }) } } diff --git a/pages/workbench/index.vue b/pages/workbench/index.vue new file mode 100644 index 0000000..060d5bb --- /dev/null +++ b/pages/workbench/index.vue @@ -0,0 +1,166 @@ + + + + + \ No newline at end of file diff --git a/store/index.js b/store/index.js index f800c36..0c93ccd 100644 --- a/store/index.js +++ b/store/index.js @@ -1,5 +1,4 @@ -const globaldata = { - token: '', +const globaldata = { encryptHeader: 'encrypt-key', clientId: '428a8310cd442757ae699df5d894f051', RSA_PUBLIC_KEY: 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==', diff --git a/uni.scss b/uni.scss index aae255e..ba1afb9 100644 --- a/uni.scss +++ b/uni.scss @@ -14,6 +14,7 @@ /* 图片地址 */ // $img-url: 'https://hw-bm-1307203087.cos.ap-beijing.myqcloud.com'; + $img-url: 'https://frp-off.com:47543/appstatic'; diff --git a/utils/request.js b/utils/request.js index 8139ed1..6e32879 100644 --- a/utils/request.js +++ b/utils/request.js @@ -19,10 +19,11 @@ const encryptHeader = getGlobalData('encryptHeader'); const baseURL = 'https://frp-off.com:47543' const getToken = () => { - return getGlobalData('token') + return uni.getStorageSync('token') } export function request(options) { + options.headers = options.headers || {} // 加密 const isEncrypt = options.headers && (options.headers.isEncrypt === 'true' || options.headers.isEncrypt === true); @@ -37,6 +38,7 @@ export function request(options) { if (getToken() && !isToken) { options.headers['Authorization'] = 'Bearer ' + getToken(); } + options.headers['clientid'] = getGlobalData('clientId'); return new Promise((resolve, reject) => { uni.request({ @@ -49,11 +51,6 @@ export function request(options) { let code = res.data.code let msg = res.data.msg if (code === 200) { - uni.showToast({ - title: msg.length < 10 ? msg : '成功', - icon: 'success', - duration: 2000 - }) resolve(res.data) } else { if (code === 401) { @@ -62,6 +59,9 @@ export function request(options) { icon: 'error', duration: 2000 }) + uni.reLaunch({ + url: '/pages/login/index' + }) } else { uni.showToast({ title: msg.length < 10 ? msg : '网络错误请重试',