From 5f15803f17435ca99de87b56f05186698be2b2fe Mon Sep 17 00:00:00 2001 From: dengbw Date: Mon, 18 Oct 2021 14:08:10 +0800 Subject: [PATCH] admin_material_1018 --- api/controllers/wxapp/material/Home.php | 63 +++++++++++++++++-- .../app/material/Material_template_model.php | 2 +- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/api/controllers/wxapp/material/Home.php b/api/controllers/wxapp/material/Home.php index 810efc7d..c1077388 100644 --- a/api/controllers/wxapp/material/Home.php +++ b/api/controllers/wxapp/material/Home.php @@ -24,6 +24,7 @@ class Home extends Wxapp $this->majia_white = array('get');//超级管理员披上马甲可操作权限 $this->load->model('app/material/Material_template_model', 'mdTemplate'); $this->load->model('app/material/Material_biz_model', 'mdMaterialBiz'); + $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); $this->load->model("biz/biz_model", 'mdBiz'); $this->biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']); $this->app_id == 1 && $this->app_id = 2;//获取狸车宝数据 @@ -38,22 +39,76 @@ class Home extends Wxapp protected function get_tabs() { $list = array(); - foreach ($this->mdTemplate->typeAry() as $key => $value) { - $list[] = array('id' => $key, 'name' => $value); + //根据品牌做分类 + $brand_ids = 0; + if ($this->biz_id) {//查找门店授权品牌 + $re_b = $this->mdBiz->get(array('id' => $this->biz_id, 'status' => 1)); + if ($re_b['jsondata']) { + $jsondata = json_decode($re_b['jsondata'], true); + $jsondata['auto_brands'] && $brand_ids = implode($jsondata['auto_brands'], ','); + } } + $brand_ids && $list = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'id,name'); +// foreach ($this->mdTemplate->typeAry() as $key => $value) { +//// $list[] = array('id' => $key, 'name' => $value); +//// } $this->data['title'] = '推广素材'; $this->data['list'] = $list; return $list; } /** - * Notes:推广素材_list + * Notes:获取品牌素材_lists + * Created on: 2021/10/18 11:51 + * Created by: dengbw + * @return array + * @throws Hd_exception + */ + protected function get_lists() + { + $page = $this->input_param('page'); + $size = $this->input_param('size'); + $brand_id = intval($this->input_param('type')); + if (!$brand_id) { + throw new Hd_exception('参数错误', API_CODE_FAIL); + } + !$page && $page = 1; + !$size && $size = 10; + $brand_id = $brand_id . ','; + $lists = array(); + $where = array('app_id' => $this->app_id, 'type in(4,1)' => null, "brand_ids like '%{$brand_id}%'" => null, 'status' => 1); + $total = $this->mdTemplate->count($where); + $fileds = 'id,title,cover,json_data'; + $res = $this->mdTemplate->select($where, "id desc", $page, $size, $fileds); + foreach ($res as $key2 => $value2) { + $setValue = array(); + $moments = ''; + $re_biz = $this->mdMaterialBiz->get(array('app_id' => $this->app_id, 't_id' => $value2['id'], 'biz_id' => $this->biz_id)); + $setValue['id'] = intval($value2['id']); + $setValue['title'] = $value2['title']; + $setValue['cover'] = $value2['cover'] ? build_qiniu_image_url($value2['cover']) : ''; + $setValue['if_add'] = $re_biz ? 1 : 0; + if ($value2['json_data']) { + $json_data = json_decode($value2['json_data'], true); + $json_data['moments'] && $moments = $json_data['moments']; + } + $setValue['moments'] = $moments; + $lists[] = $setValue; + } + $this->data['show'] = 'image'; + $this->data['list'] = $lists; + $this->data['total'] = $total; + return $this->data; + } + + /** + * Notes:获取分类素材_lists * Created on: 2021/10/11 11:47 * Created by: dengbw * @return array * @throws Exception */ - protected function get_lists() + protected function get_type_lists() { $page = $this->input_param('page'); $size = $this->input_param('size'); diff --git a/common/models/app/material/Material_template_model.php b/common/models/app/material/Material_template_model.php index 34193e17..47f74804 100644 --- a/common/models/app/material/Material_template_model.php +++ b/common/models/app/material/Material_template_model.php @@ -24,7 +24,7 @@ class Material_template_model extends HD_Model public function typeAry() { return array(4 => '朋友圈蓄客海报', 1 => '朋友圈蓄客视频'); - //return array(4 => '图片海报', 1 => '推广视频', 2 => '朋友圈海报', 3 => '朋友圈文案'); + //return array(4 => '朋友圈蓄客海报', 1 => '朋友圈蓄客视频', 2 => '朋友圈蓄客轮播海报', 3 => '朋友圈蓄客文案'); } /**