diff --git a/src/App.vue b/src/App.vue
index 1b75fa3d..273719aa 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,6 +1,21 @@
-
+
diff --git a/src/components/custom-title/index.vue b/src/components/custom-title/index.vue
new file mode 100644
index 00000000..1d11da7f
--- /dev/null
+++ b/src/components/custom-title/index.vue
@@ -0,0 +1,61 @@
+
+
+
+
+
diff --git a/src/components/self-tabbar/index.vue b/src/components/self-tabbar/index.vue
index 51168af9..a70e9c23 100644
--- a/src/components/self-tabbar/index.vue
+++ b/src/components/self-tabbar/index.vue
@@ -23,7 +23,7 @@
-
-
diff --git a/src/http/apis.js b/src/http/apis.js
new file mode 100644
index 00000000..f59c4e61
--- /dev/null
+++ b/src/http/apis.js
@@ -0,0 +1,18 @@
+import uniReq from '@/http/init'
+export const login=(data)=> {
+ return uniReq.post({
+ url: '/api/user/login/wx/telnum',
+ data
+ })
+}
+export const getInfo=()=> {
+ return uniReq.post({
+ url: '/api/user/info'
+ })
+}
+export const ticketlist=(data)=> {
+ return uniReq.post({
+ url: '/ticket/ticketList',
+ data
+ })
+}
diff --git a/src/http/deposit.js b/src/http/deposit.js
deleted file mode 100644
index 5c88cc8c..00000000
--- a/src/http/deposit.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import http from "./interface";
-
-// 地点
-export const address = () => {
- return http.request({
- url: "/api/warehouse/address",
- method: "POST",
- });
-};
-export default {
- address,
-};
diff --git a/src/http/index.js b/src/http/index.js
deleted file mode 100644
index 7238da2c..00000000
--- a/src/http/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import deposit from "./deposit";
-import login from "./login";
-export default {
- deposit,
- login,
-};
diff --git a/src/http/init.js b/src/http/init.js
new file mode 100644
index 00000000..31ba0740
--- /dev/null
+++ b/src/http/init.js
@@ -0,0 +1,25 @@
+import {uniRequest} from "@/http/main";
+
+export default uniRequest.created({
+ //baseUrl: 'http://172.16.100.93:9052',
+ baseUrl: 'http://192.168.88.122:9021',
+ header: {
+ Authorization: uni.getStorageSync('token') ?? ''
+ },
+ interceptor: {
+ request(config){
+ uni.showLoading({
+ title: '加载中...',
+ mask: true
+ })
+ setTimeout(()=>{
+ uni.hideLoading()
+ },5000)
+ return config
+ },
+ response(response) {
+ uni.hideLoading()
+ return response.data
+ }
+ }
+})
diff --git a/src/http/init.ts b/src/http/init.ts
deleted file mode 100644
index 5adb3fd5..00000000
--- a/src/http/init.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import {uniFetch} from "@/http/main";
-const fetch = new uniFetch({
- baseUrl: 'https://warehouse.szjixun.cn',
- requestInterceptor:(config)=>{
- return config
- },
- responseInterceptor:(response)=>{
- if (response.data?.status === 401) {
- let curPage = getCurrentPages();
- let route = curPage[curPage.length - 1].route; //获取当前页面的路由
- if (route !== "pages/login/index") {
- uni.navigateTo({
- url: "/pages/login/index",
- });
- }
- }
- return response
- }
-})
-export default fetch
diff --git a/src/http/login.js b/src/http/login.js
deleted file mode 100644
index 47da7f45..00000000
--- a/src/http/login.js
+++ /dev/null
@@ -1,57 +0,0 @@
-
-import fetch from "@/http/init";
-// openId
-export const login = (data) => {
- return fetch.request({
- url: "/api/wxuser/openid",
- method: "POST",
- data,
- });
-};
-// 获取手机号
-export const getTel = (data) => {
- return fetch.request({
- url: "/api/wxuser/get/telnum",
- method: "POST",
- data,
- });
-};
-// 注册
-export const register = (data) => {
- return fetch.request({
- url: "/api/wxuser/register",
- method: "POST",
- data,
- });
-};
-// 身份验证
-export const chenckId = (data) => {
- return fetch.request({
- url: "/api/wxuser/ocr",
- method: "POST",
- data,
- });
-};
-// 法大大
-export const fddRealName = (data) => {
- return fetch.request({
- url: "/api/wxuser/bind/fdd",
- method: "POST",
- data,
- });
-};
-//法大大是否验证
-export const checkFdd = () => {
- return fetch.request({
- url: "/api/wxuser/fdd/check",
- method: "POST",
- });
-};
-export default {
- login,
- getTel,
- register,
- chenckId,
- fddRealName,
- checkFdd,
-};
diff --git a/src/http/main.ts b/src/http/main.ts
index d0051861..6ca24dca 100644
--- a/src/http/main.ts
+++ b/src/http/main.ts
@@ -16,7 +16,7 @@ type HttpMethod =
interface RequestOptions {
baseUrl?: string;
- url: string;
+ url?: string;
data?: Record;
method?: HttpMethod;
header?: Record;
@@ -37,30 +37,26 @@ interface RequestOptions {
enableCookie?: boolean,
cloudCache?: object | boolean,
defer?: boolean,
- requestInterceptor?: RequestInterceptor,
- responseInterceptor?: ResponseInterceptor
+ interceptor?:{
+ request?: RequestInterceptor,
+ response?: ResponseInterceptor
+ }
}
-
-type instantiationParameters = Omit, 'url'> & {
- baseUrl: string;
-};
type RequestInterceptor = (config: RequestOptions) => RequestOptions;
type ResponseInterceptor = (response: any) => any;
-class uniFetch {
- baseUrl: string;
+class uniRequest {
+ baseUrl?: string;
defaultHeader: Record;
- interceptors: { request: RequestInterceptor | undefined; response: ResponseInterceptor | undefined };
-
- constructor(request: instantiationParameters) {
+ interceptors: { request?: RequestInterceptor; response?: ResponseInterceptor };
+ constructor(request: RequestOptions) {
this.baseUrl = request.baseUrl;
this.defaultHeader = {
"Content-Type": "application/json;charset=UTF-8",
...request.header,
};
- this.interceptors = {request: request.requestInterceptor, response: request.responseInterceptor};
+ this.interceptors = {request: request.interceptor?.request, response: request.interceptor?.response};
}
-
setBaseUrl(baseUrl: string): void {
this.baseUrl = baseUrl;
}
@@ -68,18 +64,20 @@ class uniFetch {
setDefaultHeader(header: Record): void {
this.defaultHeader = header;
}
-
+ static created(options: RequestOptions){
+ return new uniRequest(options);
+ }
request(options: RequestOptions): Promise {
options = this.buildRequestOptions(options)
options = options || {};
options.baseUrl = options.baseUrl || this.baseUrl;
- options.url = options.baseUrl + options.url;
+ options.url = `${options.baseUrl}${options.url}`;
options.data = options.data || {};
options.method = (options.method?.toUpperCase() || "GET") as HttpMethod;
options.header = options.header || this.defaultHeader;
- if (typeof options.requestInterceptor === 'function') {
- options = options.requestInterceptor(options);
- } else if (typeof this.interceptors.request === 'function') {
+ if (typeof options.interceptor?.request === 'function') {
+ options = options.interceptor.request(options);
+ } else if (typeof this.interceptors?.request === 'function') {
options = this.interceptors.request(options);
}
return new Promise((resolve, reject) => {
@@ -87,7 +85,7 @@ class uniFetch {
uni.request({
...options,
success: (res) => {
- const response = this.handleResponse(res);
+ const response = this.handleResponse(res,options);
resolve(response);
},
fail: (err) => {
@@ -98,16 +96,13 @@ class uniFetch {
});
}
- private handleResponse(response: any): any {
- if (this.interceptors.response) {
- response = this.interceptors.response(response);
- }
- const statusCode = response.statusCode;
- if (statusCode === 200) {
- return response.data;
- } else {
- throw response;
+ private handleResponse(response: any,options:RequestOptions): any {
+ if (options.interceptor?.response){
+ response = options.interceptor?.response(response);
+ }else if (this.interceptors?.response) {
+ response = this.interceptors?.response(response);
}
+ return response
}
private handleError(error: any): any {
@@ -158,4 +153,4 @@ class uniFetch {
}
}
-export {uniFetch}
+export {uniRequest}
diff --git a/src/main.ts b/src/main.ts
index 7b2984c6..087a7fe8 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,13 +2,12 @@ import { createSSRApp } from "vue";
import * as Pinia from "pinia";
import tmui from "./tmui";
import App from "./App.vue";
-// @ts-ignore
-import api from "@/http";
-import title from "./components/Title/index.vue";
+
+import customTitle from "./components/custom-title/index.vue";
export function createApp() {
const app = createSSRApp(App);
- app.config.globalProperties.$api = api;
- app.component("title", title);
+
+ app.component("customTitle", customTitle);
app.use(tmui, { shareDisable: false } as Tmui.tmuiConfig);
return {
app,
diff --git a/src/manifest.json b/src/manifest.json
index 3f2d325d..03af850f 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -97,7 +97,7 @@
},
"quickapp": {},
"mp-weixin": {
- "appid": "",
+ "appid": "wx7da502ffb626aa8a",
"darkmode": false,
"setting": {
"urlCheck": false,
@@ -193,4 +193,4 @@
"enable": false
}
}
-}
\ No newline at end of file
+}
diff --git a/src/pages.json b/src/pages.json
index ea5139ce..4f8db04a 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -28,7 +28,6 @@
}
}
},
-
{
"path": "pages/ticket/index",
"style": {
@@ -43,6 +42,7 @@
{
"path": "pages/login/index",
"style": {
+ "navigationStyle": "custom",
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"app-plus": {
diff --git a/src/pages/home/index.vue b/src/pages/home/index.vue
index 4b8c3256..e8fc6982 100644
--- a/src/pages/home/index.vue
+++ b/src/pages/home/index.vue
@@ -1,93 +1,22 @@
+
+
-
-
-
-