diff --git a/src/app.tsx b/src/app.tsx index 1b48ab1..ab38461 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -4,7 +4,6 @@ import Error from 'src/components/baseBuiltComp/Error' import { store } from './store' import './app.scss' import { Get, getStorage, preloadResource, requestUrlCreator } from './utils' -import { IUserInfo } from './common-model' import { JSON_MAP } from './static/SVG/lottie-map' function App(props) { @@ -15,7 +14,7 @@ function App(props) { useLaunch(async () => { /** 1. 校验登陆态 */ - const token = getStorage('userInfo')?.token + const token = getStorage('userInfo')?.token /** 2. 校验获取用户信息 */ /** TODO: 需和后端确定响应体 */ diff --git a/src/common-model.ts b/src/common-model.ts index 0a93207..bff23c5 100644 --- a/src/common-model.ts +++ b/src/common-model.ts @@ -35,7 +35,7 @@ export interface ICommonState { /** 默认store值 从storage中激活 */ export const defaultValue: ICommonState = { - userInfo: getStorage('userInfo') || {}, + userInfo: getStorage('userInfo') || {}, system: { coolStartSuccess: false, hasAccountCompleted: false, diff --git a/src/components/baseBuiltComp/FORBIDDEN/index.module.scss b/src/components/baseBuiltComp/FORBIDDEN/index.module.scss index 41881a1..8d865c4 100644 --- a/src/components/baseBuiltComp/FORBIDDEN/index.module.scss +++ b/src/components/baseBuiltComp/FORBIDDEN/index.module.scss @@ -5,8 +5,8 @@ flex-direction: column; justify-content: center; align-items: center; - width: 100vw; - height: 100vh; + width: 100%; + height: 100%; &__bgContainer { position: relative; @@ -16,8 +16,8 @@ height: 70%; align-items: center; - - &__canvas {} + &__canvas { + } &__title { text-align: center; @@ -27,5 +27,4 @@ color: $base-element-color; } } - -} \ No newline at end of file +} diff --git a/src/components/baseBuiltComp/FORBIDDEN/index.tsx b/src/components/baseBuiltComp/FORBIDDEN/index.tsx index 5aabfae..4a06527 100644 --- a/src/components/baseBuiltComp/FORBIDDEN/index.tsx +++ b/src/components/baseBuiltComp/FORBIDDEN/index.tsx @@ -1,22 +1,31 @@ import { Button, Canvas, CoverView, View } from '@tarojs/components' -import { $ } from 'src/utils' +import { $, URL, goTo } from 'src/utils' import useAnimation from 'src/hooks/useAnimation' import { JSON_MAP } from 'src/static/SVG/lottie-map' -import { useEffect } from 'react' +import { useCallback, useEffect } from 'react' import './index.module.scss' -const Index = () => { +const Index = (props) => { const { run, instance } = useAnimation({ node: $('#ForbiddenContainer__bgContainer__canvas'), template: JSON_MAP['forbidden'], isAutoRun: false, }) + + const goToIndex = useCallback(() => { + goTo({ + url: URL.Index, + methodType: 'reLaunch', + options: { authorize: false }, + }) + }, []) + useEffect(() => { run() // setTimeout(() => { // instance?.pause() // }, 4000); - }, [instance]) + }, [instance, run]) return ( @@ -28,7 +37,11 @@ const Index = () => { SRY 你没有权限访问该页面 - + {props.children ? ( + + ) : ( + + )} ) diff --git a/src/components/baseBuiltComp/HocWrap/index.tsx b/src/components/baseBuiltComp/HocWrap/index.tsx index e9ca49a..0e8860f 100644 --- a/src/components/baseBuiltComp/HocWrap/index.tsx +++ b/src/components/baseBuiltComp/HocWrap/index.tsx @@ -21,14 +21,14 @@ export const Authorize = (Component) => { } /** @HOC 禁止页面要求必须是已授权的 */ -export const Forbidden = (Component) => { +export const Forbidden = (Component, props?: any) => { return React.memo(() => { const state = useSelector((root: RootState) => root.common) if (!state.system.coolStartSuccess) { return } else { if (state.userInfo.isBindManage) return - return + return {props} } }) } diff --git a/src/components/baseBuiltComp/Loading/index.module.scss b/src/components/baseBuiltComp/Loading/index.module.scss index 6935166..86bcefd 100644 --- a/src/components/baseBuiltComp/Loading/index.module.scss +++ b/src/components/baseBuiltComp/Loading/index.module.scss @@ -14,10 +14,10 @@ align-items: center; width: 100%; height: 100%; + z-index: 1000; &__canvas { width: 100%; // height: 40%; } - -} \ No newline at end of file +} diff --git a/src/config.ts b/src/config.ts index 88062e9..0696267 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,7 +6,6 @@ export const config: Config = { 'pages/main/Index/index', 'pages/main/Calendar/index', 'pages/main/Manage/index', - 'pages/main/Manage/Publish/index', 'pages/main/My/index', // 'pages/Detail/index', // 'pages/Initial/index', diff --git a/src/hooks/useRequest.ts b/src/hooks/useRequest.ts index 454e223..3a312e9 100644 --- a/src/hooks/useRequest.ts +++ b/src/hooks/useRequest.ts @@ -71,6 +71,8 @@ const useRequest = (requestFn: TRequestFn, options?: TRequestOptions) => { /** 请求开始 */ PerfTackerInstance.requestBegin() res = await fn({ url, data: req, silent }) + console.log(res.extraData?.count) + /* __PURE__ */ console.log(' === 响应返回 === ', res) /** 校验是否成功 */ diff --git a/src/pages/Detail/components/Poster.tsx b/src/pages/Detail/components/Poster.tsx new file mode 100644 index 0000000..453fe72 --- /dev/null +++ b/src/pages/Detail/components/Poster.tsx @@ -0,0 +1,107 @@ +import React, { useRef, FC, useCallback, useState } from 'react' +import { pxTransform } from '@tarojs/taro' +import { PosterRender, PosterRenderRef } from '@poster-render/taro-react' +import { View } from '@tarojs/components' +import Button from '@taroify/core/button/button' +import { TTaskItem, getStorage, showToast, trackJsError } from 'src/utils' +import './poster.scss' + +const lists = (data: TTaskItem) => [ + { + type: 'image', + x: 0, + y: 0, + width: 540, + height: 960, + backgroundColor: 'black', + src: 'https://hx.404fwf.cn/notifyBoard/img/backposter.png', + mode: 'contain', + }, + { + type: 'text', + textAlign: 'center', + x: 270, + y: 340, + lineNum: 3, + width: 350, + height: 30, + text: data.title, + color: 'black', + fontSize: 30, + baseLine: 'top', + fontWeight: 'Bold', + }, + { + type: 'text', + textAlign: 'left', + x: 80, + y: 400, + lineNum: 15, + width: 372, + height: 22, + text: data.desc, + color: 'black', + fontSize: 22, + lineHeight: 30, + }, +] + +type TPosterProps = { + posterData: TTaskItem +} +const Index: FC = ({ posterData }) => { + const posterRender = useRef(null) + const [posterPath, setPath] = useState() + + // TODO: 加埋点 + const savePosterToPhoto = useCallback( + () => + posterRender.current?.savePosterToPhoto().then((path) => { + showToast(`已保存到相册 ${path}`) + setPath(path || '') + }), + [posterRender], + ) + const trackError = useCallback((type, err) => { + showToast('保存图片失败了,重新进入尝试一下') + trackJsError({ + token: getStorage('userInfo').token || 'no_login', + errMsg: err, + errName: type, + location: 'detail/poster', + }) + }, []) + + return ( + + trackError('poster_render_failed', err)} + onSaveFail={(err) => trackError('poster_save_failed', err)} + list={lists(posterData)} + /> + + {!posterPath ? ( + + ) : ( + + )} + + + ) +} + +export default React.memo(Index) diff --git a/src/pages/Detail/components/poster.scss b/src/pages/Detail/components/poster.scss new file mode 100644 index 0000000..b154a05 --- /dev/null +++ b/src/pages/Detail/components/poster.scss @@ -0,0 +1,15 @@ +.poster_wrapper { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + + .button_groups { + display: flex; + justify-content: space-around; + width: 70%; + margin-top: 80rpx; + } +} diff --git a/src/pages/Detail/index.config.ts b/src/pages/Detail/index.config.ts index 5453636..d8922e7 100644 --- a/src/pages/Detail/index.config.ts +++ b/src/pages/Detail/index.config.ts @@ -8,7 +8,7 @@ export default definePageConfig({ /** 开启朋友分享 */ enableShareAppMessage: true, /** 开启朋友圈分享 */ - enableShareTimeline: true, + enableShareTimeline: false, /** 自定义背景颜色 */ backgroundColor: '#ffffff', /** 非首页设置返回Home */ diff --git a/src/pages/Detail/index.module.scss b/src/pages/Detail/index.module.scss index e69de29..5e6e64d 100644 --- a/src/pages/Detail/index.module.scss +++ b/src/pages/Detail/index.module.scss @@ -0,0 +1,149 @@ +.detail_wrapper { + display: flex; + flex-direction: column; + width: 100vw; + height: 100vh; + overflow-y: scroll; + padding: 0 30rpx 0 30rpx; + box-sizing: border-box; + + .title_wrapper { + display: flex; + align-items: center; + justify-content: space-between; + width: 100%; + margin: 0 0 20rpx 0; + box-sizing: border-box; + + .title_wrapper__text { + font-size: 40rpx; + font-weight: 700; + font-family: AlibabaPuHuiTi; + } + + .title_wrapper__tags { + display: flex; + + .tag { + padding: 5rpx 20rpx 5rpx 20rpx; + background-color: rgb(15, 198, 15); + border-radius: 25rpx; + margin-right: 10rpx; + } + } + } + + .body_wrapper { + width: 100%; + box-sizing: border-box; + height: auto; + border: 2rpx dashed #aeabab; + border-radius: 15rpx; + padding: 30rpx 20rpx 20rpx 20rpx; + + &__title { + font-size: 30rpx; + font-weight: bold; + font-family: AlibabaPuHuiTi; + } + + .font-line { + font-size: 26rpx; + color: #7b7979; + margin: 5rpx 0 5rpx 0; + } + + &__content { + font-size: 26rpx; + color: #7b7979; + margin: 5rpx 0 5rpx 0; + } + + &__imgs { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(30%, 1fr)); + grid-gap: 10px; + width: 100%; + height: auto; + margin-top: 30rpx; + + .img-view { + width: 100%; + margin: 5px; + aspect-ratio: 1; + + .img { + object-fit: cover; + width: 100%; + height: 100%; + } + } + } + } + + .btn_wrapper { + .btn_groups { + display: flex; + justify-content: space-between; + width: 100%; + height: auto; + margin-top: 20rpx; + } + + .half-btn { + display: flex; + justify-content: center; + align-items: center; + width: 47%; + height: 80rpx; + border-radius: 40rpx; + } + + .border { + border: 1rpx solid black; + } + + .green { + background-color: rgb(16, 196, 16); + } + + .full-btn { + width: 100%; + height: 80rpx; + border-radius: 40rpx; + } + } +} + +.poster-popup { + display: flex; + position: absolute; + left: 0; + top: 0; + flex-direction: column; + // justify-content: center; + align-items: center; + z-index: 1000; + + .poster_section { + height: 80%; + width: 100%; + } + + .closeBtn_section { + } +} + +.popup { + position: absolute; + width: 100vw; + height: 100vh; +} + +.mask { + background-color: #fff; +} + +.bold { + font-weight: bold; +} diff --git a/src/pages/Detail/index.tsx b/src/pages/Detail/index.tsx index 12cbc69..8b6423b 100644 --- a/src/pages/Detail/index.tsx +++ b/src/pages/Detail/index.tsx @@ -1,104 +1,151 @@ -import { Canvas, View } from '@tarojs/components' -import React, { useEffect, useRef, FC } from 'react' -import Taro, { pxTransform } from '@tarojs/taro' -import { URL, getCurrentPage, goTo, $, getCurrentPageInstance } from 'src/utils' -import { PosterRender, PosterRenderRef } from '@poster-render/taro-react' +import { View, Text, Image } from '@tarojs/components' +import React, { FC, useCallback, useState } from 'react' +import Taro, { useShareAppMessage } from '@tarojs/taro' +import { + Post, + TTaskItem, + getCurrentPage, + query, + requestUrlCreator, + showToast, + taskStatusEnum, + timeFormat, +} from 'src/utils' +import Button from '@taroify/core/button/button' +import useRequest from 'src/hooks/useRequest' +import Loading from 'src/components/baseBuiltComp/Loading' import './index.module.scss' +import Poster from './components/Poster' -// const Index = () => { -// // const storage = query() -// // const { data, loading, err, run } = useRequest( -// // () => ({ -// // url: requestUrlCreator({ absolutePath: '/detail' }), -// // type: 'Get', -// // reqData: { -// // id: storage?.id -// // }, -// // silent: true -// // }), { auto: true } -// // ) -// // console.log(query()); -// useEffect(() => { -// console.log(getCurrentPage()) +const Index: FC = () => { + const { data, loading, err } = useRequest( + () => ({ + url: requestUrlCreator({ absolutePath: '/detail' }), + type: 'Get', + reqData: { + id: query()?.id, + }, + silent: true, + }), + { auto: true }, + ) -// // console.log('我调用了一次', query()); -// }, []) -// return ( -// -// {/* loading ? : loading结束了 */} -// goTo({ url: URL.Setting, methodType: 'navigateTo' })}> -// loading结束了 -// -// -// ) -// } + const [isShowPoster, setIsShowPoster] = useState(false) + const updateTaskStatus = useCallback(() => { + if (data!.status > 1) { + showToast('任务已过期,无法更新状态') + return + } + Post({ + url: requestUrlCreator({ absolutePath: '/changeStatus' }), + data: { + id: data?.id, + status: !data?.status, + }, + }) + }, [data]) -const lists = [ - { - type: 'rect', - x: 0, - y: 0, - width: 644, - height: 1104, - radius: 0, - backgroundColor: 'black', - }, - { - type: 'image', - x: 250, - y: 40, - width: 185, - height: 210, - mode: 'cover', - src: 'https://p6-passport.byteacctimg.com/img/user-avatar/25facc1742ed0fa4856946823517dbe7~180x180.awebp', - radius: 90, - }, - { - type: 'line', - x: 50, - y: 50, - destX: 200, - destY: 50, - color: '#fff', - lineWidth: 4, - }, - { - type: 'text', - x: 100, - y: 180, - width: 150, - height: 30, - text: '中二猪猪猪', - color: '#fff', - fontSize: 28, - textAlign: 'left', - baseLine: 'top', - textDecoration: 'line-through', - }, -] + useShareAppMessage((payload) => { + const { from, target } = payload + const dataset = target?.['dataset'] || {} + let imageUrl = 'https://hx.404fwf.cn/notifyBoard/img/share_img3.png' + let title = '有新作业偷袭!请注意查收~' + console.log(payload) -const Index: FC = () => { - const posterRender = useRef(null) + if (from === 'button' && dataset?.poster?.path) { + imageUrl = dataset?.poster?.path + title = '我创建了一个作业海报,快来看看叭!' + } + return { + title, + imageUrl, + path: getCurrentPage().route + '?id=' + query()?.id + '&isShare=true', + } + }) + if (loading) { + return + } return ( - console.log('onRender')} - onLongTap={() => posterRender.current?.savePosterToPhoto()} - onRenderFail={(err) => console.error('onRenderFail', err?.message)} - onSave={(url) => console.log('onSave', url)} - onSaveFail={(err) => console.error('onSaveFail', err?.message)} - list={lists} - /> + + + 作业详情 + + {data!.tags?.map((tag) => { + return ( + + {tag} + + ) + })} + + + + {data?.title} + + 截止日期: + {timeFormat(data?.time, 'YYYY年MM月DD日 hh:mm:ss')} + + + 发布人: + {data?.publisher} + + + 内容: + {'\n'}        + {data?.desc} + + + <> + {(data!.imgs || []).map((img) => { + return ( + { + Taro.previewImage({ + current: img, + urls: [...(data?.imgs || [])], + }) + }} + key={1} + > + + + ) + })} + + + + {!query().isShare && ( + + + + + + {data!.status < 2 && ( + + + + )} + + )} + {isShowPoster && ( + + + + + setIsShowPoster(false)}> + ❌ + + + )} + ) } diff --git a/src/pages/main/Manage/Publish/index.module.scss b/src/pages/Detail/types.ts similarity index 100% rename from src/pages/main/Manage/Publish/index.module.scss rename to src/pages/Detail/types.ts diff --git a/src/pages/main/Index/components/Tasklist/task-item.tsx b/src/pages/main/Index/components/Tasklist/task-item.tsx index 52a7792..cb0f68b 100644 --- a/src/pages/main/Index/components/Tasklist/task-item.tsx +++ b/src/pages/main/Index/components/Tasklist/task-item.tsx @@ -1,6 +1,6 @@ import { View, Text } from '@tarojs/components' import React from 'react' -import { Delete, Put, URL, goTo, subscribeHOF, timeFormat } from 'src/utils' +import { Delete, Put, TTaskItem, URL, goTo, subscribeHOF, timeFormat } from 'src/utils' import { SwipeCell } from '@taroify/core' import { TGeneralObject } from 'src/types' import type { SwipeCellProps } from '@taroify/core/swipe-cell/swipe-cell' @@ -10,7 +10,7 @@ import { Replay as ReplayIcon, Exchange as ExchangeIcon, } from '@taroify/icons' -import { TPropsThrough, TTaskItem } from '../../types' +import { TPropsThrough } from '../../types' import { IndexContextProvider, TASK_STATUS, taskInterUrl, tplIds } from '../../common' import './item.module.scss' @@ -129,7 +129,12 @@ class Index extends React.PureComponent { @subscribeHOF(tplIds) goToDetail() { console.log(' === 点击卡片,详情页开始跳转 === ') - goTo({ url: URL.Detail, methodType: 'navigateTo', extraParams: { id: this.props.taskInfo.id } }) + goTo({ + url: URL.Detail, + methodType: 'navigateTo', + extraParams: { id: this.props.taskInfo.id }, + options: { authorize: false }, + }) } /** 删除任务 */ diff --git a/src/pages/main/Index/components/Tasklist/task-list.tsx b/src/pages/main/Index/components/Tasklist/task-list.tsx index 555b4c3..10a2ed4 100644 --- a/src/pages/main/Index/components/Tasklist/task-list.tsx +++ b/src/pages/main/Index/components/Tasklist/task-list.tsx @@ -1,8 +1,9 @@ import { Button, View } from '@tarojs/components' import React, { FC, useCallback, useContext, useMemo, useState } from 'react' import { Divider, Empty, List, PullRefresh } from '@taroify/core' +import { TTaskItem } from 'src/utils' import TaskItem from './task-item' -import { TStateHookUpdateFn, TTaskItem, TTaskList } from '../../types' +import { TStateHookUpdateFn, TTaskList } from '../../types' import { IndexContextProvider } from '../../common' import './list.module.scss' @@ -93,48 +94,54 @@ const Index: FC<{ lists: TTaskList; setPage: TStateHookUpdateFn }> = ({ [filterType, lists, updateList], ) return ( - - {/* TODO: 暂时取消上拉加载 */} - - { - /** 要求lists存在并且长度>0 */ - isCanShowList ? ( - <> - {lists.map((v, index) => { - return ( - - - - ) - })} - {/* 没有更多页面了,增加分割线 */} - {page < 0 ? ( - + // {/* TODO: 暂时取消上拉加载 */} + + { + /** 要求lists存在并且长度>0 */ + isCanShowList ? ( + <> + {lists.map((v, index) => { + return ( + { + e.stopPropagation() + e.preventDefault() }} > - 到底了呦~ - - ) : ( - /* 用来兜底用户删了过多元素,从而无法触发触底的case */ - - )} - - ) : ( - /** lists不存在或lists长度为0 */ - - - 暂时没有更多了 - - ) - } - - + + + ) + })} + {/* 没有更多页面了,增加分割线 */} + {page < 0 ? ( + + 到底了呦~ + + ) : ( + /* 用来兜底用户删了过多元素,从而无法触发触底的case */ + + )} + + ) : ( + /** lists不存在或lists长度为0 */ + + + 暂时没有更多了 + + ) + } + + // ) } diff --git a/src/pages/main/Index/types.ts b/src/pages/main/Index/types.ts index f4b1a97..04fcc7c 100644 --- a/src/pages/main/Index/types.ts +++ b/src/pages/main/Index/types.ts @@ -1,16 +1,6 @@ import React from 'react' import useRequest from 'src/hooks/useRequest' - -/** 任务的类型 */ -export type TTaskItem = { - title: string - time: number - desc: string - /** 当前任务状态 */ - status: 0 | 1 | 2 - /** 当前任务ID */ - id: number -} +import { TTaskItem } from 'src/utils' /** 任务列表的类型 */ export type TTaskList = TTaskItem[] diff --git a/src/pages/main/Manage/Publish/index.config.ts b/src/pages/main/Manage/Publish/index.config.ts deleted file mode 100644 index e6280eb..0000000 --- a/src/pages/main/Manage/Publish/index.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -export default definePageConfig({ - /** 页面标题 */ - navigationBarTitleText: '发布', - /** 是否开启下拉刷新 */ - enablePullDownRefresh: false, - /** 自定义导航栏 */ - navigationStyle: 'custom', - /** 自定义背景颜色 */ - backgroundColor: '#ffffff', -}) diff --git a/src/pages/main/Manage/Publish/index.tsx b/src/pages/main/Manage/Publish/index.tsx deleted file mode 100644 index 7359ace..0000000 --- a/src/pages/main/Manage/Publish/index.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { View } from '@tarojs/components' - -const Index = () => { - return 管理-发布页面 -} - -export default Index diff --git a/src/pages/main/Manage/components/apple.modules.scss b/src/pages/main/Manage/components/apple.modules.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/main/Manage/components/apply-manage.tsx b/src/pages/main/Manage/components/apply-manage.tsx new file mode 100644 index 0000000..719aa72 --- /dev/null +++ b/src/pages/main/Manage/components/apply-manage.tsx @@ -0,0 +1,15 @@ +import { Input, View } from '@tarojs/components' +import React, { FC } from 'react' +import './apple.modules.scss' + +const Index: FC<{ setCurrentTab: React.Dispatch> }> = () => { + return ( + + 输入框 + 申请授权 + 查看授权历史 + + ) +} + +export default React.memo(Index) diff --git a/src/pages/main/Manage/components/work-manage.tsx b/src/pages/main/Manage/components/work-manage.tsx new file mode 100644 index 0000000..712045c --- /dev/null +++ b/src/pages/main/Manage/components/work-manage.tsx @@ -0,0 +1,10 @@ +import { View } from '@tarojs/components' +import React from 'react' +import { Forbidden } from 'src/components/baseBuiltComp/HocWrap' +import './work.modules.scss' + +const Index = () => { + return 1 +} + +export default React.memo(Forbidden(Index)) diff --git a/src/pages/main/Manage/components/work.modules.scss b/src/pages/main/Manage/components/work.modules.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/main/Manage/index.config.ts b/src/pages/main/Manage/index.config.ts index 0bce516..03f148a 100644 --- a/src/pages/main/Manage/index.config.ts +++ b/src/pages/main/Manage/index.config.ts @@ -1,10 +1,8 @@ export default definePageConfig({ /** 页面标题 */ - navigationBarTitleText: '管理页面', + navigationBarTitleText: '', /** 是否开启下拉刷新 */ enablePullDownRefresh: false, - /** 自定义导航栏 */ - navigationStyle: 'custom', /** 自定义背景颜色 */ backgroundColor: '#ffffff', }) diff --git a/src/pages/main/Manage/index.module.scss b/src/pages/main/Manage/index.module.scss index e69de29..6922089 100644 --- a/src/pages/main/Manage/index.module.scss +++ b/src/pages/main/Manage/index.module.scss @@ -0,0 +1,65 @@ +.manage_wrapper { + display: flex; + flex-direction: column; + width: 100vw; + height: 100vh; + overflow-y: scroll; + padding: 0 30rpx 0 30rpx; + box-sizing: border-box; + + .body_wrapper { + width: 100%; + height: 90%; + border: 1rpx solid rgb(131, 214, 110); + box-sizing: border-box; + margin-top: 1%; + border-radius: 20rpx; + .tabs_areas { + display: flex; + width: 100%; + height: 6%; + .tag_item { + display: flex; + justify-content: center; + align-items: center; + width: 140rpx; + height: 100%; + border-radius: 20rpx 20rpx 0 0; + background-color: rgb(93, 232, 135); + margin-right: 5rpx; + } + + .active { + box-shadow: 5rpx -2rpx 10rpx rgb(86, 85, 85); + } + } + + .tabs_views { + width: 100%; + height: 94%; + } + } +} + +.title_wrapper { + display: flex; + align-items: center; + justify-content: space-between; + width: 100%; + margin: 0 0 10rpx 0; + box-sizing: border-box; + + .title_wrapper__text { + font-size: 45rpx; + font-weight: 700; + font-family: AlibabaPuHuiTi; + } +} + +.space { + width: 94%; + height: 1rpx; + background-color: rgb(220, 217, 217); + margin: 10rpx 0 10rpx 3%; + box-sizing: border-box; +} diff --git a/src/pages/main/Manage/index.tsx b/src/pages/main/Manage/index.tsx index 1bce1c1..862740f 100644 --- a/src/pages/main/Manage/index.tsx +++ b/src/pages/main/Manage/index.tsx @@ -1,11 +1,47 @@ -import React from 'react' +import React, { useMemo, useState } from 'react' import { View, Text } from '@tarojs/components' -// import { Forbidden } from 'src/components/baseBuiltComp/HocWrap' +import classNames from 'classnames' +import WorkManage from './components/work-manage' +import ApplyManage from './components/apply-manage' +import './index.module.scss' +const tabs = [ + { + name: '授权管理', + component: ApplyManage, + }, + { + name: '发布管理', + component: WorkManage, + }, +] const Index = () => { + const [currentTab, setTab] = useState(0) + const ViewComponent = useMemo(() => tabs[currentTab].component, [currentTab]) return ( - - 管理页面 + + + 作业详情 + + + + + {tabs.map((tab, i) => { + return ( + setTab(i)} + > + {tab.name} + + ) + })} + + + + + ) } diff --git a/src/static/SVG/lottie-map.ts b/src/static/SVG/lottie-map.ts index 8c75ad6..1b799ec 100644 --- a/src/static/SVG/lottie-map.ts +++ b/src/static/SVG/lottie-map.ts @@ -1,22 +1,16 @@ const BASE_CDN_DOMAIN = 'https://hx.404fwf.cn/notifyBoard/SVG/' +const _uri = (subpath: string) => BASE_CDN_DOMAIN + subpath -/** 只读元组 */ -const MAPPING = [ - '404', - 'forbidden', - 'loading1', - 'loading2', - 'loading3', - 'loading4', - 'loading5', - 'loading6', - 'loading7', - 'success', - 'initial_success', -] as const - -/** lottie动画映射 */ -export const JSON_MAP = MAPPING.reduce((pre, cur) => { - pre[cur] = BASE_CDN_DOMAIN + cur + '.json' - return pre -}, {} as Record<(typeof MAPPING)[number], string>) +/** 只读lottie动画映射 */ +export const JSON_MAP = { + '404': _uri('404.json'), + forbidden: _uri('forbidden.json'), + loading1: _uri('loading1.json'), + loading2: _uri('loading2.json'), + loading3: _uri('loading3.json'), + loading4: _uri('loading4.json'), + loading5: _uri('loading5.json'), + loading6: _uri('loading6.json'), + loading7: _uri('loading7.json'), + success: _uri('success.json'), +} as const diff --git a/src/utils/perfTrack/business.ts b/src/utils/perfTrack/business.ts index 02ce46a..3703552 100644 --- a/src/utils/perfTrack/business.ts +++ b/src/utils/perfTrack/business.ts @@ -23,7 +23,6 @@ type TTrackAPIErrorParams = Pick & { reqData?: TGeneralObject | string | undefined errMsg: any } - /** 网络请求错误埋点 */ export const trackAPIError = ({ token, @@ -44,3 +43,38 @@ export const trackAPIError = ({ }, }) } + +/** 请求错误埋点 */ +type TTrackJsErrorParams = Pick & { + token: string + errMsg: any + location: string + errName: string +} +/** 运行时错误上报 */ +export const trackJsError = ({ + token, + extraParams = {}, + errMsg, + location, + errName, +}: TTrackJsErrorParams) => { + /* __PURE__ */ console.log( + ' === 运行时错误埋点上报 === ', + token, + location, + errName, + extraParams, + errMsg, + ) + trackEvent({ + eventId: BUSINESS_EVENT_MAP.API_ERROR, + extraParams: { + ...extraParams, + token, + err_msg: JSON.stringify(errMsg), + location, + errName, + }, + }) +} diff --git a/src/utils/request/Result.ts b/src/utils/request/Result.ts index 4f1ee22..2854bcf 100644 --- a/src/utils/request/Result.ts +++ b/src/utils/request/Result.ts @@ -2,10 +2,9 @@ import exception from './exception' interface IResultWrapBase { data: T - // header: object, - // cookies: string, msg: string code: number + extraData: { [key: string]: any } isSuccess: boolean } @@ -14,6 +13,7 @@ class ResultWrapBase implements Partial> { private _data?: T private _msg?: string private _code?: number + private _extraData?: { [key: string]: any } private _isSuccess?: boolean /** 获取请求数据 */ @@ -31,6 +31,11 @@ class ResultWrapBase implements Partial> { return this._code } + /** 用于获取非标准code-msg-data结构的额外参数 */ + get extraData() { + return this._extraData + } + /** 获得到是否成功请求 */ get isSuccess() { return this._isSuccess @@ -40,6 +45,7 @@ class ResultWrapBase implements Partial> { this._data = params.data this._msg = params.msg this._code = params.code + this._extraData = params.extraData this._isSuccess = params.isSuccess } } diff --git a/src/utils/request/business.ts b/src/utils/request/business.ts index 543345e..cdf594b 100644 --- a/src/utils/request/business.ts +++ b/src/utils/request/business.ts @@ -27,7 +27,7 @@ export const request = ( ...baseExtraConfig, ...params, header: { - token: getStorage('userInfo').token, + token: getStorage('userInfo').token, ...params.header, }, }) @@ -43,11 +43,16 @@ export const request = ( } const { data, code, msg } = originData + const extraData = Object.keys(originData) + .filter((k) => !['code', 'data', 'msg'].includes(k)) + .reduce((pre, cur) => (pre[cur] = originData[cur]), {}) + resInstance = new ResultWrap({ data, msg, code, isSuccess: !type, + extraData, type, }) if (!params.silent) { @@ -60,7 +65,7 @@ export const request = ( if (!type) { /** 上报错误埋点 */ trackAPIError({ - token: getStorage('userInfo').token || 'noLogin', + token: getStorage('userInfo').token || 'no_login', api: params.url, reqData: params.data, errMsg: msg, @@ -73,6 +78,20 @@ export const request = ( msg: _err, type: 'system_error', }) + if (!params.silent) { + const { loadingNeedMask: mask } = params + showToast({ + title: '执行失败了.....', + mask, + }) + } + /** 上报错误埋点 */ + trackAPIError({ + token: getStorage('userInfo').token || 'no_login', + api: params.url, + reqData: params.data, + errMsg: _err, + }) } resolve(resInstance) }) diff --git a/src/utils/request/request.ts b/src/utils/request/request.ts index bc8db04..1a77e10 100644 --- a/src/utils/request/request.ts +++ b/src/utils/request/request.ts @@ -1,5 +1,5 @@ import Taro from '@tarojs/taro' -import { hideLoading, showLoading, showToast } from '../extraUiEffect' +import { hideLoading, showLoading } from '../extraUiEffect' /** Taro.request入参类型 */ type TTaroRequestParams = Parameters>[0] diff --git a/src/utils/route/constants.ts b/src/utils/route/constants.ts index 13a811d..3870d01 100644 --- a/src/utils/route/constants.ts +++ b/src/utils/route/constants.ts @@ -5,8 +5,6 @@ export const enum URL { Calendar = '/pages/main/Calendar/index', /** 管理页面 */ Manage = '/pages/main/Manage/index', - /** 发布页面 */ - ManagePublish = '/pages/main/Manage/index', /** 我的页面 */ My = '/pages/main/My/index', /** 详细页面 */ diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 7874cbc..99b951e 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -1,21 +1,17 @@ import Taro from '@tarojs/taro' -import { ISystemInfo, IUserInfo } from 'src/common-model' +import { IUserInfo } from 'src/common-model' import { isObj } from './jsBase' /** 可存储的storage接口 */ export interface IStorageData { userInfo: IUserInfo - system: ISystemInfo & { - /** 是否弹过未授权消息 */ - isPopNoAuthorizeMessage?: boolean - } } type TStorageKey = keyof IStorageData /** * 获取本地存储 */ -export const getStorage = (key: TStorageKey): T => { +export const getStorage = (key: K): IStorageData[K] => { return Taro.getStorageSync(key) } diff --git a/src/utils/subscribe.ts b/src/utils/subscribe.ts index 45e0abc..effe37c 100644 --- a/src/utils/subscribe.ts +++ b/src/utils/subscribe.ts @@ -79,8 +79,8 @@ export function subscribeHOF(tplIds: string[]) { /** 额外执行订阅逻辑 */ descriptor.value = async function () { /** 先等授权逻辑走完 */ - const { errno } = await subscribe({ tplId: tplIds }) - return !errno ? originalFunction.apply(this, arguments) : () => void 0 + subscribe({ tplId: tplIds }) + return originalFunction.apply(this, arguments) } return descriptor } diff --git a/src/utils/types/entity/index.ts b/src/utils/types/entity/index.ts new file mode 100644 index 0000000..746e7a9 --- /dev/null +++ b/src/utils/types/entity/index.ts @@ -0,0 +1 @@ +export * from './task' diff --git a/src/utils/types/entity/task.ts b/src/utils/types/entity/task.ts new file mode 100644 index 0000000..e66893d --- /dev/null +++ b/src/utils/types/entity/task.ts @@ -0,0 +1,22 @@ +/** 任务的类型 */ +export type TTaskItem = { + title: string + time: number + desc: string + /* 当前任务状态 */ + status: 0 | 1 | 2 + /* 当前任务ID */ + id: number + /* 标签 */ + tags?: string[] + imgs?: string[] + /* 发布人 */ + publisher: string +} + +/** 任务状态的枚举 */ +export const taskStatusEnum = { + 0: '未完成', + 1: '已完成', + 2: '已过期', +} diff --git a/src/utils/types/index.ts b/src/utils/types/index.ts index 73b6124..3d9b976 100644 --- a/src/utils/types/index.ts +++ b/src/utils/types/index.ts @@ -1 +1,2 @@ export * from './enumHelper' +export * from './entity'