作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

三期代码提交

正在显示 50 个修改的文件 包含 1978 行增加765 行删除
{"license":"regular","licenseto":"30453","licensekey":"MvLUpyxGr0cbewSd isolvNTM71vSlABVPUrVepKNIrz+w6D2adnw5fWgV5Q=","files":["public\\assets\\addons\\summernote\\css\\summernote.css","public\\assets\\addons\\summernote\\font\\summernote.eot","public\\assets\\addons\\summernote\\font\\summernote.ttf","public\\assets\\addons\\summernote\\font\\summernote.woff","public\\assets\\addons\\summernote\\js\\summernote.js","public\\assets\\addons\\summernote\\js\\summernote.min.js","public\\assets\\addons\\summernote\\lang\\summernote-zh-CN.js","public\\assets\\addons\\summernote\\lang\\summernote-zh-CN.min.js","public\\assets\\addons\\summernote\\lang\\summernote-zh-TW.js","public\\assets\\addons\\summernote\\lang\\summernote-zh-TW.min.js"]}
\ No newline at end of file
<?php
namespace addons\summernote;
use think\Addons;
/**
* Summernote富文本编辑器
*/
class Summernote extends Addons
{
/**
* 插件安装方法
* @return bool
*/
public function install()
{
return true;
}
/**
* 插件卸载方法
* @return bool
*/
public function uninstall()
{
return true;
}
}
require.config({
paths: {
'summernote': '../addons/summernote/lang/summernote-zh-CN.min'
},
shim: {
'summernote': ['../addons/summernote/js/summernote.min', 'css!../addons/summernote/css/summernote.css'],
}
});
require(['form', 'upload'], function (Form, Upload) {
var _bindevent = Form.events.bindevent;
Form.events.bindevent = function (form) {
_bindevent.apply(this, [form]);
try {
//绑定summernote事件
if ($(".summernote,.editor", form).size() > 0) {
require(['summernote'], function () {
var imageButton = function (context) {
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="fa fa-file-image-o"/>',
tooltip: __('Choose'),
click: function () {
parent.Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=image/*", __('Choose'), {
callback: function (data) {
var urlArr = data.url.split(/\,/);
$.each(urlArr, function () {
var url = Fast.api.cdnurl(this);
context.invoke('editor.insertImage', url);
});
}
});
return false;
}
});
return button.render();
};
var attachmentButton = function (context) {
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="fa fa-file"/>',
tooltip: __('Choose'),
click: function () {
parent.Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=*", __('Choose'), {
callback: function (data) {
var urlArr = data.url.split(/\,/);
$.each(urlArr, function () {
var url = Fast.api.cdnurl(this);
var node = $("<a href='" + url + "'>" + url + "</a>");
context.invoke('insertNode', node[0]);
});
}
});
return false;
}
});
return button.render();
};
$(".summernote,.editor", form).summernote({
height: 250,
lang: 'zh-CN',
fontNames: [
'Arial', 'Arial Black', 'Serif', 'Sans', 'Courier',
'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
"Open Sans", "Hiragino Sans GB", "Microsoft YaHei",
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆',
],
fontNamesIgnoreCheck: [
"Open Sans", "Microsoft YaHei",
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
],
toolbar: [
['style', ['style', 'undo', 'redo']],
['font', ['bold', 'underline', 'strikethrough', 'clear']],
['fontname', ['color', 'fontname', 'fontsize']],
['para', ['ul', 'ol', 'paragraph', 'height']],
['table', ['table', 'hr']],
['insert', ['link', 'picture', 'video']],
['select', ['image', 'attachment']],
['view', ['fullscreen', 'codeview', 'help']],
],
buttons: {
image: imageButton,
attachment: attachmentButton,
},
dialogsInBody: true,
followingToolbar: false,
callbacks: {
onChange: function (contents) {
$(this).val(contents);
$(this).trigger('change');
},
onInit: function () {
},
onImageUpload: function (files) {
var that = this;
//依次上传图片
for (var i = 0; i < files.length; i++) {
Upload.api.send(files[i], function (data) {
var url = Fast.api.cdnurl(data.url);
$(that).summernote("insertImage", url, 'filename');
});
}
}
}
});
});
}
} catch (e) {
}
};
});
<?php
namespace addons\summernote\controller;
use think\addons\Controller;
class Index extends Controller
{
public function index()
{
$this->error("当前插件暂无前台页面");
}
}
name = summernote
title = Summernote富文本编辑器
intro = 修改后台默认编辑器为Summernote
author = Karson
website = http://www.fastadmin.net
version = 1.0.4
state = 1
url = /addons/summernote
license = regular
licenseto = 30453
... ... @@ -22,6 +22,7 @@ class Factory extends Backend
{
parent::_initialize();
$this->model = new \app\admin\model\Factory;
$this->view->assign("hotdataList", $this->model->getHotdataList());
}
... ...
... ... @@ -24,6 +24,9 @@ class Job extends Backend
parent::_initialize();
$this->model = new \app\admin\model\Job;
$this->view->assign("typeList", $this->model->getTypeList());
$this->view->assign("lookdataList", $this->model->getLookdataList());
$this->view->assign("putdataList", $this->model->getPutdataList());
}
public function import()
... ...
... ... @@ -37,6 +37,8 @@ class User extends Backend
}
unset($v);
$this->view->assign("userdata", $userdata);
$this->view->assign("roledataList", $this->model->getRoledataList());
}
/**
... ...
... ... @@ -9,5 +9,8 @@ return [
'Work_subsidy' => '工时补贴价格(元/时)',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Hotdata' => '是否热门',
'Hotdata 0' => '否',
'Hotdata 1' => '是',
'Weigh' => '权重'
];
... ...
... ... @@ -11,6 +11,13 @@ return [
'Type 1' => '长期工',
'Type 2' => '兼职',
'Type 3' => '短期工',
'Lookdata' => '状态',
'Lookdata 0' => '全部可看',
'Lookdata 1' => '部分可看',
'Lookdata 2' => '部分不可看',
'Putdata' => '上下架',
'Putdata 0' => '上架',
'Putdata 1' => '下架',
'Factory_price' => '工厂工价(元/时)',
'Subsidy_price' => '平台补贴(元/时)',
'Factory_price_total' => '补贴后工价(元/时)',
... ... @@ -23,4 +30,5 @@ return [
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Weigh' => '权重',
'Label_ids' => '标签',
];
... ...
... ... @@ -6,7 +6,8 @@ return [
'Realname' => '姓名',
'Mobile' => '手机号',
'Idcard' => '身份证号',
'Idcard_front' => '身份证正面',
// 'Idcard_front' => '身份证正面',
'Idcard_front' => '收款码',
'Idcard_back' => '身份证背面',
'Status' => '状态',
'Status 0' => '待审核',
... ...
... ... @@ -34,9 +34,13 @@ return [
'Is_work' => '是否在职',
'Is_complete' => '补贴是否完成',
'Work_subsidy' => '工时补贴价格(元/时)',
'Recruit_subsidy'=> '招聘补贴上级价格(元/时)',
'Recruit_subsidy'=> '招聘补贴上一级价格(元/时)',
'Recruit_subsidy2'=> '招聘补贴上二级价格(元/时)',
'Work_subsidy_month' => '工时月工资(元/月)',
'Recruit_subsidy_month' => '招聘月工资(元/月)',
'Lower_num' => '可以看到几级下级',
'Factory_id' => '入职工厂',
'Roledata' =>'角色',
'Roledata 0' =>'用户',
'Roledata 1' =>'合伙人',
];
... ...
... ... @@ -25,7 +25,7 @@ class Factory extends Model
// 追加属性
protected $append = [
'hotdata_text'
];
... ... @@ -37,7 +37,17 @@ class Factory extends Model
});
}
public function getHotdataList()
{
return ['0' => __('Hotdata 0'), '1' => __('Hotdata 1')];
}
public function getHotdataTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['hotdata']) ? $data['hotdata'] : '');
$list = $this->getHotdataList();
return isset($list[$value]) ? $list[$value] : '';
}
... ...
... ... @@ -25,7 +25,9 @@ class Job extends Model
// 追加属性
protected $append = [
'type_text'
'type_text',
'lookdata_text',
'putdata_text'
];
protected static function init()
... ... @@ -49,6 +51,30 @@ class Job extends Model
return implode(',', array_intersect_key($list, array_flip($valueArr)));
}
public function getLookdataList()
{
return ['0' => __('Lookdata 0'), '1' => __('Lookdata 1'),'2'=>__('Lookdata 2')];
}
public function getLookdataTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['lookdata']) ? $data['lookdata'] : '');
$list = $this->getLookdataList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getPutdataList()
{
return ['0' => __('Putdata 0'), '1' => __('Putdata 1')];
}
public function getPutdataTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['putdata']) ? $data['putdata'] : '');
$list = $this->getPutdataList();
return isset($list[$value]) ? $list[$value] : '';
}
protected function setTypeAttr($value)
{
return is_array($value) ? implode(',', $value) : $value;
... ...
... ... @@ -20,7 +20,8 @@ class User extends Model
protected $append = [
'prevtime_text',
'logintime_text',
'jointime_text'
'jointime_text',
'roledata_text'
];
public function getOriginData()
... ... @@ -68,6 +69,17 @@ class User extends Model
return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
}
public function getRoledataList()
{
return ['0' => __('Roledata 0'), '1' => __('Roledata 1')];
}
public function getRoledataTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['roledata']) ? $data['roledata'] : '');
$list = $this->getRoledataList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getPrevtimeTextAttr($value, $data)
{
$value = $value ? $value : $data['prevtime'];
... ...
... ... @@ -30,6 +30,19 @@
<input id="c-work_subsidy" data-rule="requird" class="form-control" name="row[work_subsidy]" type="number" value="0.00">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Hotdata')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="hotdataList" item="vo"}
<label for="row[hotdata]-{$key}"><input id="row[hotdata]-{$key}" name="row[hotdata]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -30,6 +30,19 @@
<input id="c-work_subsidy" data-rule="requird" class="form-control" name="row[work_subsidy]" type="number" value="{$row.work_subsidy|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Hotdata')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="hotdataList" item="vo"}
<label for="row[hotdata]-{$key}"><input id="row[hotdata]-{$key}" name="row[hotdata]" type="radio" value="{$key}" {in name="key" value="$row.hotdata"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -121,9 +121,40 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Lookdata')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="lookdataList" item="vo"}
<label for="row[lookdata]-{$key}"><input id="row[lookdata]-{$key}" name="row[lookdata]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group job hide">
<label class="control-label col-xs-12 col-sm-2">{:__('User_ids')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_ids" data-source="user/user/index" data-multiple="true" data-field="nickname" class="form-control selectpage" name="row[user_ids]" type="text" value="">
<input id="c-user_ids" data-source="user/user/index" data-params='{"custom[roledata]":"1"}' data-multiple="true" data-field="nickname" class="form-control selectpage" name="row[user_ids]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Putdata')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="putdataList" item="vo"}
<label for="row[putdata]-{$key}"><input id="row[putdata]-{$key}" name="row[putdata]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Label_ids')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-label_ids" data-source="label/index" data-field="title" data-multiple="true" class="form-control selectpage" name="row[label_ids]" type="text" value="">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -121,9 +121,41 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Lookdata')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="lookdataList" item="vo"}
<label for="row[lookdata]-{$key}"><input id="row[lookdata]-{$key}" name="row[lookdata]" type="radio" value="{$key}" {in name="key" value="$row.lookdata"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group job hide">
<label class="control-label col-xs-12 col-sm-2">{:__('User_ids')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_ids" data-source="user/user/index" data-multiple="true" data-field="nickname" class="form-control selectpage" name="row[user_ids]" type="text" value="{$row.user_ids|htmlentities}">
<input id="c-user_ids" data-source="user/user/index" data-params='{"custom[roledata]":"1"}' data-multiple="true" data-field="nickname" class="form-control selectpage" name="row[user_ids]" type="text" value="{$row.user_ids|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Label_ids')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-label_ids" data-source="label/index" data-field="title" data-multiple="true" class="form-control selectpage" name="row[label_ids]" type="text" value="{$row.label_ids|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Putdata')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="putdataList" item="vo"}
<label for="row[putdata]-{$key}"><input id="row[putdata]-{$key}" name="row[putdata]" type="radio" value="{$key}" {in name="key" value="$row.putdata"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">
... ...
... ... @@ -58,6 +58,19 @@
{:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('拉黑')], $row['status'])}
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Roledata')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="roledataList" item="vo"}
<label for="row[Roledata]-{$key}"><input id="row[roledata]-{$key}" name="row[roledata]" type="radio" value="{$key}" {in name="key" value="$row.roledata"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<!--<div class="form-group">
<label for="c-work_subsidy" class="control-label col-xs-12 col-sm-2">{:__('Work_subsidy')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -13,6 +13,7 @@ use think\Hook;
/**
* 公共接口
* @ApiWeigh(2)
*/
class Common extends Api
{
... ...
... ... @@ -6,6 +6,7 @@ use app\common\controller\Api;
/**
* 示例接口
* @ApiWeigh(2)
*/
class Demo extends Api
{
... ...
... ... @@ -8,6 +8,7 @@ use app\common\model\User;
/**
* 邮箱验证码接口
* @ApiWeigh(2)
*/
class Ems extends Api
{
... ...
... ... @@ -7,6 +7,7 @@ use app\api\model\Factory;
use app\api\model\Job;
use app\api\model\JobCollect;
use app\api\model\JobKeyword;
use app\common\model\Inform;
use app\common\model\User;
use fast\Tree;
use app\common\controller\Wechat;
... ... @@ -14,6 +15,7 @@ use app\common\controller\Api;
/**
* 首页接口
* @ApiWeigh(2)
*/
class Index extends Api
{
... ... @@ -144,7 +146,11 @@ class Index extends Api
"subsidy_price": "40.00", //平台补贴(元/时)
"factory_price_total": "40.00", //工价
"salary": "6000~7000", //月收入
"people_num": 23 //报名人数
"people_num": 23, //报名人数
"label_name": [ //标签
"包吃",
"包住"
]
}]
}
})
... ... @@ -182,19 +188,28 @@ class Index extends Api
}
$where .= "job_name like '%{$keyword}%'";
}
$where .= $where ? ' and ' : '';
$where .= "putdata = '0'";
// 哪些人及其下级可查看
if($this->auth->id){
$parentsIds = Tree::instance()->init(collection(User::select())->toArray())->getParentsIds($this->auth->id, true);
// 部分可看
$findinset = [];
foreach ($parentsIds as $pid){
$findinset[] = "find_in_set({$pid},user_ids)";
}
// 部分不可看
$findinsetn = [];
foreach ($parentsIds as $pid){
$findinsetn[] = "find_in_set({$pid},user_ids) = 0";
}
$where .= $where ? ' and ' : '';
$where .= "(".implode(' or ',$findinset)." or user_ids = '')";
$where .= "((".implode(' or ',$findinset)." and lookdata = '1') or (lookdata = '0') or (".implode(' or ',$findinsetn)." and lookdata = '2'))";
}
// 附近
$distance = '1';
$juli = 0;
if($lng && $lat){
$distance = "ROUND(
$juli = "ROUND(
6378.138 * 2 * ASIN(
SQRT(
POW(
... ... @@ -213,7 +228,7 @@ class Index extends Api
2
)
)
) , 2
) * 1000
)";
}
// 职位类型
... ... @@ -222,11 +237,11 @@ class Index extends Api
$where .= "find_in_set({$type},type)";
}
$data = Job::where($where)
->field("*,{$distance} distance")
->order(['distance'=>'asc','weigh'=>'desc'])
->field("*,$juli juli,if($juli > 1000,CONCAT(ROUND($juli/1000,1),'km'),CONCAT($juli,'m')) distance")
->order(['juli'=>'asc','weigh'=>'desc'])
->paginate($page_num,false,['page'=>$page])
->each(function($v){
$v->visible(['id','cover','job_name','salary','people_num','factory_price_total','factory_price','subsidy_price']);
$v->visible(['id','cover','job_name','salary','people_num','factory_price_total','factory_price','subsidy_price','label_ids'])->append(['distance']);
})->toArray();
$this->success('成功',$data);
}
... ... @@ -303,7 +318,7 @@ class Index extends Api
$where .= $where ? ' and ' : '';
$where .= "(".implode(' or ',$findinset)." or user_ids = '')";
}
$data = Job::alias('j')
->join('job_collect jc','jc.job_id = j.id and user_id = '.$this->auth->id)
->where($where)
... ... @@ -340,19 +355,32 @@ class Index extends Api
"subsidy_price": "10.00", //平台补贴价格
"factory_price_total": "70.00", //补贴后工价
"salary": "5000~6000", // 月收入
"is_collect": 0 //是否收藏:0=否,1=是
"label_name": [ //标签
"包吃",
"包住"
],
"is_collect": 0 ,//是否收藏:0=否,1=是
"inform": {//通知
"id": 5, //通知id
"content": "hi哈佛地方", //通知内容
"status": "1",
"job_id": 7
}
}
})
*/
public function jobInfo()
{
$user_id = $this->auth->id; //用户id
$job_id = $this->request->param('job_id');
empty($job_id) && $this->error('缺少必需参数');
$info = Job::get($job_id);
empty($info) && $this->error('职位信息不存在');
$collect = JobCollect::where('user_id',$this->auth->id)->where('job_id',$job_id)->find();
$info->is_collect = !empty($collect) ? 1 : 0;
$info->visible(['id','images','job_name','factory_price_total','factory_price','subsidy_price','salary','content'])->append(['is_collect']);
$deposit = new Inform;
$info['inform'] = $deposit->where(['status'=>'1','job_id'=>$job_id,'deletetime'=>null])->order('id desc')->field('id,content,status,job_id')->find();
$info->visible(['id','images','job_name','factory_price_total','factory_price','subsidy_price','salary','content','lng','lat','label_ids'])->append(['is_collect','inform']);
$this->success('成功',$info);
}
... ... @@ -421,50 +449,82 @@ class Index extends Api
$user_id = $this->auth->id > 0 ? $this->auth->id : 0;
$qrcode_id = "{$job_id}_{$user_id}";
$qrcode = $dir.'/qrcode_'.$qrcode_id.'.png';
if(!file_exists($qrcode)){
$user_id = $this->auth->id > 0 ? $this->auth->id : 0;
// $qrcode_width = 192;
$qrcode_width = 1100;
if(!file_exists($qrcode) || imagesx(imagecreatefromjpeg(ROOT_PATH.'public/'.$qrcode)) != $qrcode_width){
$response = Wechat::miniProgram()->app_code->getUnlimit($qrcode_id, [
'page' => 'pages/zhiwei_xq/zhiwei_xq',
'width' => 280, //最小宽度280
'width' => $qrcode_width, //最小宽度280
]);
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
$response->saveAs($dir, str_replace($dir.'/','',$qrcode));
}
// 280不满足,再缩小
\think\Image::open($qrcode)->thumb(120,120,\think\Image::THUMB_CENTER)->save($qrcode);
\think\Image::open($qrcode)->thumb($qrcode_width,$qrcode_width,\think\Image::THUMB_CENTER)->save($qrcode);
}
//将职位封面图保存到本地
$job_cover = $dir.'/cover_'.$job_id.'.png';
file_put_contents($job_cover,file_get_contents($job['cover']));
\think\Image::open($job_cover)->thumb(84,84,\think\Image::THUMB_CENTER)->save($job_cover);
$path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
$filename = $dir.'/'.$job_id.'.png';
$image = \think\Image::open(ROOT_PATH.'public/assets/img/miniProgram/job_back.png');
// 职位名称居中
$size = 12;
$box1 = imagettfbbox($size, 0, $path_ttf, $job['job_name']);
$box1_minx = min($box1[0], $box1[2], $box1[4], $box1[6]);
$box1_maxx = max($box1[0], $box1[2], $box1[4], $box1[6]);
/* 计算文字初始坐标和尺寸 */
$w = $box1_maxx - $box1_minx;
$box1_minx += ($image->width() - $w) / 2;
// 备注居中
$last_text = '长安此图识别二维码,进入小程序';
$box2 = imagettfbbox($size, 0, $path_ttf, $last_text);
$box2_minx = min($box2[0], $box2[2], $box2[4], $box2[6]);
$box2_maxx = max($box2[0], $box2[2], $box2[4], $box2[6]);
/* 计算文字初始坐标和尺寸 */
$w = $box2_maxx - $box2_minx;
$box2_minx += ($image->width() - $w) / 2;
$image->water($job_cover,[129,120])
->text($job['job_name'],$path_ttf,$size,'#020202',[$box1_minx,215])
->water($qrcode,[111,262])
->text($last_text,$path_ttf,$size,'#969799',[$box2_minx,410])
->save($filename);
$url = request()->domain().'/'.$filename.'?v='.time();
// //将职位图片首图保存到本地
// $images = db('job')->where('id',$job_id)->value('images');
// $image = cdnurl(explode(',',$images)[0],true);
// // $image = 'https://recruit.brofirst.cn'.explode(',',$images)[0];
// $job_image = $dir.'/image_'.$job_id.'.png';
// file_put_contents($job_image,file_get_contents($image));
// \think\Image::open($job_image)->thumb(637,352,\think\Image::THUMB_CENTER)->save($job_image);
//
// $path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
// $filename = $dir.'/'.$job_id.'.png';
//
// $image = \think\Image::open(ROOT_PATH.'public/assets/img/miniProgram/job_back_v2.png');
// // 职位名称居中
// $size = 30;
// $box1 = imagettfbbox($size, 0, $path_ttf, $job['job_name']);
// $box1_minx = min($box1[0], $box1[2], $box1[4], $box1[6]);
// $box1_maxx = max($box1[0], $box1[2], $box1[4], $box1[6]);
// /* 计算文字初始坐标和尺寸 */
// $w = $box1_maxx - $box1_minx;
// $box1_minx += ($image->width() - $w) / 2;
//
// // 工价
// $size_11 = 25;
// $factory_price_total = '工价:'.$job['factory_price_total'].'元/小时';
// $box2 = imagettfbbox($size_11, 0, $path_ttf, $factory_price_total);
// $box2_minx = min($box2[0], $box2[2], $box2[4], $box2[6]);
// $box2_maxx = max($box2[0], $box2[2], $box2[4], $box2[6]);
// /* 计算文字初始坐标和尺寸 */
// $w = $box2_maxx - $box2_minx;
// $box2_minx += $image->width() - $w - 106;
//
// // 工资
// $salary = '工资:'.$job['salary'];
// $box3 = imagettfbbox($size_11, 0, $path_ttf, $salary);
// $box3_minx = min($box3[0], $box3[2], $box3[4], $box3[6]);
// $box3_maxx = max($box3[0], $box3[2], $box3[4], $box3[6]);
// /* 计算文字初始坐标和尺寸 */
// $w = $box3_maxx - $box3_minx;
// $box3_minx += $image->width() - $w - 106;
//
// // 备注居中
// $last_text = '码上报名';
// $box4 = imagettfbbox($size, 0, $path_ttf, $last_text);
// $box4_minx = min($box4[0], $box4[2], $box4[4], $box4[6]);
// $box4_maxx = max($box4[0], $box4[2], $box4[4], $box4[6]);
// /* 计算文字初始坐标和尺寸 */
// $w = $box4_maxx - $box4_minx;
// $box4_minx += ($image->width() - $w) / 2;
//
// $image->water($job_image,[25,25])
// ->text($job['job_name'],$path_ttf,$size,'#323233',[$box1_minx,411])
// ->text($job['job_name'],$path_ttf,$size,'#323233',[$box1_minx+1,411]) //画两遍,加粗
// ->text($factory_price_total,$path_ttf,$size_11,'#323233',[$box2_minx,477])
// ->text($factory_price_total,$path_ttf,$size_11,'#323233',[$box2_minx+1,477])
// ->text($salary,$path_ttf,$size_11,'#323233',[$box3_minx,532])
// ->text($salary,$path_ttf,$size_11,'#323233',[$box3_minx+1,532])
// ->text($last_text,$path_ttf,$size,'#FE9515',[$box4_minx,641])
// ->text($last_text,$path_ttf,$size,'#FE9515',[$box4_minx+1,641])
// ->water($qrcode,[249,698])
// ->save($filename);
// $url = request()->domain().'/'.$filename.'?v='.time();
$url = request()->domain().'/'.$qrcode.'?v='.time();
$this->success('成功',compact('url'));
}
... ...
... ... @@ -9,6 +9,7 @@ use think\Hook;
/**
* 手机短信接口
* @ApiWeigh(2)
*/
class Sms extends Api
{
... ...
... ... @@ -7,6 +7,7 @@ use fast\Random;
/**
* Token接口
* @ApiWeigh(2)
*/
class Token extends Api
{
... ... @@ -14,8 +15,20 @@ class Token extends Api
protected $noNeedRight = '*';
/**
* 检测Token是否过期
*
* @ApiWeigh (99)
* @ApiTitle (检测Token是否过期)
* @ApiSummary (检测Token是否过期)
* @ApiMethod (GET)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiReturn({
"code": 1,
"msg": "",
"time": "1621402970",
"data": {
"token": "545eed64-39c4-437e-8285-ac94c03e4921", //token
"expires_in": 2591951 //剩余有效时间
}
})
*/
public function check()
{
... ... @@ -25,8 +38,20 @@ class Token extends Api
}
/**
* 刷新Token
*
* @ApiWeigh (97)
* @ApiTitle (刷新Token)
* @ApiSummary (刷新Token)
* @ApiMethod (GET)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiReturn({
"code": 1,
"msg": "",
"time": "1621403556",
"data": {
"token": "175c6d84-42af-4c59-bce0-ad8a66eb5f3f", //token
"expires_in": 2592000 //剩余有效时间
}
})
*/
public function refresh()
{
... ...
... ... @@ -5,27 +5,40 @@ namespace app\api\controller;
use app\common\controller\Api;
use app\common\library\Ems;
use app\common\library\Sms;
use app\common\model\Inform;
use fast\Random;
use fast\Tree;
use think\Exception;
use think\exception\PDOException;
use think\Validate;
use think\Db;
use addons\third\model\Third;
use app\api\model\Realname;
use app\api\model\UserKeyword;
use app\api\model\UserWorkLog;
use app\api\model\UserWorkSubsidyLog;
use app\api\model\UserRecruitSubsidyLog;
use app\api\model\UserSalary;
use app\api\model\Factory;
use app\api\model\FactoryUser;
use app\api\model\UserBorrow;
use app\common\controller\Wechat;
/**
* 会员接口
* @ApiWeigh(2)
*/
class User extends Api
{
protected $noNeedLogin = ['login', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile', 'third','get_session_key','authority','getPhoneNumber','workSubsidyContent','recruitSubsidyContent'];
protected $noNeedLogin = ['login', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile', 'third','get_session_key','authority','getPhoneNumber','workSubsidyContent','recruitSubsidyContent','factoryList'];
protected $noNeedRight = '*';
// 用户列表
public $user_list = [];
// 可查看几级下级
public $lower_num = 0;
// 我的下级用户ID
public $my_children_ids = [];
public function _initialize()
{
... ... @@ -51,38 +64,125 @@ class User extends Api
"nickname": "admin", //昵称
"mobile": "13888888888", //手机号
"avatar": "/uploads/20201123/8894d62100f2f920ffb2f38063b63f2d.jpg", //原始头像地址
"is_work": "0", //是否在职:0=否,1=是
"work_subsidy": "2.00", //工时补贴价格(元/时)
"work_subsidy_month": "600.00", //工时月工资(元/月)
"recruit_subsidy_month": "300.00", //招聘月工资(元/月)
"url": "/u/1",
"realname_status": "0", // 实名认证状态:-1=未申请,0=申请中,1=通过,2=未通过
"full_avatar": "http://www.recruit.top/uploads/20201123/8894d62100f2f920ffb2f38063b63f2d.jpg", //完整头像地址
},
"recruit_subsidy": {
"hour": "1.00", //招聘补贴价格(元/时)
"day": "10.00", //招聘补贴价格(元/天)
"month": "300.00" //招聘补贴价格(元/月)
"is_work": "1", //是否在职:0=否,1=是
"factory": { //工厂
"id": 1, //工厂ID
"factory_shortname": "" //工厂简称
}
}
}
})
*/
public function index()
{
$user = $this->auth->getUser();
// 格式化头像
$user->full_avatar = cdnurl($user->avatar,true);
// 实名认证状态
$realname = Realname::get(['user_id'=>$this->auth->id]);
$user->realname_status = empty($realname) ? '-1' : $realname['status'];
$user->visible(['id','avatar','nickname','mobile','is_work','work_subsidy','work_subsidy_month','recruit_subsidy_month'])->append(['realname_status','full_avatar']);
// 招聘补贴
$recruit_subsidy = [
'hour' => sprintf("%.2f",config('site.recruit_subsidy')),
'day' => sprintf("%.2f",config('site.recruit_subsidy') * 10),
'month' => sprintf("%.2f",config('site.recruit_subsidy') * 10 * 30),
$user = $this->model->get($this->auth->id,['factory']);
// 未入职工厂
if(!$user->getRelation('factory')){
$user['is_work'] = '0';
$user['factory'] = '';
}
$user->visible(['id','avatar','nickname','mobile','is_work','factory']);
$this->success('成功', compact('user'));
}
/**
* @ApiWeigh (97)
* @ApiTitle (劳务管理-工资)
* @ApiSummary (劳务管理-工资)
* @ApiMethod (POST)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1612234313",
"data": {
"work_hours_month": "0.0", //本月打卡总工时
"work_salary_month": "0.00", //本月打卡工资
"work_subsidy": "2.00", //工时补贴(元/小时)
"work_subsidy_month": 0, //本月工时补贴
"lower_work_hours_month": 0, //下级打卡总工时
"recruit_subsidy_month": 0, //下级招聘补贴工资
"salary": 0 //本月共收入
"notice" : "通知内容" // 通知
}
})
*/
public function salary()
{
$user = $this->model->get($this->auth->id);
// 我的下级本月总工时和本月返我的总招聘补贴
$lower_work_hours_month = $this->model
->where('pid',$user['id'])
->where('is_work','1')
->sum('work_hours_month');
// 我的本月共收入
$salary = UserSalary::where('user_id',$user['id'])
->where('year_month',date('Y-m'))
->value('salary');
if(!$salary){
$salary = $user['work_salary_month'] + $user['work_subsidy_month'] + $user['recruit_subsidy_month'];
}
$data = [
'work_hours_month' => $user['work_hours_month'],
'work_salary_month' => $user['work_salary_month'],
'work_subsidy' => ($user['is_work'] == '1' && $user['factory']) ? $user['factory']['work_subsidy'] : 0,
'work_subsidy_month' => $user['work_subsidy_month'],
'lower_work_hours_month' => $lower_work_hours_month,
'recruit_subsidy_month' => $user['recruit_subsidy_month'],
'salary' => $salary,
'notice' => config('site.notice'),
];
$this->success('成功', compact('user','recruit_subsidy'));
$this->success('成功', $data);
}
/**
* @ApiWeigh (97)
* @ApiTitle (劳务管理-工资-历史收入)
* @ApiSummary (劳务管理-工资-历史收入)
* @ApiMethod (POST)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
* @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1620612745",
"data": {
"total": 1,
"per_page": 15,
"current_page": 1,
"last_page": 1,
"data": [{
"id": 32,
"user_id": 711,
"salary": "600.00", //总工资
"year_month": "2021年04月", //月份
"createtime": 1615769765,
"updatetime": 1615769765,
"work_hours": "0.0", //总工时
"work_subsidy": "0.00", //在职奖励
"recruit_subsidy": "0.00", //推荐奖励
"status": "0" //状态:0=待审核,1=已结算
}]
}
})
*/
public function salaryList()
{
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
$data = UserSalary::where('user_id',$this->auth->id)
->order('createtime desc')
->paginate($page_num,false,['page'=>$page])
->each(function($v){
// 格式化年月
$v->year_month = date('Y年m月',strtotime($v['year_month']));
});
$this->success('成功', $data);
}
/**
... ... @@ -193,7 +293,7 @@ class User extends Api
}
/**
* @ApiWeigh (97)
* @ApiWeigh (95)
* @ApiTitle (编辑资料)
* @ApiSummary (编辑资料)
* @ApiMethod (POST)
... ... @@ -381,7 +481,190 @@ class User extends Api
}
/**
* @ApiWeigh (95)
* @ApiWeigh (94)
* @ApiTitle (工厂列表)
* @ApiSummary (工厂列表)
* @ApiMethod (POST)
* @ApiReturn ({
"code": 1,
"msg": "入职成功后,驻厂将会为您服务",
"time": "1612233294",
"data": [{
"id": 1, //工厂ID
"factory_name": "新美亚电子(深圳)有限公司", //工厂名称
"factory_shortname": "" //工厂简称
}]
})
*/
public function factoryList()
{
$list = Factory::field('id,factory_name,factory_shortname')->select();
$this->success('入职成功后,驻厂将会为您服务',$list);
}
/**
* @ApiTitle 热门工厂
* @ApiMethod (POST)
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1620371474",
"data": [{
"id": 20, //工厂id
"factory_name": "中天世纪实业有限公司", //工厂名称
"factory_shortname": "中天世纪实业有限公司" //工厂简称
}]
})
*/
public function hot(){
$list = Factory::where(['hotdata'=>'1'])->field('id,factory_name,factory_shortname')->select();
$this->success('成功',$list);
}
/**
* @ApiWeigh (94)
* @ApiTitle (工厂搜索列表)
* @ApiSummary (工厂搜索列表)
* @ApiMethod (POST)
* @ApiParams (name="factory_name", type="string", required=true, description="工厂名称")
* @ApiParams (name="page", type="string", required=true, description="分页")
* @ApiReturn ({
"code": 1,
"msg": "入职成功后,驻厂将会为您服务",
"time": "1620372317",
"data": {
"total": 2,
"per_page": 15,
"current_page": 1,
"last_page": 1,
"data": [{
"id": 1, //工厂id
"factory_name": "新美亚电子(深圳)有限公司", //工厂名称
"factory_shortname": "新美亚" //工厂简称
}]
}
})
*/
public function factory()
{
$factory_name = $this->request->param('factory_name');
$where= [];
if (!empty($factory_name)){
$where['factory_name'] = ['like', '%' . $factory_name . '%'];
}
$list = Factory::where($where)->field('id,factory_name,factory_shortname')->paginate();
$this->success('入职成功后,驻厂将会为您服务',$list);
}
/**
* @ApiWeigh (93)
* @ApiTitle (确认入职)
* @ApiSummary (确认入职)
* @ApiMethod (POST)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiParams (name="factory_id", type="inter", required=true, description="工厂ID")
* @ApiParams (name="join_time", type="inter", required=true, description="入职时间")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": null
})
*/
public function joinFactory()
{
$user = $this->model->get($this->auth->id);
$factory_id = $this->request->param('factory_id');
$join_time= $this->request->param('join_time');
empty($factory_id) && $this->error('缺少必需参数');
$factory = Factory::get($factory_id);
empty($factory) && $this->error('工厂不存在');
if($user['is_work'] == '1' && $user['factory']){
$this->error('已入职,确认入职无效');
}
$has = FactoryUser::where('user_id',$user['id'])->order('createtime desc')->find();
if(!empty($has)){
$has['status'] == '0' && $this->error('正在审核中,请勿重复操作');
}
FactoryUser::create([
'user_id' => $user['id'],
'factory_id' => $factory_id,
'join_time' =>$join_time,
]);
$this->success('入职成功后,驻厂将会为您服务');
}
/**
* @ApiTitle 入职页面文本
* @ApiMethod (POST)
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1620373282",
"data": "1.输入入职工厂\r\n2.选择工厂,提交入职" //文本内容
})
*/
public function con(){
$content = config('site.content');
$this->success('成功',$content);
}
/**
* @ApiWeigh (91)
* @ApiTitle (办理离职)
* @ApiSummary (办理离职)
* @ApiMethod (POST)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiParams (name="factory_id", type="inter", required=true, description="工厂ID")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": null
})
*/
public function quitFactory()
{
$factory_id = $this->request->param('factory_id');
empty($factory_id) && $this->error('缺少必需参数');
$factory = Factory::get($factory_id);
empty($factory) && $this->error('入职企业不存在');
$user = $this->auth->getUser();
if(empty($user['factory_id']) || $user['is_work'] == '0'){
$this->error('未入职');
}
$user['factory_id'] != $factory_id && $this->error('未入职该工厂');
$factory_user = FactoryUser::where('user_id',$this->auth->id)
->where('factory_id',$factory_id)
->where('status','1')
->find();
if(!$factory_user){
$factory_user = new FactoryUser;
}
Db::startTrans();
try {
// 记录离职状态
$factory_user->save([
'factory_id' => $factory_id,
'user_id' => $this->auth->id,
'status' => '3',
'quit_time' => time(),
]);
// 修改用户为未入职
$user->save(['is_work'=>'0','factory_id'=>0,'join_time'=>0]);
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
$this->success('离职后之前数据将会暂停');
}
/**
* @ApiWeigh (89)
* @ApiTitle (实名认证)
* @ApiSummary (实名认证)
* @ApiMethod (POST)
... ... @@ -389,8 +672,7 @@ class User extends Api
* @ApiParams (name="realname", type="string", required=true, description="姓名")
* @ApiParams (name="idcard", type="string", required=true, description="身份证号")
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
* @ApiParams (name="idcard_front", type="string", required=true, description="上传身份证正面")
* @ApiParams (name="idcard_back", type="string", required=true, description="上传身份证反面")
* @ApiParams (name="idcard_front", type="string", required=true, description="上传收款码")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
... ... @@ -402,11 +684,12 @@ class User extends Api
$post = $this->request->param();
empty($post['realname']) && $this->error('请填写姓名');
empty($post['idcard']) && $this->error('请填写身份证号');
empty($post['realname']) && $this->error('请填写姓名');
empty($post['mobile']) && $this->error('请填写手机号');
empty($post['idcard_front']) && $this->error('请上传身份证正面');
empty($post['idcard_back']) && $this->error('请上传身份证反面');
empty($post['idcard_front']) && $this->error('请上传收款码');
// empty($post['idcard_back']) && $this->error('请上传身份证反面');
$realname = Realname::get(['user_id'=>$this->auth->id]);
$realname['status'] == '0' && $this->error('认证正在审核中,请勿重复操作');
$realname['status'] == '1' && $this->error('实名认证已通过审核,请勿重复操作');
if(empty($realname)){
$realname = new Realname;
}
... ... @@ -418,7 +701,52 @@ class User extends Api
}
/**
* @ApiWeigh (93)
* @ApiTitle 认证页面通知
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1620439310",
"data": {
"id": 3, //通知id
"content": "认证通知" //通知内容
}
})
*/
public function give(){
$inform= new Inform;
$reclist = $inform
->where(['status'=>'2'])
->order('id desc')
->field('id,content')
->find();
$this->success('成功',$reclist);
}
/**
* @ApiWeigh (87)
* @ApiTitle (实名认证状态)
* @ApiSummary (实名认证状态)
* @ApiMethod (POST)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
'status': '1', // 实名认证状态:0=申请中,1=通过,2=未申请
}
})
*/
public function realnameStatus()
{
// 实名认证状态
$info = Realname::get(['user_id'=>$this->auth->id]);
$status = empty($info) ? '2' : $info['status'];
$this->success('成功',compact('status'));
}
/**
* @ApiWeigh (85)
* @ApiTitle (code获取session_key和openid)
* @ApiSummary (code获取session_key和openid)
* @ApiMethod (POST)
... ... @@ -431,6 +759,7 @@ class User extends Api
"data": {
"session_key": "1qyMwZRVdlBmQLwRYtYSgA==",
"token": "9e4648c7-c640-4e41-b758-dd1a8ef7a7ae",
"openid": "9e4648c7-c640-4e41-b758-dd1a8ef7a7ae",
}
})
*/
... ... @@ -466,13 +795,14 @@ class User extends Api
}
/**
* @ApiWeigh (91)
* @ApiWeigh (83)
* @ApiTitle (用户授权登录)
* @ApiSummary (用户授权登录)
* @ApiMethod (POST)
* @ApiParams (name="sessionKey", type="string", required=true, description="小程序sessionKey")
* @ApiParams (name="iv", type="string", required=true, description="小程序iv")
* @ApiParams (name="encryptData", type="string", required=true, description="小程序encryptData")
* @ApiParams (name="openid", type="string", required=true, description="openid")
* @ApiParams (name="user_id", type="inter", required=false, description="扫码获取的用户ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
... ... @@ -488,6 +818,7 @@ class User extends Api
{
$param = $this->request->param();
$pid = isset($param['user_id']) ? $param['user_id'] : 0; //上级ID
\think\Log::write('授权登录user_id:'.$pid);
$validate = new \think\Validate([
'sessionKey' => 'require',
'iv' => 'require',
... ... @@ -504,8 +835,14 @@ class User extends Api
// 获取小程序配置
$app = Wechat::miniProgram();
$user_info = $app->encryptor->decryptData($param['sessionKey'], $param['iv'], $param['encryptData']);
// 2021年4月13之后的获取不到openid
if(empty($user_info['openId'])){
empty($param['openid']) && $this->error('传参缺少openid');
$user_info['openId'] = $param['openid'];
}
// 判断用户是否授权
$user_model = new \app\common\model\User();
$where = [
'openid' => $user_info['openId']
];
... ... @@ -516,10 +853,10 @@ class User extends Api
$ip = request()->ip();
$time = time();
// 更新用户信息
$user = $user_model->get($third['user_id']);
$user = $this->model->get($third['user_id']);
// 账号被删除重新添加
if(!$user){
$user = $user_model;
$user = $this->model;
$user->id = $third['user_id'];
$user->nickname = $user_info['nickName'];
$user->avatar = $user_info['avatarUrl'];
... ... @@ -553,11 +890,11 @@ class User extends Api
'prevtime' => $time,
'pid' => $this->model->get($pid) ? $pid : 0 //上级ID
];
$result = $user_model->save($user_insert);
$user_id = $user_model->getLastInsID();
$result = $this->model->save($user_insert);
$user_id = $this->model->getLastInsID();
// 生成小程序二维码
// $minicode = makeQrcode($user_id,'user_qrcode'.$user_id.'.png','pages/clock/clock');
// $user_model->isUpdate(true)->save(['qrcode'=>$minicode],['id'=>$user_id]);
// $this->model->isUpdate(true)->save(['qrcode'=>$minicode],['id'=>$user_id]);
$third_insert = [
'user_id' => $user_id,
'platform' => 'wechat',
... ... @@ -591,7 +928,7 @@ class User extends Api
}
/**
* @ApiWeigh (89)
* @ApiWeigh (81)
* @ApiTitle (用户授权获取手机号)
* @ApiSummary (用户授权获取手机号)
* @ApiMethod (POST)
... ... @@ -639,13 +976,13 @@ class User extends Api
// 新用户绑定手机号
$third = Third::where('openid',$param['openid'])->find();
if(!empty($data['phoneNumber']) && $third){
Db::name('user')->where('id',$third['user_id'])->update(['mobile'=>$data['phoneNumber']]);
$this->model->where('id',$third['user_id'])->update(['mobile'=>$data['phoneNumber']]);
}
$this->success('授权成功',$data);
}
/**
* @ApiWeigh (87)
* @ApiWeigh (79)
* @ApiTitle (工时补贴介绍)
* @ApiSummary (工时补贴介绍)
* @ApiMethod (POST)
... ... @@ -662,7 +999,7 @@ class User extends Api
}
/**
* @ApiWeigh (85)
* @ApiWeigh (77)
* @ApiTitle (招聘补贴介绍)
* @ApiSummary (招聘补贴介绍)
* @ApiMethod (POST)
... ... @@ -679,7 +1016,370 @@ class User extends Api
}
/**
* @ApiWeigh (85)
* @ApiWeigh (75)
* @ApiTitle (记一笔工时)
* @ApiSummary (记一笔工时)
* @ApiMethod (POST)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiParams (name="work_date", type="string", required=true, description="工作日期")
* @ApiParams (name="work_hours", type="string", required=true, description="工作时长")
* @ApiParams (name="work_price", type="string", required=true, description="工价")
* @ApiParams (name="work_type", type="string", required=true, description="班次:1=白班,2=夜班,3=休班")
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1606124276",
"data": "<p>招聘补贴富文本详情介绍</p>" //招聘补贴介绍
})
*/
public function logWork(){
$user = $this->model->get($this->auth->id);
$post = $this->request->param();
empty($post['work_date']) && $this->error('请选择工作日期');
$post['work_date'] = strtotime($post['work_date']) + 1; //日期转时间戳,加1为了用whereTime
$post['work_date'] >= strtotime('+1days',strtotime(date('Y-m-d'))) && $this->error('打卡日期不能大于今天');
empty($post['work_type']) && $this->error('请选择班次');
$work_salary = 0;
if($post['work_type'] != '3'){
empty($post['work_hours']) && $this->error('请选择工作时长');
empty($post['work_price']) && $this->error('请填写工价');
$work_salary = round($post['work_hours'] * $post['work_price'],2);
}
$log = UserWorkLog::where('user_id',$user['id'])->where('work_date',$post['work_date'])->find();
if(!$log){
$log = new UserWorkLog;
}
// 记录连续打卡天数
$yesterday = UserWorkLog::where('user_id',$user['id'])
->where('work_type','in','1,2')
->whereTime('work_date','yesterday')
->find();
$today = UserWorkLog::where('user_id',$user['id'])
->where('work_type','in','1,2')
->whereTime('work_date','today')
->find();
$log_days = $user['log_days'] == 0 ? 1 : ($yesterday && !$today ? ($user['log_days'] + 1) : $user['log_days']);
Db::startTrans();
try {
/*记录打卡*/
$log->save(array_merge([
'user_id' => $user['id'],
'work_salary' => $work_salary
],$post));
/*更新用户数据*/
$update_data = [];
// 更新本月工时、本月打卡工资和本月打卡次数
if(date('Y-m',$post['work_date']) == date('Y-m')){
// 本月工时
$update_data['work_hours_month'] = UserWorkLog::where('user_id',$user['id'])
->where('work_type','in','1,2')
->whereTime('work_date','month')
->sum('work_hours');
// 本月打卡工资
$update_data['work_salary_month'] = UserWorkLog::where('user_id',$user['id'])
->where('work_type','in','1,2')
->whereTime('work_date','month')
->sum('work_salary');
// 记录入职打卡工厂
if($user['is_work'] == '1' && !empty($user['factory'])){
$log->isUpdate(true)->save(['factory_id'=>$user['factory']['id']]);
}
// 本月打卡次数
$update_data['log_days_month'] = UserWorkLog::where('user_id',$user['id'])
->whereTime('work_date','month')
->count();
}
$update_data['log_days'] = $log_days;
if($update_data){
$user->save($update_data);
}
// 计算该月工资
$this->salaryCalculate($log,$user);
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
$this->success('打卡成功');
}
/**
* @ApiInternal
* @ApiTitle (计算该月工资)
* @ApiSummary (计算该月工资)
*/
private function salaryCalculate($log,$user){
/*记录该月工时补贴和招聘补贴*/
if(!empty($log['factory_id'])){
// 工时补贴
$find1 = UserWorkSubsidyLog::get(['user_work_log_id'=>$log['id']]);
if(!$find1){
$find1 = new UserWorkSubsidyLog;
}
$work_subsidy = $log['factory'] ? $log['factory']['work_subsidy'] : 1;
$find1->save([
'user_id' => $user['id'],
'work_subsidy' => round($work_subsidy * $log['work_hours'],2),
'work_date' => $log['work_date'],
'user_work_log_id' => $log['id'],
]);
// 招聘补贴上一级
$parent = $this->model->get($user['pid']);
if($parent){
$find2 = UserRecruitSubsidyLog::get(['user_work_log_id'=>$log['id'],'leave'=>0]);
if(!$find2){
$find2 = new UserRecruitSubsidyLog;
}
$find2->save([
'user_id' => $user['pid'],
'recruit_subsidy' => round($user['recruit_subsidy'] * $log['work_hours'],2),
'work_date' => $log['work_date'],
'children_id' => $user['id'],
'user_work_log_id' => $log['id'],
'leave' => 0,
]);
// 招聘补贴上二级
$pid2 =$this->mobel->where(['id'=>$parent['pid']])->find();
if($pid2){
$find2 = UserRecruitSubsidyLog::get(['user_work_log_id'=>$log['id'],'leave'=>1]);
if(!$find2){
$find2 = new UserRecruitSubsidyLog;
}
$find2->save([
'user_id' => $pid2['pid'],
'recruit_subsidy' => round($user['recruit_subsidy2'] * $log['work_hours'],2),
'work_date' => $log['work_date'],
'children_id' => $user['id'],
'user_work_log_id' => $log['id'],
'leave' => 1,
]);
}
}
}
/*记录该月总工资*/
$year_month = date('Y-m',$log['work_date']);
$user_salary = UserSalary::where('user_id',$user['id'])
->where('year_month',$year_month)
->find();
if(!$user_salary){
$user_salary = new UserSalary;
}
$month_start = strtotime($year_month);
$month_end = strtotime('+1 month',$month_start);
$work_salary_total = UserWorkLog::where('user_id',$user['id'])
->where('work_type','in','1,2')
->where("work_date >= {$month_start} and work_date < {$month_end}")
->sum('work_salary'); //月打卡总工资
$work_hours = UserWorkLog::where('user_id',$user['id'])
->where('work_type','in','1,2')
->where("work_date >= {$month_start} and work_date < {$month_end}")
->sum('work_hours'); //总工时
$work_subsidy_total = UserWorkSubsidyLog::where('user_id',$user['id'])
->where("work_date >= {$month_start} and work_date < {$month_end}")
->sum('work_subsidy'); //月工时总补贴
$recruit_subsidy_total = UserRecruitSubsidyLog::where('user_id',$user['id'])
->where("work_date >= {$month_start} and work_date < {$month_end}")
->sum('recruit_subsidy'); //月招聘总补贴
$user_salary->save([
'user_id' => $user['id'],
'salary' => round($work_salary_total + $work_subsidy_total + $recruit_subsidy_total,2),
'year_month' => $year_month,
'work_hours' => $work_hours,
'work_subsidy' => $work_subsidy_total,
'recruit_subsidy' => $recruit_subsidy_total,
'status' => '0',
]);
// 本月的工时补贴和招聘补贴
if($user['is_work'] == '1' && !empty($user['factory']) && $year_month == date('Y-m')){
// 本月工时补贴统计
$user->isUpdate(true)->save(['work_subsidy_month'=>$work_subsidy_total]);
// 给上级返招聘补贴
$parent = $this->model->get($user['pid']);
if($parent){
$parent->save(['recruit_subsidy_month'=>UserRecruitSubsidyLog::where('user_id',$user['pid'])
->where("work_date >= {$month_start} and work_date < {$month_end}")
->sum('recruit_subsidy')]);
}
}
return true;
}
/**
* @ApiWeigh (73)
* @ApiTitle (工时详情)
* @ApiSummary (工时详情)
* @ApiMethod (POST)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiParams (name="work_date", type="string", required=true, description="工作日期")
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1612340182",
"data": {
"id": 18, //ID
"user_id": 72,
"work_date": "2021-02-02", //工作日期
"work_hours": "4.5", //工时时长
"work_price": "20.00", //工价
"work_salary": "90.00", //今日收入
"work_type": "1", //班次:1=白班,2=夜班,3=休班
"createtime": 1612279627,
"updatetime": 1612279627
}
})
*/
public function workLogInfo(){
$work_date = $this->request->param('work_date');
$work_date = strtotime($work_date) + 1;
$info = UserWorkLog::where('user_id',$this->auth->id)->where('work_date',$work_date)->find();
$info['work_date'] = empty($info) ? date('Y-m-d') : date('Y-m-d',$info['work_date']);
$this->success('成功',$info);
}
/**
* @ApiWeigh (71)
* @ApiTitle (工时统计图)
* @ApiSummary (工时统计图)
* @ApiMethod (POST)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiParams (name="month", type="string", required=true, description="年月")
* @ApiReturn ({
"code": 1,
"msg": "打卡成功",
"time": "1612279947",
"data": {
"work_hours_month": 9, //工时时长
"work_salary_month": 180, //收入
"list": [{ //本月数据
"id": 14,
"work_date": "01", //打卡日期
"work_hours": "4.5", //工时
"work_type": "1", //班次:1=白班,2=夜班,3=休班
}]
}
})
*/
public function workLogList(){
$month = $this->request->param('month');
empty($month) && $this->error('缺少必需参数');
$starttime = strtotime($month);
$endtime = strtotime('+1 month',$starttime) - 1;
$list = UserWorkLog::where('user_id',$this->auth->id)
->where('work_date','between',[$starttime,$endtime])
->field('id,work_date,work_hours,work_type,work_salary')
->select();
// 打卡日期只显示当月日
$arr = ['1'=>'白班','2'=>'夜班','3'=>'休班'];
foreach ($list as $v){
$v['work_date'] = date('d',$v['work_date']);
if($v['work_type'] == '3'){
$v['work_hours'] = 0;
}
$v['work_type'] = !empty($arr[$v['work_type']]) ? $arr[$v['work_type']] : '错误';
}
$work_hours_month = array_sum(array_column($list,'work_hours'));
$work_salary_month = array_sum(array_column($list,'work_salary'));
$this->success('打卡成功',compact('work_hours_month','work_salary_month','list'));
}
/**
* @ApiWeigh (69)
* @ApiTitle (借支-打卡天数)
* @ApiSummary (借支-打卡天数)
* @ApiMethod (POST)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1612319531",
"data": {
"log_days": 1, //连续打卡天数
"limit_days": 7, //打卡满7天
"borrow_money": "300.00" //借支金额
}
})
*/
public function logDays(){
$user = $this->auth->getUser();
if($user['is_work'] == '0' || !$user['factory_id']){
$this->error('抱歉,未入职不可申请');
}
$factory = Factory::get($user['factory_id']);
empty($factory) && $this->error('您入职的工厂已被删除,请选择其他工厂入职');
$this->success('成功',[
'log_days' => $user['log_days'],
'limit_days' => 7,
'borrow_money' => $factory['borrow_money']
]);
}
/**
* @ApiWeigh (67)
* @ApiTitle (借支)
* @ApiSummary (借支)
* @ApiMethod (POST)
* @ApiHeaders (name="token", type="string", required=true, description="请求的token")
* @ApiParams (name="is_confirm", type="inter", required=true, description="是否确认:0=否,1=是")
* @ApiReturn ({
"code": 1, //1=完成,2=未满打卡,3=确认借支
"msg": "成功",
"time": "1606124276",
"data": {
"log_days": 1, //连续打卡天数
"limit_days": 7, //打卡满7天
"borrow_money": "300.00" //借支金额
}
})
*/
public function borrow(){
$user = $this->auth->getUser();
$is_confirm = $this->request->param('is_confirm','0');
if($user['is_work'] == '0' || !$user['factory_id']){
$this->error('抱歉,未入职不可申请');
}
$factory = Factory::get($user['factory_id']);
empty($factory) && $this->error('您入职的工厂已被删除,请选择其他工厂入职');
$user_borrow = UserBorrow::where('user_id',$user['id'])
->where('factory_id',$user['factory_id'])
->where('status','0')
->order('createtime desc')
->find();
!empty($user_borrow) && $this->error('借支正在审核中,无法再次申请');
$limit_days = 7;
$data = [
'log_days' => $user['log_days'],
'limit_days' => $limit_days,
'borrow_money' => $factory['borrow_money']
];
$user['log_days'] < $limit_days && $this->error('您已打卡'.$user['log_days'].'天,不满'.$limit_days.'天,条件不足无法申请借支',$data,2);
if(!$is_confirm){
$this->error('您已打卡满'.$user['log_days'].'天,可借'.$factory['borrow_money'].'元,是否申请借支?',$data,3);
}
Db::startTrans();
try {
$user->save(['log_days'=>0]);
UserBorrow::create([
'user_id' => $user['id'],
'factory_id' => $user['factory_id'],
'borrow_money' => $factory['borrow_money']
]);
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
$this->success('本次借支已完成,请重新打卡满'.$limit_days.'天可申请借支',$data);
}
/**
* @ApiWeigh (65)
* @ApiTitle (分享)
* @ApiSummary (分享)
* @ApiMethod (POST)
... ... @@ -694,7 +1394,7 @@ class User extends Api
*/
public function userPoster()
{
$user = \app\api\model\User::get($this->auth->id);
$user = $this->model->get($this->auth->id);
empty($user['avatar']) && $this->error('请先上传头像');
!url_exists($user['avatar']) && $this->error('头像失效,请更新头像');
// 本地路径
... ... @@ -702,50 +1402,153 @@ class User extends Api
if (!file_exists($dir)){
mkdir($dir,0777,true);
}
// 用户小程序码
$qrcode = $dir.'/qrcode_'.$user['id'].'.png';
if(!file_exists($qrcode)){
// $qrcode_width = 338;
$qrcode_width = 1100;
if(!file_exists($qrcode) || imagesx(imagecreatefromjpeg(ROOT_PATH.'public/'.$qrcode)) != $qrcode_width){
$response = Wechat::miniProgram()->app_code->getUnlimit($user['id'], [
'page' => 'pages/indexone/indexone',
'width' => 280, //最小宽度280
'width' => $qrcode_width, //最小宽度280
]);
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
$response->saveAs($dir, str_replace($dir.'/','',$qrcode));
}
// 280不满足,再缩小
\think\Image::open($qrcode)->thumb(169,169,\think\Image::THUMB_CENTER)->save($qrcode);
}
//将用户头像保存到本地
$avatar = $dir.'/avatar_'.$user['id'].'.png';
file_put_contents($avatar,file_get_contents($user['avatar']));
\think\Image::open($avatar)->thumb(64,64,\think\Image::THUMB_CENTER)->save($avatar);
createRoundImg($avatar);
$path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
$filename = $dir.'/'.$user['id'].'.png';
$image = \think\Image::open(ROOT_PATH.'public/assets/img/miniProgram/user_back.png');
// 昵称居中
$nickname = $user['nickname'];
$size = 12;
$box1 = imagettfbbox($size, 0, $path_ttf, $nickname);
$box1_minx = min($box1[0], $box1[2], $box1[4], $box1[6]);
$box1_maxx = max($box1[0], $box1[2], $box1[4], $box1[6]);
/* 计算文字初始坐标和尺寸 */
$w = $box1_maxx - $box1_minx;
$box1_minx += ($image->width() - $w) / 2;
$image->water($avatar,[156,52])
->text($nickname,$path_ttf,$size,'#020202',[$box1_minx,131])
->water($qrcode,[103,181])
->save($filename);
$url = request()->domain().'/'.$filename.'?v='.time();
\think\Image::open($qrcode)->thumb($qrcode_width,$qrcode_width,\think\Image::THUMB_CENTER)->save($qrcode); //压缩kb
}
// //将用户头像保存到本地
// $avatar = $dir.'/avatar_'.$user['id'].'.png';
// file_put_contents($avatar,file_get_contents($user['avatar']));
// \think\Image::open($avatar)->thumb(128,128,\think\Image::THUMB_CENTER)->save($avatar);
// createRoundImg($avatar);
//
// $path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
// $filename = $dir.'/'.$user['id'].'.png';
//
// $image = \think\Image::open(ROOT_PATH.'public/assets/img/miniProgram/user_back_v2.png');
// // 昵称居中
// $nickname = $user['nickname'];
// $size = 30;
// $box1 = imagettfbbox($size, 0, $path_ttf, $nickname);
// $box1_minx = min($box1[0], $box1[2], $box1[4], $box1[6]);
// $box1_maxx = max($box1[0], $box1[2], $box1[4], $box1[6]);
// /* 计算文字初始坐标和尺寸 */
// $w = $box1_maxx - $box1_minx;
// $box1_minx += ($image->width() - $w) / 2;
// $image->water($avatar,[312,104])
// ->text($nickname,$path_ttf,$size,'#000000',[$box1_minx,262])
// ->water($qrcode,[206,362])
// ->save($filename);
// $url = request()->domain().'/'.$filename.'?v='.time();
$url = request()->domain().'/'.$qrcode.'?v='.time();
$this->success('成功',compact('url'));
}
// /**
// * @ApiWeigh (63)
// * @ApiTitle (下级)
// * @ApiSummary (下级)
// * @ApiMethod (POST)
// * @ApiHeaders (name="token", type="string", required=true, description="请求的token")
// * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
// * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
// * @ApiParams (name="is_work", type="string", required=false, description="是否在职:0=否,1=是")
// * @ApiParams (name="keyword", type="string", required=false, description="关键字搜索")
// * @ApiReturn ({
// "code": 1,
// "msg": "成功",
// "time": "1606359935",
// "data": {
// "total": 2, //总人数
// "per_page": 15,
// "current_page": 1,
// "last_page": 1,
// "data": [{
// "id": 3, //用户ID
// "nickname": "admin2", //昵称
// "mobile": "13888888888", //手机号
// "avatar": "http://www.recruit.top/uploads/20201123/8894d62100f2f920ffb2f38063b63f2d.jpg", //头像
// "is_work": "0", //是否在职
// "is_complete": "0", //补贴是否完成:0=否,1=是
// "give_recruit_subsidy": 2, //工资
// "work_hours_month": "0.0", //本月总工时
// "factory": { //工厂
// "id": 1, //工厂ID
// "factory_shortname": "" //工厂简称
// }
// }]
// }
// })
// */
// public function aaa()
// {
// $user = $this->auth->getUser();
// $page = $this->request->param('page', 1, 'intval');
// $page_num = $this->request->param('page_num', 10, 'intval');
// $is_work = $this->request->param('is_work'); //是否在职:0=否,1=是
// $keyword = $this->request->param('keyword');
// // 可查看下级
// if(!$this->my_children_ids){
// $this->user_list = $this->model->where('status','normal')->field('id,pid')->select();
//// $this->lower_num = $this->auth->lower_num;
// $this->lower_num = 2;
// $this->my_children_ids = $this->getChildrenIds($this->auth->id);
// }
// $where['id'] = ['in',$this->my_children_ids];
//// $where['pid'] = $user['id']; //下一级
// if($is_work != ''){
// $where['is_work'] = $is_work;
// }
// // 关键字
// if(!empty($keyword)){
// // 记录搜索关键词
// if($this->auth->id){
// $has = UserKeyword::where('user_id',$this->auth->id)
// ->where('keyword',$keyword)
// ->find();
// if(!$has){
// $keyword_list = UserKeyword::order('createtime asc')->select();
// // 超过10条的删除
// if(count($keyword_list) > 10){
// UserKeyword::where('id',$keyword_list[0]['id'])->delete();
// }
// UserKeyword::create([
// 'user_id' => $this->auth->id,
// 'keyword' => $keyword
// ]);
// }else{
// $has->updatetime = time();
// $has->save();
// }
// }
// $where['nickname'] = ['like','%'.$keyword.'%'];
// }
// $data = $this->model
// ->with(['factory'])
// ->where($where)
// ->order('createtime desc')
// ->paginate($page_num,false,['page'=>$page])
// ->each(function($v){
// if(Validate::regex($v['mobile'], "^1\d{10}$")){
// $v['mobile'] = substr_replace($v['mobile'],'*****',3,5);
// }
// $v->give_recruit_subsidy = round($v['recruit_subsidy']*$v['work_hours_month'],2);
// // 未入职工厂
// if(!$v->getRelation('factory')){
// $v['is_work'] = '0';
// $v['factory'] = '';
// }
// $v->visible(['id','avatar','nickname','is_work','mobile','is_complete','work_hours_month','factory'])->append(['give_recruit_subsidy']);
// });
// $this->success('成功',$data);
// }
/**
* @ApiWeigh (83)
* @ApiWeigh (63)
* @ApiTitle (下级)
* @ApiSummary (下级)
* @ApiMethod (POST)
... ... @@ -770,6 +1573,13 @@ class User extends Api
"avatar": "http://www.recruit.top/uploads/20201123/8894d62100f2f920ffb2f38063b63f2d.jpg", //头像
"is_work": "0", //是否在职
"is_complete": "0", //补贴是否完成:0=否,1=是
"give_recruit_subsidy": 2, //工资
"work_hours_month": "0.0", //本月总工时
"num":'a', //标识:a为一级,b为二级
"factory": { //工厂
"id": 1, //工厂ID
"factory_shortname": "" //工厂简称
}
}]
}
})
... ... @@ -777,14 +1587,23 @@ class User extends Api
public function lowerList()
{
$user = $this->auth->getUser();
// var_dump($user['id']);
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
$is_work = $this->request->param('is_work'); //是否在职:0=否,1=是
$keyword = $this->request->param('keyword');
$this->user_list = $this->model->where('status','normal')->field('id,pid')->select();
$this->lower_num = $user['lower_num'];
$childrenIds = $this->getChildrenIds($user['id']);
$where['id'] = ['in',$childrenIds];
// $where['pid'] = $user['id']; //下一级
// 下二级
$xia_ids = $this->model
->where('pid',$user['id'])
->column('id');
if(!empty($xia_ids)){
$xia_xia_ids = $this->model
->where('pid','in',$xia_ids)
->column('id');
$xia_ids = $xia_xia_ids ? array_merge($xia_ids,$xia_xia_ids) : $xia_ids;
}
$where['id'] = $xia_ids ? ['in',$xia_ids] : 0;
if($is_work != ''){
$where['is_work'] = $is_work;
}
... ... @@ -813,6 +1632,7 @@ class User extends Api
$where['nickname'] = ['like','%'.$keyword.'%'];
}
$data = $this->model
->with(['factory'])
->where($where)
->order('createtime desc')
->paginate($page_num,false,['page'=>$page])
... ... @@ -820,13 +1640,24 @@ class User extends Api
if(Validate::regex($v['mobile'], "^1\d{10}$")){
$v['mobile'] = substr_replace($v['mobile'],'*****',3,5);
}
$v->visible(['id','avatar','nickname','is_work','mobile','is_complete']);
})->toArray();
$v->give_recruit_subsidy = round($v['recruit_subsidy']*$v['work_hours_month'],2);
// 未入职工厂
if(!$v->getRelation('factory')){
$v['is_work'] = '0';
$v['factory'] = '';
}
if ($v['pid'] == $this->auth->id){
$v['num'] ='a';
}else{
$v['num'] ='b';
}
$v->visible(['id','avatar','nickname','is_work','mobile','is_complete','work_hours_month','factory'])->append(['give_recruit_subsidy','num']);
});
$this->success('成功',$data);
}
/**
* @ApiWeigh (81)
* @ApiWeigh (61)
* @ApiTitle (搜索历史)
* @ApiSummary (搜索历史)
* @ApiMethod (POST)
... ... @@ -852,7 +1683,7 @@ class User extends Api
}
/**
* @ApiWeigh (79)
* @ApiWeigh (59)
* @ApiTitle (搜索历史-清空)
* @ApiSummary (搜索历史-清空)
* @ApiMethod (POST)
... ... @@ -873,7 +1704,7 @@ class User extends Api
}
/**
* @ApiWeigh (77)
* @ApiWeigh (57)
* @ApiTitle (下级的下级)
* @ApiSummary (下级的下级)
* @ApiMethod (POST)
... ... @@ -893,6 +1724,10 @@ class User extends Api
"avatar": "http://www.recruit.top/uploads/20201123/8894d62100f2f920ffb2f38063b63f2d.jpg", //头像
"is_work": "0", //是否在职:0=否,1=是
"is_complete": "0", //补贴是否完成:0=否,1=是
"factory": { //工厂
"id": 1, //工厂ID
"factory_shortname": "" //工厂简称
}
},
"list": { //下级的下级
"total": 3, //总数据
... ... @@ -906,6 +1741,12 @@ class User extends Api
"avatar": "", //头像
"is_work": "1", //是否在职:0=否,1=是
"is_complete": "0", //补贴是否完成:0=否,1=是
"give_recruit_subsidy": 2, //工资
"work_hours_month": "0.0", //本月总工时
"factory": { //工厂
"id": 1, //工厂ID
"factory_shortname": "" //工厂简称
}
}]
}
}
... ... @@ -917,17 +1758,24 @@ class User extends Api
$page = $this->request->param('page', 1, 'intval');
$page_num = $this->request->param('page_num', 10, 'intval');
$is_work = $this->request->param('is_work'); //是否在职:0=否,1=是
$this->user_list = $this->model->where('status','normal')->field('id,pid')->select();
empty($user_id) && $this->error('缺少必需参数');
$user = $this->model->get($user_id);
$user = $this->model->get($user_id,['factory']);
empty($user) && $this->error('下级用户信息不存在');
$this->lower_num = $user['lower_num'];
$childrenIds = $this->getChildrenIds($user['id']);
$where['id'] = ['in',$childrenIds];
// 可查看下级
if(!$this->my_children_ids){
$this->user_list = $this->model->where('status','normal')->field('id,pid')->select();
$this->lower_num = $this->auth->lower_num;
$this->my_children_ids = $this->getChildrenIds($this->auth->id);
}
$where['id'] = ['in',$this->my_children_ids];
$where['pid'] = $user_id;
if($is_work != ''){
$where['is_work'] = $is_work;
}
$list = $this->model
->with(['factory'])
->where($where)
->order('createtime desc')
->paginate($page_num,false,['page'=>$page])
... ... @@ -935,12 +1783,18 @@ class User extends Api
if(Validate::regex($v['mobile'], "^1\d{10}$")){
$v['mobile'] = substr_replace($v['mobile'],'*****',3,5);
}
$v->visible(['id','avatar','nickname','is_work','mobile','is_complete']);
})->toArray();
$v->give_recruit_subsidy = round($v['recruit_subsidy']*$v['work_hours_month'],2);
// 未入职工厂
if(!$v->getRelation('factory')){
$v['is_work'] = '0';
$v['factory'] = '';
}
$v->visible(['id','avatar','nickname','is_work','mobile','is_complete','work_hours_month','factory'])->append(['give_recruit_subsidy']);
});
if(Validate::regex($user['mobile'], "^1\d{10}$")){
$user['mobile'] = substr_replace($user['mobile'],'*****',3,5);
}
$user->visible(['id','avatar','nickname','is_work','mobile','is_complete']);
$user->visible(['id','avatar','nickname','is_work','mobile','is_complete','factory']);
$this->success('成功',compact('user','list'));
}
... ... @@ -967,4 +1821,42 @@ class User extends Api
}
return $newarr;
}
/**
* @ApiTitle 劳务管理通知
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1620294367",
"data": {
"id": 680, //通知id
"content": "恭喜您入驻搜房帝平台!" //通知内容
}
})
*/
public function record(){
$is_work = $this->auth->is_work; //是否在职:0=否,1=是
if ($is_work == 0){ //未入职
$where['status'] = '0';
$where['deletetime']=null;
$inform= new Inform;
$reclist = $inform
->where($where)
->order('id desc')
->field('id,content')
->find();
}
if ($is_work == 1){
$factory_id = $this->auth->factory_id; //工厂id//已入职
$where['factory_id']=$factory_id;
$inform= new Inform;
$reclist = $inform
->where($where)
->order('id desc')
->field('id,content')
->find();
}
$this->success('成功',$reclist);
}
}
... ...
... ... @@ -7,6 +7,7 @@ use app\common\model\User;
/**
* 验证接口
* @ApiWeigh(2)
*/
class Validate extends Api
{
... ...
... ... @@ -15,8 +15,20 @@ class Token extends Api
protected $noNeedRight = '*';
/**
* 检测Token是否过期
*
* @ApiWeigh (99)
* @ApiTitle (检测Token是否过期)
* @ApiSummary (检测Token是否过期)
* @ApiMethod (GET)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiReturn({
"code": 1,
"msg": "",
"time": "1621402970",
"data": {
"token": "545eed64-39c4-437e-8285-ac94c03e4921", //token
"expires_in": 2591951 //剩余有效时间
}
})
*/
public function check()
{
... ... @@ -26,8 +38,20 @@ class Token extends Api
}
/**
* 刷新Token
*
* @ApiWeigh (97)
* @ApiTitle (刷新Token)
* @ApiSummary (刷新Token)
* @ApiMethod (GET)
* @ApiHeaders (name="token", type="string", required=true, description="请求的Token")
* @ApiReturn({
"code": 1,
"msg": "",
"time": "1621403556",
"data": {
"token": "175c6d84-42af-4c59-bce0-ad8a66eb5f3f", //token
"expires_in": 2592000 //剩余有效时间
}
})
*/
public function refresh()
{
... ...
... ... @@ -12,12 +12,28 @@ class Job extends Model
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $append = [
'label_name',
];
// 格式化封面图
public function getCoverAttr($value){
return empty($value) ? '' : cdnurl($value,true);
}
//标签
public function getLabelNameAttr($value,$data){
if (empty($data['label_ids'])){
return [];
}
$project_ids = explode(",", $data['label_ids']);
$project = [];
foreach ($project_ids as $j){
$project[]= model('\app\common\model\Label')->where(['id'=>$j])->value('title');
}
return $project;
}
// 格式化图片
public function getImagesAttr($value,$data){
$arr = [];
... ...
... ... @@ -82,7 +82,7 @@ if (!function_exists('cdnurl')) {
* @param boolean $domain 是否显示域名 或者直接传入域名
* @return string
*/
function cdnurl($url, $domain = false)
function cdnurl($url, $domain = true)
{
$regex = "/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i";
$url = preg_match($regex, $url) ? $url : \think\Config::get('upload.cdnurl') . $url;
... ...
... ... @@ -26,7 +26,7 @@ class Auth
//默认配置
protected $config = [];
protected $options = [];
protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score'];
protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score','is_work','factory_id'];
public function __construct($options = [])
{
... ...
... ... @@ -28,9 +28,12 @@ return [
'mail_smtp_pass' => 'password',
'mail_verify_type' => '2',
'mail_from' => '10000@qq.com',
'recruit_subsidy_content' => '<p>由于网络招聘由工厂直招直接对接求职者省去中间环节,取代中间劳务费用,把利润补贴给求职者,达到双赢效果。</p><p><img src="http://recruit.t.brotop.cn//uploads/20201218/a17a7a8cb9aa711d05c8b6c185240d08.jpg" data-filename="filename" style="width: 665px;"><br></p><p><br></p>',
'recruit_subsidy_content' => '<p>由于网络招聘由工厂直招直接对接求职者省去中间环节,取代中间劳务费用,把利润补贴给求职者,达到双赢效果。</p><p><img src="http://recruit.t.brotop.cn//uploads/20201218/a17a7a8cb9aa711d05c8b6c185240d08.jpg" style="width: 665px;"/><br/></p><p><br/></p>',
'recruit_subsidy' => '1',
'work_subsidy_content' => '<div>由本平台小程序入职员工,可获得平台工时补贴,</div><div>补贴给求职者本人1-3元/时,</div><div>工资比其他人多300-1000元/月。</div><div><img src="http://recruit.t.brotop.cn//uploads/20201218/2b24ef40e14b31003e8f6a8fca6bdc49.jpg" data-filename="filename" style="width: 665px;"><br></div>',
'agent_content' => '<p><img src="http://recruit.t.brotop.cn//uploads/20201218/12936b5ad8e4a2b8861d154f8899338c.jpg" data-filename="filename" style="width: 665px;"><br></p>',
'notice' => '巴山楚水凄凉地,responsibility',
'work_subsidy_content' => '<div>由本平台小程序入职员工,可获得平台工时补贴,</div><div>补贴给求职者本人1-3元/时,</div><div>工资比其他人多300-1000元/月。</div><div><img src="http://recruit.t.brotop.cn//uploads/20201218/2b24ef40e14b31003e8f6a8fca6bdc49.jpg" style="width: 665px;"/><br/></div>',
'agent_content' => '',
'notice' => '工时每满300个小时,平台补贴300元',
'link' => 'https://mp.weixin.qq.com/s?__biz=MzkwNTIzOTMyMA==&mid=100000003&idx=1&sn=2c2f7a3d14016a5cab1bc926f9827789&chksm=40fb8f74778c06625363df68550c8a6e3b7b77c3a37a9acb0d45ca67473d1b3bfbe019946fe7&mpshare=1&scene=1&srcid=0517B23dia4DeM9arotlNkYL&sharer_sharetime=1621246415044&sharer_shareid=0222b3ff489427a506473cee3e8233b9#rd',
'guanzhu' => '关注公众号',
'guan' => '关注公众号',
];
... ...
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
\ No newline at end of file
... ...
此 diff 太大无法显示。
@font-face{font-family:"summernote";font-style:normal;font-weight:normal;src:url("../font/summernote.eot?dbafe969167589eda84514394d126413");src:url("../font/summernote.eot?#iefix") format("embedded-opentype"),url("../font/summernote.woff?dbafe969167589eda84514394d126413") format("woff"),url("../font/summernote.ttf?dbafe969167589eda84514394d126413") format("truetype")}[class^="note-icon-"]:before,[class*=" note-icon-"]:before{display:inline-block;font:normal normal normal 14px summernote;font-size:inherit;-webkit-font-smoothing:antialiased;text-decoration:inherit;text-rendering:auto;text-transform:none;vertical-align:middle;speak:none;-moz-osx-font-smoothing:grayscale}.note-icon-align-center:before,.note-icon-align-indent:before,.note-icon-align-justify:before,.note-icon-align-left:before,.note-icon-align-outdent:before,.note-icon-align-right:before,.note-icon-align:before,.note-icon-arrow-circle-down:before,.note-icon-arrow-circle-left:before,.note-icon-arrow-circle-right:before,.note-icon-arrow-circle-up:before,.note-icon-arrows-alt:before,.note-icon-arrows-h:before,.note-icon-arrows-v:before,.note-icon-bold:before,.note-icon-caret:before,.note-icon-chain-broken:before,.note-icon-circle:before,.note-icon-close:before,.note-icon-code:before,.note-icon-col-after:before,.note-icon-col-before:before,.note-icon-col-remove:before,.note-icon-eraser:before,.note-icon-font:before,.note-icon-frame:before,.note-icon-italic:before,.note-icon-link:before,.note-icon-magic:before,.note-icon-menu-check:before,.note-icon-minus:before,.note-icon-orderedlist:before,.note-icon-pencil:before,.note-icon-picture:before,.note-icon-question:before,.note-icon-redo:before,.note-icon-row-above:before,.note-icon-row-below:before,.note-icon-row-remove:before,.note-icon-special-character:before,.note-icon-square:before,.note-icon-strikethrough:before,.note-icon-subscript:before,.note-icon-summernote:before,.note-icon-superscript:before,.note-icon-table:before,.note-icon-text-height:before,.note-icon-trash:before,.note-icon-underline:before,.note-icon-undo:before,.note-icon-unorderedlist:before,.note-icon-video:before{display:inline-block;font-family:"summernote";font-style:normal;font-weight:normal;text-decoration:inherit}.note-icon-align-center:before{content:"\f101"}.note-icon-align-indent:before{content:"\f102"}.note-icon-align-justify:before{content:"\f103"}.note-icon-align-left:before{content:"\f104"}.note-icon-align-outdent:before{content:"\f105"}.note-icon-align-right:before{content:"\f106"}.note-icon-align:before{content:"\f107"}.note-icon-arrow-circle-down:before{content:"\f108"}.note-icon-arrow-circle-left:before{content:"\f109"}.note-icon-arrow-circle-right:before{content:"\f10a"}.note-icon-arrow-circle-up:before{content:"\f10b"}.note-icon-arrows-alt:before{content:"\f10c"}.note-icon-arrows-h:before{content:"\f10d"}.note-icon-arrows-v:before{content:"\f10e"}.note-icon-bold:before{content:"\f10f"}.note-icon-caret:before{content:"\f110"}.note-icon-chain-broken:before{content:"\f111"}.note-icon-circle:before{content:"\f112"}.note-icon-close:before{content:"\f113"}.note-icon-code:before{content:"\f114"}.note-icon-col-after:before{content:"\f115"}.note-icon-col-before:before{content:"\f116"}.note-icon-col-remove:before{content:"\f117"}.note-icon-eraser:before{content:"\f118"}.note-icon-font:before{content:"\f119"}.note-icon-frame:before{content:"\f11a"}.note-icon-italic:before{content:"\f11b"}.note-icon-link:before{content:"\f11c"}.note-icon-magic:before{content:"\f11d"}.note-icon-menu-check:before{content:"\f11e"}.note-icon-minus:before{content:"\f11f"}.note-icon-orderedlist:before{content:"\f120"}.note-icon-pencil:before{content:"\f121"}.note-icon-picture:before{content:"\f122"}.note-icon-question:before{content:"\f123"}.note-icon-redo:before{content:"\f124"}.note-icon-row-above:before{content:"\f125"}.note-icon-row-below:before{content:"\f126"}.note-icon-row-remove:before{content:"\f127"}.note-icon-special-character:before{content:"\f128"}.note-icon-square:before{content:"\f129"}.note-icon-strikethrough:before{content:"\f12a"}.note-icon-subscript:before{content:"\f12b"}.note-icon-summernote:before{content:"\f12c"}.note-icon-superscript:before{content:"\f12d"}.note-icon-table:before{content:"\f12e"}.note-icon-text-height:before{content:"\f12f"}.note-icon-trash:before{content:"\f130"}.note-icon-underline:before{content:"\f131"}.note-icon-undo:before{content:"\f132"}.note-icon-unorderedlist:before{content:"\f133"}.note-icon-video:before{content:"\f134"}.note-editor{position:relative}.note-editor .note-dropzone{position:absolute;z-index:100;display:none;color:#87cefa;background-color:#fff;opacity:.95}.note-editor .note-dropzone .note-dropzone-message{display:table-cell;font-size:28px;font-weight:700;text-align:center;vertical-align:middle}.note-editor .note-dropzone.hover{color:#098ddf}.note-editor.dragover .note-dropzone{display:table}.note-editor .note-editing-area{position:relative}.note-editor .note-editing-area .note-editable{outline:0}.note-editor .note-editing-area .note-editable sup{vertical-align:super}.note-editor .note-editing-area .note-editable sub{vertical-align:sub}.note-editor .note-editing-area img.note-float-left{margin-right:10px}.note-editor .note-editing-area img.note-float-right{margin-left:10px}.note-editor.note-frame{border:1px solid #a9a9a9}.note-editor.note-frame.codeview .note-editing-area .note-editable{display:none}.note-editor.note-frame.codeview .note-editing-area .note-codable{display:block}.note-editor.note-frame .note-editing-area{overflow:hidden}.note-editor.note-frame .note-editing-area .note-editable{padding:10px;overflow:auto;color:#000;word-wrap:break-word;background-color:#fff}.note-editor.note-frame .note-editing-area .note-editable[contenteditable="false"]{background-color:#e5e5e5}.note-editor.note-frame .note-editing-area .note-codable{display:none;width:100%;padding:10px;margin-bottom:0;font-family:Menlo,Monaco,monospace,sans-serif;font-size:14px;color:#ccc;background-color:#222;border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;box-shadow:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;resize:none}.note-editor.note-frame.fullscreen{position:fixed;top:0;left:0;z-index:1050;width:100%!important}.note-editor.note-frame.fullscreen .note-editable{background-color:#fff}.note-editor.note-frame.fullscreen .note-resizebar{display:none}.note-editor.note-frame .note-status-output{display:block;width:100%;height:20px;margin-bottom:0;font-size:14px;line-height:1.42857143;color:#000;border:0;border-top:1px solid #e2e2e2}.note-editor.note-frame .note-status-output:empty{height:0;border-top:0 solid transparent}.note-editor.note-frame .note-status-output .pull-right{float:right!important}.note-editor.note-frame .note-status-output .text-muted{color:#777}.note-editor.note-frame .note-status-output .text-primary{color:#286090}.note-editor.note-frame .note-status-output .text-success{color:#3c763d}.note-editor.note-frame .note-status-output .text-info{color:#31708f}.note-editor.note-frame .note-status-output .text-warning{color:#8a6d3b}.note-editor.note-frame .note-status-output .text-danger{color:#a94442}.note-editor.note-frame .note-status-output .alert{padding:7px 10px 2px 10px;margin:-7px 0 0 0;color:#000;background-color:#f5f5f5;border-radius:0}.note-editor.note-frame .note-status-output .alert .note-icon{margin-right:5px}.note-editor.note-frame .note-status-output .alert-success{color:#3c763d!important;background-color:#dff0d8!important}.note-editor.note-frame .note-status-output .alert-info{color:#31708f!important;background-color:#d9edf7!important}.note-editor.note-frame .note-status-output .alert-warning{color:#8a6d3b!important;background-color:#fcf8e3!important}.note-editor.note-frame .note-status-output .alert-danger{color:#a94442!important;background-color:#f2dede!important}.note-editor.note-frame .note-statusbar{background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.note-editor.note-frame .note-statusbar .note-resizebar{width:100%;height:9px;padding-top:1px;cursor:ns-resize}.note-editor.note-frame .note-statusbar .note-resizebar .note-icon-bar{width:20px;margin:1px auto;border-top:1px solid #a9a9a9}.note-editor.note-frame .note-statusbar.locked .note-resizebar{cursor:default}.note-editor.note-frame .note-statusbar.locked .note-resizebar .note-icon-bar{display:none}.note-editor.note-frame .note-placeholder{padding:10px}.note-popover.popover{max-width:none}.note-popover.popover .popover-content a{display:inline-block;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:middle}.note-popover.popover .arrow{left:20px!important}.note-toolbar{position:relative;z-index:99}.note-popover .popover-content,.panel-heading.note-toolbar{padding:0 0 5px 5px;margin:0}.note-popover .popover-content>.btn-group,.panel-heading.note-toolbar>.btn-group{margin-top:5px;margin-right:5px;margin-left:0}.note-popover .popover-content .btn-group .note-table,.panel-heading.note-toolbar .btn-group .note-table{min-width:0;padding:5px}.note-popover .popover-content .btn-group .note-table .note-dimension-picker,.panel-heading.note-toolbar .btn-group .note-table .note-dimension-picker{font-size:18px}.note-popover .popover-content .btn-group .note-table .note-dimension-picker .note-dimension-picker-mousecatcher,.panel-heading.note-toolbar .btn-group .note-table .note-dimension-picker .note-dimension-picker-mousecatcher{position:absolute!important;z-index:3;width:10em;height:10em;cursor:pointer}.note-popover .popover-content .btn-group .note-table .note-dimension-picker .note-dimension-picker-unhighlighted,.panel-heading.note-toolbar .btn-group .note-table .note-dimension-picker .note-dimension-picker-unhighlighted{position:relative!important;z-index:1;width:5em;height:5em;background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASAgMAAAAroGbEAAAACVBMVEUAAIj4+Pjp6ekKlAqjAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfYAR0BKhmnaJzPAAAAG0lEQVQI12NgAAOtVatWMTCohoaGUY+EmIkEAEruEzK2J7tvAAAAAElFTkSuQmCC') repeat}.note-popover .popover-content .btn-group .note-table .note-dimension-picker .note-dimension-picker-highlighted,.panel-heading.note-toolbar .btn-group .note-table .note-dimension-picker .note-dimension-picker-highlighted{position:absolute!important;z-index:2;width:1em;height:1em;background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASAgMAAAAroGbEAAAACVBMVEUAAIjd6vvD2f9LKLW+AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfYAR0BKwNDEVT0AAAAG0lEQVQI12NgAAOtVatWMTCohoaGUY+EmIkEAEruEzK2J7tvAAAAAElFTkSuQmCC') repeat}.note-popover .popover-content .note-style .dropdown-style blockquote,.panel-heading.note-toolbar .note-style .dropdown-style blockquote,.note-popover .popover-content .note-style .dropdown-style pre,.panel-heading.note-toolbar .note-style .dropdown-style pre{padding:5px 10px;margin:0}.note-popover .popover-content .note-style .dropdown-style h1,.panel-heading.note-toolbar .note-style .dropdown-style h1,.note-popover .popover-content .note-style .dropdown-style h2,.panel-heading.note-toolbar .note-style .dropdown-style h2,.note-popover .popover-content .note-style .dropdown-style h3,.panel-heading.note-toolbar .note-style .dropdown-style h3,.note-popover .popover-content .note-style .dropdown-style h4,.panel-heading.note-toolbar .note-style .dropdown-style h4,.note-popover .popover-content .note-style .dropdown-style h5,.panel-heading.note-toolbar .note-style .dropdown-style h5,.note-popover .popover-content .note-style .dropdown-style h6,.panel-heading.note-toolbar .note-style .dropdown-style h6,.note-popover .popover-content .note-style .dropdown-style p,.panel-heading.note-toolbar .note-style .dropdown-style p{padding:0;margin:0}.note-popover .popover-content .note-color .dropdown-toggle,.panel-heading.note-toolbar .note-color .dropdown-toggle{width:20px;padding-left:5px}.note-popover .popover-content .note-color .dropdown-menu,.panel-heading.note-toolbar .note-color .dropdown-menu{min-width:337px}.note-popover .popover-content .note-color .dropdown-menu .note-palette,.panel-heading.note-toolbar .note-color .dropdown-menu .note-palette{display:inline-block;width:160px;margin:0}.note-popover .popover-content .note-color .dropdown-menu .note-palette:first-child,.panel-heading.note-toolbar .note-color .dropdown-menu .note-palette:first-child{margin:0 5px}.note-popover .popover-content .note-color .dropdown-menu .note-palette .note-palette-title,.panel-heading.note-toolbar .note-color .dropdown-menu .note-palette .note-palette-title{margin:2px 7px;font-size:12px;text-align:center;border-bottom:1px solid #eee}.note-popover .popover-content .note-color .dropdown-menu .note-palette .note-color-reset,.panel-heading.note-toolbar .note-color .dropdown-menu .note-palette .note-color-reset{width:100%;padding:0 3px;margin:3px;font-size:11px;cursor:pointer;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.note-popover .popover-content .note-color .dropdown-menu .note-palette .note-color-row,.panel-heading.note-toolbar .note-color .dropdown-menu .note-palette .note-color-row{height:20px}.note-popover .popover-content .note-color .dropdown-menu .note-palette .note-color-reset:hover,.panel-heading.note-toolbar .note-color .dropdown-menu .note-palette .note-color-reset:hover{background:#eee}.note-popover .popover-content .note-para .dropdown-menu,.panel-heading.note-toolbar .note-para .dropdown-menu{min-width:216px;padding:5px}.note-popover .popover-content .note-para .dropdown-menu>div:first-child,.panel-heading.note-toolbar .note-para .dropdown-menu>div:first-child{margin-right:5px}.note-popover .popover-content .dropdown-menu,.panel-heading.note-toolbar .dropdown-menu{min-width:90px}.note-popover .popover-content .dropdown-menu.right,.panel-heading.note-toolbar .dropdown-menu.right{right:0;left:auto}.note-popover .popover-content .dropdown-menu.right::before,.panel-heading.note-toolbar .dropdown-menu.right::before{right:9px;left:auto!important}.note-popover .popover-content .dropdown-menu.right::after,.panel-heading.note-toolbar .dropdown-menu.right::after{right:10px;left:auto!important}.note-popover .popover-content .dropdown-menu.note-check li a i,.panel-heading.note-toolbar .dropdown-menu.note-check li a i{color:deepskyblue;visibility:hidden}.note-popover .popover-content .dropdown-menu.note-check li a.checked i,.panel-heading.note-toolbar .dropdown-menu.note-check li a.checked i{visibility:visible}.note-popover .popover-content .note-fontsize-10,.panel-heading.note-toolbar .note-fontsize-10{font-size:10px}.note-popover .popover-content .note-color-palette,.panel-heading.note-toolbar .note-color-palette{line-height:1}.note-popover .popover-content .note-color-palette div .note-color-btn,.panel-heading.note-toolbar .note-color-palette div .note-color-btn{width:20px;height:20px;padding:0;margin:0;border:1px solid #fff}.note-popover .popover-content .note-color-palette div .note-color-btn:hover,.panel-heading.note-toolbar .note-color-palette div .note-color-btn:hover{border:1px solid #000}.note-dialog>div{display:none}.note-dialog .form-group{margin-right:0;margin-left:0}.note-dialog .note-modal-form{margin:0}.note-dialog .note-image-dialog .note-dropzone{min-height:100px;margin-bottom:10px;font-size:30px;line-height:4;color:lightgray;text-align:center;border:4px dashed lightgray}@-moz-document url-prefix(){.note-image-input{height:auto}}.note-placeholder{position:absolute;display:none;color:gray}.note-handle .note-control-selection{position:absolute;display:none;border:1px solid #000}.note-handle .note-control-selection>div{position:absolute}.note-handle .note-control-selection .note-control-selection-bg{width:100%;height:100%;background-color:#000;-webkit-opacity:.3;-khtml-opacity:.3;-moz-opacity:.3;opacity:.3;-ms-filter:alpha(opacity=30);filter:alpha(opacity=30)}.note-handle .note-control-selection .note-control-handle{width:7px;height:7px;border:1px solid #000}.note-handle .note-control-selection .note-control-holder{width:7px;height:7px;border:1px solid #000}.note-handle .note-control-selection .note-control-sizing{width:7px;height:7px;background-color:#fff;border:1px solid #000}.note-handle .note-control-selection .note-control-nw{top:-5px;left:-5px;border-right:0;border-bottom:0}.note-handle .note-control-selection .note-control-ne{top:-5px;right:-5px;border-bottom:0;border-left:none}.note-handle .note-control-selection .note-control-sw{bottom:-5px;left:-5px;border-top:0;border-right:0}.note-handle .note-control-selection .note-control-se{right:-5px;bottom:-5px;cursor:se-resize}.note-handle .note-control-selection .note-control-se.note-control-holder{cursor:default;border-top:0;border-left:none}.note-handle .note-control-selection .note-control-selection-info{right:0;bottom:0;padding:5px;margin:5px;font-size:12px;color:#fff;background-color:#000;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-opacity:.7;-khtml-opacity:.7;-moz-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70)}.note-hint-popover{min-width:100px;padding:2px}.note-hint-popover .popover-content{max-height:150px;padding:3px;overflow:auto}.note-hint-popover .popover-content .note-hint-group .note-hint-item{display:block!important;padding:3px}.note-hint-popover .popover-content .note-hint-group .note-hint-item.active,.note-hint-popover .popover-content .note-hint-group .note-hint-item:hover{display:block;clear:both;font-weight:400;line-height:1.4;color:#fff;text-decoration:none;white-space:nowrap;cursor:pointer;background-color:#428bca;outline:0}
\ No newline at end of file
(function($) {
$.extend($.summernote.lang, {
'zh-CN': {
font: {
bold: '粗体',
italic: '斜体',
underline: '下划线',
clear: '清除格式',
height: '行高',
name: '字体',
strikethrough: '删除线',
subscript: '下标',
superscript: '上标',
size: '字号'
},
image: {
image: '图片',
insert: '插入图片',
resizeFull: '缩放至 100%',
resizeHalf: '缩放至 50%',
resizeQuarter: '缩放至 25%',
floatLeft: '靠左浮动',
floatRight: '靠右浮动',
floatNone: '取消浮动',
shapeRounded: '形状: 圆角',
shapeCircle: '形状: 圆',
shapeThumbnail: '形状: 缩略图',
shapeNone: '形状: 无',
dragImageHere: '将图片拖拽至此处',
dropImage: 'Drop image or Text',
selectFromFiles: '从本地上传',
maximumFileSize: '文件大小最大值',
maximumFileSizeError: '文件大小超出最大值。',
url: '图片地址',
remove: '移除图片',
original: 'Original'
},
video: {
video: '视频',
videoLink: '视频链接',
insert: '插入视频',
url: '视频地址',
providers: '(优酷, 腾讯, Instagram, DailyMotion, Youtube等)'
},
link: {
link: '链接',
insert: '插入链接',
unlink: '去除链接',
edit: '编辑链接',
textToDisplay: '显示文本',
url: '链接地址',
openInNewWindow: '在新窗口打开'
},
table: {
table: '表格',
addRowAbove: 'Add row above',
addRowBelow: 'Add row below',
addColLeft: 'Add column left',
addColRight: 'Add column right',
delRow: 'Delete row',
delCol: 'Delete column',
delTable: 'Delete table'
},
hr: {
insert: '水平线'
},
style: {
style: '样式',
p: '普通',
blockquote: '引用',
pre: '代码',
h1: '标题 1',
h2: '标题 2',
h3: '标题 3',
h4: '标题 4',
h5: '标题 5',
h6: '标题 6'
},
lists: {
unordered: '无序列表',
ordered: '有序列表'
},
options: {
help: '帮助',
fullscreen: '全屏',
codeview: '源代码'
},
paragraph: {
paragraph: '段落',
outdent: '减少缩进',
indent: '增加缩进',
left: '左对齐',
center: '居中对齐',
right: '右对齐',
justify: '两端对齐'
},
color: {
recent: '最近使用',
more: '更多',
background: '背景',
foreground: '前景',
transparent: '透明',
setTransparent: '透明',
reset: '重置',
resetToDefault: '默认'
},
shortcut: {
shortcuts: '快捷键',
close: '关闭',
textFormatting: '文本格式',
action: '动作',
paragraphFormatting: '段落格式',
documentStyle: '文档样式',
extraKeys: '额外按键'
},
help: {
insertParagraph: '插入段落',
undo: '撤销',
redo: '重做',
tab: '增加缩进',
untab: '减少缩进',
bold: '粗体',
italic: '斜体',
underline: '下划线',
strikethrough: '删除线',
removeFormat: '清除格式',
justifyLeft: '左对齐',
justifyCenter: '居中对齐',
justifyRight: '右对齐',
justifyFull: '两端对齐',
insertUnorderedList: '无序列表',
insertOrderedList: '有序列表',
outdent: '减少缩进',
indent: '增加缩进',
formatPara: '设置选中内容样式为 普通',
formatH1: '设置选中内容样式为 标题1',
formatH2: '设置选中内容样式为 标题2',
formatH3: '设置选中内容样式为 标题3',
formatH4: '设置选中内容样式为 标题4',
formatH5: '设置选中内容样式为 标题5',
formatH6: '设置选中内容样式为 标题6',
insertHorizontalRule: '插入水平线',
'linkDialog.show': '显示链接对话框'
},
history: {
undo: '撤销',
redo: '重做'
},
specialChar: {
specialChar: 'SPECIAL CHARACTERS',
select: 'Select Special characters'
}
}
});
})(jQuery);
/*! Summernote v0.8.10 | (c) 2013- Alan Hong and other contributors | MIT license */
!function(e){e.extend(e.summernote.lang,{"zh-CN":{font:{bold:"粗体",italic:"斜体",underline:"下划线",clear:"清除格式",height:"行高",name:"字体",strikethrough:"删除线",subscript:"下标",superscript:"上标",size:"字号"},image:{image:"图片",insert:"插入图片",resizeFull:"缩放至 100%",resizeHalf:"缩放至 50%",resizeQuarter:"缩放至 25%",floatLeft:"靠左浮动",floatRight:"靠右浮动",floatNone:"取消浮动",shapeRounded:"形状: 圆角",shapeCircle:"形状: 圆",shapeThumbnail:"形状: 缩略图",shapeNone:"形状: 无",dragImageHere:"将图片拖拽至此处",dropImage:"Drop image or Text",selectFromFiles:"从本地上传",maximumFileSize:"文件大小最大值",maximumFileSizeError:"文件大小超出最大值。",url:"图片地址",remove:"移除图片",original:"Original"},video:{video:"视频",videoLink:"视频链接",insert:"插入视频",url:"视频地址",providers:"(优酷, 腾讯, Instagram, DailyMotion, Youtube等)"},link:{link:"链接",insert:"插入链接",unlink:"去除链接",edit:"编辑链接",textToDisplay:"显示文本",url:"链接地址",openInNewWindow:"在新窗口打开"},table:{table:"表格",addRowAbove:"Add row above",addRowBelow:"Add row below",addColLeft:"Add column left",addColRight:"Add column right",delRow:"Delete row",delCol:"Delete column",delTable:"Delete table"},hr:{insert:"水平线"},style:{style:"样式",p:"普通",blockquote:"引用",pre:"代码",h1:"标题 1",h2:"标题 2",h3:"标题 3",h4:"标题 4",h5:"标题 5",h6:"标题 6"},lists:{unordered:"无序列表",ordered:"有序列表"},options:{help:"帮助",fullscreen:"全屏",codeview:"源代码"},paragraph:{paragraph:"段落",outdent:"减少缩进",indent:"增加缩进",left:"左对齐",center:"居中对齐",right:"右对齐",justify:"两端对齐"},color:{recent:"最近使用",more:"更多",background:"背景",foreground:"前景",transparent:"透明",setTransparent:"透明",reset:"重置",resetToDefault:"默认"},shortcut:{shortcuts:"快捷键",close:"关闭",textFormatting:"文本格式",action:"动作",paragraphFormatting:"段落格式",documentStyle:"文档样式",extraKeys:"额外按键"},help:{insertParagraph:"插入段落",undo:"撤销",redo:"重做",tab:"增加缩进",untab:"减少缩进",bold:"粗体",italic:"斜体",underline:"下划线",strikethrough:"删除线",removeFormat:"清除格式",justifyLeft:"左对齐",justifyCenter:"居中对齐",justifyRight:"右对齐",justifyFull:"两端对齐",insertUnorderedList:"无序列表",insertOrderedList:"有序列表",outdent:"减少缩进",indent:"增加缩进",formatPara:"设置选中内容样式为 普通",formatH1:"设置选中内容样式为 标题1",formatH2:"设置选中内容样式为 标题2",formatH3:"设置选中内容样式为 标题3",formatH4:"设置选中内容样式为 标题4",formatH5:"设置选中内容样式为 标题5",formatH6:"设置选中内容样式为 标题6",insertHorizontalRule:"插入水平线","linkDialog.show":"显示链接对话框"},history:{undo:"撤销",redo:"重做"},specialChar:{specialChar:"SPECIAL CHARACTERS",select:"Select Special characters"}}})}(jQuery);
\ No newline at end of file
(function($) {
$.extend($.summernote.lang, {
'zh-TW': {
font: {
bold: '粗體',
italic: '斜體',
underline: '底線',
clear: '清除格式',
height: '行高',
name: '字體',
strikethrough: '刪除線',
subscript: '下標',
superscript: '上標',
size: '字號'
},
image: {
image: '圖片',
insert: '插入圖片',
resizeFull: '縮放至100%',
resizeHalf: '縮放至 50%',
resizeQuarter: '縮放至 25%',
floatLeft: '靠左浮動',
floatRight: '靠右浮動',
floatNone: '取消浮動',
shapeRounded: '形狀: 圓角',
shapeCircle: '形狀: 圓',
shapeThumbnail: '形狀: 縮略圖',
shapeNone: '形狀: 無',
dragImageHere: '將圖片拖曳至此處',
dropImage: 'Drop image or Text',
selectFromFiles: '從本機上傳',
maximumFileSize: '文件大小最大值',
maximumFileSizeError: '文件大小超出最大值。',
url: '圖片網址',
remove: '移除圖片',
original: 'Original'
},
video: {
video: '影片',
videoLink: '影片連結',
insert: '插入影片',
url: '影片網址',
providers: '(優酷, Instagram, DailyMotion, Youtube等)'
},
link: {
link: '連結',
insert: '插入連結',
unlink: '取消連結',
edit: '編輯連結',
textToDisplay: '顯示文字',
url: '連結網址',
openInNewWindow: '在新視窗開啟'
},
table: {
table: '表格',
addRowAbove: 'Add row above',
addRowBelow: 'Add row below',
addColLeft: 'Add column left',
addColRight: 'Add column right',
delRow: 'Delete row',
delCol: 'Delete column',
delTable: 'Delete table'
},
hr: {
insert: '水平線'
},
style: {
style: '樣式',
p: '一般',
blockquote: '引用區塊',
pre: '程式碼區塊',
h1: '標題 1',
h2: '標題 2',
h3: '標題 3',
h4: '標題 4',
h5: '標題 5',
h6: '標題 6'
},
lists: {
unordered: '項目清單',
ordered: '編號清單'
},
options: {
help: '幫助',
fullscreen: '全螢幕',
codeview: '原始碼'
},
paragraph: {
paragraph: '段落',
outdent: '取消縮排',
indent: '增加縮排',
left: '靠右對齊',
center: '靠中對齊',
right: '靠右對齊',
justify: '左右對齊'
},
color: {
recent: '字型顏色',
more: '更多',
background: '背景',
foreground: '前景',
transparent: '透明',
setTransparent: '透明',
reset: '重設',
resetToDefault: '默認'
},
shortcut: {
shortcuts: '快捷鍵',
close: '關閉',
textFormatting: '文字格式',
action: '動作',
paragraphFormatting: '段落格式',
documentStyle: '文件格式',
extraKeys: '額外按鍵'
},
help: {
'insertParagraph': 'Insert Paragraph',
'undo': 'Undoes the last command',
'redo': 'Redoes the last command',
'tab': 'Tab',
'untab': 'Untab',
'bold': 'Set a bold style',
'italic': 'Set a italic style',
'underline': 'Set a underline style',
'strikethrough': 'Set a strikethrough style',
'removeFormat': 'Clean a style',
'justifyLeft': 'Set left align',
'justifyCenter': 'Set center align',
'justifyRight': 'Set right align',
'justifyFull': 'Set full align',
'insertUnorderedList': 'Toggle unordered list',
'insertOrderedList': 'Toggle ordered list',
'outdent': 'Outdent on current paragraph',
'indent': 'Indent on current paragraph',
'formatPara': 'Change current block\'s format as a paragraph(P tag)',
'formatH1': 'Change current block\'s format as H1',
'formatH2': 'Change current block\'s format as H2',
'formatH3': 'Change current block\'s format as H3',
'formatH4': 'Change current block\'s format as H4',
'formatH5': 'Change current block\'s format as H5',
'formatH6': 'Change current block\'s format as H6',
'insertHorizontalRule': 'Insert horizontal rule',
'linkDialog.show': 'Show Link Dialog'
},
history: {
undo: '復原',
redo: '取消復原'
},
specialChar: {
specialChar: 'SPECIAL CHARACTERS',
select: 'Select Special characters'
}
}
});
})(jQuery);
/*! Summernote v0.8.10 | (c) 2013- Alan Hong and other contributors | MIT license */
!function(e){e.extend(e.summernote.lang,{"zh-TW":{font:{bold:"粗體",italic:"斜體",underline:"底線",clear:"清除格式",height:"行高",name:"字體",strikethrough:"刪除線",subscript:"下標",superscript:"上標",size:"字號"},image:{image:"圖片",insert:"插入圖片",resizeFull:"縮放至100%",resizeHalf:"縮放至 50%",resizeQuarter:"縮放至 25%",floatLeft:"靠左浮動",floatRight:"靠右浮動",floatNone:"取消浮動",shapeRounded:"形狀: 圓角",shapeCircle:"形狀: 圓",shapeThumbnail:"形狀: 縮略圖",shapeNone:"形狀: 無",dragImageHere:"將圖片拖曳至此處",dropImage:"Drop image or Text",selectFromFiles:"從本機上傳",maximumFileSize:"文件大小最大值",maximumFileSizeError:"文件大小超出最大值。",url:"圖片網址",remove:"移除圖片",original:"Original"},video:{video:"影片",videoLink:"影片連結",insert:"插入影片",url:"影片網址",providers:"(優酷, Instagram, DailyMotion, Youtube等)"},link:{link:"連結",insert:"插入連結",unlink:"取消連結",edit:"編輯連結",textToDisplay:"顯示文字",url:"連結網址",openInNewWindow:"在新視窗開啟"},table:{table:"表格",addRowAbove:"Add row above",addRowBelow:"Add row below",addColLeft:"Add column left",addColRight:"Add column right",delRow:"Delete row",delCol:"Delete column",delTable:"Delete table"},hr:{insert:"水平線"},style:{style:"樣式",p:"一般",blockquote:"引用區塊",pre:"程式碼區塊",h1:"標題 1",h2:"標題 2",h3:"標題 3",h4:"標題 4",h5:"標題 5",h6:"標題 6"},lists:{unordered:"項目清單",ordered:"編號清單"},options:{help:"幫助",fullscreen:"全螢幕",codeview:"原始碼"},paragraph:{paragraph:"段落",outdent:"取消縮排",indent:"增加縮排",left:"靠右對齊",center:"靠中對齊",right:"靠右對齊",justify:"左右對齊"},color:{recent:"字型顏色",more:"更多",background:"背景",foreground:"前景",transparent:"透明",setTransparent:"透明",reset:"重設",resetToDefault:"默認"},shortcut:{shortcuts:"快捷鍵",close:"關閉",textFormatting:"文字格式",action:"動作",paragraphFormatting:"段落格式",documentStyle:"文件格式",extraKeys:"額外按鍵"},help:{insertParagraph:"Insert Paragraph",undo:"Undoes the last command",redo:"Redoes the last command",tab:"Tab",untab:"Untab",bold:"Set a bold style",italic:"Set a italic style",underline:"Set a underline style",strikethrough:"Set a strikethrough style",removeFormat:"Clean a style",justifyLeft:"Set left align",justifyCenter:"Set center align",justifyRight:"Set right align",justifyFull:"Set full align",insertUnorderedList:"Toggle unordered list",insertOrderedList:"Toggle ordered list",outdent:"Outdent on current paragraph",indent:"Indent on current paragraph",formatPara:"Change current block's format as a paragraph(P tag)",formatH1:"Change current block's format as H1",formatH2:"Change current block's format as H2",formatH3:"Change current block's format as H3",formatH4:"Change current block's format as H4",formatH5:"Change current block's format as H5",formatH6:"Change current block's format as H6",insertHorizontalRule:"Insert horizontal rule","linkDialog.show":"Show Link Dialog"},history:{undo:"復原",redo:"取消復原"},specialChar:{specialChar:"SPECIAL CHARACTERS",select:"Select Special characters"}}})}(jQuery);
\ No newline at end of file
... ... @@ -30,133 +30,619 @@ define([], function () {
});
});
if (Config.modulename === 'index' && Config.controllername === 'user' && ['login', 'register'].indexOf(Config.actionname) > -1 && $("#register-form,#login-form").size() > 0) {
$('<style>.social-login{display:flex}.social-login a{flex:1;margin:0 2px;}.social-login a:first-child{margin-left:0;}.social-login a:last-child{margin-right:0;}</style>').appendTo("head");
$("#register-form,#login-form").append('<div class="form-group social-login"></div>');
if (Config.third.status.indexOf("wechat") > -1) {
$('<a class="btn btn-success" href="' + Fast.api.fixurl('/third/connect/wechat') + '"><i class="fa fa-wechat"></i> 微信登录</a>').appendTo(".social-login");
}
if (Config.third.status.indexOf("qq") > -1) {
$('<a class="btn btn-info" href="' + Fast.api.fixurl('/third/connect/qq') + '"><i class="fa fa-qq"></i> QQ登录</a>').appendTo(".social-login");
}
if (Config.third.status.indexOf("weibo") > -1) {
$('<a class="btn btn-danger" href="' + Fast.api.fixurl('/third/connect/weibo') + '"><i class="fa fa-weibo"></i> 微博登录</a>').appendTo(".social-login");
}
}
window.UEDITOR_HOME_URL = Config.__CDN__ + "/assets/addons/ueditor/";
require.config({
paths: {
'summernote': '../addons/summernote/lang/summernote-zh-CN.min'
'ueditor.config': '../addons/ueditor/ueditor.config',
'ueditor': '../addons/ueditor/ueditor.all.min',
'ueditor.zh': '../addons/ueditor/lang/zh-cn/zh-cn',
'zeroclipboard': '../addons/ueditor/third-party/zeroclipboard/ZeroClipboard.min',
},
shim: {
'summernote': ['../addons/summernote/js/summernote.min', 'css!../addons/summernote/css/summernote.css'],
'ueditor': {
deps: ['zeroclipboard', 'ueditor.config'],
exports: 'UE',
init: function (ZeroClipboard) {
//导出到全局变量,供ueditor使用
window.ZeroClipboard = ZeroClipboard;
},
},
'ueditor.zh': ['ueditor']
}
});
require(['form', 'upload'], function (Form, Upload) {
var _bindevent = Form.events.bindevent;
Form.events.bindevent = function (form) {
_bindevent.apply(this, [form]);
try {
//绑定summernote事件
if ($(".summernote,.editor", form).size() > 0) {
require(['summernote'], function () {
var imageButton = function (context) {
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="fa fa-file-image-o"/>',
tooltip: __('Choose'),
click: function () {
parent.Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=image/*", __('Choose'), {
callback: function (data) {
var urlArr = data.url.split(/\,/);
$.each(urlArr, function () {
var url = Fast.api.cdnurl(this);
context.invoke('editor.insertImage', url);
});
require(['form', 'upload', 'ueditor', 'ueditor.zh'], function (Form, Upload, UE, undefined) {
UE.plugin.register('simpleupload', function () {
var me = this,
isLoaded = false,
containerBtn;
function initUploadBtn() {
var w = containerBtn.offsetWidth || 20,
h = containerBtn.offsetHeight || 20,
btnIframe = document.createElement('iframe'),
btnStyle = 'display:block;width:' + w + 'px;height:' + h + 'px;overflow:hidden;border:0;margin:0;padding:0;position:absolute;top:0;left:0;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;cursor:pointer;';
UE.dom.domUtils.on(btnIframe, 'load', function () {
var timestrap = (+new Date()).toString(36),
wrapper,
btnIframeDoc,
btnIframeBody;
btnIframeDoc = (btnIframe.contentDocument || btnIframe.contentWindow.document);
btnIframeBody = btnIframeDoc.body;
wrapper = btnIframeDoc.createElement('div');
wrapper.innerHTML = '<form id="edui_form_' + timestrap + '" target="edui_iframe_' + timestrap + '" method="POST" enctype="multipart/form-data" action="' + me.getOpt('serverUrl') + '" ' +
'style="' + btnStyle + '">' +
'<input id="edui_input_' + timestrap + '" type="file" accept="image/*" name="' + me.options.imageFieldName + '" ' +
'style="' + btnStyle + '">' +
'</form>' +
'<iframe id="edui_iframe_' + timestrap + '" name="edui_iframe_' + timestrap + '" style="display:none;width:0;height:0;border:0;margin:0;padding:0;position:absolute;"></iframe>';
wrapper.className = 'edui-' + me.options.theme;
wrapper.id = me.ui.id + '_iframeupload';
btnIframeBody.style.cssText = btnStyle;
btnIframeBody.style.width = w + 'px';
btnIframeBody.style.height = h + 'px';
btnIframeBody.appendChild(wrapper);
if (btnIframeBody.parentNode) {
btnIframeBody.parentNode.style.width = w + 'px';
btnIframeBody.parentNode.style.height = w + 'px';
}
var form = btnIframeDoc.getElementById('edui_form_' + timestrap);
var input = btnIframeDoc.getElementById('edui_input_' + timestrap);
var iframe = btnIframeDoc.getElementById('edui_iframe_' + timestrap);
UE.dom.domUtils.on(input, 'change', function () {
if (!input.value) return;
var loadingId = 'loading_' + (+new Date()).toString(36);
var params = UE.utils.serializeParam(me.queryCommandValue('serverparam')) || '';
var imageActionUrl = me.getActionUrl(me.getOpt('imageActionName'));
var allowFiles = me.getOpt('imageAllowFiles');
me.focus();
me.execCommand('inserthtml', '<img class="loadingclass" id="' + loadingId + '" src="' + me.options.themePath + me.options.theme + '/images/spacer.gif" title="' + (me.getLang('simpleupload.loading') || '') + '" >');
function showErrorLoader(title) {
if (loadingId) {
var loader = me.document.getElementById(loadingId);
loader && UE.dom.domUtils.remove(loader);
me.fireEvent('showmessage', {
'id': loadingId,
'content': title,
'type': 'error',
'timeout': 4000
});
}
}
// 判断文件格式是否错误
var filename = input.value,
fileext = filename ? filename.substr(filename.lastIndexOf('.')) : '';
if (!fileext || (allowFiles && (allowFiles.join('') + '.').indexOf(fileext.toLowerCase() + '.') == -1)) {
showErrorLoader(me.getLang('simpleupload.exceedTypeError'));
return;
}
for (var i = 0; i < this.files.length; i++) {
Upload.api.send(this.files[i], function (data) {
var url = Fast.api.cdnurl(data.url);
loader = me.document.getElementById(loadingId);
loader.setAttribute('src', url);
loader.setAttribute('_src', url);
loader.setAttribute('title', '');
loader.setAttribute('alt', '');
loader.removeAttribute('id');
UE.dom.domUtils.removeClasses(loader, 'loadingclass');
form.reset();
});
}
});
var stateTimer;
me.addListener('selectionchange', function () {
clearTimeout(stateTimer);
stateTimer = setTimeout(function () {
var state = me.queryCommandState('simpleupload');
if (state == -1) {
input.disabled = 'disabled';
} else {
input.disabled = false;
}
}, 400);
});
isLoaded = true;
});
btnIframe.style.cssText = btnStyle;
containerBtn.appendChild(btnIframe);
}
return {
bindEvents: {
'ready': function () {
//设置loading的样式
UE.utils.cssRule('loading',
'.loadingclass{display:inline-block;cursor:default;background: url(\'' +
this.options.themePath +
this.options.theme + '/images/loading.gif\') no-repeat center center transparent;border:1px solid #cccccc;margin-right:1px;height: 22px;width: 22px;}\n' +
'.loaderrorclass{display:inline-block;cursor:default;background: url(\'' +
this.options.themePath +
this.options.theme + '/images/loaderror.png\') no-repeat center center transparent;border:1px solid #cccccc;margin-right:1px;height: 22px;width: 22px;' +
'}',
this.document);
},
/* 初始化简单上传按钮 */
'simpleuploadbtnready': function (type, container) {
containerBtn = container;
me.afterConfigReady(initUploadBtn);
}
},
outputRule: function (root) {
UE.utils.each(root.getNodesByTagName('img'), function (n) {
if (/\b(loaderrorclass)|(bloaderrorclass)\b/.test(n.getAttr('class'))) {
n.parentNode.removeChild(n);
}
});
},
commands: {
'simpleupload': {
queryCommandState: function () {
return isLoaded ? 0 : -1;
}
}
}
}
});
UE.plugin.register('autoupload', function () {
function sendAndInsertFile(file, editor) {
var me = editor;
//模拟数据
var fieldName, urlPrefix, maxSize, allowFiles, actionUrl,
loadingHtml, errorHandler, successHandler,
filetype = /image\/\w+/i.test(file.type) ? 'image' : 'file',
loadingId = 'loading_' + (+new Date()).toString(36);
fieldName = me.getOpt(filetype + 'FieldName');
urlPrefix = me.getOpt(filetype + 'UrlPrefix');
maxSize = me.getOpt(filetype + 'MaxSize');
allowFiles = me.getOpt(filetype + 'AllowFiles');
actionUrl = me.getActionUrl(me.getOpt(filetype + 'ActionName'));
errorHandler = function (title) {
var loader = me.document.getElementById(loadingId);
loader && UE.dom.domUtils.remove(loader);
me.fireEvent('showmessage', {
'id': loadingId,
'content': title,
'type': 'error',
'timeout': 4000
});
};
if (filetype == 'image') {
loadingHtml = '<img class="loadingclass" id="' + loadingId + '" src="' +
me.options.themePath + me.options.theme +
'/images/spacer.gif" title="' + (me.getLang('autoupload.loading') || '') + '" >';
successHandler = function (data) {
var link = urlPrefix + data.url,
loader = me.document.getElementById(loadingId);
if (loader) {
loader.setAttribute('src', link);
loader.setAttribute('_src', link);
loader.setAttribute('title', data.title || '');
loader.setAttribute('alt', data.original || '');
loader.removeAttribute('id');
UE.dom.domUtils.removeClasses(loader, 'loadingclass');
}
};
} else {
loadingHtml = '<p>' +
'<img class="loadingclass" id="' + loadingId + '" src="' +
me.options.themePath + me.options.theme +
'/images/spacer.gif" title="' + (me.getLang('autoupload.loading') || '') + '" >' +
'</p>';
successHandler = function (data) {
var link = urlPrefix + data.url,
loader = me.document.getElementById(loadingId);
var rng = me.selection.getRange(),
bk = rng.createBookmark();
rng.selectNode(loader).select();
me.execCommand('insertfile', {
'url': link
});
rng.moveToBookmark(bk).select();
};
}
/* 插入loading的占位符 */
me.execCommand('inserthtml', loadingHtml);
/* 判断后端配置是否没有加载成功 */
if (!me.getOpt(filetype + 'ActionName')) {
errorHandler(me.getLang('autoupload.errorLoadConfig'));
return;
}
/* 判断文件大小是否超出限制 */
if (file.size > maxSize) {
errorHandler(me.getLang('autoupload.exceedSizeError'));
return;
}
/* 判断文件格式是否超出允许 */
var fileext = file.name ? file.name.substr(file.name.lastIndexOf('.')) : '';
if ((fileext && filetype != 'image') || (allowFiles && (allowFiles.join('') + '.').indexOf(fileext.toLowerCase() + '.') == -1)) {
errorHandler(me.getLang('autoupload.exceedTypeError'));
return;
}
try {
Upload.api.send(file, function (data) {
var url = Fast.api.cdnurl(data.url);
successHandler({
"state": "SUCCESS",
"url": url,
"title": file.name,
"original": file.name,
"type": fileext,
"size": file['size']
});
});
} catch (er) {
errorHandler(me.getLang('autoupload.loadError'));
}
}
function getPasteImage(e) {
return e.clipboardData && e.clipboardData.items && e.clipboardData.items.length == 1 && /^image\//.test(e.clipboardData.items[0].type) ? e.clipboardData.items : null;
}
function getDropImage(e) {
return e.dataTransfer && e.dataTransfer.files ? e.dataTransfer.files : null;
}
return {
outputRule: function (root) {
UE.utils.each(root.getNodesByTagName('img'), function (n) {
if (/\b(loaderrorclass)|(bloaderrorclass)\b/.test(n.getAttr('class'))) {
n.parentNode.removeChild(n);
}
});
UE.utils.each(root.getNodesByTagName('p'), function (n) {
if (/\bloadpara\b/.test(n.getAttr('class'))) {
n.parentNode.removeChild(n);
}
});
},
bindEvents: {
//插入粘贴板的图片,拖放插入图片
'ready': function (e) {
var me = this;
if (window.FormData && window.FileReader) {
UE.dom.domUtils.on(me.body, 'paste drop', function (e) {
var hasImg = false,
items;
//获取粘贴板文件列表或者拖放文件列表
items = e.type == 'paste' ? getPasteImage(e) : getDropImage(e);
if (items) {
var len = items.length,
file;
while (len--) {
file = items[len];
if (file.getAsFile) file = file.getAsFile();
if (file && file.size > 0) {
sendAndInsertFile(file, me);
hasImg = true;
}
});
return false;
}
hasImg && e.preventDefault();
}
});
return button.render();
};
var attachmentButton = function (context) {
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="fa fa-file"/>',
tooltip: __('Choose'),
click: function () {
parent.Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=*", __('Choose'), {
callback: function (data) {
var urlArr = data.url.split(/\,/);
$.each(urlArr, function () {
var url = Fast.api.cdnurl(this);
var node = $("<a href='" + url + "'>" + url + "</a>");
context.invoke('insertNode', node[0]);
});
}
});
return false;
//取消拖放图片时出现的文字光标位置提示
UE.dom.domUtils.on(me.body, 'dragover', function (e) {
if (e.dataTransfer.types[0] == 'Files') {
e.preventDefault();
}
});
return button.render();
};
$(".summernote,.editor", form).summernote({
height: 250,
lang: 'zh-CN',
fontNames: [
'Arial', 'Arial Black', 'Serif', 'Sans', 'Courier',
'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
"Open Sans", "Hiragino Sans GB", "Microsoft YaHei",
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆',
],
fontNamesIgnoreCheck: [
"Open Sans", "Microsoft YaHei",
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
],
toolbar: [
['style', ['style', 'undo', 'redo']],
['font', ['bold', 'underline', 'strikethrough', 'clear']],
['fontname', ['color', 'fontname', 'fontsize']],
['para', ['ul', 'ol', 'paragraph', 'height']],
['table', ['table', 'hr']],
['insert', ['link', 'picture', 'video']],
['select', ['image', 'attachment']],
['view', ['fullscreen', 'codeview', 'help']],
],
buttons: {
image: imageButton,
attachment: attachmentButton,
},
dialogsInBody: true,
followingToolbar: false,
callbacks: {
onChange: function (contents) {
$(this).val(contents);
$(this).trigger('change');
},
onInit: function () {
},
onImageUpload: function (files) {
var that = this;
//依次上传图片
for (var i = 0; i < files.length; i++) {
Upload.api.send(files[i], function (data) {
var url = Fast.api.cdnurl(data.url);
$(that).summernote("insertImage", url, 'filename');
//设置loading的样式
UE.utils.cssRule('loading',
'.loadingclass{display:inline-block;cursor:default;background: url(\'' +
this.options.themePath +
this.options.theme + '/images/loading.gif\') no-repeat center center transparent;border:1px solid #cccccc;margin-left:1px;height: 22px;width: 22px;}\n' +
'.loaderrorclass{display:inline-block;cursor:default;background: url(\'' +
this.options.themePath +
this.options.theme + '/images/loaderror.png\') no-repeat center center transparent;border:1px solid #cccccc;margin-right:1px;height: 22px;width: 22px;' +
'}',
this.document);
}
}
}
}
});
/**
* 远程图片抓取,当开启本插件时所有不符合本地域名的图片都将被抓取成为本地服务器上的图片
*/
UE.plugins['catchremoteimage'] = function () {
var me = this,
ajax = UE.ajax;
/* 设置默认值 */
if (me.options.catchRemoteImageEnable === false) return;
me.setOpt({
catchRemoteImageEnable: false
});
me.addListener("afterpaste", function () {
me.fireEvent("catchRemoteImage");
});
me.addListener("catchRemoteImage", function () {
var catcherLocalDomain = me.getOpt('catcherLocalDomain'),
catcherActionUrl = me.getActionUrl(me.getOpt('catcherActionName')),
catcherUrlPrefix = me.getOpt('catcherUrlPrefix'),
catcherFieldName = me.getOpt('catcherFieldName');
var remoteImages = [],
imgs = UE.dom.domUtils.getElementsByTagName(me.document, "img"),
test = function (src, urls) {
if (src.indexOf(location.host) != -1 || /(^\.)|(^\/)/.test(src)) {
return true;
}
if (urls) {
for (var j = 0, url; url = urls[j++];) {
if (src.indexOf(url) !== -1) {
return true;
}
}
}
return false;
};
for (var i = 0, ci; ci = imgs[i++];) {
if (ci.getAttribute("word_img")) {
continue;
}
var src = ci.getAttribute("_src") || ci.src || "";
if (/^(https?|ftp):/i.test(src) && !test(src, catcherLocalDomain)) {
remoteImages.push(src);
}
}
if (remoteImages.length) {
catchremoteimage(remoteImages, {
//成功抓取
success:async function (r) {
try {
var info = r.state !== undefined ? r:eval("(" + r.responseText + ")");
} catch (e) {
return;
}
/* 获取源路径和新路径 */
var i, j, ci, cj, oldSrc, newSrc, list = info.list;
for (i = 0; ci = imgs[i++];) {
oldSrc = ci.getAttribute("_src") || ci.src || "";
for (j = 0; cj = list[j++];) {
//抓取失败时不做替换处理
if (oldSrc == cj.source && cj.state == "SUCCESS") {
var file = dataURLtoFile(cj.base64Data, (new Date()).valueOf() + '.jpg');
var imgUrl=await getLoaclImg(file);
newSrc = Fast.api.cdnurl(imgUrl);
UE.dom.domUtils.setAttributes(ci, {
"src": newSrc,
"_src": newSrc
});
break;
}
}
}
});
me.fireEvent('catchremotesuccess')
},
//回调失败,本次请求超时
error: function () {
me.fireEvent("catchremoteerror");
}
});
}
} catch (e) {
}
async function getLoaclImg(file){
const promise =new Promise((resolve,reject) => {
Upload.api.send(file, function (res) {
resolve(res.url);
})
})
return promise;
}
/**
* base64转file
* @param {base64数据} data
* @param {文件名} filename
*/
function dataURLtoFile(data, filename) {
var arr = data.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], filename, {
type: mime
});
}
/**
*获取base64
*
* @param {*} img
* @param {*} callbacks
*/
function catchremoteimage(img, callbacks) {
var params = UE.utils.serializeParam(me.queryCommandValue('serverparam')) || '',
url = UE.utils.formatUrl(catcherActionUrl + (catcherActionUrl.indexOf('?') == -1 ? '?':'&') + params),
isJsonp = UE.utils.isCrossDomainUrl(url),
opt = {
'method': 'POST',
'dataType': isJsonp ? 'jsonp':'',
'timeout': 60000, //单位:毫秒,回调请求超时设置。目标用户如果网速不是很快的话此处建议设置一个较大的数值
'onsuccess': callbacks["success"],
'onerror': callbacks["error"]
};
opt[catcherFieldName] = img;
ajax.request(url, opt);
}
});
};
});
if (Config.modulename === 'index' && Config.controllername === 'user' && ['login', 'register'].indexOf(Config.actionname) > -1 && $("#register-form,#login-form").size() > 0) {
$('<style>.social-login{display:flex}.social-login a{flex:1;margin:0 2px;}.social-login a:first-child{margin-left:0;}.social-login a:last-child{margin-right:0;}</style>').appendTo("head");
$("#register-form,#login-form").append('<div class="form-group social-login"></div>');
if (Config.third.status.indexOf("wechat") > -1) {
$('<a class="btn btn-success" href="' + Fast.api.fixurl('/third/connect/wechat') + '"><i class="fa fa-wechat"></i> 微信登录</a>').appendTo(".social-login");
}
if (Config.third.status.indexOf("qq") > -1) {
$('<a class="btn btn-info" href="' + Fast.api.fixurl('/third/connect/qq') + '"><i class="fa fa-qq"></i> QQ登录</a>').appendTo(".social-login");
}
if (Config.third.status.indexOf("weibo") > -1) {
$('<a class="btn btn-danger" href="' + Fast.api.fixurl('/third/connect/weibo') + '"><i class="fa fa-weibo"></i> 微博登录</a>').appendTo(".social-login");
}
}
$(".editor").each(function () {
var id = $(this).attr("id");
$(this).removeClass('form-control');
UE.list[id] = UE.getEditor(id, {
serverUrl: Fast.api.fixurl('/addons/ueditor/api/'),
allowDivTransToP: false, //阻止div自动转p标签
initialFrameWidth: '100%',
zIndex: 90,
xssFilterRules: false,
outputXssFilter: false,
inputXssFilter: false,
catchRemoteImageEnable: true
});
//监听图片上传事件
UE.list[id].addListener("uploadBtn.click", function (e, up, editor) {
var filesObj = up.getFiles();
for (var i = 0; i < filesObj.length; i++) {
(function (j) {
var file = filesObj[j];
var id = filesObj[j].id;
var name = filesObj[j].name;
Upload.api.send(file.source.source, function (data) {
var pic = {
url: Fast.api.cdnurl(data.url),
state: "SUCCESS",
title: name
};
editor.fireEvent("upload.success", id, pic, file);
});
})(i);
}
});
//打开图片管理
UE.list[id].addListener("upload.online", function (e, editor, dialog) {
dialog.close(false);
Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=image/*", "选择", {
callback: function (data) {
var urlArr = data.url.split(/\,/);
urlArr.forEach(function (item, index) {
var url = Fast.api.cdnurl(item);
editor.execCommand('insertimage', {
src: url
});
});
}
});
});
// 涂画
UE.list[id].addListener("upload.scrawl", function (e, editor, base64, dialog) {
function dataURLtoFile(dataurl, filename) {
var arr = dataurl.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], filename, {
type: mime
});
}
var file = dataURLtoFile('data:image/png;base64,' + base64, editor.getOpt('scrawlFieldName') + '.png');
Upload.api.send(file, function (data) {
editor.execCommand('insertimage', {
src: Fast.api.cdnurl(data.url)
});
dialog.close(false);
})
})
//视频上传
UE.list[id].addListener("upload.video", function (e, up, editor) {
var filesObj = up.getFiles();
for (var i = 0; i < filesObj.length; i++) {
(function (j) {
var file = filesObj[j];
var id = filesObj[j].id;
var name = filesObj[j].name;
Upload.api.send(file.source.source, function (data) {
var pic = {
url: Fast.api.cdnurl(data.url),
state: "SUCCESS",
title: name
};
editor.fireEvent("video.file.success", id, pic, file);
});
})(i);
}
});
// 附件上传
UE.list[id].addListener("upload.attachment", function (e, up, editor) {
var filesObj = up.getFiles();
for (var i = 0; i < filesObj.length; i++) {
(function (j) {
var file = filesObj[j];
var id = filesObj[j].id;
var name = filesObj[j].name;
Upload.api.send(file.source.source, function (data) {
var pic = {
url: Fast.api.cdnurl(data.url),
state: "SUCCESS",
title: name
};
editor.fireEvent("attachment.file.success", id, pic, file);
});
})(i);
}
});
//打开附件管理
UE.list[id].addListener("file.online", function (e, editor, dialog) {
dialog.close(false);
Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=application/*", "选择", {
callback: function (data) {
var urlArr = data.url.split(/\,/);
urlArr.forEach(function (item, index) {
var url = Fast.api.cdnurl(item);
editor.execCommand('insertfile', {
url: url
});
});
}
});
});
// 修复cms提取关键词和违禁词检测
UE.list[id].addListener("contentChange", function () {
$('#' + id).val(this.getContent());
})
});
});
});
\ No newline at end of file
... ...
... ... @@ -51,6 +51,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
},
edit: function () {
Controller.api.bindevent();
setTimeout(function () {
$('input[name="row[lookdata]"]').trigger("change");
}, 100);
},
api: {
bindevent: function () {
... ... @@ -60,6 +63,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
var A = parseFloat($("#c-factory_price").val()) + parseFloat($("#c-subsidy_price").val());
$("#c-factory_price_total").val(A);
});
$(document).on("change", 'input[name="row[lookdata]"]', function () {
var status = $('input[name="row[lookdata]"]:checked').val();
if(status == 0){
$('.job').addClass('hide');
}else{
$('.job').removeClass('hide');
}
});
// Form.api.bindevent($("form[role=form]"));
}
}
};
... ...
... ... @@ -30,7 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
{field: 'idcard', title: __('Idcard'), operate: 'LIKE'},
{field: 'idcard_front', title: __('Idcard_front'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
{field: 'idcard_back', title: __('Idcard_back'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
// {field: 'idcard_back', title: __('Idcard_back'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
... ...
... ... @@ -54,6 +54,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'is_complete', title: __('Is_complete'), formatter: Table.api.formatter.status, searchList: {0: __('否'), 1: __('是')}},
// {field: 'work_subsidy', title: __('Work_subsidy'), operate: false},
{field: 'recruit_subsidy', title: __('Recruit_subsidy'), operate: false},
{field: 'recruit_subsidy2', title: __('Recruit_subsidy2'), operate: false},
{field: 'work_subsidy_month', title: __('Work_subsidy_month'), operate: false},
{field: 'recruit_subsidy_month', title: __('Recruit_subsidy_month'), operate: false},
{field: 'lower_num', title: __('Lower_num'), operate: false},
... ...