material_1014

This commit is contained in:
dengbw
2021-10-14 15:41:15 +08:00
committed by lccsw
parent c953e6651b
commit 589765a2e8
14 changed files with 2136 additions and 5 deletions
+16 -5
View File
@@ -1,22 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by Vim.
* User: lcc
* Date: 2019/12/06
* Time: 10:02
*/
class Main extends HD_Controller
{
class Main extends HD_Controller{
public function __construct(){
public function __construct()
{
$this->app_id = 2;
parent::__construct();
$this->load->model('app/licheb/App_licheb_users_model', 'userM');
$this->load->model('app/material/Material_template_model', 'mdTemplate');
}
public function index(){
public function index()
{
/*应用状况*/
$conditions = array();
@@ -31,6 +34,14 @@ class Main extends HD_Controller{
array('name' => '查看详情', 'url' => '/app/licheb/member/index'),
),
);
$value = $this->mdTemplate->count();
$list[] = array(
'title' => '素材模版(个)',
'value' => $value,
'btns' => array(
array('name' => '查看详情', 'url' => '/app/material/template/index?app_id=' . $this->app_id),
),
);
$conditions[] = array('icon' => 'am-icon-home', 'list' => $list);
/*小程序设置 end*/
+288
View File
@@ -0,0 +1,288 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:素材模板
* Created on: 2021/9/30 12:45
* Created by: dengbw
*/
class Template extends HD_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('app/material/Material_template_model', 'mdTemplate');
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
}
//首页信息
public function index()
{
$this->lists();
}
//数据列表
public function lists()
{
$params = $this->input->get();
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 20;
$lists = $users = array();
$where = array('app_id' => $params['app_id']);
if ($params['type']) {
$where['type'] = $params['type'];
}
if (strlen($params['status'])) {
$where['status'] = $params['status'];
}
$count = $this->mdTemplate->count($where);
if ($count) {
$fileds = "id,title,type,status,brand_ids,c_time";
$res = $this->mdTemplate->select($where, "id desc", $params['page'], $params['size'], $fileds);
foreach ($res as $key => $value) {
$setValue = array();
$setValue['id'] = $value['id'];
$setValue['title'] = $value['title'];
$setValue['type_name'] = $this->mdTemplate->typeAry()[$value['type']];
$setValue['status_name'] = $this->mdTemplate->statusAry()[$value['status']];
$brands = '';
if ($value['brand_ids']) {
$res_b = $this->mdAutoBrand->select(array("id in ({$value['brand_ids']})" => null, 'status' => 1), "id desc", 0, 0, 'name');
if ($res_b) {
$brands = array_column($res_b, 'name');
$brands = implode(',', $brands);
}
}
$setValue['brands'] = $brands;
$setValue['c_time'] = date('Y-m-d H:i:s', $value["c_time"]);
$lists[] = $setValue;
}
}
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['typeAry'] = $this->mdTemplate->typeAry();
$this->data['statusAry'] = $this->mdTemplate->statusAry();
$this->data['_title'] = '素材模板列表';
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
return $this->show_view('/app/material/template/lists', true);
}
//展示单条数据
public function get()
{
$id = $this->input->get('id');
$info['app_id'] = intval($this->input->get('app_id'));
$info['status'] = 1;
$info['type'] = 1;
$info['cover'] = array('value' => '', 'src' => '');
$brands = $tgsp_list = $lbhb_list = $pyqwa_list = array();
if ($id) {
$re = $this->mdTemplate->get(array('id' => $id));
if (!$re || empty($re)) {
return $this->show_json(SYS_CODE_FAIL, '模板不存在!');
}
if ($re['json_data']) {
$json_data = json_decode($re['json_data'], true);
$lists = array();
foreach ($json_data['lists'] as $key => $value) {
if ($re['type'] == 1) {
if ($value['video_type'] == 1) {
$value['video_file_url'] = $value['video'];
$value['video_url'] = build_qiniu_image_url($value['video'], 0, 0, 'video');
$value['video_cover'] = $value['video_url'] . '?vframe/jpg/offset/1';
$value['img'] = $value['img_url'] = '';
} else {
$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) {
$value['img_url'] = $value['img'] ? build_qiniu_image_url($value['img']) : '';
} else if ($re['type'] == 3) {
if ($value['brands']) {
$value['brands'] = $this->mdAutoBrand->select(array("id in ({$value['brands']})" => null, 'status' => 1), "id desc", 0, 0, 'id,name');
} else {
$value['brands'] = array();
}
}
$lists[] = $value;
}
if ($re['type'] == 1) {
$tgsp_list = $lists;
} else if ($re['type'] == 2) {
$lbhb_list = $lists;
} else if ($re['type'] == 3) {
$pyqwa_list = $lists;
}
unset($re['json_data']);
}
$info = $re;
$info['cover'] = $info['cover'] ? array('value' => $info['cover'], 'src' => build_qiniu_image_url($info['cover']))
: array('value' => '', 'src' => '');
if ($info['brand_ids']) {
$brand_ids = str_replace(",0", "", $info['brand_ids']);
$brands = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'id,name');
}
$_title = '编辑素材模板';
$edit_url = '/app/material/template/edit';
} else {
$_title = '新增素材模板';
$edit_url = '/app/material/template/add';
}
$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;
$this->data['info'] = $info;
$this->data['showInfo'] = $showInfo;
$this->data['edit_url'] = $edit_url;
$this->data['_title'] = $_title;
return $this->show_view('/app/material/template/edit', true);
}
private function checkInfo($info)
{
$msg = '';
$code = SYS_CODE_FAIL;
if (!$info) {
$msg = '非法参数';
} else if (!$info['title']) {
$msg = '请输入模版名称';
} else if (!$info['cover']['value']) {
$msg = '请上传封面图';
} else if (!$info['brand_ids'] && $info['type'] != 3) {
$msg = '请选择适用品牌';
} else {
$code = SYS_CODE_SUCCESS;
}
return array('code' => $code, 'msg' => $msg);
}
//添加单条数据
public function add()
{
$info = $this->input->post('info');
$checkInfo = $this->checkInfo($info);
if (!$checkInfo['code']) {
return $this->show_json($checkInfo['code'], $checkInfo['msg']);
}
$brand_ids = '';
if ($info['brand_ids']) {
$brand_ids = implode(',', $info['brand_ids']);
if (!strstr($brand_ids, ',0')) {
$brand_ids .= ',0';
}
}
if ($info['lists']) {
$json_data = $info['json_data'];
$lists = array();
foreach ($info['lists'] as $key => $value) {
if ($info['type'] == 1) {
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']);
unset($value['img_url']);
} else if ($info['type'] == 2) {
unset($value['img_url']);
} else if ($info['type'] == 3) {
$brands = '';
if ($value['brands']) {
$brands = array_column($value['brands'], 'id');
$brands = implode(',', $brands);
}
$value['brands'] = $brands;
}
$lists[] = $value;
}
$json_data['lists'] = $lists;
$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'];
$editData['type'] = $info['type'];
$editData['brand_ids'] = $info['type'] == 3 ? '' : $brand_ids;
$editData['status'] = $info['status'];
$editData['c_time'] = time();
$id = $this->mdTemplate->add($editData);
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '新增失败!');
}
return $this->show_json(SYS_CODE_SUCCESS, '新增成功!', '/app/material/template/index?app_id=' . $info['app_id']);
}
//编辑单条数据
public function edit()
{
$info = $this->input->post('info');
$checkInfo = $this->checkInfo($info);
if (!$checkInfo['code']) {
return $this->show_json($checkInfo['code'], $checkInfo['msg']);
}
$brand_ids = '';
if ($info['brand_ids']) {
$brand_ids = implode(',', $info['brand_ids']);
if (!strstr($brand_ids, ',0')) {
$brand_ids .= ',0';
}
}
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'];
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'] == 3) {
$brands = '';
if ($value['brands']) {
$brands = array_column($value['brands'], 'id');
$brands = implode(',', $brands);
}
$value['brands'] = $brands;
}
$lists[] = $value;
}
$json_data['lists'] = $lists;
$editData['json_data'] = json_encode($json_data, JSON_UNESCAPED_UNICODE);
}
$editData['title'] = $info['title'];
$editData['cover'] = $info['cover']['value'];
$editData['type'] = $info['type'];
$editData['brand_ids'] = $info['type'] == 3 ? '' : $brand_ids;
$editData['status'] = $info['status'];
$ret = $this->mdTemplate->update($editData, array('id' => $info['id']));
if (!$ret) {
return $this->show_json(SYS_CODE_FAIL, '修改失败!');
}
return $this->show_json(SYS_CODE_SUCCESS, '修改成功!');
}
//删除单条数据
public function del()
{
}
//批量操作(默认修改状态)
public function batch()
{
}
//导出数据列表
public function export()
{
}
}
+2
View File
@@ -146,9 +146,11 @@ class Brand extends HD_Controller{
$status = $this->input->post('status');
$page = $this->input->post('page');
$size = $this->input->post('size');
$title = trim($this->input->post('title'));
$where = array();
$keyword && $where['keyword'] = $keyword;
$title && $where["name like '%{$title}%'"] = null;
if(strlen($status) > 0){
$where['status'] = $status;
} else {
+999
View File
@@ -0,0 +1,999 @@
<div id="vue-edit" class="am-form am-form-horizontal" style="width: 100%;padding: 10px">
<div class="am-form-group">
<label class="am-para-label">模版名称:</label>
<div class="am-para-input" style="width: 50%"><input type="text" placeholder="模版名称" v-model="info.title"/></div>
</div>
<div class="am-form-group">
<label class="am-para-label">状态:</label>
<div class="am-para-input">
<label class="am-checkbox-inline" v-for="(v,i) in showInfo.statusAry">
<input type="radio" :value="i" v-model="info.status"> {{v}}
</label>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">封面图:</label>
<div class="am-para-input">
<button type="button" class="am-btn am-btn-default am-btn-sm fl"
data-file="1" data-mark="" data-type="jpg,png,gif,png,jpeg"
data-uptype="qiniu" data-params-source="vue_obj.info.cover">
<i class="am-icon-cloud-upload"></i> 上传封面图
</button>
<div id="layer-photos-demo" class="layer-photos-demo fl ml10">
<img v-if="info.cover && info.cover.src"
:layer-src="info.cover.src"
:src="info.cover.src" class="w100" alt="模版封面图" data-tips-image
style="height:32px;width:50px;">
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">模版分类:</label>
<div class="am-para-input" style="width: 15%">
<select v-model="info.type">
<option :value="i" v-for="(v,i) in showInfo.typeAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group" v-if="info.type !=3">
<label class="am-para-label">适用品牌:</label>
<div class="am-para-input">
<button type="button" class="am-btn am-btn-default am-btn-sm" @click="brand_modal">+</button>
<div class="label-group-wrap label-group-sortable" style="display: inline;padding-left: 5px;">
<div class="label-group" v-for="(v,i) in brands">
<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="rm_brand(i)" class="label label-default"><i
class="fa fa-remove"></i></a>
</div>
</div>
</div>
</div>
<div class="app-editor">
<div class="app-editor-inner panel panel-default" v-if="info.type ==1">
<div class="panel-body">
<div class="page-header">
<div class="page-header-name"><h4>推广视频列表</h4></div>
<div class="page-header-option">
<small class="text-muted"></small>
</div>
</div>
<form class="form-horizontal" style="padding-left: 50px;padding-right: 50px;">
<div class="form-group">
<div class="col-sm-12">
<table class="table table-hover table-middle" style="table-layout:fixed">
<colgroup>
<col width="80px"/>
<col width="25%">
<col width="15%">
<col width="8%">
<col width="30%"/>
<col width="">
</colgroup>
<thead>
<tr>
<th class="text-center">图片</th>
<th class="text-center">标题</th>
<th class="text-center">类型</th>
<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='addModal()'>添加</a>
</th>
</tr>
</thead>
<tbody>
<template v-for="(item,index) in tgsp_list">
<tr>
<td>
<a href="javascript:void(0)" v-if="item.video_type==1"
:data-modal="'/common/show_video?video='+item.video_url"
data-title="查看视频" v-if="item.video_cover">
<img :src="item.video_cover"
style="height:auto;max-height:36px;min-width:64px;"></a>
<img data-tips-image :src="item.img_url" v-else
style="height:auto;max-height:36px;min-width:64px;">
</td>
<td class="text-center">{{item.title}}</td>
<td class="text-center" v-if="item.video_type==1">视频</td>
<td class="text-center" v-else>图片</td>
<td class="text-center">
<div :id="'group_name_txt_tgsp_'+index">{{item.order_view}} <a
href="javascript:"
@click="showGroupEditForm(index)"><i
class="fa fa-edit"></i></a></div>
<input :id="'group_name_tgsp_'+index" @blur="editGroupName(index,item.id)"
style="display: none;" type="number" class="form-control"
v-model="item.order_view" placeholder="请输入排序值">
</td>
<td class="text-center">{{item.link}}</td>
<td class="text-right">
<a href="javascript:void(0);" style="margin-top:2px;"
class="btn btn-default btn-sm" @click='addModal(item)'>编辑</a>
<a href="javascript:void(0);" style="margin-top:2px;"
class="btn btn-danger btn-sm" @click='removeAdd(index)'>删除</a>
</td>
</tr>
</template>
</tbody>
</table>
<template v-if="tgsp_list.length <=0">
<div style="text-align: center;">无数据</div>
</template>
</div>
<div id="ad-modal-1" style="display: none;">
<div class="form-horizontal" style="padding-top: 20px;">
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">标题</label>
<div class="col-sm-8">
<input type="text" class="form-control" v-model="tgsp_item.title"
placeholder="请输入标题">
</div>
</div>
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">类型</label>
<div class="col-sm-8">
<label class="am-checkbox-inline">
<input type="radio" value="1" v-model="tgsp_item.video_type"
@change="showVideo"> 视频
</label>
<label class="am-checkbox-inline">
<input type="radio" value="2" v-model="tgsp_item.video_type"
@change="showVideo"> 图片
</label>
</div>
</div>
<div id="show_video1" class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">视频</label>
<div class="col-sm-8">
<table width="100%">
<tr>
<td width="65%"><input type="text" id="video-url" name="video"
v-model="info.video_url"
placeholder="视频地址"
class="form-control"></td>
<td style="padding-left: 10px;" align="left">
<button type="button" class="am-btn am-btn-default am-btn-sm"
id="upload-video" @click="btn_video">上传视频
</button>
</td>
<td id="show-video" align="right">
<a href="javascript:void(0)"
:data-modal="'/common/show_video?video='+info.video_url"
data-title="查看视频" v-if="info.video_cover">
<img :src="info.video_cover"
style="height:auto;max-height:31px;min-width:31px;"></a>
</td>
</tr>
</table>
</div>
</div>
<div id="show_video2" class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">图片</label>
<div class="col-sm-8">
<div class="input-group" style="width: 100%">
<input type="text" style="width: 65%" name="tgsp_img" id="tgsp_img"
onchange="$(this).next('img').attr('src', $(this).data('srcs') || this.value)"
class="form-control">
<img data-tips-image name="tgsp_img_url" id="tgsp_img_url"
style="height:auto;max-height:31px;min-width:31px;margin-left: 5px;margin-right: 5px;"
/>
<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="tgsp_img">上传图片
</button>
</div>
</div>
</div>
</div>
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">链接</label>
<div class="col-sm-8">
<input type="text" class="form-control" v-model="tgsp_item.link"
placeholder="请输入链接">
</div>
</div>
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">排序值</label>
<div class="col-sm-4">
<input type="number" class="form-control" v-model="tgsp_item.order_view"
placeholder="请输入排序">
</div>
<div style="padding-top:7px;">
<small class="text-muted">越大越靠前</small>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="app-editor-inner panel panel-default" v-else-if="info.type ==2">
<div class="panel-body">
<div class="page-header">
<div class="page-header-name"><h4>轮播海报列表</h4></div>
<div class="page-header-option">
<small class="text-muted"></small>
</div>
</div>
<form class="form-horizontal" style="padding-left: 50px;padding-right: 50px;">
<div class="form-group">
<div class="col-sm-12">
<table class="table table-hover table-middle" style="table-layout:fixed">
<colgroup>
<col width="80px"/>
<col width="30%">
<col width="15%">
<col width="30%"/>
<col width="">
</colgroup>
<thead>
<tr>
<th class="text-center">图片</th>
<th class="text-center">标题</th>
<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='addModal()'>添加</a>
</th>
</tr>
</thead>
<tbody>
<template v-for="(item,index) in lbhb_list">
<tr>
<td><img data-tips-image :src="item.img_url"
style="height:auto;max-height:36px;min-width:64px;"></td>
<td class="text-center">{{item.title}}</td>
<td class="text-center">
<div :id="'group_name_txt_'+index">{{item.order_view}} <a href="javascript:"
@click="showGroupEditForm(index)"><i
class="fa fa-edit"></i></a></div>
<input :id="'group_name_'+index" @blur="editGroupName(index,item.id)"
style="display: none;" type="number" class="form-control"
v-model="item.order_view" placeholder="请输入排序值">
</td>
<td class="text-center">{{item.link}}</td>
<td class="text-right">
<a href="javascript:void(0);" style="margin-top:2px;"
class="btn btn-default btn-sm" @click='addModal(item)'>编辑</a>
<a href="javascript:void(0);" style="margin-top:2px;"
class="btn btn-danger btn-sm" @click='removeAdd(index)'>删除</a>
</td>
</tr>
</template>
</tbody>
</table>
<template v-if="lbhb_list.length <=0">
<div style="text-align: center;">无数据</div>
</template>
</div>
<div id="ad-modal-2" style="display: none;">
<div class="form-horizontal" style="padding-top: 20px;">
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">标题</label>
<div class="col-sm-8">
<input type="text" class="form-control" v-model="lbhb_item.title"
placeholder="请输入标题">
</div>
</div>
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">图片</label>
<div class="col-sm-8">
<div class="input-group" style="width: 100%">
<input type="text" style="width: 60%" name="lbhb_img" id="lbhb_img"
onchange="$(this).next('img').attr('src', $(this).data('srcs') || this.value)"
class="form-control">
<img data-tips-image name="lbhb_img_url" id="lbhb_img_url"
style="height:auto;max-height:31px;min-width:31px;margin-left: 5px;margin-right: 5px;"
/>
<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="lbhb_img">上传图片
</button>
</div>
</div>
</div>
</div>
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">链接</label>
<div class="col-sm-8">
<input type="text" class="form-control" v-model="lbhb_item.link"
placeholder="请输入链接">
</div>
</div>
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">排序值</label>
<div class="col-sm-4">
<input type="number" class="form-control" v-model="lbhb_item.order_view"
placeholder="请输入排序">
</div>
<div style="padding-top:7px;">
<small class="text-muted">越大越靠前</small>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="app-editor-inner panel panel-default" v-else-if="info.type ==3">
<div class="panel-body">
<div class="page-header">
<div class="page-header-name"><h4>朋友圈文案列表</h4></div>
<div class="page-header-option">
<small class="text-muted"></small>
</div>
</div>
<form class="form-horizontal" style="padding-left: 50px;padding-right: 50px;">
<div class="form-group">
<div class="col-sm-12">
<table class="table table-hover table-middle" style="table-layout:fixed">
<colgroup>
<col width="35%"/>
<col width="40%">
<col width="10%">
<col width="">
</colgroup>
<thead>
<tr>
<th class="text-center">文案内容</th>
<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='addModal()'>添加</a>
</th>
</tr>
</thead>
<tbody>
<template v-for="(item,index) in pyqwa_list">
<tr>
<td>{{item.content}}</td>
<td class="text-center">
<template v-for="(item2,index2) in item.brands">
<span class="label label-default sort-shop-list mr5">{{item2.name}}</span>
</template>
</td>
<td class="text-center">
<div :id="'group_name_txt_pyqwa_'+index">{{item.order_view}} <a
href="javascript:"
@click="showGroupEditForm(index)"><i
class="fa fa-edit"></i></a></div>
<input :id="'group_name_pyqwa_'+index" @blur="editGroupName(index,item.id)"
style="display: none;" type="number" class="form-control"
v-model="item.order_view" placeholder="请输入排序值">
</td>
<td class="text-right">
<a href="javascript:void(0);" style="margin-top:2px;"
class="btn btn-default btn-sm" @click='addModal(item)'>编辑</a>
<a href="javascript:void(0);" style="margin-top:2px;"
class="btn btn-danger btn-sm" @click='removeAdd(index)'>删除</a>
</td>
</tr>
</template>
</tbody>
</table>
<template v-if="pyqwa_list.length <=0">
<div style="text-align: center;">无数据</div>
</template>
</div>
</div>
<div id="ad-modal-3" style="display: none;">
<div class="form-horizontal" style="padding-top: 20px;">
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">文案内容</label>
<div class="col-sm-8">
<textarea rows="5" v-model="pyqwa_item.content" placeholder="请输入文案内容"></textarea>
</div>
</div>
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">适用品牌</label>
<div class="col-sm-8">
<button type="button" class="am-btn am-btn-default am-btn-sm"
@click="brand_modal">+
</button>
<div class="label-group-wrap label-group-sortable"
style="display: inline;padding-left: 5px;">
<div class="label-group" v-for="(v,i) in pyqwa_item.brands">
<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="rm_brand(i)"
class="label label-default"><i class="fa fa-remove"></i>
</a>
</div>
</div>
</div>
</div>
<div class="form-group" style="margin-left: 0px;margin-right: 0px;">
<label class="col-sm-2 control-label">排序值</label>
<div class="col-sm-4">
<input type="number" class="form-control" v-model="pyqwa_item.order_view"
placeholder="请输入排序">
</div>
<div style="padding-top:7px;">
<small class="text-muted">越大越靠前</small>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="am-form-group">
<a href="javascript:void(0);" @click='saveEdit();'
style="margin-left: 3.5rem;margin-top: 4rem;"
class="am-btn ml20 am-btn-sm am-btn-success w100">保存</a>
</div>
<div id="brand-modal" style="display: none;">
<div class="modal-body">
<table width="100%">
<tr>
<td width="20%">ID</td>
<td width="35%" style="font-weight: bold;padding-left: 8px;">品牌</td>
<td width="40%" 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_brand.title' placeholder="品牌关键字">
<div class="input-group-btn">
<button type="button" @click='get_brands(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_brand.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_brand(i,1)"
class="btn btn-primary btn-sm">选择</a>
<a v-else-if="v.checked==1" href="javascript:void(0);" @click="set_brand(i,0)"
class="btn btn-default btn-sm">移除</a>
</td>
</tr>
</tbody>
</table>
<div class="clearfix">
<span class="pull-left text-muted">{{modal_brand.page}}(每页{{modal_brand.size}},{{modal_brand.total}})</span>
<nav class="pull-right" aria-label="Page navigation">
<ul class="pagination pagination-sm">
<li v-if="modal_brand.page>1">
<a href="javascript:void(0);" @click="get_brands(-1);" aria-label="上一页">
<span class="glyphicon glyphicon-menu-left"></span>
</a>
</li>
<li v-if="modal_brand.next>0">
<a href="javascript:void(0);" @click="get_brands(1);" aria-label="下一页">
<span class="glyphicon glyphicon-menu-right"></span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<script>
var vue_obj;
$(document).ready(function () {
vue_obj = new Vue({
el: '#vue-edit',
data: {
info: [],
showInfo: [],
brands: [],
tgsp_list: [],
tgsp_item: {},
lbhb_list: [],
lbhb_item: {},
pyqwa_list: [],
pyqwa_item: {"brands": []},
modal_brand: {title: '', lists: [], selected: [], page: 1, size: 10, total: 0}
},
mounted: function () {
var that = this;
that.info = <?=json_encode($info, JSON_UNESCAPED_UNICODE)?>;
that.showInfo = <?=json_encode($showInfo, JSON_UNESCAPED_UNICODE)?>;
that.brands = <?=json_encode($showInfo['brands'], JSON_UNESCAPED_UNICODE)?>;
that.tgsp_list = <?=json_encode($showInfo['tgsp_list'], JSON_UNESCAPED_UNICODE)?>;
that.lbhb_list = <?=json_encode($showInfo['lbhb_list'], JSON_UNESCAPED_UNICODE)?>;
that.pyqwa_list = <?=json_encode($showInfo['pyqwa_list'], JSON_UNESCAPED_UNICODE)?>;
},
computed: {},
created: function () {
},
methods: {
brand_modal: function () {
//选择品牌
var vm = this;
var selects;
if (vm.info.type == 3) {
selects = JSON.parse(JSON.stringify(vm.pyqwa_item.brands));
} else {
selects = JSON.parse(JSON.stringify(vm.brands));
}
vm.modal_brand = {title: '', lists: [], selected: selects, page: 1, size: 10, total: 0, next: 0};
vm.get_brands();
layer.open({
type: 1,
area: ['50%', '80%'], //宽高
content: $('#brand-modal'),
title: '选取品牌',
shade: false,
btn: ['选好了'],
yes: function (index) {
layer.close(index);
if (vm.info.type == 3) {
vm.pyqwa_item.brands = JSON.parse(JSON.stringify(vm.modal_brand.selected));
vm.$forceUpdate();
} else {
vm.brands = JSON.parse(JSON.stringify(vm.modal_brand.selected));
}
}
});
},
get_brands: function (page) {
var vm = this;
if (0 == page) {
vm.modal_brand.page = 1;
vm.modal_brand.total = 0;
vm.modal_brand.next = 0;
} else if (1 == page) {
vm.modal_brand.page += 1;
} else if (-1 == page) {
vm.modal_brand.page -= 1;
}
$.ajax({
type: 'post',
url: '/auto/brand/json_lists',
dataType: 'json',
data: {
page: vm.modal_brand.page,
size: vm.modal_brand.size,
status: 1,
title: vm.modal_brand.title
},
success: function (response) {
if (response.code == 1) {
vm.modal_brand.lists = response.data.list;
vm.modal_brand.total = response.data.total;
if (vm.modal_brand.page * vm.modal_brand.size < vm.modal_brand.total) {
vm.modal_brand.next = 1;
} else {
vm.modal_brand.next = 0;
}
for (var i in vm.modal_brand.lists) {
var brand = vm.modal_brand.lists[i];
brand.checked = 0;
for (var j in vm.modal_brand.selected) {
var selected = vm.modal_brand.selected[j];
if (brand.id == selected.id) {
brand.checked = 1;
}
}
}
}
}
});
},
set_brand: function (index, checked) {
var vm = this;
var brand = vm.modal_brand.lists[index];
brand.checked = checked;
if (checked == 1) {
var selected = {id: brand.id, name: brand.name};
vm.modal_brand.selected.push(selected);
} else {
for (var i in vm.modal_brand.selected) {
selected = vm.modal_brand.selected[i];
if (brand.id == selected.id) {
vm.modal_brand.selected.splice(i, 1);
break;
}
}
}
vm.$forceUpdate();
},
rm_brand: function (index) {
var vm = this;
if (vm.info.type == 3) {
vm.pyqwa_item.brands.splice(index, 1);
vm.$forceUpdate();
} else {
vm.brands.splice(index, 1);
}
},
// 修改排序
showGroupEditForm: function (index) {
var vm = this;
if (vm.info.type == 1) {
$("#group_name_tgsp_" + index).show();
$("#group_name_txt_tgsp_" + index).hide();
$('#group_name_tgsp_' + index).focus();
} else if (vm.info.type == 2) {
$("#group_name_" + index).show();
$("#group_name_txt_" + index).hide();
$('#group_name_' + index).focus();
} else if (vm.info.type == 3) {
$("#group_name_pyqwa_" + index).show();
$("#group_name_txt_pyqwa_" + index).hide();
$('#group_name_pyqwa_' + index).focus();
}
},
// 排序
editGroupName: function (index, group_id) {
var vm = this;
if (vm.info.type == 1) {
var order_view = $("#group_name_tgsp_" + index).val();
if (order_view == '') {
layer.msg("排序值不能为空!", {icon: 2});
return false;
}
vm.tgsp_list.sort(function (a, b) {
return b.order_view - a.order_view;
})
$("#group_name_tgsp_" + index).hide();
$("#group_name_txt_tgsp_" + index).show();
} else if (vm.info.type == 2) {
var order_view = $("#group_name_" + index).val();
if (order_view == '') {
layer.msg("排序值不能为空!", {icon: 2});
return false;
}
vm.lbhb_list.sort(function (a, b) {
return b.order_view - a.order_view;
})
$("#group_name_" + index).hide();
$("#group_name_txt_" + index).show();
} else if (vm.info.type == 3) {
var order_view = $("#group_name_pyqwa_" + index).val();
if (order_view == '') {
layer.msg("排序值不能为空!", {icon: 2});
return false;
}
vm.pyqwa_list.sort(function (a, b) {
return b.order_view - a.order_view;
})
$("#group_name_pyqwa_" + index).hide();
$("#group_name_txt_pyqwa_" + index).show();
}
},
showVideo: function () {
var that = this;
if (that.tgsp_item.video_type == 1) {
$("#show_video1").show();
$("#show_video2").hide();
} else {
$("#show_video1").hide();
$("#show_video2").show();
}
},
addModal: function (item) {
var that = this;
if (that.info.type == 1) {
var _title = '新增推广视频';
that.tgsp_item = {
"title": "",
"video_file_url": "",
"video_url": "",
"video_cover": "",
"img": "",
"img_url": "",
"link": "",
"video_type": 1,
"order_view": 50
};
if (item) {
_title = '编辑推广视频';
that.tgsp_item = item;
that.info.video_file_url = item.video_file_url;
that.info.video_url = item.video_url;
that.info.video_cover = item.video_cover;
} else {
that.info.video_file_url = "";
that.info.video_url = "";
that.info.video_cover = "";
}
$('#tgsp_img').val(that.tgsp_item.img);
$("#tgsp_img_url").attr('src', that.tgsp_item.img_url);
that.showVideo();
layer.open({
type: 1,
area: ['50%'], //宽高
content: $('#ad-modal-1'),
title: _title,
shade: false,
btn: ['确定', '取消'],
yes: function (index) {
var _img = $('#tgsp_img').val();
var _img_url = $("#tgsp_img_url")[0].src;
if (!item) {
that.tgsp_list.push({
title: that.tgsp_item.title,
video_file_url: that.info.video_file_url,
video_url: that.info.video_url,
video_cover: that.info.video_cover,
video_type: that.tgsp_item.video_type,
img: _img,
img_url: _img_url,
link: that.tgsp_item.link,
order_view: that.tgsp_item.order_view
});
} else {
if (that.tgsp_item.video_type == 1) {
item.video_file_url = that.info.video_file_url;
item.video_url = that.info.video_url;
item.video_cover = that.info.video_cover;
} else {
item.img = _img;
item.img_url = _img_url;
}
}
that.tgsp_list.sort(function (a, b) {
return b.order_view - a.order_view;
})
layer.close(index);
}
});
} else if (that.info.type == 2) {
var _title = '新增轮播海报';
that.lbhb_item = {};
var _img = '';
var _img_url = '';
if (item) {
that.lbhb_item = item;
_title = '编辑轮播海报';
_img = item.img;
_img_url = item.img_url;
} else {
that.lbhb_item = {"order_view": 50};
}
$('#lbhb_img').val(_img);
$("#lbhb_img_url").attr('src', _img_url);
layer.open({
type: 1,
area: ['50%'], //宽高
content: $('#ad-modal-2'),
title: _title,
shade: false,
btn: ['确定', '取消'],
yes: function (index) {
_img = $('#lbhb_img').val();
_img_url = $("#lbhb_img_url")[0].src;
if (!item) {
that.lbhb_list.push({
title: that.lbhb_item.title,
img: _img,
img_url: _img_url,
link: that.lbhb_item.link,
order_view: that.lbhb_item.order_view
});
} else {
item.img = _img;
item.img_url = _img_url;
}
that.lbhb_list.sort(function (a, b) {
return b.order_view - a.order_view;
})
layer.close(index);
}
});
} else if (that.info.type == 3) {
var _title = '新增编辑朋友圈文案';
that.pyqwa_item = {};
if (item) {
that.pyqwa_item = item;
_title = '编辑朋友圈文案';
} else {
that.pyqwa_item = {"content": "", "brands": [], "order_view": 50};
}
layer.open({
type: 1,
area: ['50%'], //宽高
content: $('#ad-modal-3'),
title: _title,
shade: false,
btn: ['确定', '取消'],
yes: function (index) {
if (!item) {
that.pyqwa_list.push({
content: that.pyqwa_item.content,
brands: that.pyqwa_item.brands,
order_view: that.pyqwa_item.order_view
});
}
that.pyqwa_list.sort(function (a, b) {
return b.order_view - a.order_view;
})
layer.close(index);
}
});
}
},
removeAdd: function (index) {
var vm = this;
if (vm.info.type == 1) {
vm.tgsp_list.splice(index, 1);
} else if (vm.info.type == 2) {
vm.lbhb_list.splice(index, 1);
} else if (vm.info.type == 3) {
vm.pyqwa_list.splice(index, 1);
}
},
btn_video: function () {
upvideo(this);
},
saveEdit: function () {
var vm = this;
//获取精品
var brand_ids = [];
for (var i in vm.brands) {
brand_ids.push(vm.brands[i]['id']);
}
vm.info.brand_ids = brand_ids;
if (vm.info.type == 1) {
vm.info.lists = vm.tgsp_list;
} else if (vm.info.type == 2) {
vm.info.lists = vm.lbhb_list;
} else if (vm.info.type == 3) {
vm.info.lists = vm.pyqwa_list;
}
$.ajax({
url: <?=json_encode($edit_url)?>,
type: 'post',
dataType: 'json',
data: {
info: vm.info
},
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 () {
if (data.url != '') {
$.form.href(data.url);
} else {
$.form.reload();
}
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
layer.closeAll('loading');
},
});
}
}
});
});
function upvideo(btn) {
var show_video = $('#show-video');
var _this = $(btn);
var qiniu = new Qiniu.UploaderBuilder()
.domain('https://upload-z2.qiniup.com')//配置参考https://developer.qiniu.com/kodo/manual/1671/region-endpoint
.retry(0)//设置重传次数,默认0,不重传
.size(1024 * 1024)//分片大小,最多为4MB,单位为字节,默认1MB
.chunk(true)//是否分块上传,默认true,当chunk=true并且文件大于4MB才会进行分块上传
.auto(true)//选中文件后立即上传,默认true
.multiple(false)//是否支持多文件选中,默认true
.accept(['video/*'])//过滤文件,默认无
.tokenShare(true)//在一次上传队列中,是否分享token,如果为false每上传一个文件都需要请求一次Token,默认true
.tokenFunc(function (setToken, task) {
//token获取函数,token获取完成后,必须调用`setToken(token);`不然上传任务不会执行。
var ret = $.ajax({
url: "/common/qiniu_token",
type: 'POST',
data: {filename: task.key, type: "video"},
async: false
}).responseText;
ret = JSON.parse(ret);
setToken(ret.data);
})
.listener({
onReady: function (tasks) {
// write(tasks)
}, onStart: function (tasks) {
}, onTaskGetKey: function (task) {
//为每一个上传的文件指定key,如果不指定则由七牛服务器自行处理
var ret = $.ajax({
url: "/common/qiniu_video",
type: 'POST',
data: {filename: task.file.name},
async: false
}).responseText;
ret = JSON.parse(ret);
if (ret.code == 0) {
layer.msg(ret.msg, {icon: 2});
return;
}
return ret.data;
}, onTaskProgress: function (task) {
show_video.empty();
show_video.prepend("进度" + task.progress + "%");
}, onTaskSuccess: function (task) {
// console.log(task);
show_video.empty();
var res = task._result.data;
vue_obj.info.video_file_url = res.file_url;
vue_obj.info.video_url = 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="查看视频">' +
'<img src="' + res.site_url + '?vframe/jpg/offset/1" ' +
'style="height:auto;max-height:32px;min-width:32px"></a>';
show_video.prepend(html);
$('#video-url').val(res.site_url);
}, onTaskFail: function (task) {
show_video.empty();
show_video.prepend("上传失败");
}, onTaskRetry: function (task) {
// write(task)
}, onFinish: function (tasks) {
// write(tasks)
}
}).build();
qiniu.chooseFile();
}
</script>
<link rel="stylesheet" type="text/css" href="/static/css/appitem/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/appitem/AdminLTE.min.css">
<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>
@@ -0,0 +1,81 @@
<div class="coms-table-wrap mt10">
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="/app/material/template/index">
<input type="hidden" name="app_id" value="<?= $params['app_id'] ?>">
<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="name" value="<?= $params['name'] ?>"/>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">模板分类:</label>
<div class="am-para-inline w100">
<select name="type">
<option value="">全部</option>
<?php foreach ($typeAry as $key => $value) { ?>
<option value="<?= $key ?>"
<?= $key == $params['type'] ? 'selected' : '' ?>><?= $value ?></option>
<? } ?>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">状态:</label>
<div class="am-para-inline w100">
<select name="status">
<option value="">全部</option>
<?php foreach ($statusAry as $key => $value) { ?>
<option value="<?= $key ?>"
<?= strlen($params['status']) && $key == $params['status'] ? 'selected' : '' ?>><?= $value ?></option>
<? } ?>
</select>
</div>
</div>
<div class="am-form-group fl ml30">
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
</div>
<div class="am-form-group fl ml10">
<button type="button" data-open="/app/material/template/get?app_id=<?= $params['app_id'] ?>"
class="am-btn am-btn-success am-btn-sm w100">新增
</button>
</div>
</div>
</form>
<div class="coms-table-bd">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="3%"><span>id</span></th>
<th width="15%"><span>模板名称</span></th>
<th width="10%"><span>模板分类</span></th>
<th width="25%"><span>适用品牌</span></th>
<th width="7%"><span>状态</span></th>
<th width="10%"><span>创建时间</span></th>
<th width="6%"><span>操作</span></th>
</tr>
</thead>
<tbody>
<?php foreach ($lists as $v) { ?>
<tr>
<td><?= $v['id'] ?></td>
<td><?= $v['title'] ?></td>
<td><?= $v['type_name'] ?></td>
<td><?= $v['brands'] ?></td>
<td><?= $v['status_name'] ?></td>
<td><?= $v['c_time'] ?></td>
<td><a data-open="/app/material/template/get?id=<?= $v['id'] ?>"
class="am-btn am-btn-primary am-btn-xs">修改</a></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>
+59
View File
@@ -327,6 +327,65 @@ class Hd extends CI_Controller {
}
}
/**
* 推广素材入口
*/
public function material()
{
define('WXAPP_ITEMS', 1);
//加载输入参数
$this->input_param();
$app_id = $this->input_param('app_id');
!$app_id && $app_id = $this->input_param('vipcard_id');
$version = $this->input_param('version');
$sversion = $this->input_param('sversion');
$this->log_file = get_class($this) . "_{$app_id}.log";
//应用ID为空
if (!$app_id) {
debug_log("[fail]" . __FUNCTION__ . ":app_id is null; uri_string:" . $this->uri->uri_string(), $this->log_file);
return $this->print_return($this->return_error(API_CODE_INVILD_PARAM, '请求丢失'));
}
//签名不正确
if (!$this->vaild_sign()) {
debug_log("[fail]" . __FUNCTION__ . ":sign check fail; uri_string:" . $this->uri->uri_string() . "; param:" . json_encode($this->inputs), $this->log_file);
return $this->print_return($this->return_error(API_CODE_INVILD_PARAM, '非法请求'));
}
$app = self::$apps[$app_id];
$class_name = ucfirst($this->uri->segment(3));
if ($this->uri->segment(4)) {
$method = $this->request . "_" . $this->uri->segment(4);
} else {
$method = $this->request;
}
//app定制ct
$file_name = APPPATH . "controllers/wxapp/material/{$app}/{$class_name}.php";
//ct不存在
if (file_exists($file_name)) {
require_once $file_name;
} else {
//app定制ct不存在,使用公共ct
$file_name = APPPATH . "controllers/wxapp/material/{$class_name}.php";
if (file_exists($file_name)) {
require_once $file_name;
} else {
debug_log("[fail]" . __FUNCTION__ . ": file '{$file_name}' not exist; method:{$method}, app_id:" . $app_id, $this->log_file);
return $this->print_return($this->return_error(API_CODE_NONE, '非法请求'));
}
}
try {
$class = new $class_name($this->inputs, $app);
$result = $class->$method($version, $sversion);
if (!$result) {
throw new Exception('', ERR_SYS_FAIL);
}
return $this->print_return($result);
} catch (Exception $e) {
return $this->print_return($this->return_error($e->getCode(), $e->getMessage()));
}
}
/**
* 测试签名(开发环境)
*/
+1
View File
@@ -119,6 +119,7 @@ class User extends Wxapp{
'tel' => $tel,
'group_id' => $user['group_id'],
'group_name' => $group_name,
'biz_id' => $biz_id,
'biz_name' => $biz['biz_name'] ? $biz['biz_name'] : ''
);
+135
View File
@@ -0,0 +1,135 @@
<?php
defined('WXAPP_ITEMS') OR exit('No direct script access allowed');
ini_set('display_errors', 'On');
error_reporting(E_ERROR);
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
/**
* Notes:店铺
* Created on: 2021/10/9 15:16
* Created by: dengbw
*/
class Biz extends Wxapp
{
private $cf_id = 24;//素材报名
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = '';//
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$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('app/material/Material_biz_statistics_model', 'mdBizStatistics');
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
$this->load->model("biz/biz_model", 'mdBiz');
$this->app_id == 1 && $this->app_id = 2;//获取狸车宝数据
}
/**
* Notes:店铺首页
* Created on: 2021/10/12 11:47
* Created by: dengbw
* @return array
* @throws Exception
*/
protected function get()
{
$biz_id = intval($this->input_param('biz_id'));
$re = $this->mdBiz->get(array('id' => $biz_id, 'status' => 1));
if (!$re || empty($re)) {
throw new Hd_exception('门店不存在', API_CODE_FAIL);
}
//加店铺浏览
$where_s = ['app_id' => $this->app_id, 'biz_id' => $biz_id, 't_id' => 0, 'day' => date('Y-m-d')];
$re_s = $this->mdBizStatistics->get($where_s);
if ($re_s) {
$this->mdBizStatistics->update(['browse_num = browse_num+1' => null], $where_s);
} else {
$where_s['browse_num'] = 1;
$this->mdBizStatistics->add($where_s);
}
$auto_brands = $list = array();
if ($re['jsondata']) {
$jsondata = json_decode($re['jsondata'], true);
if ($jsondata['auto_brands']) {
$brand_ids = implode(',', $jsondata['auto_brands']);
$res_b = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'name');
$res_b && $auto_brands = array_column($res_b, 'name');
}
}
$where = ['a.status' => 1, 'b.app_id' => $this->app_id, 'b.biz_id' => $biz_id];
$this->mdTemplate->db->from('lc_material_template as a');
$this->mdTemplate->db->join('lc_material_biz as b', "b.t_id=a.id", 'left');
$this->mdTemplate->db->select('a.id, a.cover,b.biz_id,b.app_id');
$this->mdTemplate->db->where($where);
$this->mdTemplate->db->order_by('a.id Desc');
$this->mdTemplate->db->limit(50);
$res = $this->mdTemplate->db->get()->result_array();
foreach ($res as $key => $value) {
$list[] = array(
'id' => $value['id'],
'cover' => $value['cover'] ? build_qiniu_image_url($value['cover']) : '');
}
//统计浏览数
$re_s = $this->mdBizStatistics->sum('browse_num', ['app_id' => $this->app_id, 'biz_id' => $biz_id]);
$orders = $this->mdBizStatistics->count_order(array('c.biz_id' => $biz_id, 'c.cf_id' => $this->cf_id, 'c.status >=' => 0));
$this->data['title'] = '店铺';
$this->data['biz_name'] = $re['biz_name'];
$this->data['address'] = $re['address'];
$this->data['lat'] = $re['lat'];
$this->data['lng'] = $re['lng'];
$this->data['auto_brands'] = $auto_brands;
$this->data['statistics'] = $re_s['browse_num'] . '人浏览 | ' . $orders . '笔成交';
$this->data['topics'] = array('title' => '热门', 'list' => $list);
return $this->data;
}
/**
* Notes:预约报名
* Created on: 2021/10/12 17:51
* Created by: dengbw
* @throws Hd_exception
*/
protected function put()
{
$biz_id = intval($this->input_param('biz_id'));
$t_id = intval($this->input_param('t_id'));
if (!$biz_id || !$this->session['mobile']) {
throw new Hd_exception('参数错误', API_CODE_FAIL);
}
$re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]);
if (!$re_biz) {
return $this->Hd_exception(SYS_CODE_FAIL, '预约的门店不存在!');
}
$add_data = [
'name' => $this->session['uname'] ? $this->session['uname'] : '',
'mobile' => $this->session['mobile'],
'biz_id' => $biz_id,
'city_id' => $re_biz['city_id'],
'county_id' => $re_biz['county_id'],
'cf_title' => '自有资源',
'cf_id' => $this->cf_id,
't_id' => $t_id,
'p_time' => date('Y-m-d H:i:s'),
'c_time' => time()
];
$where = ['biz_id' => $biz_id, 'mobile' => $add_data['mobile'], 'cf_id' => $this->cf_id];
$t_id && $where['t_id'] = $t_id;
$re_cus = $this->mdCustomers->get($where);
if ($re_cus) {
throw new Hd_exception('您已经预约报名了', API_CODE_FAIL);
}
$id = $this->mdCustomers->add($add_data);
if (!$id) {
throw new Hd_exception('预约报名失败!', API_CODE_FAIL);
}
throw new Hd_exception('预约报名成功!', API_CODE_SUCCESS);
}
}
+202
View File
@@ -0,0 +1,202 @@
<?php
defined('WXAPP_ITEMS') OR exit('No direct script access allowed');
ini_set('display_errors', 'On');
error_reporting(E_ERROR);
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
/**
* Notes:推广素材
* Created on: 2021/10/9 15:16
* Created by: dengbw
*/
class Home extends Wxapp
{
private $biz_id = 0;
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = '';//
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$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("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;//获取狸车宝数据
}
/**
* Notes:推广素材_tab
* Created on: 2021/10/13 11:42
* Created by: dengbw
* @return array
*/
protected function get_tabs()
{
$list = array();
foreach ($this->mdTemplate->typeAry() as $key => $value) {
$list[] = array('id' => $key, 'name' => $value);
}
$this->data['title'] = '推广素材';
$this->data['list'] = $list;
return $list;
}
/**
* Notes:推广素材_list
* Created on: 2021/10/11 11:47
* Created by: dengbw
* @return array
* @throws Exception
*/
protected function get_lists()
{
$page = $this->input_param('page');
$size = $this->input_param('size');
$type = intval($this->input_param('type'));
!$page && $page = 1;
!$size && $size = 10;
!$type && $type = 1;
$brand_ids = array();
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 = $jsondata['auto_brands'];
}
}
$lists = array();
$total = 0;
$show = 'image';
if ($brand_ids) {
$where = array('app_id' => $this->app_id, 'type' => $type, 'status' => 1);
if ($type == 3) {
$show = 'text';
$res = $this->mdTemplate->select($where, "id desc", 1, 1, 'json_data');
if ($res[0]['json_data']) {
$json_data = json_decode($res[0]['json_data'], true);
$total = count($json_data['lists']);
foreach ($json_data['lists'] as $key2 => $value2) {
if ($value2['brands']) {
$brands = $value2['brands'] . ',';
foreach ($brand_ids as $key3 => $value3) {
if (strstr($brands, $value3 . ',')) {
$lists[] = array('content' => $value2['content']);
break;
}
}
}
}
}
} else {
$or_str = '';
foreach ($brand_ids as $key3 => $value3) {
$brand_id = $value3 . ',';
$or_str = $or_str ? $or_str . " OR brand_ids like '%{$brand_id}%'" : "brand_ids like '%{$brand_id}%'";
}
$where[' (' . $or_str . ') '] = null;
$total = $this->mdTemplate->count($where);
$fileds = 'id,title,cover';
$res = $this->mdTemplate->select($where, "id desc", $page, $size, $fileds);
foreach ($res as $key2 => $value2) {
$value2['cover'] = $value2['cover'] ? build_qiniu_image_url($value2['cover']) : '';
$re_biz = $this->mdMaterialBiz->get(array('app_id' => $this->app_id, 't_id' => $value2['id'], 'biz_id' => $this->biz_id));
$value2['if_add'] = $re_biz ? 1 : 0;
$lists[] = $value2;
}
}
}
$this->data['show'] = $show;
$this->data['list'] = $lists;
$this->data['total'] = $total;
return $this->data;
}
/**
* Notes:生成专题
* Created on: 2021/10/11 16:14
* Created by: dengbw
* @throws Hd_exception
*/
protected function put_topic()
{
$t_id = intval($this->input_param('t_id'));
if (!$t_id || !$this->biz_id) {
throw new Hd_exception('参数错误', API_CODE_FAIL);
}
$where = array('app_id' => $this->app_id, 't_id' => $t_id, 'biz_id' => $this->biz_id);
$re = $this->mdMaterialBiz->get($where);
if ($re) {
throw new Hd_exception('该专题已经生成过了~', API_CODE_FAIL);
}
$where['c_time'] = time();
$id = $this->mdMaterialBiz->add($where);
if ($id) {
throw new Exception('专题生成成功', API_CODE_SUCCESS);
} else {
throw new Exception('专题生成失败', API_CODE_FAIL);
}
}
/**
* Notes:获取二维码
* Created on: 2021/8/27 16:34
* Created by: dengbw
* @return array
* @throws Hd_Exception
*/
protected function get_qrcode()
{
$scene = $this->input_param('scene');
$page = $this->input_param('page');
$width = $this->input_param('width');
if (0 == strlen($scene)) {
throw new Hd_Exception('二维码参数必填', API_CODE_INVILD_PARAM);
}
return $this->qrcode($scene, $page, $width);
}
/**
* Notes:获取图片二维码
* Created on: 2021/8/27 16:33
* Created by: dengbw
* @param $scene
* @param string $page
* @param int $width
* @param string $fig
* @return array
* @throws Hd_Exception
*/
private function qrcode($scene, $page = '', $width = 0, $fig = 'liche')
{
$path = "{$page}?{$scene}";
$width && $path .= "{$width}";
if ($fig) {
$this->config->load('app', true, true);
$configs = $this->config->item('app');
$config = $configs[$fig];
if (!$config) {
debug_log("[error] " . __FUNCTION__ . ": config not exist;fig={$fig}", $this->log_file);
throw new Hd_Exception('请求的小程序不存在', API_CODE_INVILD_PARAM);
}
$wxconfig = $config['wx'];
} else {
$wxconfig = $this->wx_config;
$fig = $this->app_key;
}
$filename = "{$fig}/" . substr(md5($path), 8, 16);
$this->load->library('Hdwechat');
$hdwechat = new Hdwechat($wxconfig);
$ret = $hdwechat->qrcode($filename, $scene, $page, $width);
if (!$ret) {
throw new Hd_Exception('生成失败,稍后重试', API_CODE_FAIL);
}
$data = array('url' => $ret['url']);
return $data;
}
}
@@ -0,0 +1,160 @@
<?php
defined('WXAPP_ITEMS') OR exit('No direct script access allowed');
ini_set('display_errors', 'On');
error_reporting(E_ERROR);
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
/**
* Notes:数据分析
* Created on: 2021/10/13 15:16
* Created by: dengbw
*/
class Statistics extends Wxapp
{
private $biz_id = 0;
private $cf_id = 24;//素材报名
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = '';//
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$this->majia_white = array('get');//超级管理员披上马甲可操作权限
$this->load->model('app/material/Material_biz_statistics_model', 'mdBizStatistics');
$this->load->model('app/material/Material_template_model', 'mdTemplate');
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$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;//获取狸车宝数据
}
/**
* Notes:数据分析首页
* Created on: 2021/10/12 11:47
* Created by: dengbw
* @return array
* @throws Exception
*/
protected function get()
{
if (!$this->biz_id) {
throw new Hd_exception('门店不存在!', API_CODE_FAIL);
}
$re_biz = $this->mdBiz->get(['id' => $this->biz_id, 'status' => 1]);
if (!$re_biz) {
return $this->show_json(SYS_CODE_FAIL, '门店不存在!');
}
$topic_list = array();
$where = ['a.status' => 1, 'b.app_id' => $this->app_id, 'b.biz_id' => $this->biz_id];
$this->mdTemplate->db->from('lc_material_template as a');
$this->mdTemplate->db->join('lc_material_biz as b', "b.t_id=a.id", 'left');
$this->mdTemplate->db->select('a.id, a.title,b.biz_id,b.app_id');
$this->mdTemplate->db->where($where);
$this->mdTemplate->db->order_by('a.id Desc');
$this->mdTemplate->db->limit(50);
$res = $this->mdTemplate->db->get()->result_array();
foreach ($res as $key => $value) {
$topic_list[] = array('id' => $value['id'], 'title' => $value['title']);
}
$this->data['title'] = '数据分析';
$this->data['biz_name'] = $re_biz['biz_name'];
$this->data['topic_list'] = $topic_list;
return $this->data;
}
/**
* Notes:累计数据
* Created on: 2021/10/13 14:51
* Created by: dengbw
* @return array
*/
protected function get_cal()
{
$day = $this->input_param('day');
$t_id = intval($this->input_param('t_id'));
$where_s = array('app_id' => $this->app_id, 'biz_id' => $this->biz_id);
$where_c = array('biz_id' => $this->biz_id, 'cf_id' => $this->cf_id, 'status >=' => 0);
$where_o = array('c.biz_id' => $this->biz_id, 'c.cf_id' => $this->cf_id, 'c.status >=' => 0);
if ($day) {
$where_s['day'] = $day;
$where_c['c_time>='] = strtotime($day . ' 00:00:00');
$where_c['c_time<='] = strtotime($day . ' 23:59:59');
$where_o['o.c_time>='] = strtotime($day . ' 00:00:00');
$where_o['o.c_time<='] = strtotime($day . ' 23:59:59');
}
if ($t_id) {
$where_s['t_id'] = $t_id;
$where_c['t_id '] = $t_id;
$where_o['c.t_id'] = $t_id;
}
$re_s = $this->mdBizStatistics->sum('browse_num', $where_s);
$count_c = $this->mdCustomers->count($where_c);
$count_o = $this->mdBizStatistics->count_order($where_o);
$data = [
['icon' => 'icon-liulan', 'name' => '浏览次数', 'value' => intval($re_s['browse_num'])],
['icon' => 'icon-baoming', 'name' => '报名客户', 'value' => $count_c],
['icon' => 'icon-dingdan', 'name' => '订单客户', 'value' => $count_o]
];
return $data;
}
/**
* Notes:图表
* Created on: 2021/10/13 10:59
* Created by: dengbw
* @return array
*/
protected function get_chart()
{
$xAxis = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
$year = date('Y');
$browse_data = $enroll_data = $orders_data = [];
$where_s = array('app_id' => $this->app_id, 'biz_id' => $this->biz_id);
$where_c = array('biz_id' => $this->biz_id, 'cf_id' => $this->cf_id, 'status >=' => 0);
$where_o = array('c.biz_id' => $this->biz_id, 'c.cf_id' => $this->cf_id, 'c.status >=' => 0);
foreach ($xAxis as $key => $value) {
$value < 10 && $value = '0' . $value;
$s_day = $year . '-' . $value . '-01';//第一天
$e_day = date('Y-m-d', strtotime("$s_day +1 month -1 day"));//最后一天
//浏览
$re_s = $this->mdBizStatistics->sum('browse_num', array_merge($where_s, array('day>=' => $s_day, 'day<=' => $e_day)));
$s_time = strtotime($s_day . ' 00:00:00');
$e_time = strtotime($e_day . ' 23:59:59');
//客户
$count_c = $this->mdCustomers->count(array_merge($where_c, array('c_time>=' => $s_time, 'c_time<=' => $e_time)));
//订单
$count_o = $this->mdBizStatistics->count_order(array_merge($where_o, array('o.c_time>=' => $s_time, 'o.c_time<=' => $e_time)));
$browse_data[] = intval($re_s['browse_num']);
$enroll_data[] = $count_c;
$orders_data[] = $count_o;
}
$data = [
'legend' => ["浏览", "客户", "订单"],
'xAxis' => $xAxis,
'series' => [
[
'name' => '浏览',
'type' => 'line',
'smooth' => true,
'data' => $browse_data,
],
[
'name' => '客户',
'type' => 'line',
'smooth' => true,
'data' => $enroll_data,
],
[
'name' => '订单',
'type' => 'line',
'smooth' => true,
'data' => $orders_data,
]
]
];
return $data;
}
}
+88
View File
@@ -0,0 +1,88 @@
<?php
defined('WXAPP_ITEMS') OR exit('No direct script access allowed');
ini_set('display_errors', 'On');
error_reporting(E_ERROR);
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
/**
* Notes:专题
* Created on: 2021/10/9 15:16
* Created by: dengbw
*/
class Topic extends Wxapp
{
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = '';//
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$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('app/material/Material_biz_statistics_model', 'mdBizStatistics');
$this->app_id == 1 && $this->app_id = 2;//获取狸车宝数据
}
/**
* Notes:专题首页
* Created on: 2021/10/12 11:47
* Created by: dengbw
* @return array
* @throws Exception
*/
protected function get()
{
$id = intval($this->input_param('id'));
$biz_id = intval($this->input_param('biz_id'));
$re = $this->mdTemplate->get(array('id' => $id, 'status' => 1));
if (!$re || empty($re)) {
throw new Hd_exception('专题不存在', API_CODE_FAIL);
}
if ($biz_id) {
$re_biz = $this->mdMaterialBiz->get(array('app_id' => $this->app_id, 't_id' => $id, 'biz_id' => $biz_id));
if (!$re_biz || empty($re_biz)) {
throw new Hd_exception('门店还未创建专题', API_CODE_FAIL);
}
//加店铺专题浏览
$where_s = ['app_id' => $this->app_id, 'biz_id' => $biz_id, 't_id' => $id, 'day' => date('Y-m-d')];
$re_s = $this->mdBizStatistics->get($where_s);
if ($re_s) {
$this->mdBizStatistics->update(['browse_num = browse_num+1' => null], $where_s);
} else {
$where_s['browse_num'] = 1;
$this->mdBizStatistics->add($where_s);
}
}
$lists = array();
if ($re['json_data']) {
$json_data = json_decode($re['json_data'], true);
foreach ($json_data['lists'] as $key => $value) {
$setValue = array();
$setValue['title'] = $value['title'];
if ($re['type'] == 1) {
$setValue['video_type'] = intval($value['video_type']);
if ($value['video_type'] == 1) {
$setValue['video'] = $value['video'] ? build_qiniu_image_url($value['video'], 0, 0, 'video') : '';
$setValue['video_cover'] = $value['video'] ? $value['video'] . '?vframe/jpg/offset/1' : '';
} else {
$setValue['img'] = $value['img'] ? build_qiniu_image_url($value['img']) : '';
$setValue['link'] = $value['link'];
}
} else if ($re['type'] == 2) {
$setValue['img'] = $value['img'] ? build_qiniu_image_url($value['img']) : '';
$setValue['link'] = $value['link'];
}
$lists[] = $setValue;
}
}
$this->data['id'] = $id;
$this->data['type'] = $re['type'];
$this->data['sign_up'] = 1;
$this->data['lists'] = $lists;
return $this->data;
}
}
@@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:门店素材模板
* Created on: 2021/10/11 12:45
* Created by: dengbw
*/
class Material_biz_model extends HD_Model
{
private $table_name = 'lc_material_biz';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,49 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:门店素材统计表
* Created on: 2021/10/11 12:45
* Created by: dengbw
*/
class Material_biz_statistics_model extends HD_Model
{
private $table_name = 'lc_material_biz_statistics';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
//关联订单
public function count_order($where)
{
return $this->select_order($where, 'o.rid', '', '', '', 1);
}
public function select_order($where = array(), $order = '', $page = 0, $page_size = 20, $fileds = '', $count = 0)
{
!$fileds && $fileds = 'o.*';
$this->db->select($fileds);
$this->db->from('lc_receiver_orders as o');
$this->db->join('lc_receiver_customers as c', 'c.id = o.rid', 'left');
if ($where) {
$this->db->where($where);
}
if ($count) {
return $this->db->count_all_results();
}
if ($order) {
$this->db->order_by($order);
}
if ($page) {
$offset = ($page - 1) * $page_size;
$limit = $page_size;
} else {
$offset = null;
$limit = null;
}
$this->db->limit($limit, $offset);
return $this->db->get()->result_array();
}
}
@@ -0,0 +1,39 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:素材模板
* Created on: 2021/9/30 12:45
* Created by: dengbw
*/
class Material_template_model extends HD_Model
{
private $table_name = 'lc_material_template';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:素材分类
* Created on: 2021/9/15 10:25
* Created by: dengbw
* @return array
*/
public function typeAry()
{
return array(1 => '推广视频', 2 => '轮播海报', 3 => '朋友圈文案');
}
/**
* Notes:状态
* Created on: 2021/9/15 10:25
* Created by: dengbw
* @return array
*/
public function statusAry()
{
return array(1 => '正常', 0 => '下架', -1 => '删除');
}
}