Commit 11d81f9a authored by gengshaojing's avatar gengshaojing

add: 生成二维码工具

parent bc46526a
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"@types/qr-image": "^3.2.4",
"axios": "^0.21.1", "axios": "^0.21.1",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"dayjs": "^1.10.6", "dayjs": "^1.10.6",
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
"koa-static": "^5.0.0", "koa-static": "^5.0.0",
"koa-views": "^7.0.1", "koa-views": "^7.0.1",
"moment": "^2.29.1", "moment": "^2.29.1",
"qr-image": "^3.2.0",
"request": "^2.88.2", "request": "^2.88.2",
"uglifyjs-webpack-plugin": "^2.2.0", "uglifyjs-webpack-plugin": "^2.2.0",
"uuid": "^8.3.2", "uuid": "^8.3.2",
......
const qr = require('qr-image');
exports.gen_qr_code = async (ctx) => {
const url = ctx.query.url;
try {
let img = qr.image(decodeURIComponent(url));
ctx.type= 'image/png';
ctx.body = img;
} catch (e) {
ctx.type='text/html;charset=utf-8';
ctx.body='<h1>414 Request-URI Too Large</h1>';
}
};
...@@ -9,12 +9,14 @@ const goods = require('./controllers/goods'); ...@@ -9,12 +9,14 @@ const goods = require('./controllers/goods');
const activity = require('./controllers/activity'); const activity = require('./controllers/activity');
const withdrawal = require('./controllers/withdrawal'); const withdrawal = require('./controllers/withdrawal');
const groupmeal = require('./controllers/groupmeal'); const groupmeal = require('./controllers/groupmeal');
const qr_code = require('./controllers/qr-code');
const router = Router(); const router = Router();
const API_VERSION = "/api/v1"; const API_VERSION = "/api/v1";
router.get(/^\/op.*/, static.index) router.get(/^\/op.*/, static.index)
router.get(`${API_VERSION}/qr_code`, qr_code.gen_qr_code);
router.get(`${API_VERSION}/fetch_user`, system.fetch_user); router.get(`${API_VERSION}/fetch_user`, system.fetch_user);
router.get(`${API_VERSION}/user/:type`, user.query) router.get(`${API_VERSION}/user/:type`, user.query)
router.post(`${API_VERSION}/J_login`, system.J_login); router.post(`${API_VERSION}/J_login`, system.J_login);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment