Przeglądaj źródła

chore: 拆分md

zhangyuhan 1 rok temu
rodzic
commit
ca1faa0d44

+ 21 - 0
apps/mobile/src/data/README.md

@@ -0,0 +1,21 @@
+### LINKS 页面地址
+定义app、wx页面地址
+
+#### 示例
+```js
+import { LINKS } from '@/data'
+
+console.log(LINKS.超级订阅落地页)
+// {
+//   app: '/jyapp/vipsubscribe/introducePage',
+//   wx: '/front/vipsubscribe/introducePage'
+// }
+```
+#### 与 openAppOrWxPage 自动匹配环境,打开外部项目链接
+```js
+import { openAppOrWxPage } from '@/utils'
+import { LINKS } from '@/data'
+
+// 打开外部项目链接
+openAppOrWxPage(LINKS.超级订阅落地页)
+```

+ 15 - 0
apps/mobile/src/store/README.md

@@ -0,0 +1,15 @@
+### direction
+获取页面进入方式
+
+#### 示例
+```js
+this.$store.state.direction
+```
+
+#### Options
+| 结果 | 描述 |
+| :----: | :----: |
+| reload | 初始化路由 / 刷新进入路由 |
+| forward | 其他路由前进到当前路由 |
+| back | 其他路由返回当前路由 |
+

+ 71 - 0
apps/mobile/src/utils/README.md

@@ -0,0 +1,71 @@
+### $env, $envs
+项目运行环境
+
+#### 示例
+```js
+import { env, envs } from '@/utils'
+
+env.platform // 平台wx/app/h5
+env.platformOS // 系统平台android/ios
+envs.inWX // 判断是否是微信浏览器
+envs.inApp // 判断是否是app
+envs.inH5 // 判断是否是网页
+```
+
+### openLinkOfOther
+打开外部项目地址,自动区分补全前缀地址
+
+#### 示例
+```js
+import { openLinkOfOther } from '@/utils'
+
+// 根据环境,自动补全
+openLinkOfOther('/jyapp/vipsubscribe/introducePage')
+
+// 手动全路径
+openLinkOfOther('https://jianyu360.cn/jyapp/vipsubscribe/introducePage')
+```
+
+### openAppOrWxPage
+打开外部项目地址,自动区分补全前缀地址
+
+#### 示例
+```js
+import { openAppOrWxPage } from '@/utils'
+
+openAppOrWxPage({
+  app: '/jyapp/vipsubscribe/introducePage',
+  wx: '/front/vipsubscribe/introducePage'
+})
+
+// 携带参数
+openAppOrWxPage({
+  app: '/jyapp/vipsubscribe/introducePage',
+  wx: '/front/vipsubscribe/introducePage'
+}, {
+  query: {
+    type: 'type'
+  }
+})
+```
+
+### callChangeTab
+切换底部导航
+
+#### Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| name | 需要切换到的TabName 对应关系 search:搜索 subscribe:订阅 box:百宝箱 me:我的 message:消息 | String | - |
+| router | 当前项目需传递 this.$router | String | - |
+
+#### 示例
+```js
+import { callChangeTab } from '@/utils'
+
+// 当前项目 Tabbar
+callChangeTab('search', this.$router)
+
+// 旧项目 Tabbar
+callChangeTab('box')
+```
+

+ 100 - 0
apps/mobile/src/utils/directive/README.md

@@ -0,0 +1,100 @@
+## 指令
+项目自定义指令
+
+### v-active
+用于实现自定义 active / press 点击样式效果
+
+#### 示例
+```html
+<button v-active="{ css: 'active', time: 260 }">v-active 示例</button>
+```
+
+#### Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| css | 用于添加的className | String | active |
+| time | 最大展示时长 ms, -1表示只有touchEnd时候才移除css的样式 | Number | -1 |
+
+
+### v-visited
+用于实现添加信息已访问样式,点击时自动存储对应 id, type 用于回显判断,基于实例方法 $visited 的简单封装
+
+#### 示例
+```html
+<!--简写-->
+<button v-visited.content="id">v-visited 示例</button>
+
+<!--等同于如下完整参数-->
+<button v-visited="{ css: 'visited', id: '信息唯一标识', type: 'content' }">v-visited 示例</button>
+
+<!--仅使用自动添加 className, 禁用点击自动缓存 -->
+<button v-visited.content.stop="id">v-visited 示例</button>
+
+<!--等同于如下完整参数-->
+<button v-visited="{ id: '信息唯一标识', type: 'content', stopClick: true }">v-visited 示例</button>
+```
+
+#### Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| css | 用于添加的已访问className | String | visited |
+| id | 信息唯一标识 | String | - |
+| type | 信息类型 | String (content、issued、ent、buyer、project) | - |
+| stopClick | 禁用点击自动缓存 | Boolean | false |
+
+#### Types 信息类型
+```
+content: 'article/content/*',   标讯详情页
+issued: 'article/issued',       供应详情页
+ent: 'ent(_ser)?_portrait',     企业详情页
+buyer: 'client_portrayal',      采购单位详情页
+project: 'client_follow_detail' 项目关注详情页
+```
+
+
+### v-keep
+用于实现收藏业务功能, 基于实例方法 $keep 的简单封装
+
+#### 示例
+```html
+<button v-keep="{ id: 'id1'}">
+    基础 v-keep 收藏示例
+</button>
+```
+```html
+<button
+    v-keep="{
+        status: false,
+        id: ['id1', 'id2']
+    }"
+>
+    批量 v-keep 收藏示例
+</button>
+```
+#### Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| loadingTip | 加载提示 | String | 提交中 |
+| showLabel | 是否需要选择标签 | Boolean | true |
+| status | 当前是否处于收藏状态 | Boolean | false |
+| id |  用于收藏的 id | String / Array | - |
+| getContainer |  指定挂载的节点 | String / Function | body / () => Element |
+| complete | 业务回调 type 是否完成业务  | Function | ({ type, message }, response) => null |
+
+
+### v-leave-info
+用于简单留资事件绑定
+
+场景:收藏、下载附件、免费体验等操作需先进行是否需要留资判断
+
+流程:绑定指令,传入指令所需参数source。
+指令会自行绑定点击事件并执行留资判断。如果需要留资,直接跳转留资页面
+
+#### 示例
+```html
+<button v-leave-info="'article_collection'"></button>
+```
+#### Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| source | 留资source字段 | String | '' |

+ 102 - 0
apps/mobile/src/utils/format/README.md

@@ -0,0 +1,102 @@
+### calcNotExactTime
+时间格式化工具函数
+
+#### Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| exact | 快捷格式, 见下方 | String | - |
+| unit | 时间单位 [ms | s] | String | ms |
+
+#### 示例
+```js
+// 获取今天00:00:00 - 23:59:59
+calcNotExactTime('today')
+// {
+//   start: '时间戳',
+//   end: '时间戳'
+// }
+```
+
+#### Exacts 支持的格式
+```
+today 今天
+yesterday 昨天
+lately3 近3天
+lately-7 近7天
+lately7 近7天
+lately-30 近30天
+lately30 近30天
+lately90 近90天
+lately180 1近80天
+thisYear 今年全年
+thisyear 最近1年
+lastYear 去年全年
+sinceLastYear 去年至今
+sinceYearBeforeLast 前年至今
+threeyear 最近3年
+fiveyear 最近5年
+```
+
+### formatMoney
+金额格式化函数
+
+#### Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| money | 金额 | String, Number | - |
+| config | 类型 [full | number | unit] | String | full |
+| config.type | 配置项 | Object | 见下方详细字段 |
+| config.level | 初始单位索引 | Number | 0 |
+| config.levelArr | 单位数组 | Array | ['元', '万元', '亿元', '万亿元'] |
+| config.unit | 计算单位 | Number | 10000 |
+| config.digit | 精度,保留小数位数 | Number | 2 |
+| config.degrade | 指定单位索引时,所需精度不够是否降级单位 | Boolean | false |
+
+#### 基础示例
+```js
+formatMoney('1000')
+// 1000元
+
+formatMoney('1000', {
+  type: 'number'
+})
+// 1000
+
+formatMoney('1000', {
+  type: 'unit'
+})
+// 元
+```
+
+#### 复杂示例
+```js
+// 指定单位为万,格式化
+formatMoney('1', {
+  level: 1
+})
+// '' 默认精度为2,格式化后值为0
+
+formatMoney('1', {
+  digit: 4,
+  level: 1
+})
+// 0.0001万元
+
+formatMoney('1', {
+  degrade: true,
+  level: 1
+})
+// 1元 允许降级一个单位
+```
+
+#### 自定义示例
+```js
+// 自定义单位用法
+formatMoney('1000000', {
+    type: 'full',
+    level: 0,
+    unit: 10,
+    levelArr: ['分', '角', '元', '0元', '00元', '000元', '万元']
+})
+// 1万元
+```

+ 153 - 0
apps/mobile/src/utils/prototype/README.md

@@ -0,0 +1,153 @@
+### $keep
+用于实现收藏业务功能, 也可以使用指令 v-keep
+
+#### 示例
+```js
+this.status = false
+this.$keep.action({
+  status: this.status,
+  id: '',
+  complete: ({ type, message }) => {
+    if (type) {
+      this.status = !this.status
+    }
+  }
+})
+```
+
+#### Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| loadingTip | 加载提示 | String | 提交中 |
+| showLabel | 是否需要选择标签 | Boolean | true |
+| status | 当前是否处于收藏状态 | Boolean | false |
+| id |  用于收藏的 id | String / Array | - |
+| getContainer |  指定挂载的节点 | String / Function | body / () => Element |
+| complete | 业务回调 type 是否完成业务  | Function | ({ type, message }, response) => null |
+| source | 留资业务 source | String | article_collection |
+| stopLeaveInfo | 是否禁用留资业务 | Boolaan | false |
+| beforeRedirect | 留资业务回调 beforeRedirect  | Function | (conf, response) => null |
+
+
+### $storage
+用于快捷实现本地存储存取数据
+
+#### Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| prefix | 前缀 | String | package.json-name |
+| storage | localStorage/sessionStorage | Object | localStorage |
+| expires | 过期时间 | Date | -1 |
+| login | 是否添加特殊标识,标识登录时需清除的数据 | Boolean | false |
+| loginPrefix | 标识登录时需清除的数据的特殊附加前缀 | String | -login-clear- |
+
+#### 示例
+```js
+// 存
+this.$storage.set('test key', 'this is test value')
+
+// 取
+this.$storage.get('test key')
+// 取,没有值时使用默认值
+this.$storage.get('test key', 'this is default value')
+
+// 清除
+this.$storage.rm('test key')
+```
+
+#### 复杂示例
+```js
+// 存 设置过期时间为 今天23:59:59
+this.$storage.set('test key', 'this is test value', {
+  expires: 'today'
+})
+
+// 存 使用 sessionStorage
+this.$storage.set('test key', 'this is test value', {
+  storage: sessionStorage
+})
+
+// 存 APP端用户退出、登录时清除,或 Cookies.sessionID 变更时清除
+this.$storage.set('test key', 'this is test value', {
+  login: true
+})
+```
+
+### $visited
+用于快捷实现已访问信息存储,及回显判断,简单用法参见指令 v-visited
+
+#### 示例
+
+```js
+// 新增访问记录
+this.$visited.push({
+  type: '信息类型',
+  id: '信息唯一标识'
+})
+
+// 检查是否存在访问记录
+this.$visited.check({
+  type: '信息类型',
+  id: '信息唯一标识'
+})
+
+// 手动更新数据,获取最新本地存储数据,清除过期数据,更新 list
+this.$visited.refreshVisited()
+```
+
+#### Types 信息类型
+```
+content: 'article/content/*',   标讯详情页
+issued: 'article/issued',       供应详情页
+ent: 'ent(_ser)?_portrait',     企业详情页
+buyer: 'client_portrayal',      采购单位详情页
+project: 'client_follow_detail' 项目关注详情页
+```
+
+### $leaveInfo
+用于实现留资功能以及复杂留资逻辑判断的函数, 也可以使用指令 v-leave-info 使用简单功能
+
+#### 示例
+```js
+// 如果this.$leaveInfo中抛出异常,则do something中的内容不再执行
+// 如果beforeLeaveInfo中抛出Error,则do something中的内容不再执行
+// 判断是否需要留资
+await this.$leaveInfo({
+  source: 'listLeaveSource',
+  beforeRedirect: beforeLeaveInfo
+})
+
+// do something
+console.log('star')
+```
+```js
+// 自定义提示
+async function beforeLeaveInfo (conf, { retainedCapital: needLeaveInfo }) {
+  if (needLeaveInfo) {
+    await this.$dialog.confirm({
+      className: 'j-confirm-dialog',
+      closeOnClickOverlay: true,
+      showCancelButton: false,
+      message: '重要项目一键创建标签收藏!请完善个人信息,为您匹配精准服务',
+      confirmButtonText: '立即前往'
+    })
+    // throw new Error('需要留资,beforeRedirect中阻止了后续事件执行')
+  }
+}
+```
+
+#### Conf Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| source | 留资id(必传) | String | '' |
+| params | 额外参数 | Object | {} |
+| beforeRedirect | 需要跳转前的回调,`throw new Error('xxx') 中断后续操作`,支持Promise | Function | - |
+| redirect |  跳转操作,默认跳转留资 | Function | - |
+
+#### callback params Options
+| 参数 | 描述 | 类型 | 默认值 |
+| :----: | :----: | :----: | :----: |
+| source | 留资id | String | '' |
+| params | 额外参数 | Object | {} |
+| fource | 是否强制留资 | Boolean | false |
+| retainedCapital |  是否需要留资。是则跳转留资页面 | Boolean | false |

+ 1 - 0
docs/sitemap.md

@@ -0,0 +1 @@
+