From 020b2b001f95f9b618361c489e929dbddf30d302 Mon Sep 17 00:00:00 2001 From: ihzero Date: Wed, 24 Apr 2024 16:04:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85=E5=9F=BA=E7=A1=80=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/base-comp/base-api.vue | 56 +++++ src/components/base-comp/base-data.vue | 59 +++++ src/components/mescroll-api/one.vue | 2 + src/composables/http.ts | 57 +++++ src/pages copy.json | 316 ------------------------- src/pages/data/brokerage/index.vue | 34 +-- src/pages/mine/index.vue | 118 ++++----- src/pages/task/components/item.vue | 25 +- src/pages/task/detail copy.vue | 76 ++++++ src/pages/task/detail.vue | 79 ++++--- src/pages/task/index copy.vue | 74 ------ 11 files changed, 376 insertions(+), 520 deletions(-) create mode 100644 src/components/base-comp/base-api.vue create mode 100644 src/components/base-comp/base-data.vue create mode 100644 src/composables/http.ts delete mode 100644 src/pages copy.json create mode 100644 src/pages/task/detail copy.vue delete mode 100644 src/pages/task/index copy.vue diff --git a/src/components/base-comp/base-api.vue b/src/components/base-comp/base-api.vue new file mode 100644 index 0000000..b9d7e47 --- /dev/null +++ b/src/components/base-comp/base-api.vue @@ -0,0 +1,56 @@ + + diff --git a/src/components/base-comp/base-data.vue b/src/components/base-comp/base-data.vue new file mode 100644 index 0000000..1458ee3 --- /dev/null +++ b/src/components/base-comp/base-data.vue @@ -0,0 +1,59 @@ + + diff --git a/src/components/mescroll-api/one.vue b/src/components/mescroll-api/one.vue index ed283ff..a877e56 100644 --- a/src/components/mescroll-api/one.vue +++ b/src/components/mescroll-api/one.vue @@ -62,4 +62,6 @@ const upCallback = async (mescroll) => { mescroll.endErr() // 隐藏加载进度 }) } + + diff --git a/src/composables/http.ts b/src/composables/http.ts new file mode 100644 index 0000000..e765e91 --- /dev/null +++ b/src/composables/http.ts @@ -0,0 +1,57 @@ +/** +* nuxt项目目录/composables/http.ts +*/ +// 基于useFetch()的网络请求封装 + +//全局基础URL +const BASEURL: string = "http://127.xxx.xxx:3000"; //全局后台服务器请求地址 + +//定义ts变量类型接口 +interface HttpParms { + baseURL?: string, //请求的基本URL,即后台服务器地址,(若服务器请求地址只有一个,可不填) + url: string, //请求api接口地址 + method?: any, //请求方法 + query?: any, //添加查询搜索参数到URL + body?: any //请求体 +} + +/** + * 网络请求方法 + * @param obj 请求参数 + * @returns 响应结果 + */ +export const http = (obj: HttpParms) => { + const res = new Promise((resolve, reject) => { + useFetch( + (obj.baseURL ?? BASEURL) + obj.url, + { + method: obj.method ?? "GET", + query: obj?.query ?? null, + body: obj?.body ?? null, + onRequest({ request, options }) { + // 设置请求报头 + options.headers = options.headers || {} + /**如果接口需求携带token请求,则可先自行使用官方的useCookie()方法设置Cookie存储后,再使用useCookie()方法,取出token使用。如下例子:*/ + //const token = useCookie('token') + //@ts-ignore + //options.headers.Authorization = token.value||null + }, + onRequestError({ request, options, error }) { + // 处理请求错误 + console.log("服务器链接失败!") + reject(error) + }, + onResponse({ request, response, options }) { + // 处理响应数据 + resolve(response._data) + }, + onResponseError({ request, response, options }) { + // 处理响应错误 + } + }, + + ) + }) + return res; + +} diff --git a/src/pages copy.json b/src/pages copy.json deleted file mode 100644 index c0120a3..0000000 --- a/src/pages copy.json +++ /dev/null @@ -1,316 +0,0 @@ -{ - "pages": [ - { - "path": "pages/login/index", - "style": { - "navigationBarTitleText": "登录" - } - }, - { - "path": "pages/home/index", - "style": { - "navigationBarTitleText": "首页" - } - }, - { - "path": "pages/revert/index", - "style": { - "navigationBarTitleText": "上报" - } - }, - { - "path": "pages/statement/index", - "style": { - "navigationBarTitleText": "报表" - } - }, - { - "path": "pages/mine/index", - "style": { - "navigationBarTitleText": "我的" - } - } - ], - "subPackages": [ - { - "root": "pages/data", - "pages": [ - { - "path": "brokerage/index", - "style": { - "navigationBarTitleText": "提成数据" - } - }, - { - "path": "performance/index", - "style": { - "navigationBarTitleText": "业绩数据" - } - }, - { - "path": "upload/index", - "style": { - "navigationBarTitleText": "上传数据" - } - } - ] - }, - { - "root": "pages/user", - "pages": [ - { - "path": "index", - "style": { - "navigationBarTitleText": "员工管理" - } - }, - { - "path": "update", - "style": { - "navigationBarTitleText": "修改信息" - } - }, - { - "path": "detail", - "style": { - "navigationBarTitleText": "员工详情" - } - } - ] - }, - { - "root": "pages/setting", - "pages": [ - { - "path": "index", - "style": { - "navigationBarTitleText": "设置" - } - }, - { - "path": "password", - "style": { - "navigationBarTitleText": "修改密码" - } - }, - { - "path": "complain", - "style": { - "navigationBarTitleText": "举报投诉" - } - }, - { - "path": "suggestion", - "style": { - "navigationBarTitleText": "意见箱" - } - } - ] - }, - { - "root": "pages/task", - "pages": [ - { - "path": "index", - "style": { - "navigationBarTitleText": "任务列表" - } - }, - { - "path": "submit", - "style": { - "navigationBarTitleText": "任务提交" - } - }, - { - "path": "task_hygienes_submit", - "style": { - "navigationBarTitleText": "清洁任务提交" - } - }, - { - "path": "task_ledgers_submit", - "style": { - "navigationBarTitleText": "数据上报" - } - }, - { - "path": "detail", - "style": { - "navigationBarTitleText": "任务详情" - } - } - ] - }, - { - "root": "pages/expense-account", - "pages": [ - { - "path": "index", - "style": { - "navigationBarTitleText": "报销管理" - } - }, - { - "path": "submit", - "style": { - "navigationBarTitleText": "报销提交" - } - } - ] - }, - { - "root": "pages/work", - "pages": [ - { - "path": "list", - "style": { - "navigationBarTitleText": "升职申请" - } - }, - { - "path": "detail", - "style": { - "navigationBarTitleText": "升职申请" - } - }, - { - "path": "create", - "style": { - "navigationBarTitleText": "升职申请" - } - } - ] - }, - { - "root": "pages/make-card", - "pages": [ - { - "path": "list", - "style": { - "navigationBarTitleText": "补卡申请" - } - }, - { - "path": "create", - "style": { - "navigationBarTitleText": "补卡申请" - } - }, - { - "path": "detail", - "style": { - "navigationBarTitleText": "补卡审核" - } - } - ] - }, - { - "root": "pages/ask-leave", - "pages": [ - { - "path": "list", - "style": { - "navigationBarTitleText": "请假申请" - } - }, - { - "path": "create", - "style": { - "navigationBarTitleText": "请假申请" - } - }, - { - "path": "detail", - "style": { - "navigationBarTitleText": "请假详情" - } - } - ] - }, - { - "root": "pages/train-books", - "pages": [ - { - "path": "index", - "style": { - "navigationBarTitleText": "培训课件" - } - }, - { - "path": "detail", - "style": { - "navigationBarTitleText": "培训课件" - } - } - ] - }, - { - "root": "pages/examination", - "pages": [ - { - "path": "index", - "style": { - "navigationBarTitleText": "培训考试" - } - }, - { - "path": "detail", - "style": { - "navigationBarTitleText": "培训考试" - } - } - ] - } - ], - "globalStyle": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "uni-app", - "navigationBarBackgroundColor": "#FFFFFF", - "backgroundColor": "#FFFFFF", - "navigationStyle": "custom", - "backgroundColorTop": "#FFFFFF", - "app-plus": { - "bounce": "none", - "scrollIndicator": "none" - } - }, - "tabBar": { - "color": "#333", - "selectedColor": "#ff3c2a", - "borderStyle": "black", - "backgroundColor": "#ffffff", - "list": [ - { - "pagePath": "pages/home/index", - "selectedIconPath": "static/images/home.png", - "iconPath": "static/images/home.png", - "text": "首页" - }, - { - "pagePath": "pages/revert/index", - "selectedIconPath": "static/images/home.png", - "iconPath": "static/images/home.png", - "text": "上报" - }, - { - "pagePath": "pages/statement/index", - "selectedIconPath": "static/images/home.png", - "iconPath": "static/images/home.png", - "text": "报表" - }, - { - "pagePath": "pages/mine/index", - "selectedIconPath": "static/images/home.png", - "iconPath": "static/images/home.png", - "text": "我的" - } - ] - }, - "easycom": { - "autoscan": true, - "custom": { - "^uv-(.*)": "@climblee/uv-ui/components/uv-$1/uv-$1.vue" - } - } -} diff --git a/src/pages/data/brokerage/index.vue b/src/pages/data/brokerage/index.vue index 9d1f51a..950f002 100644 --- a/src/pages/data/brokerage/index.vue +++ b/src/pages/data/brokerage/index.vue @@ -1,14 +1,13 @@ @@ -18,33 +17,10 @@ import Item from './components/item.vue' import { onLoad } from '@dcloudio/uni-app' import { http } from '@/utils/request' import { ref } from 'vue' +import MescrollItem from '@/components/mescroll-api/one' import { onPageScroll, onReachBottom } from '@dcloudio/uni-app' -import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js' - -const { mescrollInit, downCallback, getMescroll } = useMescroll( - onPageScroll, - onReachBottom -) - -const list = ref([]) +import useMescrollComp from '@/uni_modules/mescroll-uni/hooks/useMescrollComp.js' +const { mescrollItem } = useMescrollComp(onPageScroll, onReachBottom) - -const upCallback = async (mescroll) => { - const { size, num } = mescroll - try { - const resData = await http.get('/account/store-master-commissions', { - params: { - per_page: size, - page: num, - }, - }) - const curPageData = resData.data || [] - if (num === 1) list.value = [] - list.value = list.value.concat(curPageData) - mescroll.endSuccess(curPageData.length) - } catch (error) { - mescroll.endErr() // 请求失败, 结束加载 - } -} diff --git a/src/pages/mine/index.vue b/src/pages/mine/index.vue index ad259db..0d60900 100644 --- a/src/pages/mine/index.vue +++ b/src/pages/mine/index.vue @@ -15,102 +15,110 @@ - + diff --git a/src/pages/task/components/item.vue b/src/pages/task/components/item.vue index 1868bdf..c184bcb 100644 --- a/src/pages/task/components/item.vue +++ b/src/pages/task/components/item.vue @@ -17,19 +17,10 @@ 任务时间:{{ timeFormat(item.start_at, 'yyyy年mm月dd日') }} - {{ timeFormat(item.end_at, 'yyyy年mm月dd日') }} - diff --git a/src/pages/task/detail.vue b/src/pages/task/detail.vue index 77b2395..5cb962f 100644 --- a/src/pages/task/detail.vue +++ b/src/pages/task/detail.vue @@ -1,47 +1,23 @@ diff --git a/src/pages/task/index copy.vue b/src/pages/task/index copy.vue deleted file mode 100644 index d9cdff6..0000000 --- a/src/pages/task/index copy.vue +++ /dev/null @@ -1,74 +0,0 @@ - -