lzj500 3 роки тому
батько
коміт
06ffd120dd


BIN
images/daoru.jpg


+ 0 - 5
index.md

@@ -1,5 +0,0 @@
-### 这是首页
-
-![](images/1.jpg)
-
-上面是图片

+ 160 - 0
其它规范示例/其它编码.md

@@ -0,0 +1,160 @@
+在方法中,分支不要嵌套
+
+```
+login(){
+	if(!this.hasRead){
+		uni.showModal({
+			title: '提示',
+			content: '请勾选用户协议',
+			showCancel: false,
+		});
+	}else{
+		if(this.phone == '' || !this.phone){
+			uni.showModal({
+				title: '提示',
+				content: '请填写手机号码',
+				showCancel: false,
+			});
+		}else{
+			if(this.loginType == 0 && (this.code == '' || !this.code)){
+				uni.showModal({
+					title: '提示',
+					content: '请填写验证码',
+					showCancel: false,
+				});
+			}else{
+				if(this.loginType == 1 && (this.password == '' || !this.password)){
+					uni.showModal({
+						title: '提示',
+						content: '请输入密码',
+						showCancel: false,
+					});
+				}else{
+					var that = this;
+					console.log('openid',that.openid);
+					uni.request({
+						url: config.apiHost + config.apiUrl.sendLoginData,
+						data: {phone: that.phone, type: 'code', code: that.code, openId: that.openid, loginType: that.loginType, password: that.password}	,
+						success: function (res) {
+							let response = res.data;
+							if(response.code == 0){
+								uni.setStorageSync('adminId', response.data.id);
+								uni.setStorageSync('schoolId', response.data.schoolId);
+								let redirect = uni.getStorageSync('redirectUrl');
+								if(!response.data.mp_open_id || response.data.mp_open_id == ''){
+									//跳转新的webview页面获取用户公众号的openid
+									uni.navigateTo({
+										url: '/pages/index/open?userId='+ response.data.id
+									})
+									return;
+								}
+								// uni.setStorageSync('adminTypes', response.data.types);
+								uni.showToast({
+									title: '登录成功,即将跳转首页',
+									duration: 2000
+								});
+								if(redirect){
+									uni.reLaunch({
+										url: redirect
+									});
+								}else{
+									uni.reLaunch({
+										url: '/pages/index/index'
+									});
+								}
+							}else{
+								uni.showModal({
+									title: '提示',
+									content: response.msg,
+									showCancel: false,
+								});
+							}
+						}
+					});
+				}
+			}
+		}
+	}
+},
+```
+
+修改后
+
+```
+login0() {
+	if (!this.hasRead) {
+		uni.showModal({
+			title: "提示",
+			content: "请勾选用户协议",
+			showCancel: false
+		});
+		return;
+	}
+	if (this.phone == "" || !this.phone) {
+		uni.showModal({
+			title: "提示",
+			content: "请填写手机号码",
+			showCancel: false
+		});
+		return;
+	}
+	if (this.loginType == 0 && (this.code == "" || !this.code)) {
+		uni.showModal({
+			title: "提示",
+			content: "请填写验证码",
+			showCancel: false
+		});
+		return;
+	}
+	if (this.loginType == 1 && (this.password == "" || !this.password)) {
+		uni.showModal({
+			title: "提示",
+			content: "请输入密码",
+			showCancel: false
+		});
+		return;
+	} else {
+		var that = this;
+		console.log("openid", that.openid);
+		uni.request({
+			url: config.apiHost + config.apiUrl.sendLoginData,
+			data: { phone: that.phone, type: "code", code: that.code, openId: that.openid, loginType: that.loginType, password: that.password },
+			success: function (res) {
+				let response = res.data;
+				if (response.code == 0) {
+					uni.setStorageSync("adminId", response.data.id);
+					uni.setStorageSync("schoolId", response.data.schoolId);
+					let redirect = uni.getStorageSync("redirectUrl");
+					if (!response.data.mp_open_id || response.data.mp_open_id == "") {
+						//跳转新的webview页面获取用户公众号的openid
+						uni.navigateTo({
+							url: "/pages/index/open?userId=" + response.data.id
+						});
+						return;
+					}
+					// uni.setStorageSync('adminTypes', response.data.types);
+					uni.showToast({
+						title: "登录成功,即将跳转首页",
+						duration: 2000
+					});
+					if (redirect) {
+						uni.reLaunch({
+							url: redirect
+						});
+					} else {
+						uni.reLaunch({
+							url: "/pages/index/index"
+						});
+					}
+				} else {
+					uni.showModal({
+						title: "提示",
+						content: response.msg,
+						showCancel: false
+					});
+				}
+			}
+		});
+	}
+},
+```

+ 8 - 0
前端规范.md

@@ -0,0 +1,8 @@
+# 前端规范
+
+- 编码规范
+
+  - 前端编码规范,参考:http://alloyteam.github.io/CodeGuide/
+  - 前端异步回调嵌套不允许超过 2 层
+
+- 图片资源,如无透明要求,不允许使用 png、gif 格式

+ 5 - 0
功能设计约束/导入功能.md

@@ -0,0 +1,5 @@
+# 导入功能
+
+1.导入功能必须要提供模板下载 2.导入文档如果允许部分导入成功,部分失败,须提供导入结果下载。
+参考下图:
+![](../images/daoru.jpg)

+ 5 - 0
功能设计约束/支付功能.md

@@ -0,0 +1,5 @@
+# 支付功能
+
+1.前台只提供订单 ID,支付参数全由后台查询生成。不允许前台提交金额  
+2.前台支付成功后,要有支付结果查询机制  
+3.后端要实现订单支付轮循任务,对待支付的订单支付结果进行查询,如果超时未支付,要使订单状态过期

+ 32 - 0
后端规范.md

@@ -0,0 +1,32 @@
+# php 编译规范
+
+- 编码无特殊说明,参考 PSR 规范
+  https://www.kancloud.cn/thinkphp/php-fig-psr/3139
+
+- thinkPHP 编码注意事项
+
+  - 事务要在控制器中实现,不允许在模型中实现
+  - 在 THINKPHP6 中,跨域要基于中间件实现,不要在 index.php 文件中实现
+    参考文档:thinkphp6 解决跨域.note
+    链接:http://note.youdao.com/noteshare?id=88846717ae6024219e544832557d7583&sub=93F626A294EE49F889F4F1B8B71E2CC3
+    错误示例
+    /public/index.php
+
+    ```
+    define('WEB_DIR',dirname(str_replace($_SERVER['DOCUMENT_ROOT'],"",$\_SERVER['SCRIPT_FILENAME'])));//定义根目录虚拟路径
+    header("Access-Control-Allow-Credentials:true");
+    header("Access-Control-Allow-Origin:*");//注意修改这里填写你的前端的域名
+    header("Access-Control-Max-Age:3600");
+    header("Access-Control-Allow-Headers:\_,Content-Type,Fetch-Mode,accept,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,SessionToken");
+    header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS, POIST');
+    // 执行 HTTP 应用并响应
+    $http = (new App())->http;
+    $response = $http->run();
+    $response->send();
+    $http->end($response);
+    ```
+
+  - 复杂的业务操作建议放在流程中,不要放在控制器中实现。例如 订单退订、订单核销等。
+
+- 方法要写注释,说明方法功能
+- 单个函数代码行数不要超过 200 行(注释不算),单个文件代码行数建议超过 2000 行(注释不算)

+ 94 - 0
基础框架.md

@@ -0,0 +1,94 @@
+# 基础框架
+
+http://192.168.0.80:3000/yckj/yckj_framework
+
+## 目录说明
+
+```
+|-- thinkphp6 后端项目,基于thinkPHP6
+|-- d2-admin 后台前端项目,基于d2admin简化版本
+|-- uniapp_cli 移动端前端项目,基于cli命令行的uniapp
+  |-- public index.html模板目录
+  |-- src 源码目录,如果是用hbuilderx编译,直接导入scr目录进行编译
+```
+
+### 项目配置
+
+##### d2admin
+
+基于以下配置,通过使用 vscode 作为编辑 器,可以实现保存代码时自动 补全和自动格式化功能。由于各种组件 eslint 编码规范不一致,是否使用由个人决定
+
+###### .prettierrc
+
+```
+{
+    "printWidth": 1000,
+    "tabWidth": 2,
+    "useTabs": true,
+    "singleQuote": false,
+    "semi": true,
+    "trailingComma": "none",
+    "bracketSpacing": true
+}
+```
+
+###### .vscode/.settings.json
+
+```
+{
+    "editor.lineNumbers": "on", //开启行数提示
+    "editor.quickSuggestions": {
+        //开启自动显示建议
+        "other": true,
+        "comments": true,
+        "strings": true
+    }, //制表符符号eslint
+    "editor.formatOnSave": true, //每次保存自动格式化
+    // "eslint.autoFixOnSave": true, // 每次保存的时候将代码按eslint格式进行修复
+    "editor.codeActionsOnSave": {
+        "source.fixAll": true
+    },
+    "prettier.eslintIntegration": true, //让prettier使用eslint的代码格式进行校验
+    "prettier.semi": true, //去掉代码结尾的分号
+    "prettier.singleQuote": false, //使用带引号替代双引号
+    "javascript.format.insertSpaceBeforeFunctionParenthesis": true, //让函数(名)和后面的括号之间加个空格
+    "vetur.format.defaultFormatter.html": "js-beautify-html", //格式化.vue中html
+    "vetur.format.defaultFormatter.js": "vscode-typescript", //让vue中的js按编辑器自带的ts格式进行格式化
+    "vetur.format.defaultFormatterOptions": {
+        "js-beautify-html": {
+            "wrap_attributes": "force-aligned" //属性强制折行对齐
+        }
+    },
+    "eslint.validate": [
+        "javascript",
+        "javascriptreact",
+        "html",
+        "vue"
+    ],
+    "eslint.workingDirectories": []
+}
+
+```
+
+###### .eslintignore 忽略 js 和 vue 文件
+
+```
+**/*.js
+**/*.vue
+```
+
+### 相关知识
+
+thinkphp 文档: [http://kancloud.cn/manual/thinkphp6_0/content](http://kancloud.cn/manual/thinkphp6_0/content)
+
+d2admin 文档: [https://d2.pub/zh/doc/d2-admin/](https://d2.pub/zh/doc/d2-admin/)
+
+uniapp 文档: [https://uniapp.dcloud.io/](https://uniapp.dcloud.io/)
+
+[文档:d2admin 修改组件默认大小.note](http://note.youdao.com/noteshare?id=7aa4fdbbac32ee7683c6f835ccec67a2&sub=240C6888D9534DB5A8207A3E2BF5FFA3)
+
+[文档:d2admin 不使用框架页面的方法.note](http://note.youdao.com/noteshare?id=51bad13c3e3d8ef94ab7b6015c2e2e01&sub=3C96C1300A474BB6815E6E3CB8135E20)
+
+[文档:d2admin 修改环境变量.note](http://note.youdao.com/noteshare?id=566eb5adb8a6425ceb5f3b01f51df9d1&sub=5FE4BE2B48DD4E6CBE470C03F04B2DCC)
+
+[文档:d2admin 部署在相对路径.note](http://note.youdao.com/noteshare?id=9249cc2c90291fd0193cb1f314c2daa4&sub=7A16FE8AA54B42ED9317DFA7FDD4B11F)

+ 18 - 0
常用库推荐.md

@@ -0,0 +1,18 @@
+## 后端
+
+- 微信接口开发:easywechat
+  https://gitee.com/overtrue/wechat
+- PDF 导出:tcpdf
+  https://github.com/tecnickcom/tcpdf
+- excel 操作:PHPOffice/PhpSpreadsheet
+  https://github.com/PHPOffice/PhpSpreadsheet
+
+## 前端
+
+- 异步组件 await-to-js
+- 时间日期库:dayjs
+- EXCEL 操作:xlsx
+  https://www.npmjs.com/package/xlsx
+- uniapp ui 框架:uview ui
+  uview ui 如果不是开发 APP,不要使用 v2 版本,使用 1.X 版本即可
+  https://v1.uviewui.com/