作者 王晓刚
1 个管道 的构建 通过 耗费 9 秒

图片生成

... ... @@ -42,10 +42,11 @@ class OrderSalesmanController extends WeChatBaseController
$user_id = $this->user_id;
$where['salesman_uid'] = ['eq',$user_id];
$where['indent_type'] = ['eq',2];
$where['state'] = ['neq',4];
$where['state'] = ['eq',2];
$indentModel = new IndentModel();
$data = $indentModel->selectData($where);
$indentGoodsModel = new IndentGoodsModel();
$indent_ids = [];
foreach($data as $key => $vo){
$indent_goods = $indentGoodsModel->selectData(['indent_id'=>$vo['id']]);
$data[$key]['indent_goods'] = $indent_goods;
... ... @@ -53,9 +54,17 @@ class OrderSalesmanController extends WeChatBaseController
if($vo['indent_type'] == 1){
$data[$key]['dizhi'] = Db::name('address') -> where('id',$vo['indent_address']) -> find();
}
$indent_ids[] = $vo['id'];
}
$goods_count = $indentGoodsModel->where(['indent_id'=>['in',$indent_ids]])->group('goods_id')->order('indent_id desc')->select()->toArray();
foreach($goods_count as $key => $g_c){
$number_sum = $indentGoodsModel->where(['indent_id'=>['in',$indent_ids],'goods_id'=>$g_c['goods_id']])->sum('number');
$goods_count[$key]['number_sum'] = $number_sum;
}
$this->assign('goods_count',$goods_count);
$school = Db::name('school')->where('uid',$user_id)->order('create_time desc')->select()->toArray();
if(count($school)!=0){
$schools = [];
foreach ($school as $key => $val){
$schools[$key]['value'] = $val['id'];
$schools[$key]['text'] = $val['school'];
... ... @@ -64,8 +73,8 @@ class OrderSalesmanController extends WeChatBaseController
}else{
$this->assign('school','');
}
$this->assign('data',$data);
$this->assign('count',count($data));
return $this->fetch();
}
public function getGradeClass(){
... ... @@ -94,19 +103,21 @@ class OrderSalesmanController extends WeChatBaseController
if(!empty($param['state'])){
$where['state'] = ['eq',$param['state']];
}else{
$where['state'] = ['neq',4];
$where['state'] = ['eq',2];
}
if(!empty($param['is_courier'])){
$where['is_courier'] = ['eq',$param['is_courier']];
}else{
$where['is_courier'] = ['eq',1];
}
// else{
// $where['is_courier'] = ['eq',1];
// }
$user_id = $this->user_id;
$where['salesman_uid'] = ['eq',$user_id];
$where['indent_type'] = ['eq',2];
$indentModel = new IndentModel();
$data = $indentModel->selectData($where);
$indentGoodsModel = new IndentGoodsModel();
$indent_ids = [];
foreach($data as $key => $vo){
$indent_goods = $indentGoodsModel->selectData(['indent_id'=>$vo['id']]);
$data[$key]['indent_goods'] = $indent_goods;
... ... @@ -116,8 +127,16 @@ class OrderSalesmanController extends WeChatBaseController
$data[$key]['detailed'] = $address['detailed'];
$data[$key]['phone'] = $address['phone'];
}
$indent_ids[] = $vo['id'];
}
$goods_count = $indentGoodsModel->where(['indent_id'=>['in',$indent_ids]])->group('goods_id')->order('indent_id desc')->select()->toArray();
foreach($goods_count as $key => $g_c){
$number_sum = $indentGoodsModel->where(['indent_id'=>['in',$indent_ids],'goods_id'=>$g_c['goods_id']])->sum('number');
$goods_count[$key]['number_sum'] = $number_sum;
}
$this->success('SUCCESS','',$data);
$result['data'] = $data;
$result['goods_count'] = $goods_count;
$this->success('SUCCESS','',$result);
}
public function send(){
$param = $this->request->param();
... ...
... ... @@ -10,7 +10,7 @@
// [ 入口文件 ]
// 调试模式开关
define("APP_DEBUG",false);
define("APP_DEBUG",true);
// 定义CMF根目录,可更改此目录
define('CMF_ROOT', __DIR__ . '/../');
... ...
... ... @@ -413,7 +413,14 @@
</if>
</foreach>
<div class="shuju_zongshu">搜索结果为<span class="count">{:count($arr2)}</span></div>
<div class="view_img" style="padding: 0 0.3rem">
<div class="goods" style="overflow: hidden">
<foreach name="$goods_count" item="g_c">
<div class="shuju_zongshu" style="float: left;width: 50%;height: 20px;">
<span style="width: 70%;height:20px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: block;float: left;">{$g_c.book_name}</span>:{$g_c.number_sum}
</div>
</foreach>
</div>
<div class="view_img" style="padding: 0 0.3rem;display:none;">
<div class="log_three_select_one log_three_select_btn down" href="javascript:;" id="view_cavans">查看订单截图</div>
</div>
<!-- 列表内容 -->
... ... @@ -985,9 +992,10 @@
'type': "GET",
'data': {'school': school, 'grade': grade, 'state': state, 'is_courier': is_courier},
'success': (function (data) {
console.log(data);
var index = $('.log_three_tab_top div').index($('.aaa'));
if (data.code == 1) {
var result = data.data;
var result = data.data.data;
if (result.length == 0) {
var html = "<div style=\"text-align: center;width: 100%;height:100%;margin:0 auto;\">暂无数据</div>";
} else {
... ... @@ -1143,6 +1151,15 @@
$('.count').html(i);
$('.log_three_list_contant').eq(index).html(html);
update();
var goods_count = data.data.goods_count;
var goods_count_html = '';
$(goods_count).each(function(key,g_c){
console.log(g_c);
goods_count_html += "<div class=\"shuju_zongshu\" style=\"float: left;width: 50%;height: 20px;\">\n" +
" <span style=\"width: 70%;height:20px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: block;float: left;\">"+g_c.book_name+"</span>:"+g_c.number_sum+"\n" +
" </div>"
})
$('.goods').html(goods_count_html)
} else {
alert('未知错误');
}
... ... @@ -1255,6 +1272,8 @@
var count = Number($('.count').text());
if (count > 0) {
count--;
}else{
$('.view_img').hide();
}
$(".count").text(count);
alert(res.msg)
... ... @@ -1405,43 +1424,47 @@
}
</script>
<script>
var img_url = '';
var k= $("#orderlist").offset().top;
var canvas2 = document.createElement("canvas");
let
_canvas = document.querySelector('#orderlist');
var w = parseInt(window.getComputedStyle(_canvas).width);
var h = parseInt(window.getComputedStyle(_canvas).height);
//将canvas画布放大若干倍,然后盛放在较小的容器内,就显得不模糊了
canvas2.width = w * 2;
canvas2.height = (h + 400) * 2;
canvas2.style.width = w + "px";
canvas2.style.height = h + "px";
//可以按照自己的需求,对context的参数修改,translate指的是偏移量
// var context = canvas.getContext("2d");
// context.translate(0,0);
var context = canvas2.getContext("2d");
context.scale(2, 2);
html2canvas(document.querySelector('#orderlist'), { canvas: canvas2 }).then(function(canvas) {
//document.body.appendChild(canvas);
//canvas转换成url,然后利用a标签的download属性,直接下载,绕过上传服务器再下载
$.ajax({
type: 'POST',
url: "{:url('upload_img')}",
data: {img:canvas.toDataURL(),top:k},
dataType: 'json',
success: function (res) {
img_url = res.data
}
});
// document.querySelector(".down").setAttribute('href', canvas.toDataURL());
});
$('#view_cavans').click(function(){
wx.previewImage({
current: img_url, // 当前显示图片的http链接
urls: [img_url] // 需要预览的图片http链接列表
var count = "{$count}";
if(count > 0) {
var img_url = '';
var k= $("#orderlist").offset().top;
var canvas2 = document.createElement("canvas");
let
_canvas = document.querySelector('#orderlist');
var w = parseInt(window.getComputedStyle(_canvas).width);
var h = parseInt(window.getComputedStyle(_canvas).height);
//将canvas画布放大若干倍,然后盛放在较小的容器内,就显得不模糊了
canvas2.width = w * 2;
canvas2.height = (h + 400) * 2;
canvas2.style.width = w + "px";
canvas2.style.height = h + "px";
//可以按照自己的需求,对context的参数修改,translate指的是偏移量
// var context = canvas.getContext("2d");
// context.translate(0,0);
var context = canvas2.getContext("2d");
context.scale(2, 2);
html2canvas(document.querySelector('#orderlist'), { canvas: canvas2 }).then(function(canvas) {
//document.body.appendChild(canvas);
//canvas转换成url,然后利用a标签的download属性,直接下载,绕过上传服务器再下载
$.ajax({
type: 'POST',
url: "{:url('upload_img')}",
data: {img:canvas.toDataURL(),top:k},
dataType: 'json',
success: function (res) {
img_url = res.data;
$('.view_img').css('display','block');
}
});
// document.querySelector(".down").setAttribute('href', canvas.toDataURL());
});
})
$('#view_cavans').click(function(){
wx.previewImage({
current: img_url, // 当前显示图片的http链接
urls: [img_url] // 需要预览的图片http链接列表
});
})
}
</script>
</body>
... ...
... ... @@ -204,8 +204,8 @@ class WeChatBaseController extends BaseController
*/
public function checkWeChatUserLogin()
{
// $user = Db::name('user')->where('id',6)->find();
// cmf_update_current_user($user);
$user = Db::name('user')->where('id',6)->find();
cmf_update_current_user($user);
// session('user',null);
$userId = cmf_get_current_user_id();
if (empty($userId)) {
... ...