From 9fdf43f07c8e4705fb408862d627e2222d1829fb Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Thu, 5 Aug 2021 15:28:05 +0800 Subject: [PATCH] edit-liche-api --- admin/controllers/auto/Series.php | 38 ++++++----- admin/views/auto/series/edit.php | 30 +++++++++ admin/views/auto/series/lists.php | 65 +++++++++++++++++++ api/controllers/wxapp/liche/Aptinfo.php | 10 ++- api/controllers/wxapp/liche/Udata.php | 38 +++++++---- .../models/app/liche/App_liche_cms_model.php | 4 +- common/models/auto/Auto_series_model.php | 5 ++ 7 files changed, 157 insertions(+), 33 deletions(-) create mode 100755 admin/views/auto/series/edit.php create mode 100755 admin/views/auto/series/lists.php diff --git a/admin/controllers/auto/Series.php b/admin/controllers/auto/Series.php index 0711b664..b1bc86f4 100644 --- a/admin/controllers/auto/Series.php +++ b/admin/controllers/auto/Series.php @@ -26,14 +26,18 @@ class Series extends HD_Controller{ $size = 20; $where["status > -1"] = null; $params['title'] && $where["name like '%{$params['title']}%'"] = null; - $count = $this->auto_brand_model->count($where); - $rows = $this->auto_brand_model->select($where, 'id desc', $page, $size); - $status_arr = $this->auto_brand_model->get_status(); + $count = $this->auto_series_model->count($where); + $rows = $this->auto_series_model->select($where, 'id desc', $page, $size); + $status_arr = $this->auto_series_model->get_status(); $list = []; if($rows){ + $brand_arr = array_column($rows,'brand_id'); + $brand_rows = $this->auto_brand_model->get_map_by_ids($brand_arr,'id,name'); foreach($rows as $key=>$val){ + $brand_name = $brand_rows[$val['brand_id']] ? $brand_rows[$val['brand_id']][0]['name'] : ''; $list[] = [ 'id' => $val['id'], + 'brand_name' => $brand_name, 'name' => $val['name'], 'status' => $val['status'], 'status_name' => $status_arr[$val['status']], @@ -44,8 +48,8 @@ class Series extends HD_Controller{ $this->data['lists'] = $list; $this->data['params'] = $params; $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); - $this->data['_title'] = '品牌列表'; - $this->show_view('auto/brand/lists', true); + $this->data['_title'] = '车系列表'; + $this->show_view('auto/series/lists', true); } public function get(){ @@ -53,15 +57,15 @@ class Series extends HD_Controller{ $info = []; if ($id) { - $info = $this->auto_brand_model->get(array('id' => $id)); + $info = $this->auto_series_model->get(array('id' => $id)); if (!$info || empty($info)) { return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); } } $this->data['info'] = $info; - $this->data['_title'] = $id ? '编辑品牌' : '新增品牌'; - return $this->show_view('auto/brand/edit'); + $this->data['_title'] = $id ? '编辑车系' : '新增车系'; + return $this->show_view('auto/series/edit'); } public function add(){ @@ -72,18 +76,18 @@ class Series extends HD_Controller{ $name = $this->input->post('name'); $img = $this->input->post('img'); if (!$name || empty($name)) { - return $this->show_json(SYS_CODE_FAIL, '品牌名称不能为空'); + return $this->show_json(SYS_CODE_FAIL, '车系名称不能为空'); } - $old = $this->auto_brand_model->get(['name'=>$name,'status>'=>-1]); + $old = $this->auto_series_model->get(['name'=>$name,'status>'=>-1]); if ($old) { - return $this->show_json(SYS_CODE_FAIL, '品牌已经存在'); + return $this->show_json(SYS_CODE_FAIL, '车系已经存在'); } $add_data = array( 'name' => $name, 'logo' => $img, 'c_time' => time() ); - $brand_id = $this->auto_brand_model->add($add_data); + $brand_id = $this->auto_series_model->add($add_data); if (!$brand_id) { return $this->show_json(SYS_CODE_FAIL, '添加失败'); } @@ -102,14 +106,14 @@ class Series extends HD_Controller{ return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); } if (!$name) { - return $this->show_json(SYS_CODE_FAIL, '品牌名称不能为空'); + return $this->show_json(SYS_CODE_FAIL, '车系名称不能为空'); } - //防止品牌名称重复 + //防止车系名称重复 $where = array('name' => $name, "status<>-1" => null); $id && $where['id <>'] = $id; - $old = $this->auto_brand_model->get($where); + $old = $this->auto_series_model->get($where); if ($old) { - return $this->show_json(SYS_CODE_FAIL, '品牌已经存在'); + return $this->show_json(SYS_CODE_FAIL, '车系已经存在'); } $up_data = array( 'name' => $name, @@ -126,7 +130,7 @@ class Series extends HD_Controller{ } $stauts = $this->input->post('status'); $where = array('id' => $id); - $this->auto_brand_model->update(array('status' => $stauts), $where); + $this->auto_series_model->update(array('status' => $stauts), $where); return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } diff --git a/admin/views/auto/series/edit.php b/admin/views/auto/series/edit.php new file mode 100755 index 00000000..f332ead2 --- /dev/null +++ b/admin/views/auto/series/edit.php @@ -0,0 +1,30 @@ +
+ +
+ +
+ +
+
+
+ +
+
+ + + + + 尺寸100x100 +
+
+
+
+
+ +
+
+
diff --git a/admin/views/auto/series/lists.php b/admin/views/auto/series/lists.php new file mode 100755 index 00000000..312fe674 --- /dev/null +++ b/admin/views/auto/series/lists.php @@ -0,0 +1,65 @@ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
ID品牌名称车系名称状态创建时间操作
+ | + + 禁用 + + 恢复 + +
+
+
+
+ +
+
+
+ + diff --git a/api/controllers/wxapp/liche/Aptinfo.php b/api/controllers/wxapp/liche/Aptinfo.php index 614a3e72..04038f88 100644 --- a/api/controllers/wxapp/liche/Aptinfo.php +++ b/api/controllers/wxapp/liche/Aptinfo.php @@ -18,6 +18,7 @@ class Aptinfo extends Wxapp{ $this->check_status = array();//用户状态校验 $this->check_mobile = array();//需要手机号 $this->check_headimg =array();//授权微信信息 + $this->load->model('app/appusual/app_cms_model', 'cms_model'); } @@ -25,6 +26,7 @@ class Aptinfo extends Wxapp{ $this->load->model('area_model'); $city_code = $this->input_param('c_code'); + $cms_id = $this->input_param('cms_id'); !$city_code && $city_code = 350206; @@ -61,10 +63,16 @@ class Aptinfo extends Wxapp{ $default = $city_row['city_name'].'/'.$city_row['county_name']; $c_list = array_merge($city_list,$county_list); + //获取背景图 + $img = 'https://qs.haodian.cn/wechat_app/liche/buyCar/ex-default.jpg'; + if($cms_id){ + $cms = $this->cms_model->get(['id'=>$cms_id]); + $cms['cover'] && $img = build_qiniu_image_url($cms['cover']); + } $data = [ 'city_list' => $c_list, 'def_city' => $default, - 'img' => 'https://qs.haodian.cn/wechat_app/liche/buyCar/ex-default.jpg', + 'img' => $img, ]; return $data; } diff --git a/api/controllers/wxapp/liche/Udata.php b/api/controllers/wxapp/liche/Udata.php index abb2c3ae..7706b19e 100644 --- a/api/controllers/wxapp/liche/Udata.php +++ b/api/controllers/wxapp/liche/Udata.php @@ -25,11 +25,13 @@ class Udata extends Wxapp{ throw new Exception('参数错误', API_CODE_INVILD_PARAM); } + $url_arr = parse_url($cms['url']); + $arr_query = convert_url_query($url_arr['query']); + $page = $url_arr['path']; + $udata = $this->udata_model->get(['cf_id'=>$id,'app_uid'=>$uid,'type'=>0,'datatype'=>'img']); - if(!$udata){ - $url_arr = parse_url($cms['url']); - $arr_query = convert_url_query($url_arr['query']); - $page = $url_arr['path']; + $jsondata = json_decode($udata['jsondata'],true); + if(!$udata || $jsondata['page']!=$page){ $this->config->load('app', true); $appconfig = $this->config->item('liche', 'app'); $wxconfig = $appconfig['wx']; @@ -46,16 +48,24 @@ class Udata extends Wxapp{ 'page' => $page, 'scene' => $scene ]; - $add_data = [ - 'cf_id' => $id, - 'app_uid' => $uid, - 'type' => 0, - 'datatype' => 'img', - 'dataurl' => $result['file'], - 'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE), - 'c_time' => time() - ]; - $this->udata_model->add($add_data); + if(!$udata){ + $add_data = [ + 'cf_id' => $id, + 'app_uid' => $uid, + 'type' => 0, + 'datatype' => 'img', + 'dataurl' => $result['file'], + 'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE), + 'c_time' => time() + ]; + $this->udata_model->add($add_data); + }else{ + $update = [ + 'dataurl' => $result['file'], + 'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE), + ]; + $this->udata_model->update($update,['id'=>$udata['id']]); + } $img = $result['url']; }else{ $img = build_qiniu_image_url($udata['dataurl']); diff --git a/common/models/app/liche/App_liche_cms_model.php b/common/models/app/liche/App_liche_cms_model.php index cf2e8e18..5496cacf 100755 --- a/common/models/app/liche/App_liche_cms_model.php +++ b/common/models/app/liche/App_liche_cms_model.php @@ -10,7 +10,9 @@ class App_liche_cms_model extends HD_Model{ private $table_name = 'lc_app_liche_cms'; private $posion_arr = [ - '首页bannber','热门活动','购车banner','活动专题','狸车海报','公号测评','朋友圈','其它' + 0 => '首页bannber',1 => '热门活动', 2 => '购车banner', + 4 => '狸车海报', 3 => '活动专题', 5 => '公号测评', + 6 => '朋友圈',7 => '其它' ]; public function __construct() diff --git a/common/models/auto/Auto_series_model.php b/common/models/auto/Auto_series_model.php index 218a3708..d9711abc 100644 --- a/common/models/auto/Auto_series_model.php +++ b/common/models/auto/Auto_series_model.php @@ -8,6 +8,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class Auto_series_model extends HD_Model{ private $table_name = 'lc_auto_series'; + private $status_arr = [ '-1' => '删除',0 => '下架',1 => '正常']; public function __construct() { @@ -64,4 +65,8 @@ class Auto_series_model extends HD_Model{ return $this->db->get()->result_array(); } + //获取状态 + public function get_status(){ + return $this->status_arr; + } }