客服奖励 字体文件
This commit is contained in:
parent
dd38c92ec3
commit
1f2cc26b9f
@ -3,6 +3,11 @@ import gamesRouter from './games';
|
||||
import settingsRouter from './settings';
|
||||
import platformsRouter from './platforms';
|
||||
import shareRouter from './share';
|
||||
import rewardRouter from './reward';
|
||||
|
||||
|
||||
|
||||
// 小程序 关联
|
||||
import mpShareRouter from './mp_share';
|
||||
|
||||
const router = new Router();
|
||||
@ -11,6 +16,7 @@ router.use('/settings', settingsRouter);
|
||||
router.use('/platforms', platformsRouter);
|
||||
router.use('/share', shareRouter);
|
||||
router.use('/mp_share', mpShareRouter);
|
||||
router.use('/reward', rewardRouter);
|
||||
router.use('/', gamesRouter);
|
||||
|
||||
export default router;
|
||||
|
@ -8,6 +8,9 @@ import Template from '../../models/mp_share/Template'
|
||||
|
||||
const router = new Router()
|
||||
|
||||
// TODO: 添加 logs与权限验证
|
||||
// TODO: 判断请求是否来自小程序
|
||||
|
||||
// 生成预览图
|
||||
router.post('/get_pic', async (req, res, next) => {
|
||||
const body = req.body
|
||||
@ -48,6 +51,51 @@ router.post('/get_pic', async (req, res, next) => {
|
||||
}
|
||||
})
|
||||
|
||||
// 查询单个模板
|
||||
router.get('/get_tpl', async (req, res, next) => {
|
||||
const query = req.query
|
||||
try {
|
||||
const result = await Template.findOne({
|
||||
_id: query.tpl_uid,
|
||||
deleted: false,
|
||||
})
|
||||
if (!result) {
|
||||
res.send({
|
||||
errcode: 1,
|
||||
errmsg: '模板不存在或已删除!',
|
||||
})
|
||||
return
|
||||
}
|
||||
res.send({
|
||||
errcode: 0,
|
||||
tpl: result,
|
||||
})
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
// 查询模板列表
|
||||
router.get('/get_tpls', async (req, res, next) => {
|
||||
const query = req.query
|
||||
const currentPage = query.currentPage || 0
|
||||
const pageSize = query.pageSize || 0
|
||||
const start = (currentPage - 1) * pageSize
|
||||
const limit = Number(pageSize)
|
||||
try {
|
||||
const result = await Template.find({deleted: false})
|
||||
.skip(start)
|
||||
.limit(limit)
|
||||
const total = await Template.find({
|
||||
deleted: false,
|
||||
}).countDocuments()
|
||||
|
||||
res.json({errcode: 0, errmsg: '', records: result, total: total})
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
// 保存模板
|
||||
router.post('/save_tpl', async (req, res, next) => {
|
||||
const body = req.body
|
||||
@ -62,7 +110,31 @@ router.post('/save_tpl', async (req, res, next) => {
|
||||
return
|
||||
}
|
||||
tpl.createdBy = req.user.username || ''
|
||||
const result = await Template.save(tpl)
|
||||
const newTpl = new Template(tpl)
|
||||
const result = await newTpl.save()
|
||||
res.send({
|
||||
errcode: 0,
|
||||
result: result
|
||||
})
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
// 修改模板
|
||||
router.post('/update_tpl', async (req, res, next) => {
|
||||
const body = req.body
|
||||
const tpl = body.tpl
|
||||
try {
|
||||
const searchRes = await Template.findOne({_id: tpl._id})
|
||||
if (!searchRes) {
|
||||
res.send({
|
||||
errcode: 1,
|
||||
errmsg: '模板不存在或已删除!',
|
||||
})
|
||||
return
|
||||
}
|
||||
const result = await Template.updateOne({_id: tpl._id}, tpl)
|
||||
res.send({
|
||||
errcode: 0,
|
||||
})
|
||||
@ -71,12 +143,27 @@ router.post('/save_tpl', async (req, res, next) => {
|
||||
}
|
||||
})
|
||||
|
||||
// 修改模板
|
||||
|
||||
// 删除模板
|
||||
router.post('/del_tpl', async (req, res, next) => {
|
||||
const body = req.body
|
||||
const _id = body._id
|
||||
try {
|
||||
const searchRes = await Template.findOne({_id: _id})
|
||||
if (!searchRes) {
|
||||
res.send({
|
||||
errcode: 1,
|
||||
errmsg: '模板不存在或已删除!',
|
||||
})
|
||||
return
|
||||
}
|
||||
const result = await Template.updateOne({_id: _id}, {deleted: true})
|
||||
res.send({
|
||||
errcode: 0,
|
||||
})
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
// 查询单个模板
|
||||
|
||||
// 获取模板列表
|
||||
|
||||
export default router
|
||||
|
144
src/controllers/games/reward.js
Normal file
144
src/controllers/games/reward.js
Normal file
@ -0,0 +1,144 @@
|
||||
import {Router} from 'express'
|
||||
import logger from '../../utils/logger'
|
||||
import CustomerReplay from '../../models/snoopy/CustomerReplay'
|
||||
|
||||
const router = new Router()
|
||||
|
||||
// 获取奖励列表
|
||||
router.get('/list', async (req, res, next) => {
|
||||
// 权限判断
|
||||
const hasPerm =
|
||||
req.user.permissions.includes(`${req.body.uid}-readable`) ||
|
||||
req.user.permissions.includes(`${req.body.uid}-edit`) ||
|
||||
req.user.permissions.includes(`${req.body.uid}-publish`) ||
|
||||
req.user.permissions.includes(`games-writeable`)
|
||||
if (!hasPerm) {
|
||||
res.status(403).send({
|
||||
errcode: 1,
|
||||
errmsg: '用户无此游戏奖励列表查看权限!',
|
||||
})
|
||||
return
|
||||
}
|
||||
const query = req.query
|
||||
const game_id = query.game_id
|
||||
const currentPage = query.currentPage || 0
|
||||
const pageSize = query.pageSize || 0
|
||||
const start = (currentPage - 1) * pageSize
|
||||
const limit = parseInt(pageSize)
|
||||
try {
|
||||
const records = await CustomerReplay.find({
|
||||
game_id: game_id,
|
||||
deleted: false,
|
||||
})
|
||||
.skip(start)
|
||||
.limit(limit)
|
||||
.sort({createdAt: 'desc'})
|
||||
const total = await CustomerReplay.find({
|
||||
game_id: game_id,
|
||||
deleted: false,
|
||||
}).countDocuments()
|
||||
res.json({errcode: 0, errmsg: '', records: records, total: total})
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
// 保存奖励配置
|
||||
router.post('/save', async (req, res, next) => {
|
||||
// 权限判断
|
||||
const hasPerm =
|
||||
req.user.permissions.includes(`${req.body.uid}-edit`) ||
|
||||
req.user.permissions.includes(`${req.body.uid}-publish`) ||
|
||||
req.user.permissions.includes(`games-writeable`)
|
||||
if (!hasPerm) {
|
||||
res.status(403).send({
|
||||
errcode: 1,
|
||||
errmsg: '用户无此游戏奖励编辑权限!',
|
||||
})
|
||||
return
|
||||
}
|
||||
logger.db(req, '游戏管理', '客服奖励', '更新客服奖励');
|
||||
|
||||
const body = req.body
|
||||
try {
|
||||
let record
|
||||
if (body._id) {
|
||||
record = await CustomerReplay.findById(body._id)
|
||||
}
|
||||
record = CustomerReplay.parseReq(req, record)
|
||||
await record.save()
|
||||
res.json({errcode: 0, errmsg: ''})
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
// 删除奖励配置
|
||||
router.post('/del', async (req, res, next) => {
|
||||
// 权限判断
|
||||
const hasPerm =
|
||||
req.user.permissions.includes(`${req.body.uid}-edit`) ||
|
||||
req.user.permissions.includes(`${req.body.uid}-publish`) ||
|
||||
req.user.permissions.includes(`games-writeable`)
|
||||
if (!hasPerm) {
|
||||
res.status(403).send({
|
||||
errcode: 1,
|
||||
errmsg: '用户无此游戏奖励编辑权限!',
|
||||
})
|
||||
return
|
||||
}
|
||||
logger.db(req, '游戏管理', '客服奖励', '删除客服奖励');
|
||||
const body = req.body
|
||||
try {
|
||||
if (body.ids) {
|
||||
const record = await CustomerReplay.where({_id: {$in: body.ids}})
|
||||
.updateMany({
|
||||
deleted: true,
|
||||
delete_time: new Date(),
|
||||
deletedBy: req.user.id,
|
||||
})
|
||||
.exec()
|
||||
res.json({errcode: 0, errmsg: '', count: record.n})
|
||||
} else {
|
||||
res.json({errcode: 101, errmsg: '无有效奖励!'})
|
||||
}
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
// 启用禁用奖励配置
|
||||
router.post('/switch', async (req, res, next) => {
|
||||
// 权限判断
|
||||
const hasPerm =
|
||||
req.user.permissions.includes(`${req.body.uid}-edit`) ||
|
||||
req.user.permissions.includes(`${req.body.uid}-publish`) ||
|
||||
req.user.permissions.includes(`games-writeable`)
|
||||
if (!hasPerm) {
|
||||
res.status(403).send({
|
||||
errcode: 1,
|
||||
errmsg: '用户无此游戏奖励编辑权限!',
|
||||
})
|
||||
return
|
||||
}
|
||||
logger.db(req, '游戏管理', '客服奖励', '切换客服奖励状态');
|
||||
const body = req.body
|
||||
const type = body.type // 启用: true 禁用 false
|
||||
try {
|
||||
if (body.ids) {
|
||||
const record = await CustomerReplay.where({
|
||||
_id: {$in: body.ids},
|
||||
})
|
||||
.updateMany({actived: type})
|
||||
.exec()
|
||||
res.json({errcode: 0, errmsg: '', count: record.n})
|
||||
} else {
|
||||
res.json({errcode: 101, errmsg: '无有效奖励!'})
|
||||
}
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
@ -68,10 +68,9 @@ router.post('/list', async (req, res, next) => {
|
||||
opt.game_id = gameId;
|
||||
}
|
||||
if (shareType) {
|
||||
console.log(shareType)
|
||||
opt.share_type = shareType;
|
||||
}
|
||||
if (type) {
|
||||
if (type !== '') {
|
||||
opt.type = type;
|
||||
}
|
||||
let records;
|
||||
|
BIN
src/fonts/1001.ttf
Normal file
BIN
src/fonts/1001.ttf
Normal file
Binary file not shown.
BIN
src/fonts/1002.ttf
Normal file
BIN
src/fonts/1002.ttf
Normal file
Binary file not shown.
BIN
src/fonts/1003.ttf
Normal file
BIN
src/fonts/1003.ttf
Normal file
Binary file not shown.
BIN
src/fonts/1004.ttf
Normal file
BIN
src/fonts/1004.ttf
Normal file
Binary file not shown.
BIN
src/fonts/1005.ttf
Normal file
BIN
src/fonts/1005.ttf
Normal file
Binary file not shown.
BIN
src/fonts/1006.ttf
Normal file
BIN
src/fonts/1006.ttf
Normal file
Binary file not shown.
BIN
src/fonts/1007.ttf
Normal file
BIN
src/fonts/1007.ttf
Normal file
Binary file not shown.
BIN
src/fonts/1008.ttf
Normal file
BIN
src/fonts/1008.ttf
Normal file
Binary file not shown.
BIN
src/fonts/1009.ttf
Normal file
BIN
src/fonts/1009.ttf
Normal file
Binary file not shown.
BIN
src/fonts/1010.ttf
Normal file
BIN
src/fonts/1010.ttf
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/fonts/1012.ttf
Normal file
BIN
src/fonts/1012.ttf
Normal file
Binary file not shown.
BIN
src/fonts/2001.ttf
Normal file
BIN
src/fonts/2001.ttf
Normal file
Binary file not shown.
87
src/fonts/font_config.js
Normal file
87
src/fonts/font_config.js
Normal file
@ -0,0 +1,87 @@
|
||||
const fontConfig = {
|
||||
'1001': {
|
||||
label: '思源柔黑',
|
||||
name: 'Gen Jyuu Gothic Monospace Normal',
|
||||
value: '1001',
|
||||
path: '1001.ttf'
|
||||
},
|
||||
'2001': {
|
||||
label: '站酷意大利体',
|
||||
name: 'ZCOOL Addict Italic 01',
|
||||
value: '2001',
|
||||
path: '2001.ttf'
|
||||
},
|
||||
'1002': {
|
||||
label: '站酷高端黑',
|
||||
name: '站酷高端黑',
|
||||
value: '1002',
|
||||
path: '1002.ttf'
|
||||
},
|
||||
'1003': {
|
||||
label: '站酷快乐体',
|
||||
name: '站酷快乐体',
|
||||
value: '1003',
|
||||
path: '1003.ttf'
|
||||
},
|
||||
'1004': {
|
||||
label: '站酷酷黑体',
|
||||
name: '站酷酷黑体',
|
||||
value: '1004',
|
||||
path: '1004.ttf'
|
||||
},
|
||||
'1005': {
|
||||
label: '站酷庆科黄油体',
|
||||
name: '站酷庆科黄油体',
|
||||
value: '1005',
|
||||
path: '1005.ttf'
|
||||
},
|
||||
'1006': {
|
||||
label: '阿里汉仪智能黑体',
|
||||
name: 'AliHYAiHei-Beta',
|
||||
value: '1006',
|
||||
path: '1006.ttf'
|
||||
},
|
||||
'1007': {
|
||||
label: '汉仪贤二体',
|
||||
name: '汉仪贤二体',
|
||||
value: '1007',
|
||||
path: '1007.ttf'
|
||||
},
|
||||
'1008': {
|
||||
label: '濑户字体',
|
||||
name: 'SetoFont',
|
||||
value: '1008',
|
||||
path: '1008.ttf'
|
||||
},
|
||||
'1009': {
|
||||
label: '沐瑶软笔手写体',
|
||||
name: 'Muyao-Softbrush',
|
||||
value: '1009',
|
||||
path: '1009.ttf'
|
||||
},
|
||||
'1010': {
|
||||
label: '锐字真言体',
|
||||
name: '锐字真言体',
|
||||
value: '1010',
|
||||
path: '1010.ttf'
|
||||
},
|
||||
'1011': {
|
||||
label: '手书体',
|
||||
name: '手书体',
|
||||
value: '1011',
|
||||
path: '1011.ttf'
|
||||
},
|
||||
'1012': {
|
||||
label: '杨任东竹石体',
|
||||
name: '杨任东竹石体',
|
||||
value: '1012',
|
||||
path: '1012.ttf'
|
||||
},
|
||||
|
||||
//TODO: 淘宝华康等
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Binary file not shown.
BIN
src/fonts/tr.ttf
BIN
src/fonts/tr.ttf
Binary file not shown.
@ -14,9 +14,10 @@ const Template = new mongoose.Schema({
|
||||
base_style: {type: Object},
|
||||
views: [{type: Object}],
|
||||
comment: {type: String},
|
||||
createdBy: {type: String}
|
||||
createdBy: {type: String},
|
||||
deleted: {type: Boolean, default: false}
|
||||
}, {
|
||||
collection: 'template',
|
||||
collection: 'mp_share_template',
|
||||
timestamps: true,
|
||||
});
|
||||
|
||||
|
@ -33,7 +33,7 @@ const CustomerReplayModel = conn.model('CustomerReplay', CustomerReplay);
|
||||
CustomerReplayModel.parseReq = function(req, record) {
|
||||
if (!record) {
|
||||
record = new CustomerReplayModel({
|
||||
createdBy: req.user.id,
|
||||
createdBy: req.user.username,
|
||||
});
|
||||
}
|
||||
const body = req.body;
|
||||
|
@ -207,7 +207,7 @@ function _drawText(ctx, view) {
|
||||
// 字体大小和fontface
|
||||
ctx.font = style['font-family']
|
||||
? `${fontWeight} ${fontSize} "${style['font-family']}"`
|
||||
: `${fontWeight} ${fontSize} "Sans"`
|
||||
: `${fontWeight} ${fontSize}`
|
||||
// 文字对齐方式
|
||||
if (style['writing-mode'] === 'vertical-rl') {
|
||||
// 竖排文字
|
||||
|
Loading…
x
Reference in New Issue
Block a user