From da8373e2cb8d834597b3ce2909697a891b1de398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=98=8E?= <15870290085@163.com> Date: Sat, 16 Jan 2021 14:05:29 +0800 Subject: [PATCH] init --- api/index.js | 5 + api/request.js | 11 +- assets/languages/Chinese.json | 4 - assets/languages/English.json | 4 - components/c-page/index.vue | 2 +- manifest.json | 2 +- package.json | 1 - pages.json | 31 ++-- pages/help-form/help-form.vue | 188 ++++++++++++---------- pages/login/WXLogin.vue | 66 +++++--- pages/setting/setting.vue | 2 +- pages/test/test.vue | 8 + pages/user/Personal-Data.vue | 8 +- store/index.js | 28 +--- uview-ui/components/u-upload/u-upload.vue | 4 +- 15 files changed, 199 insertions(+), 165 deletions(-) diff --git a/api/index.js b/api/index.js index 0a668eb..6084708 100644 --- a/api/index.js +++ b/api/index.js @@ -11,5 +11,10 @@ export const helpInfo = { export const helpForm = { getTags: helpFormMock.getTags, + addInformation: (params)=>request.post("/information/addInformation",params), +} + +export const login = { + WXLogin: (params)=>request.post("/user/Thirdlogin",params) } diff --git a/api/request.js b/api/request.js index 46aabf2..6a7cafb 100644 --- a/api/request.js +++ b/api/request.js @@ -1,7 +1,9 @@ import uni_request from './requestAxios.js' +import Vue from "vue" +import store from "../store" const request = uni_request({ // 有效配置项只有三个 - baseURL: 'http://120.24.151.246:80', //baseURL + baseURL: 'http://121.5.12.180:80', //baseURL timeout: 12345, // 超时时间,单位毫秒。默认 60 秒 header: {'x-custom-header': 'x-custom-header'}, // 设置请求头,建议放在请求拦截器中 statusCode: [200, 401] // 服务器相应状态码为 200/401 时,网络请求不会 reject。也就是不会被 catch 到。如响应 401 时可以在响应拦截后 await 刷新 token + await 重新请求 + return response。即可实现无痛刷新。 @@ -12,13 +14,18 @@ request.interceptors.request.use(async (config, ...args) => { //config.header.Authorization = 'Bearer ' + $store.state.app.token // 修改请求头 //config.body.test = 'test' // 修改请求体 // config.cancel = true // 取消请求 + config.header.token = store.state.token return config }) request.interceptors.response.use(async (response, ...args) => { // 响应拦截器(可以设置多个, 同时可以也可以使用异步方法) const {data: res} = response // args[0] method args[1] url args[3] data //await new Promise(resolve => setTimeout(() => resolve(), 3000)) - if (res.code === 200) { + console.log(response); + if (res.token) { + store.commit("setToken",res.token) + } + if (res.state === 200) { //console.log('响应拦截器, 会阻塞 3 s') } return response diff --git a/assets/languages/Chinese.json b/assets/languages/Chinese.json index 1f61aeb..a28f3da 100644 --- a/assets/languages/Chinese.json +++ b/assets/languages/Chinese.json @@ -64,9 +64,5 @@ "submit": "发布", "chooseLocation": "选择任务地点", "location": "任务地点" - }, - "cTabberPopup":{ - "title1":"求助", - "title2":"动态" } } \ No newline at end of file diff --git a/assets/languages/English.json b/assets/languages/English.json index 92beb6e..323c9c6 100644 --- a/assets/languages/English.json +++ b/assets/languages/English.json @@ -63,9 +63,5 @@ "submit":"Submit", "chooseLocation": "Select mission location", "location": "Location" - }, - "cTabberPopup":{ - "title1":"Help", - "title2":"Trends" } } \ No newline at end of file diff --git a/components/c-page/index.vue b/components/c-page/index.vue index 2f7a551..c2a6eab 100644 --- a/components/c-page/index.vue +++ b/components/c-page/index.vue @@ -1,5 +1,5 @@