edit-liche-api
This commit is contained in:
@@ -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, '操作成功');
|
||||
}
|
||||
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<form class="am-form am-form-horizontal" action="<?=$info?'/auto/brand/edit':'auto/brand/add'?>" data-auto="true" method="post" style="width: 90%;padding-top: 10px">
|
||||
<input type="hidden" value="<?=$info['id']?>" name="id">
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">品牌名称:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="输入品牌名称" name="name" value="<?=$info['name']?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 0">
|
||||
<label class="am-para-label">logo:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-form-group am-form-file">
|
||||
<button type="button" class="am-btn am-btn-default am-btn-sm"
|
||||
data-file="1" data-type="jpg,png,gif,png,jpeg"
|
||||
data-uptype="qiniu" data-field="img"><i class="am-icon-cloud-upload"></i> 选择要上传的文件
|
||||
</button>
|
||||
|
||||
<input type="hidden" name="img" value="<?= $info['logo'] ?>" class="layui-input">
|
||||
<img data-tips-image style="height:auto;max-height:32px;max-width:32px"
|
||||
src="<?= $info['logo'] ? build_qiniu_image_url($info['logo']) : '' ?>"/>
|
||||
尺寸100x100
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<div class="am-para-input">
|
||||
<button class="am-btn am-btn-secondary" type="submit">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form class="form-search" onsubmit="return false" action="/auto/brand/lists">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">车系名称:</label>
|
||||
<div class="am-para-inline w200">
|
||||
<input type="text" name="title" value="<?=$params['title'] ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="submit" class="am-btn am-btn-success w100">搜索</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" data-title="新增车系" data-modal="/auto/brand/get" class="am-btn am-btn-success w100">新增</button>
|
||||
</div>
|
||||
<div class="am-form-group fr" style="font-size: 15px;padding-right: 20px;padding-top: 6px;">
|
||||
共有<?= $pager['totle'] ?>条数据
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="coms-table-bd">
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%"><span>ID</span></th>
|
||||
<th width="20%"><span>品牌名称</span></th>
|
||||
<th width="20%"><span>车系名称</span></th>
|
||||
<th width="10%"><span>状态</span></th>
|
||||
<th width="15%"><span>创建时间</span></th>
|
||||
<th width="15%"><span>操作</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($lists as $v) { ?>
|
||||
<tr>
|
||||
<td><?= $v['id'] ?></td>
|
||||
<td><?= $v['brand_name'] ?></td>
|
||||
<td><?= $v['name'] ?></td>
|
||||
<td><?= $v['status_name'] ?></td>
|
||||
<td><?= $v['c_time'] ?></td>
|
||||
<td>
|
||||
<a href="javascript:void (0);" data-title="编辑车系" data-modal="/auto/brand/get?id=<?= $v['id'] ?>"
|
||||
class="am-text-primary"><?= '编辑' ?></a> |
|
||||
<?php if ($v['status'] == 1) { ?>
|
||||
<a href="javascript:void (0);" data-ajax="post" data-action="/auto/brand/del"
|
||||
data-params-id="<?= $v['id'] ?>" data-params-status="0">禁用</a>
|
||||
<?php } else { ?>
|
||||
<a style="color: red" href="javascript:void (0);" data-ajax="post"
|
||||
data-action="/auto/brand/del"
|
||||
data-params-id="<?= $v['id'] ?>" data-params-status="1">恢复</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user