introduce_322

This commit is contained in:
dengbw
2022-03-22 17:19:46 +08:00
parent c62e78a8cc
commit f26475794f
5 changed files with 737 additions and 157 deletions
+154 -19
View File
@@ -61,32 +61,89 @@ class Introduce extends HD_Controller
];
}
}
$brandList = $this->mdAutoBrand->select(["status<>" => -1], 'id desc', 0, 0, 'id, name');
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['showInfo'] = ['statusAry' => $statusAry];
$this->data['showInfo'] = ['statusAry' => $statusAry, 'brandList' => $brandList];
$this->data['_title'] = '车型介绍列表';
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
return $this->show_view('/auto/introduce/lists', true);
}
//物料列表
public function lists_material()
{
$params = $this->input->post();
if (!$params['biz_id'] || !$params['introduces']) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
$list = [];
$introduces_ids = array_unique(array_column($params['introduces'], 'id'));
$str_ids = implode(',', $introduces_ids);
$res = $this->mdAutoIntroduce->select(["id in({$str_ids})" => null], "id desc", 0, 0);
$map_brand = $map_series = [];
$brand_ids = array_unique(array_column($res, 'brand_id'));
if ($brand_ids) {
$str_ids = implode(',', $brand_ids);
$map_brand = $this->mdAutoBrand->map('id', 'name', ["id in ({$str_ids})" => null]);
}
$s_ids = array_unique(array_column($res, 's_id'));
if ($s_ids) {
$str_ids = implode(',', $s_ids);
$map_series = $this->mdAutoSeries->map('id', 'name', ["id in ({$str_ids})" => null]);
}
foreach ($res as $key => $value) {
$brand_name = $map_brand[$value['brand_id']];
$s_name = $map_series[$value['s_id']];
$title = "{$brand_name}-{$s_name}";
$scene = "{$value['id']}_{$params['biz_id']}";
$page = 'pages/storeInfo/index';//pages/modelShow/index
$name = $params['biz_name'] . '_' . $title;
$qr_code = $this->qrcode($scene, $page, '1280px', $name);
$list[] = [
'title' => $title,
'url' => "{$page}?id={$scene}",
'qr_code' => $qr_code['url'] ? $qr_code['url'] : '',
];
}
$this->data['list'] = $list;
return $this->show_json(SYS_CODE_SUCCESS, '物料列表!');
}
//展示单条数据
public function get()
{
$id = intval($this->input->get('id'));
$info = [];
if ($id) {
$re = $this->mdAutoIntroduce->get(['id' => $id]);
if (!$re) {
return $this->show_json(SYS_CODE_FAIL, '车型不存在!');
}
$video = $re['video'] ? build_qiniu_image_url($re['video'], 0, 0, 'video') : '';
$info = array(
'id' => $re['id'],
'brand_id' => $re['brand_id'],
's_id' => $re['s_id'],
'video_file_url' => $re['video'],
'video' => $video,
'video_cover' => $video . '?vframe/jpg/offset/1',
'content' => $re['content'],
);
$title = '请选择车型';
if ($re['s_id']) {
$re_b = $this->mdAutoBrand->get(['id' => $re['brand_id']]);
$re_b && $title = $re_b['name'];
$re_s = $this->mdAutoSeries->get(['id' => $re['s_id']]);
$re_s && $title = $title ? $title . '-' . $re_s['name'] : $title;
}
$_title = '编辑车型介绍';
$showInfo = ['title' => '请选择车型', 'url' => '/auto/introduce/edit'];
$showInfo = ['title' => $title, 'url' => '/auto/introduce/edit'];
} else {
$_title = '新增车型介绍';
$info = array(
'brand_id' => 0,
's_id' => 0,
'video_file_url' => '',
'video' => '',
'video_cover' => '',
'content' => '',
@@ -97,40 +154,52 @@ class Introduce extends HD_Controller
$this->data['_title'] = $_title;
$this->data['info'] = $info;
$this->data['showInfo'] = $showInfo;
return $this->show_view('/auto/introduce/edit',true);
return $this->show_view('/auto/introduce/edit', true);
}
//添加单条数据
public function add()
{
$params = $this->input->post();
if (!$params['name']) {
return $this->show_json(SYS_CODE_FAIL, '标签名称不能为空!');
$info = $params['info'];
if (!$info) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
$re = $this->mdCustomerTag->get(array('name' => $params['name']));
if (!$info['brand_id'] || !$info['s_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择车型!');
}
if (!$info['video_file_url']) {
return $this->show_json(SYS_CODE_FAIL, '请上传视频!');
}
$re = $this->mdAutoIntroduce->get(array('brand_id' => $info['brand_id'], 's_id' => $info['s_id']));
if ($re) {
return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!');
return $this->show_json(SYS_CODE_FAIL, '车型已存在了!');
}
$this->mdCustomerTag->add(['name' => $params['name'], 'sort' => $params['sort'], 'type' => $params['type']]);
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
$this->mdAutoIntroduce->add(['brand_id' => $info['brand_id'], 's_id' => $info['s_id'], 'video' => $info['video_file_url']
, 'content' => $info['content'], 'c_time' => time()]);
return $this->show_json(SYS_CODE_SUCCESS, '新增成功', '/auto/introduce');
}
//编辑单条数据
public function edit()
{
$params = $this->input->post();
if (!$params['id']) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
$info = $params['info'];
if (!$info) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
if (!$params['name']) {
return $this->show_json(SYS_CODE_FAIL, '请输入标签名称');
if (!$info['brand_id'] || !$info['s_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择车型!');
}
$re = $this->mdCustomerTag->get(array('name' => $params['name']));
if ($re && $re['id'] != $params['id']) {
return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!');
if (!$info['video_file_url']) {
return $this->show_json(SYS_CODE_FAIL, '请上传视频!');
}
$this->mdCustomerTag->update(['name' => $params['name'], 'sort' => $params['sort'], 'type' => $params['type']]
, ['id' => $params['id']]);
$re = $this->mdAutoIntroduce->get(array('brand_id' => $info['brand_id'], 's_id' => $info['s_id']));
if ($re && $re['id'] != $info['id']) {
return $this->show_json(SYS_CODE_FAIL, '车型已存在了!');
}
$this->mdAutoIntroduce->update(['brand_id' => $info['brand_id'], 's_id' => $info['s_id'], 'content' => $info['content']
, 'video' => $info['video_file_url']], ['id' => $info['id']]);
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
@@ -167,4 +236,70 @@ class Introduce extends HD_Controller
{
}
private function qrcode($scene, $page = '', $width = 0, $name = '')
{
$path = "{$page}?{$scene}";
$width && $path .= "{$width}";
$this->load->model('app/app_model', 'mdApp');
$wxconfig = $this->mdApp->appConfig()[1]['wx'];
//$filename = "{$this->mdApp->appConfig()[1]['app_key']}/" . substr(md5($path), 8, 16);
$filename = "{$this->mdApp->appConfig()[1]['app_key']}/{$name}";
$this->load->library('hdwechat', $wxconfig);
$result = $this->hdwechat->qrcode($filename, $scene, $page, $width);
if (!$result) {
return ['url' => ''];
}
$data = array('url' => http_host_com() . '/' . $result['url']);
return $data;
}
/**
* Notes:
* Created on: 2022/3/21 16:16
* Created by: dengbw
* @return bool
*/
function json_lists()
{
$page = $this->input->post('page');
$size = $this->input->post('size');
$status = $this->input->post('status');
$brand_id = intval($this->input->post('brand_id'));
$where = array();
$brand_id && $where["brand_id"] = $brand_id;
if (strlen($status) > 0) {
$where['status'] = $status;
} else {
$where['status > -1'] = null;
}
$total = $this->mdAutoIntroduce->count($where);
$lists = array();
if ($total) {
$orderby = 'id desc';
$select = 'id,brand_id, s_id';
$res = $this->mdAutoIntroduce->select($where, $orderby, $page, $size, $select);
$map_brand = $map_series = [];
$brand_ids = array_unique(array_column($res, 'brand_id'));
if ($brand_ids) {
$str_ids = implode(',', $brand_ids);
$map_brand = $this->mdAutoBrand->map('id', 'name', ["id in ({$str_ids})" => null]);
}
$s_ids = array_unique(array_column($res, 's_id'));
if ($s_ids) {
$str_ids = implode(',', $s_ids);
$map_series = $this->mdAutoSeries->map('id', 'name', ["id in ({$str_ids})" => null]);
}
foreach ($res as $v) {
$brand_name = $map_brand[$v['brand_id']];
$s_name = $map_series[$v['s_id']];
$lists[] = array(
'id' => $v['id'],
'name' => "{$brand_name}-{$s_name}",
);
}
}
$this->data = array('total' => $total, 'list' => $lists);
return $this->show_json(SYS_CODE_SUCCESS);
}
}
+11 -5
View File
@@ -883,21 +883,27 @@ class Store extends HD_Controller
$status = $this->input->post('status');
$page = $this->input->post('page');
$size = $this->input->post('size');
$title = $this->input->post('title');
$type = $this->input->post('type');
$where = array();
if (strlen($status) > 0) {
$where['status'] = $status;
} else {
$whre['status > -1'] = null;
$where['status > -1'] = null;
}
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
$where["id in ($biz_ids)"] = null;
if ($type) {
$where["type in({$type})"] = null;
} else {
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
$where["id in ($biz_ids)"] = null;
}
}
$province_id && $where['province_id'] = $province_id;
$city_id && $where['city_id'] = $city_id;
$county_id && $where['county_id'] = $county_id;
$title && $where["biz_name like '%{$title}%'"] = null;
$total = $this->biz_model->count($where);
$lists = array();
+15 -7
View File
@@ -1,7 +1,7 @@
<div id="vue-edit" class="am-form am-form-horizontal">
<div class="am-form-group">
<label class="am-para-label">车型:</label>
<div class="am-para-input wp60 w300" style="width: 20%">
<div class="am-para-input wp60">
<button type="button" class="am-btn am-btn-default am-btn-sm"
@click="seriesModal">{{showInfo.title}}
</button>
@@ -10,7 +10,7 @@
<div class="am-form-group">
<label class="am-para-label">视频:</label>
<div class="am-para-input wp60">
<input type="text" id="video-url" name="video" v-model="info.video" placeholder="视频地址"/>
<input type="text" v-model="info.video" placeholder="视频地址"/>
<div class="am-form-inline" style="margin-top: 15px;">
<div class="am-form-group" style="margin-right: 10px;">
<button id="upload-video" type="button" class="am-btn am-btn-default am-btn-sm" @click="btn_video">
@@ -28,7 +28,7 @@
<div class="am-form-group">
<label class="am-para-label">内容:</label>
<div class="am-para-input wp60">
<textarea id="id-content" name="content" style="min-height: 250px">{{info.content}}</textarea>
<textarea id="content" name="content" style="min-height: 150px" v-model="info.content"></textarea>
</div>
</div>
<div class="am-form-group">
@@ -101,6 +101,10 @@
</div>
</div>
<script type="text/javascript">
var editor;
require(['ckeditor'], function (ckeditor) {
editor = CKEDITOR.replace('content');
});
var loading = false;
var vue_obj = new Vue({
el: '#vue-edit',
@@ -118,6 +122,10 @@
},
methods: {
seriesModal: function () {
var vm = this;
if (vm.info.brand_id) {
vm.getSeries(1);
}
layer.open({
type: 1,
area: ['50%', '50%'], //宽高
@@ -194,8 +202,7 @@
},
saveEdit: function () {
var vm = this;
vm.info.video = $('#video-url').val();
vm.info.content = $('#id-content').val();
vm.info.content = editor.getData();
$.ajax({
url: vm.showInfo.url,
type: 'post',
@@ -214,8 +221,8 @@
icon: 1,
time: 2000
}, function () {
if (vm.acto.length > 0) {
$.form.href(vm.acto);
if (data.url != '') {
$.form.href(data.url);
} else {
$.form.reload();
}
@@ -284,6 +291,7 @@
// console.log(task);
show_video.empty();
var res = task._result.data;
vue_obj.info.video_file_url = res.file_url;
vue_obj.info.video = res.site_url;
vue_obj.info.video_cover = res.site_url + '?vframe/jpg/offset/1';
var html = '<a href="javascript:void(0)" data-modal="/common/show_video?video=' + res.site_url + '" data-title="查看视频">' +
+460 -126
View File
@@ -1,5 +1,5 @@
<div class="coms-table-wrap mt10">
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
<div class="coms-table-wrap mt10" id="vue-app">
<form class="form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="auto/introduce">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
@@ -24,89 +24,224 @@
</button>
</div>
<div class="am-form-group fl ml10">
<button type="button" class="am-btn am-btn-success am-btn-sm w100">生成物料</button>
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="materialModal()">生成物料
</button>
</div>
</div>
</div>
</form>
<div class="coms-table-bd" id="vue-show">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<div v-if="!materials || materials.length==0">
<div class="coms-table-bd">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="25%"><span>车型</span></th>
<th width="10%"><span>创建时间</span></th>
<th width="10%"><span>状态</span></th>
<th width="10%"><span>操作</span></th>
</tr>
</thead>
<tbody>
<?php if ($lists) {
foreach ($lists as $v) { ?>
<tr>
<td><?= $v['title'] ?></td>
<td><?= $v['c_time'] ?></td>
<td><?= $v['status_name'] ?></td>
<td>
<a data-open="/auto/introduce/get?id=<?= $v['id'] ?>"
class="am-btn am-btn-primary am-btn-xs">编辑</a>
<? if ($v['status'] == 1) { ?>
<a data-ajax="post" data-action="/auto/introduce/edit_status"
class="am-btn am-btn-danger am-btn-xs"
data-params-id="<?= $v['id'] ?>" data-params-status="0">关闭</a>
<?
} ?>
<? if ($v['status'] == 0) { ?>
<a data-ajax="post" data-action="/auto/introduce/edit_status"
class="am-btn am-btn-success am-btn-xs"
data-params-id="<?= $v['id'] ?>" data-params-status="1">开启</a>
<? } ?>
<a data-ajax="post" data-action="/auto/introduce/del"
class="am-btn am-btn-danger am-btn-xs"
data-params-id="<?= $v['id'] ?>">删除</a></td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
<div class="coms-table-ft clearfix">
<div class="hander am-form">
</div>
<div class="coms-pagination fr mr20">
<?php page_view($pager) ?>
</div>
</div>
</div>
<div v-else class="coms-table-bd">
<div class="fl" style="padding-bottom:5px; ">【{{modal_biz.biz_name}}】物料</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="25%"><span>车型</span></th>
<th width="10%"><span>创建时间</span></th>
<th width="10%"><span>状态</span></th>
<th width="15%"><span>链接</span></th>
<th width="10%"><span>操作</span></th>
</tr>
</thead>
<tbody>
<?php if ($lists) {
foreach ($lists as $v) { ?>
<tr>
<td><?= $v['title'] ?></td>
<td><?= $v['c_time'] ?></td>
<td><?= $v['status_name'] ?></td>
<td><? if ($v['status'] == 1) { ?>
<a data-ajax="post" data-action="/auto/introduce/edit_status"
class="am-btn am-btn-danger am-btn-xs"
data-params-id="<?= $v['id'] ?>" data-params-status="0">关闭</a>
<?
} ?>
<? if ($v['status'] == 0) { ?>
<a data-ajax="post" data-action="/auto/introduce/edit_status"
class="am-btn am-btn-success am-btn-xs"
data-params-id="<?= $v['id'] ?>" data-params-status="1">开启</a>
<? } ?>
<a data-ajax="post" data-action="/auto/introduce/del" class="am-btn am-btn-danger am-btn-xs"
data-params-id="<?= $v['id'] ?>">删除</a></td>
</tr>
<?php }
} ?>
<tr v-for="(v,i) in materials">
<td>{{v.title}}</td>
<td>{{v.url}}</td>
<td>
<a :href="v.qr_code" download="二维码" target="_blank"
class="am-btn am-btn-primary am-btn-xs">下载二维码</a>
<a href="javascript:void(0);" :data-clipboard-text="v.url"
class="am-btn am-btn-primary am-btn-xs">复制链接</a>
</td>
</tr>
</tbody>
</table>
<div id="options-modal" style="display: none;">
<table class="table table-hover table-middle" style="table-layout:fixed">
<colgroup>
<col width="65%">
<col width="15%">
<col width="">
</colgroup>
<thead>
<tr>
<th class="text-center">标题</th>
<th class="text-center">排序</th>
<th class="text-right">
<a href="javascript:" style="margin-top: 2px;" class="btn btn-primary btn-sm"
@click='addOptions()'>添加</a>
</th>
</tr>
</thead>
<tbody>
<template v-for="(item,index) in optionsList">
<tr v-if="item.status==1">
<td class="text-center">
<input :id="'name_'+index" @blur="editName(index)" class="form-control"
v-model="item.name" placeholder="请输入标题"></td>
<td class="text-center">
<input :id="'group_name_'+index" @blur="editGroupName(index)" class="form-control"
v-model="item.sort" type="number" placeholder="请输入排序值">
</td>
<td class="text-right">
<a href="javascript:void(0);" style="margin-top:2px;"
class="btn btn-danger btn-sm" @click='delOptions(index)'>删除</a>
</td>
</tr>
</template>
</tbody>
</table>
</div>
<div id="material-modal" style="display: none; padding: 20px 10px 10px 0px;">
<div class="am-form am-form-horizontal">
<div class="am-form-group">
<label class="am-para-label w100">门店:</label>
<div class="am-para-input wp60">
<button type="button" class="am-btn am-btn-default am-btn-sm"
@click="bizModal">{{modal_biz.biz_name}}
</button>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label w100">车型:</label>
<div class="am-para-input">
<button type="button" class="am-btn am-btn-default am-btn-sm" @click="introduceModal">+</button>
<div class="label-group-wrap label-group-sortable" style="display: inline;padding-left: 5px;">
<div class="label-group" v-for="(v,i) in introduces">
<span class="label label-default sort-shop-list" :data-id="v.id" :data-name="v.name"
:data-sort="i">{{v.name}}</span>
<a href="javascript:void(0);" @click="rmIntroduces(i)" class="label label-default"><i
class="fa fa-remove"></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="coms-table-ft clearfix">
<div class="hander am-form">
<div id="biz-modal" style="display: none;">
<div class="modal-body">
<table width="100%">
<tr>
<td width="15%">ID</td>
<td width="65%" style="font-weight: bold;padding-left: 8px;">商家名称</td>
<td width="20%" style="padding-right: 8px;">
<label class="sr-only" for="search">商家名称</label>
<div class="input-group input-group-sm">
<input type="text" class="form-control" style="font-size: 1.2rem;font-weight: bold;"
v-model='modal_biz.title' placeholder="商家名称">
<div class="input-group-btn">
<button type="button" @click='getBiz(0);' class="btn btn-default">搜</button>
</div>
</div>
</td>
</tr>
</table>
<div style="border-bottom: 1px solid #ddd;height: 1px;margin-top: 8px;"></div>
<table class="table table-middle">
<colgroup>
<col width="15%"/>
<col width="45%"/>
<col width="20%"/>
</colgroup>
<tbody>
<tr v-for="(v,i) in modal_biz.lists">
<td>{{v.id}}</td>
<td>{{v.title}}</td>
<td class="text-right">
<a v-if="v.checked==0 || !v.checked" href="javascript:void(0);" @click="set_biz(i,1)"
class="btn btn-primary btn-sm">选择</a>
<a v-else-if="v.checked==1" href="javascript:void(0);" @click="set_biz(i,0)"
class="btn btn-default btn-sm">移除</a>
</td>
</tr>
</tbody>
</table>
<div class="clearfix">
<span class="pull-left text-muted">第{{modal_biz.page}}页(每页{{modal_biz.size}}条,共{{modal_biz.total}}条)</span>
<nav class="pull-right" aria-label="Page navigation">
<ul class="pagination pagination-sm">
<li v-if="modal_biz.page>1">
<a href="javascript:void(0);" @click="get_biz(-1);" aria-label="上一页">
<span class="glyphicon glyphicon-menu-left"></span>
</a>
</li>
<li v-if="modal_biz.next>0">
<a href="javascript:void(0);" @click="get_biz(1);" aria-label="下一页">
<span class="glyphicon glyphicon-menu-right"></span>
</a>
</li>
</ul>
</nav>
</div>
</div>
<div class="coms-pagination fr mr20">
<?php page_view($pager) ?>
</div>
<div id="introduce-modal" style="display: none;">
<div class="modal-body">
<table width="100%">
<tr>
<td width="15%">ID</td>
<td width="65%" style="font-weight: bold;padding-left: 8px;">车型</td>
<td width="20%" style="padding-right: 8px;">
<select id="id-brand_id" class="form-control" style="font-size: 1.4rem;"
@change='get_introduces(0);'
v-model="modal_introduces.brand_id">
<option value="0">选择品牌</option>
<template v-for="(v,i) in showInfo.brandList">
<option :value="v.id">{{v.name}}</option>
</template>
</select>
</td>
</tr>
</table>
<div style="border-bottom: 1px solid #ddd;height: 1px;margin-top: 8px;"></div>
<table class="table table-middle">
<colgroup>
<col width="15%"/>
<col width="45%"/>
<col width="20%"/>
</colgroup>
<tbody>
<tr v-for="(v,i) in modal_introduces.lists">
<td>{{v.id}}</td>
<td>{{v.name}}</td>
<td class="text-right">
<a v-if="v.checked==0 || !v.checked" href="javascript:void(0);" @click="set_introduces(i,1)"
class="btn btn-primary btn-sm">选择</a>
<a v-else-if="v.checked==1" href="javascript:void(0);" @click="set_introduces(i,0)"
class="btn btn-default btn-sm">移除</a>
</td>
</tr>
</tbody>
</table>
<div class="clearfix">
<span class="pull-left text-muted">第{{modal_introduces.page}}页(每页{{modal_introduces.size}}条,共{{modal_introduces.total}}条)</span>
<nav class="pull-right" aria-label="Page navigation">
<ul class="pagination pagination-sm">
<li v-if="modal_introduces.page>1">
<a href="javascript:void(0);" @click="get_introduces(-1);" aria-label="上一页">
<span class="glyphicon glyphicon-menu-left"></span>
</a>
</li>
<li v-if="modal_introduces.next>0">
<a href="javascript:void(0);" @click="get_introduces(1);" aria-label="下一页">
<span class="glyphicon glyphicon-menu-right"></span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
@@ -114,42 +249,66 @@
var vue_obj;
$(function () {
vue_obj = new Vue({
el: '#vue-show',
el: '#vue-app',
data: {
optionsList: [],
showInfo: {},
introduces: [],
materials: [],
modal_biz: {
biz_name: '请选择门店',
biz_id: 0,
title: '',
lists: [],
selected: {},
page: 1,
size: 10,
total: 0
},
modal_introduces: {brand_id: 0, title: '', lists: [], selected: [], page: 1, size: 10, total: 0}
},
mounted: function () {
var vm = this;
vm.showInfo = <?=json_encode($showInfo)?>;
},
methods: {
optionsModal: function (id, name) {
materialModal: function () {
var vm = this;
layer.open({
type: 1,
area: ['50%', '50%'], //宽高
content: $('#options-modal'),
title: '编辑【' + name + '】选项',
area: ['50%', '30%'], //宽高
content: $('#material-modal'),
title: '生成物料',
shade: false,
btn: ['保存', '取消'],
btn: ['确定', '取消'],
yes: function (index) {
if (!vm.modal_biz.biz_id) {
layer.msg('请选择门店');
return;
}
if (!vm.introduces.length) {
layer.msg('请选择车型');
return;
}
$.ajax({
url: '/receiver/tag/edit_options',
url: '/auto/introduce/lists_material',
type: 'post',
dataType: 'json',
data: {id: id, options: that.optionsList},
data: {
biz_id: vm.modal_biz.biz_id,
biz_name: vm.modal_biz.biz_name,
introduces: vm.introduces,
},
beforeSend: function () {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
},
success: function (data) {
if (data['code']) {
layer.msg(data.msg, {
icon: 1,
time: 2000
}, function () {
$.form.reload();
});
success: function (re) {
if (re.code) {
vm.materials = re.data.list;
layer.close(index);
} else {
layer.msg(data.msg, {icon: 2});
layer.msg(re.msg, {icon: 2});
}
},
complete: function () {
@@ -158,58 +317,233 @@
});
}
});
var that = this;
$.ajax({
url: '/receiver/tag/get_options',
type: 'post',
dataType: 'json',
data: {id: id},
beforeSend: function () {
},
success: function (re) {
if (re.code) {
that.optionsList = re.data.lists;
} else {
layer.msg(re.msg, {icon: 2});
}
},
complete: function () {
},
bizModal: function () {
var vm = this;
vm.get_biz();
layer.open({
type: 1,
area: ['50%', '50%'], //宽高
content: $('#biz-modal'),
title: '选择门店',
shade: false,
btn: ['确定', '取消'],
yes: function (index) {
layer.close(index);
vm.modal_biz.biz_id = vm.modal_biz.selected.id;
vm.modal_biz.biz_name = vm.modal_biz.selected.title;
}
});
},
addOptions: function () {
var that = this;
that.optionsList.push({id: 0, name: '', status: 1, sort: 50});
get_biz: function (page) {
var vm = this;
if (0 == page) {
vm.modal_biz.page = 1;
vm.modal_biz.total = 0;
vm.modal_biz.next = 0;
} else if (1 == page) {
vm.modal_biz.page += 1;
} else if (-1 == page) {
vm.modal_biz.page -= 1;
}
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
page: vm.modal_biz.page,
size: vm.modal_biz.size,
status: 1,
type: '1,2',
title: vm.modal_biz.title
},
success: function (response) {
if (response.code == 1) {
vm.modal_biz.lists = response.data.list;
vm.modal_biz.total = response.data.total;
if (vm.modal_biz.page * vm.modal_biz.size < vm.modal_biz.total) {
vm.modal_biz.next = 1;
} else {
vm.modal_biz.next = 0;
}
for (var i in vm.modal_biz.lists) {
var modal_biz = vm.modal_biz.lists[i];
if (modal_biz.id == vm.modal_biz.biz_id) {
modal_biz.checked = 1;
} else {
modal_biz.checked = 0;
}
}
}
}
});
},
delOptions: function (index) {
var that = this;
if (that.optionsList[index]['id'] > 0) {
that.optionsList[index]['status'] = -1;
set_biz: function (index, checked) {
var vm = this;
for (var i in vm.modal_biz.lists) {
var item = vm.modal_biz.lists[i];
item.checked = 0;
}
if (checked == 1) {
var item = vm.modal_biz.lists[index];
item.checked = checked;
vm.modal_biz.selected.id = item.id;
vm.modal_biz.selected.title = item.title;
} else {
that.optionsList.splice(index, 1);
vm.modal_biz.selected.id = 0;
vm.modal_biz.selected.title = '请选择门店';
}
vm.$forceUpdate();
},
editName: function (index) {
var name = $("#name_" + index).val();
if (name == '') {
layer.msg("标题不能为空!", {icon: 2});
return false;
}
introduceModal: function () {
var vm = this;
var selects = JSON.parse(JSON.stringify(vm.introduces));
vm.modal_introduces = {
brand_id: 0,
title: '',
lists: [],
selected: selects,
page: 1,
size: 10,
total: 0,
next: 0
};
vm.get_introduces();
layer.open({
type: 1,
area: ['50%', '50%'], //宽高
content: $('#introduce-modal'),
title: '选择车型',
shade: false,
btn: ['确定', '取消'],
yes: function (index) {
layer.close(index);
vm.introduces = JSON.parse(JSON.stringify(vm.modal_introduces.selected));
}
});
},
// 修改排序
editGroupName: function (index) {
var order_view = $("#group_name_" + index).val();
if (order_view == '') {
layer.msg("排序值不能为空!", {icon: 2});
return false;
get_introduces: function (page) {
var vm = this;
if (0 == page) {
vm.modal_introduces.page = 1;
vm.modal_introduces.total = 0;
vm.modal_introduces.next = 0;
} else if (1 == page) {
vm.modal_introduces.page += 1;
} else if (-1 == page) {
vm.modal_introduces.page -= 1;
}
this.optionsList.sort(function (a, b) {
return b.sort - a.sort;
})
$.ajax({
type: 'post',
url: '/auto/introduce/json_lists',
dataType: 'json',
data: {
page: vm.modal_introduces.page,
size: vm.modal_introduces.size,
status: 1,
brand_id: vm.modal_introduces.brand_id
},
success: function (response) {
if (response.code == 1) {
vm.modal_introduces.lists = response.data.list;
vm.modal_introduces.total = response.data.total;
if (vm.modal_introduces.page * vm.modal_introduces.size < vm.modal_introduces.total) {
vm.modal_introduces.next = 1;
} else {
vm.modal_introduces.next = 0;
}
for (var i in vm.modal_introduces.lists) {
var introduces = vm.modal_introduces.lists[i];
introduces.checked = 0;
for (var j in vm.modal_introduces.selected) {
var selected = vm.modal_introduces.selected[j];
if (introduces.id == selected.id) {
introduces.checked = 1;
}
}
}
}
}
});
},
set_introduces: function (index, checked) {
var vm = this;
var introduces = vm.modal_introduces.lists[index];
introduces.checked = checked;
if (checked == 1) {
var selected = {id: introduces.id, name: introduces.name};
vm.modal_introduces.selected.push(selected);
} else {
for (var i in vm.modal_introduces.selected) {
selected = vm.modal_introduces.selected[i];
if (introduces.id == selected.id) {
vm.modal_introduces.selected.splice(i, 1);
break;
}
}
}
vm.$forceUpdate();
},
rmIntroduces: function (index) {
var vm = this;
vm.introduces.splice(index, 1);
},
},
watch: {}
});
<?php page_script($pager) ?>
});
</script>
require(['clipboard'], function (Clipboard) {
var clipboard = new Clipboard('[data-clipboard-text]');
clipboard.on('success', function (e) {
$.msg.success('复制成功');
e.clearSelection();
});
clipboard.on('error', function (e) {
$.msg.error('复制失败');
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
});
</script>
<style>
.label-group-wrap {
margin-top: 10px;
font-size: 0;
}
.label-group {
display: inline-block;
margin-right: 4px;
margin-bottom: 16px;
font-size: 0;
white-space: nowrap;
}
.label-group-wrap .label, .label-group > .label {
font-size: 10px;
font-weight: normal;
margin-right: 1px;
white-space: normal;
line-height: 1.4;
}
.label {
font-weight: normal;
}
.label-group > span + a.label {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left: 1px solid #fff;
margin-left: -3px;
}
.label-group-wrap .label, .label-group > .label {
font-size: 10px;
font-weight: normal;
margin-right: 1px;
white-space: normal;
line-height: 1.4;
}
</style>
+97
View File
@@ -0,0 +1,97 @@
<?php
defined('WXAPP_APP') OR exit('No direct script access allowed');
/**
* Notes:车辆相关操作
* Created on: 2021/11/25 15:16
* Created by: dengbw
*/
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class Auto extends Wxapp
{
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = array('get');//登录白名单
}
/**
* Notes:车型介绍
* Created on: 2022/3/22 16:38
* Created by: dengbw
* @return array
* @throws Exception
*/
protected function get_introduce()
{
$this->load->model('auto/auto_introduce_model', 'mdAutoIntroduce');
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
$id = intval($this->input_param('id'));
$re = $this->mdAutoIntroduce->get(array('id' => $id, 'status' => 1));
if (!$re || empty($re)) {
throw new Exception('车型介绍不存在', API_CODE_FAIL);
}
$sign_up = $this->session['mobile'] ? 0 : 1;
$title = '';
if ($re['s_id']) {
$re_b = $this->mdAutoBrand->get(['id' => $re['brand_id']]);
$re_b && $title = $re_b['name'];
$re_s = $this->mdAutoSeries->get(['id' => $re['s_id']]);
$re_s && $title = $title ? $title . '-' . $re_s['name'] : $title;
}
$data = array(
'title' => $title . '_车型介绍',
"video" => $re['video'] ? build_qiniu_image_url($re['video'], 0, 0, 'video') : '',
'content' => $re['content'],
'sign_up' => $sign_up,
);
return $data;
}
/**
* Notes:车型介绍报名
* Created on: 2021/11/26 11:05
* Created by: dengbw
* @return mixed
* @throws Exception
*/
protected function put_introduce()
{
$biz_id = intval($this->input_param('biz_id'));
if (!$biz_id || !$this->session['mobile']) {
throw new Exception('参数错误', API_CODE_INVILD_PARAM);
}
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$this->load->model("biz/biz_model", 'mdBiz');
$re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]);
if (!$re_biz) {
throw new Exception('门店不存在!', API_CODE_FAIL);
}
$of_id = 1;//自然进店
$add_data = [
'name' => $this->session['nickname'] ? $this->session['nickname'] : '',
'mobile' => $this->session['mobile'],
'biz_id' => $biz_id,
'city_id' => $re_biz['city_id'],
'county_id' => $re_biz['county_id'],
'cf_title' => '自有资源',
'of_id' => $of_id,
'p_time' => date('Y-m-d H:i:s'),
'c_time' => time()
];
$where = ['biz_id' => $biz_id, 'mobile' => $add_data['mobile']];
$re_cus = $this->mdCustomers->get($where);
if ($re_cus) {
throw new Exception('报名成功了!', API_CODE_SUCCESS);
}
$id = $this->mdCustomers->add($add_data);
if (!$id) {
throw new Exception('预约报名失败!', API_CODE_FAIL);
}
throw new Exception('报名成功!', API_CODE_SUCCESS);
}
}