Compare commits

...

No commits in common. 'master' and 'main' have entirely different histories.
master ... main

32
.gitignore vendored

@ -1,32 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.tsbuildinfo
/unpackage/*

@ -1,16 +0,0 @@
{
// launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote
"version": "0.0",
"configurations": [
{
"app-plus": {
"launchtype": "local"
},
"default": {
"launchtype": "local"
},
"type": "uniCloud"
}
]
}

@ -1,45 +0,0 @@
# 新手常见问题
列举一些不好检索的,新手容易碰到的问题。
## 为什么我的 HBuilderx 的运行/打包按钮不可点?
HBuilderx 特性,需要在编辑器中打开任意项目下的文件才能运行/打包当前项目。
## 为什么我的项目运行不起来?
1. AppId没有获取
2. 环境没装好
3. 代码有问题
4. 依赖没装好
5. 依赖有问题
### AppID 有没有获取?
组长操作
[README.MD](./README.md#重要!写在开始!)
### 检查开发环境
安装[node](https://nodejs.cn/en/download/prebuilt-installer)
### 检查是不是代码运行之前不小心在键盘上敲了一下,导致代码错误?
拿到代码后第一时间上传git仓库这样每一次代码变更都有迹可循。
> 重新获取代码也可以
### 有没有安装依赖?
通过`git clone`的项目通常不会有第三方依赖文件夹,这需要你自己安装
前端项目有多种第三方依赖管理,常用的有`npm`、`yarn`,项目根目录下的`package.json`文件就是第三方依赖管理文件
运行安装命令如`npm install`后会在根目录下多出一个`node_modules`文件夹存放第三方依赖
### 确认第三方依赖安装的版本
可能你自动安装的依赖版本和开发者使用的依赖版本不一致,手动固定`package.json`中的依赖版本号后重新安装
> Mini-12306 已经固定了版本号

1
Q_D

@ -1 +0,0 @@
Subproject commit 9afd67d4320ab967a75ad9a38e65907cb3074bfe

@ -1,75 +1 @@
# 重要!写在开始!
请每组开发人员统一使用的`AppID`,建议由小组组长生成后分享给小组成员
1. 组长获取代码,大概率是压缩包
2. 使用[HBuilder X](https://www.dcloud.io/hbuilderx.html)打开项目文件夹
3. 在根目录下找到并打开`manifest.json`文件,在`基础配置`中`重新获取AppID`
4. 上传代码到小组代码仓库(为什么?参考[新手常见问题](./QUESTIONS.md#检查是不是代码运行之前不小心在键盘上敲了一下,导致代码错误?)
5. 通知小组成员从代码仓库中重新获取项目代码
[DCloud appid 用途/作用/使用说明](https://ask.dcloud.net.cn/article/35907)
> 相同 appid 的项目打包的 apk 文件在安装时会相互覆盖,不同的则会共存(你也不想你组的 app 被其他组覆盖安装吧)
>
> 请保管好你组的 appid
# Mini-12306 APP
软件工程开发案例 - 前端app
以下内容为项目基本情况了解,实际上手开发可查看[开发指引](./README_DEVELOPMENT.md)
另附[新手常见问题](./QUESTIONS.md)
> 若要运行此项目,请先确保已安装依赖`npm install`
> 如果运行命令报错,请查看[新手常见问题](./QUESTIONS.md#检查开发环境)
## 关于前端开发
- 上手非常简单,开发工具完备
- 开发成果可视,正反馈很及时
> 前端开发在所有代码开发中的上手难度都是最低的
> 美观的页面可以给人留下非常好的第一印象
- 小团队中前端往往还会包含 UI 的职责
> 兼职 UI 的前端会很容易端陷入`细节调整`的陷阱:花大量时间死扣一个样式细节,导致整体进度被忽略。
---
## 开发语言
- [HTML](https://developer.mozilla.org/zh-CN/docs/Learn/HTML/Introduction_to_HTML/Getting_started)
- [JavaScript](https://developer.mozilla.org/zh-CN/docs/Learn/JavaScript/First_steps/A_first_splash)
- [CSS](https://developer.mozilla.org/zh-CN/docs/Learn/Getting_started_with_the_web/CSS_basics)
> 这是前端开发基础,掌握了基础才能看懂并使用框架来简化开发
>
> 就算你是完全的零基础,看完上面的链接基本就能上手了(网页侧边栏是完整教程,简单认识的话单看链接页面即可)
> 非常简单
## 开发框架
- [Vue2](https://v2.cn.vuejs.org/v2/guide/)
- [uni-app](https://uniapp.dcloud.net.cn/)
- [uview](https://www.uviewui.com/)
> 开发框架只需要做到`能看懂、会使用`就行
> 对于开发框架,重要的是熟练,也就是代码写的越多,越熟练
## 推荐 IDE
- [HBuilder X](https://www.dcloud.io/hbuilderx.html)
> uni-app 开发专用 IDE。
> 你也可以使用自己喜欢的编辑器,但相对的运行、打包等流程就需要自己去配置了。
## 代码规范参考
- [2021 阿里代码规范(前端篇)](https://developer.aliyun.com/article/850913)
#R_J

@ -1,89 +0,0 @@
# Mini-12306 项目从零开发指引
项目使用 [uni-app](https://uniapp.dcloud.net.cn/) 前端应用框架,以类 [Vue](https://cn.vuejs.org/) 的开发方式进行 app 开发
以下是如何从零开始一个 uni-app 项目,建议按指引创建新项目先走一遍熟悉开发流程,再使用本项目中已有的代码进行开发
## 开发环境
1. 安装[node](https://nodejs.cn/en/download/prebuilt-installer)
2. 下载 uni-app 专用集成开发环境IDE[HBuilderX-高效极客技巧 (dcloud.io)](https://dcloud.io/hbuilderx.html)
3. 解压并打开`HBuilderX.exe`运行 IDE
4. 左上角`文件`→`新建`→`项目`→`uni-app`→`默认模板`
> 注意选择 vue2 版本。
> vue3 版本的 uni-app x 可以使用更高级的类型验证,但插件问题较多。
## 开发流程
### 项目结构简单说明
- `api` 前后端交互接口集中管理
- `components` 通用组件文件夹(先行了解 vue 组件概念)
- `node_modules` 第三方插件文件夹npm
- `pages` 所有能访问的页面
- `static` 静态资源(如不会修改的图标/图片)
- `store` 【进阶】Vuex跨页面数据管理
- `uni_modules` 这是 uni-app 中的 node_modulesuni-app 插件市场会导入到此文件夹)
- `utils` 常用方法、过滤器等工具
- `App.vue` 项目入口,主要是`onLauch`和全局样式
- `main.js` 项目入口,一般插件安装都会指引你在这个文件进行引入
- `manifest.json` 很重要的项目控制(打包)文件,但一般不会改到里面的东西
- `package.json` 与 node 中的同名文件对应,管理通过 npm 安装的第三方库
- `pages.json` 软件的路由配置(配置所有可以访问的页面)
- `uni.scss` 项目内置样式(注意里面只存放样式变量,不要在里面写实际样式)
### 项目运行(浏览器)
最方便开发肯定是一边改代码一边在设备中看到效果,
既然我们在 pc 上进行开发,那在浏览器中查看代码效果肯定是最方便的啦
1. HbuilderX 顶部菜单栏`运行`→`运行到浏览器`
2. 浏览器运行后打开`开发者模式F12`,切换`设备仿真`(一般是控制台左上角的第二个图标)
3. 修改项目代码,并保存,即可在浏览器中看到效果
![](README_DEVELOPMENT_files/1.jpg)
> 如果你是运行的本项目,记得使用`npm install`安装`package.json`中的依赖项
### 上手体验
参考`Hello uni-app`模板项目的源代码,在自己创建的空白项目中开发相关功能
> 对照着界面和代码一起看!(运行`Hello uni-app`项目)
1. 实现页面跳转(内置组件:导航 navigator`Hello uni-app/pages/component/navigator/navigator.vue`
2. 数据输入与提交(内置组件:表单组件)
3. 简单 js 功能(接口:界面-带数据的页面跳转、显示 loading 提示框,`Hello uni-app/pages/API/navigator/navigator.vue`
4. 与后端交互(接口:网络-发起一个请求,`Hello uni-app/pages/API/request/request.vue`
> 实际开发也是:
> → 搭建所有页面与路由配置(页面间跳转)
> → 在各页面中记录下要开发的功能
> → 实现功能逻辑(假数据)
> → 初步美化页面
> → 与后端对接(讨论修改)
> → 细节调整
## 项目打包 APP
HbuilderX 顶部菜单栏`发行:云端打包`(打包好后会在 HbuilderX 的控制台给出 apk 链接)
打包只需要勾选以下内容
- 使用公共测试证书
- 打正式包
- 快速安心打包
## 注意事项
- uview 要使用`npm`进行安装uni-app 插件市场安装的版本有问题
## 最后
以你们自己做的各种图来实现 Mini-12306
前端开发注意不要陷入页面样式细节的代码中去了,优先实现功能代码
> 建议参考`铁路12306`App 进行页面设计和功能拓展

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

@ -1,59 +0,0 @@
/**
* 用户接口
*
* 因为 Mini-12306 不存在查看其他用户详情的交互
* 故不需要区分 auth user
*/
const apiAuth = {
/**
* 用户新增(注册)
*/
add: (params) => {
return uni.$u.http.post("/register", {
account: params.account, // 用户名
password: params.password, // 密码
name: params.name, // 姓名
idCardNo: params.idCardNo,
mobileNo: params.mobileNo,
mobileCode: params.mobileCode,
bankCard: params.bankCardNo,
});
},
/**
* 用户更新
*/
update: () => {},
/**
* 用户删除
*/
delete: () => {},
/**
* 用户详情
* 正常是通过用户id获取用户信息这里没有其他用户
* 故改为通过 auth-token 获取 auth 信息
*/
detail: () => {
return uni.$u.http.get("/auth");
},
/**
* 用户列表
*/
get: () => {},
/**
* 用户登录
*/
login: (params) => {
return uni.$u.http.post("/login", {
account: params.account, // 用户名
password: params.password, // 密码
});
},
};
export default apiAuth;

@ -1,35 +0,0 @@
const apiOrders = {
/**
* 订单创建
*/
add: (params) => {
return uni.$u.http.post("/orders", {
tickets: params.tickets.map((tkt) => ({
trainNo: tkt.trainNo, // 车次
from: tkt.from, // 上车
to: tkt.to, // 下车
date: uni.$u.dayjs(tkt.date).format("YYYY/MM/DD"), // 乘车日期python 后端要求这样转,按道理应该带上时区让后端处理)
seatClass: 0, // (暂无)座位类型,一等座/二等座(不同车次叫法不一样)
passengerId: tkt.passengerId, // 乘车人这种写法是不支持添加乘车人的因为你不知道他人id
})),
});
},
/**
* 订单支付
*/
payment: (params) => {
return uni.$u.http.post(`/bank/pay`, {
orderNo: params.orderNo,
});
},
/**
* 订单支付查询
*/
queryPayment: (params) => {
return uni.$u.http.post(`/orders/${params.orderNo}/query_payment`);
},
};
export default apiOrders;

@ -1,12 +0,0 @@
const apiOther = {
/**
* 发送手机验证码
*/
sendMobileCode: (params) => {
return uni.$u.http.post("/mobile/get_verify_code", {
mobileNo: params.mobileNo, // 手机号码
});
},
};
export default apiOther;

@ -1,14 +0,0 @@
/**
* 站点接口
*/
const apiStations = {
/**
* 站点列表
*/
get: (params) => {
return uni.$u.http.get("/stations");
},
};
export default apiStations;

@ -1,18 +0,0 @@
/**
* 车票接口
*/
const apiTickets = {
/**
* 车票列表
*/
get: (params) => {
return uni.$u.http.get("/tickets", {
params: {
state: 1, // 已出票(订单已支付)
},
});
},
};
export default apiTickets;

@ -1,20 +0,0 @@
/**
* 车次接口
*/
const apiTrains = {
/**
* 车次列表
*/
get: (params) => {
return uni.$u.http.get("/trains/query_train", {
params: {
from: params.from,
to: params.to,
date: params.date,
},
});
},
};
export default apiTrains;

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>

@ -1,39 +0,0 @@
import Vue from "vue";
import App from "./App";
import store from "./store";
import "./uni.promisify.adaptor";
import uView from "uview-ui";
Vue.use(uView);
import {
dayjs,
timeFormat,
timeDiff,
hideIdCardNo,
hideMobileNo,
hideBankCardNo,
} from "./utils/filters";
Vue.filter("timeFormat", timeFormat); // 覆盖 uview 的设置
uni.$u.timeFormat = timeFormat;
uni.$u.date = undefined;
uni.$u.dayjs = dayjs;
Vue.filter("timeDiff", timeDiff);
Vue.filter("hideIdCardNo", hideIdCardNo);
Vue.filter("hideMobileNo", hideMobileNo);
Vue.filter("hideBankCardNo", hideBankCardNo);
Vue.config.productionTip = false;
App.mpType = "app";
const app = new Vue({
...App,
store,
});
// 引入请求封装将app参数传递到配置中
require("./utils/request.js")(app);
app.$mount();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 978 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 841 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 727 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 335 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1023 KiB

@ -1,35 +0,0 @@
import Vue from "vue";
import Vuex from "vuex";
import storeAuth from "./modules/auth";
Vue.use(Vuex);
const store = new Vuex.Store({
state: {
stations: [],
},
mutations: {
SET_STATIONS(state, stations) {
state.stations = stations || [];
},
},
actions: {
/**
* [{ id: 1, name: "长沙南站" }]
*/
updateStations({ commit }, stations) {
commit(
"SET_STATIONS",
stations.sort((a, b) =>
a.pinyin < b.pinyin ? -1 : a.pinyin > b.pinyin ? 1 : 0
)
);
},
},
modules: {
auth: storeAuth,
},
});
export default store;

@ -1,16 +0,0 @@
import getDefaultAuth from "./state";
export function updateAuth({ commit }, auth) {
auth = auth ?? getDefaultAuth();
if ("token" in auth) uni.setStorageSync("auth-token", auth.token);
if ("id" in auth) commit("SET_AUTH_ID", auth.id);
if ("account" in auth) commit("SET_AUTH_ACCOUNT", auth.account);
if ("name" in auth) commit("SET_AUTH_NAME", auth.name);
if ("idCardNo" in auth) commit("SET_AUTH_ID_CARD_NO", auth.idCardNo);
if ("mobileNo" in auth) commit("SET_AUTH_MOBILE_NO", auth.mobileNo);
if ("bankCardNo" in auth) commit("SET_AUTH_BANK_CARD_NO", auth.bankCardNo);
}
export function revertAuth({ dispatch }) {
dispatch("updateAuth", getDefaultAuth());
}

@ -1,15 +0,0 @@
/**
* Auth 代表登录用户信息
*/
import getDefaultAuth from "./state";
import * as mutations from "./mutations";
import * as actions from "./actions";
const storeAuth = {
state: getDefaultAuth(),
mutations,
actions,
};
export default storeAuth;

@ -1,25 +0,0 @@
import getDefaultAuth from "./state";
export function SET_AUTH_ID(state, id) {
state.id = id || getDefaultAuth().id;
}
export function SET_AUTH_ACCOUNT(state, account) {
state.account = account || getDefaultAuth().account;
}
export function SET_AUTH_NAME(state, name) {
state.name = name || getDefaultAuth().name;
}
export function SET_AUTH_ID_CARD_NO(state, idCardNo) {
state.idCardNo = idCardNo || getDefaultAuth().idCardNo;
}
export function SET_AUTH_MOBILE_NO(state, mobileNo) {
state.mobileNo = mobileNo || getDefaultAuth().mobileNo;
}
export function SET_AUTH_BANK_CARD_NO(state, bankCardNo) {
state.bankCardNo = bankCardNo || getDefaultAuth().bankCardNo;
}

@ -1,12 +0,0 @@
function getDefaultAuth() {
return {
id: undefined,
account: "", // 用户名
name: "", // 姓名
idCardNo: "", // 身份证号
mobileNo: undefined, // 手机号
bankCardNo: undefined, // 银行卡号
};
}
export default getDefaultAuth;

@ -1,10 +0,0 @@
uni.addInterceptor({
returnValue (res) {
if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then === "function")) {
return res;
}
return new Promise((resolve, reject) => {
res.then((res) => res[0] ? reject(res[0]) : resolve(res[1]));
});
},
});

@ -1,118 +0,0 @@
/**
* uni-app
*
* uni-app https://ext.dcloud.net.cn使
* 使scss使 import 便App
*
*/
/**
* App使
*
* 使scss scss 使 import
*/
@import "uview-ui/theme.scss";
/* 覆盖 theme.scs 的值 */
$u-bg-color: #f5f5f5;
/* 文字尺寸 */
$uni-font-size-sm: 14px;
$uni-font-size-base: 16px;
$uni-font-size-lg: 18px;
/* 间距 */
$space: 12px;
$spacers: (
ssm: calc(#{$space} / 3),
sm: calc(#{$space} / 2),
base: $space,
lg: calc(#{$space} / 3 * 4.5),
llg: calc(#{$space} / 3 * 6),
);
/* 颜色 */
$colors: (
primary: $u-primary,
primary-dark: $u-primary-dark,
primary-disabled: $u-primary-disabled,
primary-light: $u-primary-light,
warning: $u-warning,
warning-dark: $u-warning-dark,
warning-disabled: $u-warning-disabled,
warning-light: $u-warning-light,
success: $u-success,
success-dark: $u-success-dark,
success-disabled: $u-success-disabled,
success-light: $u-success-light,
error: $u-error,
error-dark: $u-error-dark,
error-disabled: $u-error-disabled,
error-light: $u-error-light,
info: $u-info,
info-dark: $u-info-dark,
info-disabled: $u-info-disabled,
info-light: $u-info-light,
main: $u-main-color,
content: $u-content-color,
tips: $u-tips-color,
light: $u-light-color,
white: #ffffff,
background: $u-bg-color,
app-blue: #238cfc, // rgb(35,140,252)
);
// /* */
// /* */
// $uni-color-primary: #007aff;
// $uni-color-success: #4cd964;
// $uni-color-warning: #f0ad4e;
// $uni-color-error: #dd524d;
// /* */
// $uni-text-color: #333; //
// $uni-text-color-inverse: #fff; //
// $uni-text-color-grey: #999; //
// $uni-text-color-placeholder: #808080;
// $uni-text-color-disable: #c0c0c0;
// /* */
// $uni-bg-color: #ffffff;
// $uni-bg-color-grey: #f8f8f8;
// $uni-bg-color-hover: #f1f1f1; //
// $uni-bg-color-mask: rgba(0, 0, 0, 0.4); //
// /* */
// $uni-border-color: #c8c7cc;
// /* */
// /* */
// $uni-img-size-sm: 20px;
// $uni-img-size-base: 26px;
// $uni-img-size-lg: 40px;
// /* Border Radius */
// $uni-border-radius-sm: 2px;
// $uni-border-radius-base: 3px;
// $uni-border-radius-lg: 6px;
// $uni-border-radius-circle: 50%;
// /* */
// $uni-opacity-disabled: 0.3; //
// /* */
// $uni-color-title: #2c405a; //
// $uni-font-size-title: 20px;
// $uni-color-subtitle: #555555; //
// $uni-font-size-subtitle: 26px;
// $uni-color-paragraph: #3f536e; //
// $uni-font-size-paragraph: 15px;

@ -1,46 +0,0 @@
import dayjs from "dayjs";
require("dayjs/locale/zh-cn");
import isToday from "dayjs/plugin/isToday.js";
dayjs.locale("zh-cn");
dayjs.extend(isToday);
export { dayjs };
// https://dayjs.fenxianglu.cn/category/display.html
export function timeFormat(dateTime = null, formatStr = "YYYY-MM-DD") {
return dayjs(dateTime).format(formatStr);
}
/**
* 时间间隔返回值为 xx小时xx分钟
* @param {String} fromTime
* @param {String} toTime
*/
export function timeDiff(fromTime, toTime) {
const diff = dayjs(toTime).diff(dayjs(fromTime), "minute", true);
let result = "";
if (diff >= 60) {
result += `${parseInt(diff / 60)}小时`;
}
if (diff % 60 !== 0) {
result += `${diff % 60}`;
}
return result;
}
/**
* 隐藏身份证号
* @param {String} idCardNo
*/
export function hideIdCardNo(idCardNo) {
return idCardNo.replace(/(.{4}).+(.{3})/, `$1****$2`);
}
export function hideMobileNo(mobileNo) {
return mobileNo.replace(/(.{3}).+(.{4})/, `$1****$2`);
}
export function hideBankCardNo(bankCardNo) {
return bankCardNo.replace(/(.{4}).+(.{4})/, `$1****$2`);
}

@ -1,58 +0,0 @@
export function validateRequired(
rule,
value,
callback,
{ label, trim } = { label: "", trim: false }
) {
let val = String(value ?? "");
if (trim) val = val.trim();
if (val.length === 0) {
callback(new Error(`请输入${label}`));
} else {
callback();
}
}
export function validateAccount(rule, value, callback) {
const val = String(value ?? "");
if (!val) {
callback(new Error("请输入用户名"));
} else if (/[A-Za-z][A-Za-z0-9_]{5,29}/.test(val)) {
callback();
} else {
callback(
new Error(
`用户名只能填写字母、数字、下划线开头必须为字母且长度在6~30位内`
)
);
}
}
export function validatePassword(rule, value, callback) {
const val = String(value ?? "");
if (!val) {
callback(new Error("请输入密码"));
} else if (
/(?!^\d+$)(?!^[A-Za-z]+$)(?!^_+$)^\w{6,30}$/.test(String(value ?? ""))
) {
callback();
} else {
callback(
new Error(
`密码格式错误,必须且只能包含字母、数字、下划线中的两种或两种以上`
)
);
}
}
export function validatePasswordConfirm(rule, value, callback, password) {
const val = String(value ?? "");
if (!val) {
callback(new Error("请再次输入密码"));
} else if (val !== password) {
callback(new Error("两次输入密码不一致"));
} else {
callback();
}
}

@ -1,8 +0,0 @@
export function timeAscCompareFn(aTime, bTime) {
const at = uni.$u.dayjs(aTime);
const bt = uni.$u.dayjs(bTime);
if (at.isBefore(bt)) return -1;
else if (at.isAfter(bt)) return 1;
else return 0;
}

@ -1,20 +0,0 @@
export default {
data() {
return {
uNavbarBgColor: "transparent",
uNavbarTitleColor: "transparent",
uNavbarIconColor: "var(--color-white)",
};
},
onPageScroll(e) {
let per = e.scrollTop / 200;
if (per < 0) per = 0;
else if (per > 1) per = 1;
this.uNavbarBgColor = `rgba(245,245,245,${per})`;
this.uNavbarTitleColor = `rgba(48,49,51,${per})`;
this.uNavbarIconColor = `rgba(${255 - (255 - 96) * per},${
255 - (255 - 98) * per
},${255 - (255 - 102) * per})`;
},
};

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save