From 7e133c8efb5fb1ba360ffc3a1c8bce8c7bc68d55 Mon Sep 17 00:00:00 2001 From: dengbw Date: Fri, 15 Oct 2021 16:23:02 +0800 Subject: [PATCH] admin_material_1015 --- admin/controllers/app/material/Template.php | 42 ++- admin/views/app/material/template/edit.php | 353 ++++++++++++------ api/controllers/wxapp/material/Home.php | 17 +- api/controllers/wxapp/material/Topic.php | 2 +- .../app/material/Material_template_model.php | 3 +- 5 files changed, 291 insertions(+), 126 deletions(-) diff --git a/admin/controllers/app/material/Template.php b/admin/controllers/app/material/Template.php index 49ac7b7f..9b5cd247 100644 --- a/admin/controllers/app/material/Template.php +++ b/admin/controllers/app/material/Template.php @@ -74,16 +74,23 @@ class Template extends HD_Controller $id = $this->input->get('id'); $info['app_id'] = intval($this->input->get('app_id')); $info['status'] = 1; - $info['type'] = 1; + $info['type'] = 4; $info['cover'] = array('value' => '', 'src' => ''); - $brands = $tgsp_list = $lbhb_list = $pyqwa_list = array(); + $info['moments'] = ''; + $json_lists = $json_item = $brands = $pyqwa_list = array(); + foreach ($this->mdTemplate->typeAry() as $key => $value) { + $json_lists[$key] = array(); + $json_item[$key] = array(); + } if ($id) { $re = $this->mdTemplate->get(array('id' => $id)); if (!$re || empty($re)) { return $this->show_json(SYS_CODE_FAIL, '模板不存在!'); } + $moments = ''; if ($re['json_data']) { $json_data = json_decode($re['json_data'], true); + $json_data['moments'] && $moments = $json_data['moments']; $lists = array(); foreach ($json_data['lists'] as $key => $value) { if ($re['type'] == 1) { @@ -96,7 +103,7 @@ class Template extends HD_Controller $value['img_url'] = $value['img'] ? build_qiniu_image_url($value['img']) : ''; $value['video_file_url'] = $value['video_url'] = $value['video_cover'] = ''; } - } else if ($re['type'] == 2) { + } else if ($re['type'] == 2 || $re['type'] == 4) { $value['img_url'] = $value['img'] ? build_qiniu_image_url($value['img']) : ''; } else if ($re['type'] == 3) { if ($value['brands']) { @@ -108,15 +115,18 @@ class Template extends HD_Controller $lists[] = $value; } if ($re['type'] == 1) { - $tgsp_list = $lists; + $json_lists[1] = $lists; } else if ($re['type'] == 2) { - $lbhb_list = $lists; + $json_lists[2] = $lists; } else if ($re['type'] == 3) { $pyqwa_list = $lists; + } else if ($re['type'] == 4) { + $json_lists[4] = $lists; } unset($re['json_data']); } $info = $re; + $info['moments'] = $moments; $info['cover'] = $info['cover'] ? array('value' => $info['cover'], 'src' => build_qiniu_image_url($info['cover'])) : array('value' => '', 'src' => ''); if ($info['brand_ids']) { @@ -132,9 +142,9 @@ class Template extends HD_Controller $showInfo['statusAry'] = $this->mdTemplate->statusAry(); $showInfo['typeAry'] = $this->mdTemplate->typeAry(); $showInfo['brands'] = $brands; - $showInfo['tgsp_list'] = $tgsp_list; - $showInfo['lbhb_list'] = $lbhb_list; $showInfo['pyqwa_list'] = $pyqwa_list; + $showInfo['json_lists'] = $json_lists; + $showInfo['json_item'] = $json_item; $this->data['info'] = $info; $this->data['showInfo'] = $showInfo; $this->data['edit_url'] = $edit_url; @@ -175,8 +185,8 @@ class Template extends HD_Controller $brand_ids .= ',0'; } } + $json_data['moments'] = $info['moments']; if ($info['lists']) { - $json_data = $info['json_data']; $lists = array(); foreach ($info['lists'] as $key => $value) { if ($info['type'] == 1) { @@ -188,7 +198,7 @@ class Template extends HD_Controller unset($value['video_url']); unset($value['video_cover']); unset($value['img_url']); - } else if ($info['type'] == 2) { + } else if ($info['type'] == 2 || $info['type'] == 4) { unset($value['img_url']); } else if ($info['type'] == 3) { $brands = ''; @@ -201,8 +211,8 @@ class Template extends HD_Controller $lists[] = $value; } $json_data['lists'] = $lists; - $editData['json_data'] = json_encode($json_data, JSON_UNESCAPED_UNICODE); } + $editData['json_data'] = json_encode($json_data, JSON_UNESCAPED_UNICODE); $editData['app_id'] = $info['app_id']; $editData['title'] = $info['title']; $editData['cover'] = $info['cover']['value']; @@ -232,16 +242,20 @@ class Template extends HD_Controller $brand_ids .= ',0'; } } + $json_data['moments'] = $info['moments']; if ($info['lists']) { - $json_data = $info['json_data']; $lists = array(); foreach ($info['lists'] as $key => $value) { if ($info['type'] == 1) { - $value['video'] = $value['video_file_url']; + if ($value['video_type'] == 1) { + $value['video'] = $value['video_file_url']; + unset($value['img']); + } unset($value['video_file_url']); unset($value['video_url']); unset($value['video_cover']); - } else if ($info['type'] == 2) { + unset($value['img_url']); + } else if ($info['type'] == 2 || $info['type'] == 4) { unset($value['img_url']); } else if ($info['type'] == 3) { $brands = ''; @@ -254,8 +268,8 @@ class Template extends HD_Controller $lists[] = $value; } $json_data['lists'] = $lists; - $editData['json_data'] = json_encode($json_data, JSON_UNESCAPED_UNICODE); } + $editData['json_data'] = json_encode($json_data, JSON_UNESCAPED_UNICODE); $editData['title'] = $info['title']; $editData['cover'] = $info['cover']['value']; $editData['type'] = $info['type']; diff --git a/admin/views/app/material/template/edit.php b/admin/views/app/material/template/edit.php index 2bd83ce7..33ae02f4 100644 --- a/admin/views/app/material/template/edit.php +++ b/admin/views/app/material/template/edit.php @@ -1,7 +1,7 @@
-
+
@@ -31,7 +31,9 @@
@@ -49,11 +51,17 @@
+
+ +
+ +
+