This commit is contained in:
dengbw
2022-05-07 15:15:44 +08:00
parent 3c88d34dbb
commit 3c186cb310
12 changed files with 1430 additions and 143 deletions
+423
View File
@@ -0,0 +1,423 @@
<?php
/**
* Notes:私域通-直播
* Created on: 2022/05/07 13:38
* Created by: dengbw
*/
class Sytlive extends HD_Controller
{
private $statusAry = array(-1 => '已删除', 0 => '待审核', 1 => '已通过', 2 => '未通过');
private $app_id = 2;
public function __construct()
{
parent::__construct();
$this->load->model('app/licheb/syt_live_model', 'mdSytLive');
}
public function index()
{
return $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 = array();
$where = array('status>' => -1);
$count = $this->mdSytActivity->count($where);
if ($count) {
$this->load->library('MyEncryption');
$res = $this->mdSytActivity->select($where, 'id desc', $params['page'], $params['size']);
foreach ($res as $key => $value) {
$setValue = array();
$setValue['id'] = $value['id'];
$setValue['title'] = $value['title'];
$z_title = '';
if ($value['z_id']) {
$re_t = $this->mdTopics->get(array('id' => $value['z_id']));
$re_t['title'] && $z_title = $re_t['title'];
}
$setValue['z_id'] = $value['z_id'];
$setValue['z_title'] = $z_title;
$setValue['s_time'] = $value['s_time'];
$setValue['e_time'] = $value['e_time'];
$setValue['c_time'] = date('Y-m-d H:i', $value['c_time']);
$setValue['status_name'] = $this->statusAry[$value['status']];
$url = http_host_com('home') . "/h5/syt/special?skey=" . $this->myencryption->base64url_encode("a_id=" . $value['id']);
$setValue['url'] = urlencode($url);
$lists[] = $setValue;
}
}
$this->data['_title'] = '私域通-直播列表';
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
$this->data['lists'] = $lists;
$this->data['params'] = $params;
return $this->show_view('/app/licheb/syt/live_lists', true);
}
public function get()
{
$params = $this->input->get();
$id = intval($params['id']);
$status_list = $kpi_list = array();
$posters = array('imgs_url' => array(), 'imgs' => array());
$share_title = $remark = $rule = $bg_color = $btn_color = '';
if ($id > 0) {
$re = $this->mdSytActivity->get(array('id' => $id));
if (!$re || empty($re)) {
return $this->show_json(SYS_CODE_FAIL, '活动不存在!');
}
$_title = '编辑私域通活动';
$dataInfo['editType'] = 0;
$dataInfo['edit_url'] = '/app/licheb/sytactivity/edit';
$dataInfo['brand_id'] = $re['brand_id'] ? explode(',', $re['brand_id']) : [];
$dataInfo['status'] = $re['status'];
$dataInfo['z_id'] = $re['z_id'];
if ($re['jsondata']) {
$jsondata = json_decode($re['jsondata'], true);
$share_title = $jsondata['share_title'] ? $jsondata['share_title'] : '';
$remark = $jsondata['remark'] ? $jsondata['remark'] : '';
$rule = $jsondata['rule'] ? $jsondata['rule'] : '';
$bg_color = $jsondata['bg_color'] ? $jsondata['bg_color'] : '';
$btn_color = $jsondata['btn_color'] ? $jsondata['btn_color'] : '';
if ($jsondata['posters']) {
foreach ($jsondata['posters'] as $key => $value) {
$posters['imgs_url'][] = array("value" => $value['url'], "src" => build_qiniu_image_url($value['url']));
$posters['imgs'][] = array("value" => $value['url'], "src" => build_qiniu_image_url($value['url'])
, "width" => $value['width'], "height" => $value['height']);
}
}
}
if ($re['z_id']) {
$re_t = $this->mdTopics->get(array('id' => $re['z_id']));
$dataInfo['z_title'] = $re_t['title'] ? $re_t['title'] : '';
}
$dataInfo['title'] = $re['title'];
$dataInfo['img'] = $re['img'] ? $re['img'] : '';
$dataInfo['img_url'] = $re['img'] ? build_qiniu_image_url($re['img']) : '';
$dataInfo['time'] = $re['s_time'] . " ~ " . $re['e_time'];
$jsonkpi = $re['jsonkpi'] ? json_decode($re['jsonkpi'], true) : '';
foreach ($this->mdSytKpiData->kpiAry() as $key => $value) {
$kpi_list[$key] = array("num" => $jsonkpi[$key]['num'], "score" => $jsonkpi[$key]['score']
, "title" => $value['title1'], "num_tag" => $value['num_tag'], "score_tag" => $value['score_tag']);
}
} else {
$_title = '新增私域通活动';
$dataInfo['editType'] = 2;
$dataInfo['edit_url'] = '/app/licheb/sytactivity/add';
$dataInfo['brand_id'] = [];
$dataInfo['status'] = 0;
$dataInfo['z_id'] = 0;
foreach ($this->mdSytKpiData->kpiAry() as $key => $value) {
$kpi_list[$key] = array("num" => 0, "score" => 0, "title" => $value['title1'], "num_tag" => $value['num_tag']
, "score_tag" => $value['score_tag']);
}
}
foreach ($this->statusAry as $key => $value) {
$status_list[] = array("id" => $key, "name" => $value);
}
$dataInfo['kpi_list'] = $kpi_list;
$dataInfo['id'] = $id;
$dataInfo['share_title'] = $share_title;
$dataInfo['remark'] = $remark;
$dataInfo['rule'] = $rule;
$dataInfo['bg_color'] = $bg_color;
$dataInfo['btn_color'] = $btn_color;
$this->data['info'] = $dataInfo;
$this->data['status_list'] = $status_list;
$this->data['posters'] = $posters;
$this->data['_title'] = $_title;
return $this->show_view('/app/licheb/syt/activity_edit', true);
}
public function add()
{
$info = $this->input->post('info');
$checkData = $this->checkData($info);
if (!$checkData['code']) {
return $this->show_json($checkData['code'], $checkData['msg']);
}
$brand_id = $info['brand_id'] ? implode(',', $info['brand_id']) : 0;
$re = $this->mdSytActivity->get(array("z_id" => $info['z_id'], "brand_id" => $brand_id));
if ($re) {
return $this->show_json(SYS_CODE_FAIL, '该活动已存在!');
}
$jsonkpi = json_encode($info['kpi_list'], JSON_UNESCAPED_UNICODE);
$json_data['share_title'] = $info['share_title'];
$json_data['remark'] = $info['remark'];
$json_data['rule'] = $info['rule'];
$json_data['bg_color'] = $info['bg_color'];
$json_data['btn_color'] = $info['btn_color'];
//海报
$posters = array();
if ($info['posters']) {
foreach ($info['posters'] as $key => $value) {
$posters[] = array('url' => $value['value'], 'width' => $value['width'], 'height' => $value['height']);
}
}
$json_data['posters'] = $posters;
$jsondata = json_encode($json_data, JSON_UNESCAPED_UNICODE);
$addData = array("brand_id" => $brand_id, "title" => $info['title'], "z_id" => $info['z_id'], "img" => $info['img']
, "jsonkpi" => $jsonkpi, "jsondata" => $jsondata, "status" => $info['status'], "c_time" => time());
if ($info['time']) {
$time = explode(' ~ ', $info['time']);
$addData['s_time'] = $time[0];
$addData['e_time'] = $time[1];
}
$id = $this->mdSytActivity->add($addData);
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '新增活动失败!');
}
$this->data['type'] = 'add';
$this->data['id'] = $id;
return $this->show_json(SYS_CODE_SUCCESS, '新增活动成功!');
}
public function edit()
{
$info = $this->input->post('info');
$checkData = $this->checkData($info);
if (!$checkData['code']) {
return $this->show_json($checkData['code'], $checkData['msg']);
}
if (!$info['id']) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
$jsonkpi = json_encode($info['kpi_list'], JSON_UNESCAPED_UNICODE);
$json_data['share_title'] = $info['share_title'];
$json_data['remark'] = $info['remark'];
$json_data['rule'] = $info['rule'];
$json_data['bg_color'] = $info['bg_color'];
$json_data['btn_color'] = $info['btn_color'];
//海报
$posters = array();
if ($info['posters']) {
foreach ($info['posters'] as $key => $value) {
$posters[] = array('url' => $value['value'], 'width' => $value['width'], 'height' => $value['height']);
}
}
$json_data['posters'] = $posters;
$jsondata = json_encode($json_data, JSON_UNESCAPED_UNICODE);
$brand_id = $info['brand_id'] ? implode(',', $info['brand_id']) : 0;
$updateData = array("brand_id" => $brand_id, "title" => $info['title'], "z_id" => $info['z_id'], "img" => $info['img']
, "jsonkpi" => $jsonkpi, "jsondata" => $jsondata);
if ($info['time']) {
$time = explode(' ~ ', $info['time']);
$updateData['s_time'] = $time[0];
$updateData['e_time'] = $time[1];
}
$this->mdSytActivity->update($updateData, array('id' => $info['id']));
$this->data['type'] = 'edit';
return $this->show_json(SYS_CODE_SUCCESS, '修改活动成功!');
}
/**
* Notes:修改商家状态
* Created on: 2020/8/24 11:12
* Created by: dengbw
* @return bool|void
*/
public function edit_status()
{
$info = $this->input->post('info');
if (!$info['id']) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
$this->mdSytActivity->update(array("status" => intval($info['status'])), array('id' => $info['id']));
return $this->show_json(SYS_CODE_SUCCESS, '操作成功!');
}
/**
* Notes:私域通-报名
* Created on: 2020/12/23 14:54
* Created by: dengbw
* @return bool
*/
public function get_enroll_lists()
{
$params = $this->input->get();
if (!$params['a_id']) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
$re = $this->mdSytActivity->get(array('id' => $params['a_id']));
if (!$re || empty($re)) {
return $this->show_json(SYS_CODE_FAIL, '活动不存在!');
}
$res = $this->enrollSelect($params);
$lists = $res['lists'];
$count = $res['count'];
$params = $res['params'];
$this->data['_title'] = '私域通-[' . $re['title'] . ']报名';
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
$this->data['lists'] = $lists;
$this->data['params'] = $res['params'];
return $this->show_view('/app/hdy/syt/enroll_lists', true);
}
public function enrollSelect($params)
{
$this->load->model('app/syt/syt_activity_enroll_model', 'mdSytActivityEnroll');
$this->load->model('app/syt/syt_activity_team_model', 'mdSytActivityTeam');
$this->load->model('app/hdy/app_hdy_users_model', 'mdHdyUsers');
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 20;
$params['a_id'] = intval($params['a_id']);
$lists = array();
$where = array('status' => 1, 'a_id' => $params['a_id']);
if ($params['nickname']) {
$where['nickname LIKE "%' . $params['nickname'] . '%"'] = null;
}
if ($params['mobile']) {
$where['mobile LIKE "%' . $params['mobile'] . '%"'] = null;
}
$count = $this->mdSytActivityEnroll->count($where);
if ($count) {
$res = $this->mdSytActivityEnroll->select($where, 'id desc', $params['page'], $params['size']);
foreach ($res as $key => $value) {
$setValue = array();
$setValue['id'] = $value['id'];
$setValue['nickname'] = $value['nickname'];
$setValue['mobile'] = $value['mobile'];
$cf_name = '-';
if ($value['cf_uid'] || $value['t_id']) {
if ($value['cf_uid']) {
$reUsers = $this->mdHdyUsers->get(array('id' => $value['cf_uid']));
$reUsers['nickname'] && $cf_name = $reUsers['nickname'];
} else {
$re_t = $this->mdSytActivityTeam->get(array('id' => $value['t_id']));
$re_t['name'] && $cf_name = $re_t['name'];
}
}
$setValue['cf_name'] = $cf_name;
$setValue['c_time'] = date('Y-m-d H:i', $value['c_time']);
$lists[] = $setValue;
}
}
$data['lists'] = $lists;
$data['count'] = $count;
$data['params'] = $params;
return $data;
}
/**
* Notes:检查新增/修改数据
* Created on: 2020/8/20 11:59
* Created by: dengbw
* @param $info
* @return array
*/
private function checkData($info)
{
$msg = '';
$code = SYS_CODE_FAIL;
if (!$info) {
$msg = '非法参数';
} else if (!$info['brand_id']) {
$msg = '请选择活动品牌';
} else if (!$info['z_id']) {
$msg = '请选择活动专题';
} else if (!$info['title']) {
$msg = '请输入活动标题';
} else if (!$info['time']) {
$msg = '请选择活动时间';
} else {
$code = SYS_CODE_SUCCESS;
}
return array('code' => $code, 'msg' => $msg);
}
public function del()
{
}
public function batch()
{
// TODO: Implement batch() method.
}
public function export()
{
$params = $this->input->get();
$params['page'] = 1;
$params['size'] = 10000;
$data = $indexs = array();
$res = $this->enrollSelect($params);
$fileName = '私域通报名';
foreach ($res['lists'] as $key => $value) {
$temp['nickname'] = $value['nickname'];
$temp['mobile'] = $value['mobile'];
$temp['cf_name'] = $value['cf_name'];
$temp['c_time'] = $value['c_time'];
$data[] = $temp;
}
$indexs = [
'nickname' => '报名昵称',
'mobile' => '手机号',
'cf_name' => '来源',
'c_time' => '创建时间'
];
array_unshift($data, $indexs);
$this->load->library('excel');
$this->excel->out($data, $indexs, $fileName . "_" . date('YmdHis'));
}
public function get_topics()
{
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
$topicsList = array();
$where = array('status >' => -1, 'app_id' => $this->app_id);
$title = $this->input->post('title');
$title && $where['title like "%' . $title . '%"'] = null;
$count = $this->mdTopics->count($where);
if ($count) {
$res = $this->mdTopics->select($where, 'id desc', $page, $size);
foreach ($res as $key => $value) {
$setValue = array();
$setValue['id'] = $value['id'];
$setValue['title'] = $value['title'];
$topicsList[] = $setValue;
}
}
$this->data['topicsList'] = $topicsList;
$hasNext = ceil($count / $size) > $page ? 1 : 0;
$this->data['topicsPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
return $this->show_json(SYS_CODE_SUCCESS);
}
private function get_biz_name($info)
{
$biz_name = '';
if ($info['biz_id']) {
$reBiz = $this->mdBiz->get(array('id' => $info['biz_id']), 'biz_name');
$biz_name = $reBiz['biz_name'];
} else if ($info['brand_id']) {
$reBrand = $this->mdBrand->get(array('id' => $info['brand_id']), 'brand_name');
$biz_name = $reBrand['brand_name'];
}
return $biz_name;
}
public function get_kpidata()
{
$this->load->model('app/syt/syt_activity_member_model', 'mdSytActivityMember');
$params = $this->input->get();
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 10;
$where = array('status' => 1);
$res = $this->mdSytActivityMember->select($where, 'id asc', $params['page'], $params['size']);
foreach ($res as $key => $value) {
$this->mdSytKpiData->update(array("t_id" => $value['t_id']), array("a_id" => $value['a_id'], 'cf_uid' => $value['uid']));
}
print_r($res);
exit;
}
}
+6 -4
View File
@@ -95,8 +95,8 @@ class Userslog extends HD_Controller
$map_biz[$v['biz_id']]['biz_name'] && $biz_name = $map_biz[$v['biz_id']]['biz_name'];
$map_biz[$v['biz_id']]['type'] && $biz_type = $typeAry[$map_biz[$v['biz_id']]['type']];
$temp = ['uname' => $uname, 'biz_type' => $biz_type, 'biz_name' => $biz_name, 'defeats' => $v['defeats']
, 'a_num' => $v['a_num'], 'orders' => $v['orders'], 'bills' => $v['bills'], 'follows' => $v['follows']
, 'qy_adds' => $v['qy_adds'], 'qy_dels' => $v['qy_dels'], 'log_date' => $v['log_date']];
, 'c_num' => $v['c_num'], 'a_num' => $v['a_num'], 'orders' => $v['orders'], 'bills' => $v['bills']
, 'follows' => $v['follows'], 'qy_adds' => $v['qy_adds'], 'qy_dels' => $v['qy_dels'], 'log_date' => $v['log_date']];
$customer_json = $v['customer_json'] ? json_decode($v['customer_json'], true) : [];
foreach ($offlineSources as $key1 => $value1) {
$nums = intval($v['customer_' . $key1]);
@@ -125,8 +125,9 @@ class Userslog extends HD_Controller
if ($params['size'] != 10000) {
$sum = $this->mdUsersLog->sum('customers', $where);
$menus[] = ['title' => "客户数", 'value' => intval($sum['customers']), 'tag' => '人'];
$sum_c = $this->mdUsersLog->sum('c_num', $where);
$sum = $this->mdUsersLog->sum('a_num', $where);
$menus[] = ['title' => "进店数", 'value' => intval($sum['a_num']), 'tag' => '人'];
$menus[] = ['title' => "进店人数/进店次", 'value' => intval($sum_c['c_num']) . '/' . intval($sum['a_num']), 'tag' => '人'];
$sum = $this->mdUsersLog->sum('follows', $where);
$menus[] = ['title' => "跟进数", 'value' => intval($sum['follows']), 'tag' => '个'];
$sum = $this->mdUsersLog->sum('orders', $where);
@@ -188,7 +189,8 @@ class Userslog extends HD_Controller
$indexs['customer_' . $key2] = $value2;
}
}
$indexs['a_num'] = '进店数';
$indexs['c_num'] = '进店数';
$indexs['a_num'] = '进店次数';
$indexs['follows'] = '跟进数';
$indexs['orders'] = '订单数';
$indexs['defeats'] = '战败数';
+10 -10
View File
@@ -58,16 +58,16 @@ class Auth {
$ip_arr = array_merge($ip_arr, array_column($CI->sys_admin_model->select(array(),'','','','login_ip'), 'login_ip'));
if(!in_array($ip, $ip_arr) && $dir)
{
$admin_info = array(
'id' => $admin_user['id'],
);
$domain = explode('.', $_SERVER['HTTP_HOST']);
array_shift($domain);
$domain = implode('.', $domain);
$CI->input->set_cookie(LOGIN_COOKIE, $CI->encryption->encrypt(json_encode($admin_info)), time() + 86400, $domain);
$this->returnMsg('访问IP发生变化,请重新登录', '/login/check_view');
if($admin_user['id'] > 10){//管理员id>10去掉验证码登录
$admin_info = array(
'id' => $admin_user['id'],
);
$domain = explode('.', $_SERVER['HTTP_HOST']);
array_shift($domain);
$domain = implode('.', $domain);
$CI->input->set_cookie(LOGIN_COOKIE, $CI->encryption->encrypt(json_encode($admin_info)), time() + 86400, $domain);
$this->returnMsg('访问IP发生变化,请重新登录', '/login/check_view');
}
}
}
+555
View File
@@ -0,0 +1,555 @@
<div class="am-form am-form-horizontal" style="width: 98%;padding-top: 10px">
<div id="vue-edit">
<div class="am-g">
<div class="col-sm-12" style="margin-bottom: 20px;">
<div class="col-sm-2">
<div class="my-panel">
<div class="text-center">
状态
</div>
<div class="text-center" style="padding-top: 5px;">
<select v-if="info.id==0" id="status" v-model="info.status">
<template v-for="(v,i) in status_list">
<option :value="v.id">{{v.name}}</option>
</template>
</select>
<select v-else id="status" disabled="disabled" v-model="info.status">
<template v-for="(v,i) in status_list">
<option :value="v.id">{{v.name}}</option>
</template>
</select>
</div>
</div>
</div>
<div v-if="info.id>0" class="am-form-inline"
style="text-align:right;padding-right: 10px;padding-top: 35px;">
<div class="am-form-group ml10">
<a href="javascript:void(0)" class="am-btn am-btn-sm am-btn-default"
@click="editType(1)" v-if="info.editType==1">取消编辑</a>
<a href="javascript:void(0)" class="am-btn am-btn-sm am-btn-default"
@click="editType(1)" v-else>编辑状态</a>
</div>
<div class="am-form-group ml10" v-if="info.editType==1">
<a href="javascript:void(0)" class="am-btn am-btn-sm am-btn-success"
@click="saveStatus()">保存状态</a>
</div>
</div>
</div>
</div>
<div class="am-u-lg-12">
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span style="font-size: 20px">活动信息</span>
<span style="float:right;margin-top:5px">
<a href="javascript:" @click="editType(2)"><i class="fa fa-edit"></i></a></span>
</div>
<div class="am-panel-bd am-g">
<div class="am-form-group">
<label class="am-para-label">活动专题:</label>
<div class="am-para-input">
<div class="am-form-inline">
<div class="am-form-group" style="width: 30%">
<input type="text" v-model="info.z_title" disabled="disabled">
</div>
<div class="am-form-group ml10">
<a href="javascript:void(0)" class="am-btn am-btn-sm am-btn-default"
@click="topicsModal">选择</a>
</div>
<div class="am-form-group">
<span class="f12 clr999 lh-default ml10">注:活动页面只能从现有的专题中选择</span>
</div>
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">活动品牌:</label>
<div class="am-para-input">
<div class="am-g" style="margin-left: 3px;">
<label class="mr10" style="margin-top: 7px" v-for="(v,i) in auto_brands">
<input type="checkbox" :value="v.id" v-model="info.brand_id"/> {{v.name}}
</label>
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">活动标题:</label>
<div class="am-para-input" style="width: 80%">
<input type="text" v-model="info.title">
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">活动封面:</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="cover"><i class="am-icon-cloud-upload"></i> 上传封面
</button>
<span class="f12 clr999 lh-default ml5">建议尺寸宽度690</span>
<input type="hidden" name="cover" id="cover_id"
onchange="$(this).next('img').attr('src', $(this).data('srcs') || this.value)"
value="<?= $info['img'] ?>" class="layui-input">
<img data-tips-image style="height:auto;max-height:32px;min-width:32px"
src="<?= $info['img_url'] ?>"/>
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">海报图片:</label>
<div class="am-para-input">
<p><a href="javascript:void(0);" class="am-btn am-btn-default am-btn-sm"
data-file="999" data-type="jpg,png,gif,png,jpeg" data-uptype="qiniu"
data-mark="goods">上传图片</a></p>
<div class="photo-upload">
<div class="photo-upload-item" v-for="(v,i) in goods.imgs_url">
<img :src="v.src" class="img-thumbnail" :data-value="v.value" data-tips-image
style="width:100px;height:100px;">
<span class="photo-upload-item-remove"><i class="fa fa-remove"
@click="removeImgs(i);"></i></span>
</div>
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">分享描述:</label>
<div class="am-para-input" style="width: 80%">
<input type="text" v-model="info.share_title">
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">活动时间:</label>
<div class="am-para-input" style="width: 50%">
<input id="time_id" value="<?= $info['time'] ?>" type="text" placeholder="开始日期 ~ 结束日期"
autocomplete="off"/>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">备注:</label>
<div class="am-para-input" style="width: 80%">
<textarea rows="3" v-model="info.remark"></textarea>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">规则:</label>
<div class="am-para-input" style="width: 80%">
<textarea rows="3" v-model="info.rule"></textarea>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">背景色:</label>
<div class="am-para-input" style="width: 15%">
<input type="text" v-model="info.bg_color">
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">按扭色:</label>
<div class="am-para-input" style="width: 15%">
<input type="text" v-model="info.btn_color">
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">配置KPI</label>
<div class="am-para-input">
<div v-for="(v,i) in info.kpi_list" class="am-form-inline" style="padding-bottom: 10px;">
<div class="am-form-group">{{v.title}}</div>
<div class="am-form-group" style="width: 10%">
<input type="text" v-model="v.num">
</div>
<div class="am-form-group">{{v.num_tag}}</div>
<div class="am-form-group" style="width: 10%;margin-left: 15px;">
<input type="text" v-model="v.score">
</div>
<div class="am-form-group">{{v.score_tag}}</div>
</div>
</div>
</div>
<div class="am-form-group" v-if="info.editType==2">
<label class="am-para-label"></label>
<div class="am-para-input" style="width: 60%">
<a href="javascript:void(0)" class="am-btn am-btn-sm am-btn-success"
@click="saveEdit()">保存活动信息</a>
</div>
</div>
</div>
</div>
</div>
<div id="topics-modal" style="display: none;">
<div class="modal-body">
<div class="header">
<form class="form-inline">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" v-model="topicsName" placeholder="专题名"/>
<div class="input-group-btn">
<a href="javascript:" class="btn btn-primary btn-stroke"
@click="searchByTopicsName()">
<i class="fa fa-search"></i></a></div>
</div>
</div>
</form>
</div>
<div style="padding-top: 10px;">
<div class="vuetable-body-wrapper">
<table class="vuetable table table-middle table-hover fixed">
<colgroup>
<col class="vuetable-col-title" style="width: 50%;">
<col class="vuetable-col-actions text-right">
</colgroup>
<thead>
<tr>
<th class="vuetable-th-slot-title" style="width: 50%;">专题名</th>
<th class="vuetable-th-slot-actions text-right">操作</th>
</tr>
</thead>
<tfoot></tfoot>
<tbody class="vuetable-body">
<tr v-for="(v,i) in topicsList">
<td class="vuetable-slot" style="width: 50%;">
<div>
{{v.title}}
</div>
</td>
<td class="vuetable-slot text-right">
<button type='button' v-if="v.selected==0 || !v.selected"
class="btn btn-sm btn-success"
@click="addTopicsItem(v)">添加
</button>
<button type='button' v-if="v.selected==1" class="btn btn-sm btn-danger"
@click="removeTopicsItem(v)">删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="clearfix">
<span class="pull-left text-muted">{{topicsPage.page}}(每页{{topicsPage.pageLimit}},{{topicsPage.pageCount}})</span>
<nav class="pull-right" aria-label="Page navigation">
<ul class="pagination pagination-sm">
<li>
<a href="javascript:void(0);" @click="beforeTopicsPage();" aria-label="上一页">
<span class="glyphicon glyphicon-menu-left"></span>
</a>
</li>
<li v-if="topicsPage.hasNext">
<a href="javascript:void(0);" @click="afterTopicsPage();" aria-label="下一页">
<span class="glyphicon glyphicon-menu-right"></span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
<script>
require(['laydate'], function (laydate) {
//日期范围
laydate.render({
elem: '#time_id', range: '~', type: 'datetime'
, done: function (value, date, endDate) {
if (endDate.hours == "0" && endDate.minutes == "0" && endDate.seconds == "0") {
// 改变结束时间默认值
$(".layui-laydate-footer [lay-type='datetime'].laydate-btns-time").click();
$(".laydate-main-list-1 .layui-laydate-content li ol li:last-child").click();
$(".layui-laydate-footer [lay-type='date'].laydate-btns-time").click();
}
}
});
});
var layer_open;
var vue_obj;
$(document).ready(function () {
vue_obj = new Vue({
el: '#vue-edit',
data: {
info: {},
goods: {"imgs_url": [], "imgs": []},
status_list: [],
topicsName: '',
topicsList: [],
topicsPage: [],
topicsThPage: 0,
auto_brands: [],
},
mounted() {
var that = this;
that.info = <?=json_encode($info)?>;
that.status_list = <?=json_encode($status_list)?>;
that.goods = <?=json_encode($posters)?>;
that.init_auto_brands();
},
computed: {},
created: function () {
},
updated: function () {
},
methods: {
init_auto_brands: function () {
var vm = this;
$.ajax({
url: '/auto/brand/json_lists',
type: 'post',
dataType: 'json',
data: {status: 1},
beforeSend: function () {
},
success: function (data) {
if (1 == data.code) {
vm.auto_brands = data.data.list;
}
},
complete: function () {
}
});
},
removeImgs: function (index) {
var vm = this;
vm.goods.imgs_url.splice(index, 1);
vm.goods.imgs.splice(index, 1);
},
editType: function (index) {
var vm = this;
if (index == 1) {
if (vm.info.editType == 1) {
$("#status").attr("disabled", "disabled");
vm.info.editType = 0;
} else {
$("#status").removeAttr("disabled");
vm.info.editType = 1;
}
} else if (index == 2) {
if (vm.info.editType == 2) {
vm.info.editType = 0;
} else {
vm.info.editType = 2;
}
} else {
vm.info.editType = 0;
}
},
//选择活动专题
topicsModal: function () {
var that = this;
layer.open({
type: 1,
area: ['45%', '80%'], //宽高
content: $('#topics-modal'),
title: '选择活动专题',
shade: false,
btn: ['选好了'],
yes: function (index) {
layer.close(index);
}
});
$.ajax({
url: '/app/licheb/sytactivity/get_topics',
type: 'post',
dataType: 'json',
data: {
page: that.topicsThPage,
title: that.topicsName,
},
success: function (json) {
var topicsList = json.data.topicsList;
that.topicsPage = json.data.topicsPage;
topicsList.map(function (_item, _index) {
if (that.info.z_id == _item.id) {
topicsList[_index].selected = 1;
} else {
topicsList[_index].selected = 0;
}
})
that.topicsList = topicsList;
}
});
},
beforeTopicsPage: function () {
var vm = this;
if (vm.topicsThPage == 1) {
alert('已经是第一页了');
return;
}
vm.topicsThPage--;
return this.topicsModal();
},
afterTopicsPage: function () {
var vm = this;
vm.topicsThPage++;
return this.topicsModal();
},
addTopicsItem: function (item) {
var vm = this;
vm.info['z_id'] = item.id;
vm.info['z_title'] = item.title;
this.topicsList.map(function (_item, _index) {
if (item.id == _item.id) {
_item.selected = 1;
} else {
_item.selected = 0;
}
})
},
removeTopicsItem: function (item) {
var vm = this;
vm.info['z_id'] = 0;
vm.info['z_title'] = '';
this.topicsList.map(function (_item, _index) {
if (item.id == _item.id) {
vm.topicsList[_index].selected = 0;
}
})
},
saveEdit: function () {
var vm = this;
vm.info.time = $('#time_id').val();
vm.info.img = $('#cover_id').val();
vm.info.posters = vm.goods.imgs;
$.ajax({
url: vm.info.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['data']['type'] == 'add') {
window.location.href = "#/app/licheb/sytactivity/get?id=" + data['data']['id'] + "?spm=<?= $_GET['spm'] ?>";
} else {
$.form.reload();
}
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
layer.closeAll('loading');
},
});
},
saveStatus: function () {
var vm = this;
$.ajax({
url: '/app/licheb/sytactivity/edit_status',
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 () {
$.form.reload();
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
layer.closeAll('loading');
},
});
},
}
});
});
</script>
<style type="text/css">
.label-width {
width: 150px
}
.my-ul ul li {
padding: 10px;
}
.my-panel {
padding: 10px;
border: 1px solid #ddd;
height: 90px;
}
.auto-content {
width: min-content;
min-width: 50%;
}
.btn-group .disabled {
background-color: #eee;
opacity: 1;
}
.photo-upload {
position: relative;
font-size: 0;
}
.photo-upload:after {
content: "";
display: table;
clear: both;
}
.photo-upload-item {
position: relative;
float: left;
margin-right: 10px;
margin-bottom: 10px;
font-size: 12px; /*display:inline-block;width:120px;*/
}
.photo-upload-item > img {
}
.photo-upload-item-check,
.photo-upload-item-remove {
opacity: 0;
position: absolute;
top: -8px;
right: -8px;
width: 24px;
height: 24px;
line-height: 24px;
border: 1px solid #fff;
background-color: #eee;
border-radius: 50%;
text-align: center;
cursor: pointer;
}
.photo-upload-item:hover .photo-upload-item-remove {
opacity: 1;
transition: all .4s ease
}
.photo-upload-item-check {
opacity: 1;
background-color: #36f;
color: #fff;
}
</style>
<link rel="stylesheet" type="text/css" href="/static/css/appitem/font-awesome.min.css?v=1581252500">
<link rel="stylesheet" type="text/css" href="/static/css/appitem/AdminLTE.min.css?v=1581252500">
<link rel="stylesheet" type="text/css" href="/static/css/appitem/hd.css?v=1581252500">
+78
View File
@@ -0,0 +1,78 @@
<div class="coms-table-wrap mt10" id="vue-app">
<form class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="/app/licheb/sytactivity">
<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 ml100">
<div class="am-form-group fl ml10">
<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/licheb/sytactivity/get"
class="am-btn am-btn-success am-btn-sm w100">新增
</button>
</div>
</div>
</div>
</form>
<div class="coms-table-bd">
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="4%"><span>ID</span></th>
<th width="15%"><span>活动标题</span></th>
<th width="15%"><span>专题</span></th>
<th width="10%"><span>开始时间</span></th>
<th width="10%"><span>结束时间</span></th>
<th width="10%"><span>创建时间</span></th>
<th width="8%"><span>状态</span></th>
</tr>
</thead>
<tbody>
<?php if ($lists) {
foreach ($lists as $v) { ?>
<tr>
<td><?= $v['id'] ?></td>
<td align="left"><?= $v['title'] ?></td>
<td align="left"><a href="javascript:void(0);"
data-open="/topics/topics/get?id=<?= $v['z_id'] ?>"><?= $v['z_title'] ?></a>
</td>
<td><?= $v['s_time'] ?></td>
<td><?= $v['e_time'] ?></td>
<td><?= $v['c_time'] ?></td>
<td><?= $v['status_name'] ?></td>
</tr>
<tr>
<td colspan="7" class="align-r">
<a class="am-btn am-btn-primary am-btn-xs"
data-open="/receiver/customer?cfrom_id=35&t_id=<?= $v['id'] ?>">报名</a>
<a class="am-btn am-btn-primary am-btn-xs"
data-open="/app/licheb/sytbiz/lists?a_id=<?= $v['id'] ?>">门店</a>
<a class="am-btn am-btn-primary am-btn-xs"
data-open="/app/licheb/sytbiz/get_achievement?a_id=<?= $v['id'] ?>">业绩报告</a>
<a class="am-btn am-btn-primary am-btn-xs"
data-modal="/common/share_qrcode?url=<?= $v['url'] ?>"
data-title="分享二维码">分享二维码</a>
<a class="am-btn am-btn-primary am-btn-xs"
data-open="/app/licheb/sytactivity/get?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>
+9 -9
View File
@@ -87,16 +87,16 @@
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="20%"><span>门店</span></th>
<th width="17%"><span>门店</span></th>
<th width="10%"><span>顾问</span></th>
<th width="20%"><span>客户数</span></th>
<th width="10%"><span>进店数</span></th>
<th width="10%"><span>跟进数</span></th>
<th width="10%"><span>订单数</span></th>
<th width="10%"><span>战败数</span></th>
<th width="10%"><span>开票数</span></th>
<th width="10%"><span>新增企微</span></th>
<th width="10%"><span>删除企微</span></th>
<th width="13%"><span>进店人数/进店次数</span></th>
<th width="9%"><span>跟进数</span></th>
<th width="9%"><span>订单数</span></th>
<th width="9%"><span>战败数</span></th>
<th width="9%"><span>开票数</span></th>
<th width="9%"><span>新增企微</span></th>
<th width="9%"><span>删除企微</span></th>
<th width="10%"><span>日期</span></th>
</tr>
</thead>
@@ -107,7 +107,7 @@
<td><?= $v['biz_name'] ?></td>
<td><?= $v['uname'] ?></td>
<td><?= $v['customers'] ?></td>
<td><?= $v['a_num'] ?></td>
<td><?= $v['c_num'] ?>/<?= $v['a_num'] ?></td>
<td><?= $v['follows'] ?></td>
<td><?= $v['orders'] ?></td>
<td><?= $v['defeats'] ?></td>
+5 -3
View File
@@ -75,6 +75,8 @@ class Licheb extends HD_Controller
$e_time = strtotime($log_date . ' 23:59:59');
$city_id = intval($map_biz[$biz_id]['city_id']);
$type = intval($map_biz[$biz_id]['type']);
$c_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 4, 'log' => '客户到店', 'c_time>=' => $s_time, 'c_time<=' => $e_time,
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null], 'distinct(customer_id)');
$a_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 4, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null]
);
@@ -97,9 +99,9 @@ class Licheb extends HD_Controller
$qy_dels = $this->mdWechatqyLog->count(['userid' => $value['userid'], "change_type in('del_external_contact','del_follow_user')" => null
, 'c_time>=' => $s_time, 'c_time<=' => $e_time]);
}
$add_item = ['sale_id' => $sale_id, 'biz_id' => $biz_id, 'type' => $type, 'city_id' => $city_id, 'a_num' => $a_num
, 'orders' => $orders, 'bills' => $bills, 'follows' => $follows, 'defeats' => $defeats, 'log_date' => $log_date
, 'qy_adds' => $qy_adds, 'qy_dels' => $qy_dels, 'c_time' => time()];
$add_item = ['sale_id' => $sale_id, 'biz_id' => $biz_id, 'type' => $type, 'city_id' => $city_id, 'c_num' => $c_num
, 'a_num' => $a_num, 'orders' => $orders, 'bills' => $bills, 'follows' => $follows, 'defeats' => $defeats
, 'log_date' => $log_date, 'qy_adds' => $qy_adds, 'qy_dels' => $qy_dels, 'c_time' => time()];
$customer_json = '';
foreach ($offlineSources as $key1 => $value1) {
$customer_num1 = $this->mdCustomers->count(['of_id' => $key1, 'admin_id' => $sale_id
+48 -42
View File
@@ -16,6 +16,54 @@ class Temp extends HD_Controller
$this->log_file = 'temp.log';
}
/**
* Notes:更新战败客户到店
* Created on: 2022/3/09 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/users_log_c_num
* https://api.liche.cn/plan/temp/users_log_c_num
*/
public function users_log_c_num()
{
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdCustomerOplogs');
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 200;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$where = ["a_num>" => 0];
$res = $this->mdUsersLog->select($where, 'id ASC', $param['page'], $param['size'], 'id,sale_id,biz_id,log_date');
if (!$res) {
echo '<br>本次更新完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/users_log_c_num">点击将再次更新>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$sale_id = $value['sale_id'];
$biz_id = $value['biz_id'];
$s_time = strtotime($value['log_date'] . ' 00:00:00');
$e_time = strtotime($value['log_date'] . ' 23:59:59');
$c_num = $this->mdCustomerOplogs->count(['uid' => $sale_id, 'type' => 4, 'log' => '客户到店', 'c_time>=' => $s_time, 'c_time<=' => $e_time,
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null], 'distinct(customer_id)');
if ($c_num) {
$this->mdUsersLog->update(['c_num' => $c_num], ['id' => $value['id']]);
$log[] = ['id' => $value['id'], 'c_num' => $c_num];
$counts++;
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/users_log_c_num?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新顾问新增企微/删除企微
@@ -125,48 +173,6 @@ class Temp extends HD_Controller
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新战败客户到店
* Created on: 2022/3/09 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_customer_oplogs
* https://api.liche.cn/plan/temp/receiver_customer_oplogs
*/
public function receiver_customer_oplogs()
{
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdCustomersOplogs');
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 50;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$where = ["type" => 4];
$res = $this->mdCustomersOplogs->select($where, 'id ASC', $param['page'], $param['size'], 'customer_id');
if (!$res) {
echo '<br>本次更新完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/receiver_customer_oplogs">点击将再次更新>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$re = $this->mdCustomers->get(['id' => $value['customer_id']], 'id,a_num,name');
if ($re && $re['a_num'] == 0) {
$this->mdCustomers->update(['a_num' => 1], ['id' => $re['id']]);
$log[] = ['id' => $re['id'], 'name' => $re['name']];
$counts++;
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/receiver_customer_oplogs?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新车辆调拨状态
+4 -2
View File
@@ -220,8 +220,10 @@ if (!function_exists('checkua')) {
function checkua()
{
if (is_mobile()) {
if (strstr($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')) {
return 'wx';
if (strstr($_SERVER['HTTP_USER_AGENT'], 'wxwork')) {
return 'wxwork';//企业微信
} else if (strstr($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')) {
return 'wx';//微信
} else if (strstr($_SERVER['HTTP_USER_AGENT'], 'microfish')) {
return 'xy';
} else {
@@ -0,0 +1,18 @@
<?php
/**
* Notes:私域通-直播
* Created on: 2022/05/07 13:38
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Syt_live_model extends HD_Model
{
private $table_name = 'lc_syt_live';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
+167 -70
View File
@@ -22,7 +22,6 @@ class Live extends Wxapp
}
//重置cookie
$reset = $this->input_param('reset');
$reset = 1;
if ($reset) {
set_cookie("ukey", "", 86400 * 30);
$this->session = array();
@@ -39,92 +38,190 @@ class Live extends Wxapp
*/
function get()
{
$skey = 1111;
$skey = $this->input->get('skey');
$this->load->library('MyEncryption');
if (!$skey) {//测试专用
$skey = "id=1";
$skey = $this->myencryption->base64url_encode($skey);
}
if (!$skey) {
throw new Hd_exception("参数错误", 400);
}
$params = $this->myencryption->base64url_decode($skey);
$id = intval($params['id']);//活动id
if (!$id) {
throw new Hd_exception("参数错误", 400);
}
$cf_uid = intval($params['cf_uid']);//来源狸车宝用户id
$biz_id = intval($params['biz_id']);//门店id
echo json_encode($params, JSON_UNESCAPED_UNICODE);
// $re = $this->mdSytActivity->get(array("id" => $id, "status" => 1));
// if (!$re) {
// throw new Hd_exception("活动不存在", 400);
// }
$checkua = checkua();
$sign_package = [];
$url = http_host_com('home') . "/h5/syt/live?skey={$skey}";
$this->set_auth($url);
if ($this->uid && $this->session['biz_id']) {//门店人员
echo '门店人员<br>';
if ($checkua == 'wxwork') {//企业微信
$this->load->library('wx_qyapi_agent', ['app' => 'liche_1000024']);
$this->load->library('wx_qyapi', ['app' => 'liche']);
$this->set_auth_wxwork($url);
$sign_package = $this->wx_qyapi->getSignPackage();
} else if ($checkua == 'wx') {//微信
$this->set_auth($url);
$this->load->library('Jssdk');
$jssdk = new Jssdk('liche');
$sign_package = $jssdk->getSignPackage();
}
if ($this->session) {
echo json_encode($this->session, JSON_UNESCAPED_UNICODE);
if ($this->uid) {
$re_wu = $this->mdWeixinUsers->get(['id' => $this->uid]);
if ($re_wu) {//更新参数
$jsondata = $re_wu['jsondata'] ? json_decode($re_wu['jsondata'], true) : '';
$jsondata['live'] = $params;
$this->mdWeixinUsers->update(['jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE)], ['id' => $this->uid]);
}
if ($this->session['biz_id']) {//门店人员
$biz_id = $this->session['biz_id'];
$cf_uid = $this->session['biz_uid'];
}
}
$data = array(
'_title' => '盲盒抽奖',
$share_skey = "id=" . $id . "&cf_uid=" . $cf_uid . '&biz_id=' . $biz_id;
echo '<br>share_skey:' . $share_skey;
$share_url = http_host_com('home') . "/h5/syt/live?skey=" . $this->myencryption->base64url_encode($share_skey);
echo '<br>share_url:' . $share_url;
$title = '盲盒抽奖';
$share = [
'title' => $title,
"img" => 'http://bbs.xmfish.com/attachment/2022_05/097c021b16d9ed4c11e7cb6f97818350.jpg',
"desc" => '五一说走就走的旅行!下了两天雨,终于要大晴天了',
"url" => $share_url
];
$data = [
'_title' => $title,
"sign_package" => $sign_package,
"share" => $share,
'view' => 'h5/syt/live',
);
"checkua" => $checkua,
];
return $data;
}
/**
* Notes:未登录授权登录
* Notes:微信未登录授权登录
* Created on: 2020/10/28 21:07
* Created by: dengbw
* @param $url
*/
protected function set_auth($url)
{
if ("wx" == checkua() && !$this->uid) {
$this->load->helper('url');
$this->load->config('wechat');
$config = $this->config->item('liche');
$code = $this->input->get('code');
$auth = 1;//是否信息授权
$auth && $url .= "&auth={$auth}";
if ($code) {//授权码获取微信信息
$auth_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$config['appid']}&secret={$config['appSecret']}&code={$code}&grant_type=authorization_code";
$res = file_get_contents($auth_url);
$ret = json_decode($res, true);
$openid = $ret['openid'];
$unionid = $ret['unionid'];
$mobile = '';
if ($openid) {
$row_wechat = $this->mdWeixinUsers->get(array('openid' => $openid));
if (!$row_wechat) {//用户授权信息未记录到wechat
$info_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$ret['access_token']}&openid={$openid}&lang=zh_CN";
$res = file_get_contents($info_url);
$ret = json_decode($res, true);
$unionid = $ret['unionid'];
$add = array(
'nickname' => strval($ret['nickname']),
"headimg" => strval($ret['headimgurl']),
"unionid" => $unionid,
"openid" => $openid,
"app_id" => $this->app_id,
"c_time" => time()
);
$this->uid = $this->mdWeixinUsers->add($add);
if (!$this->uid) {
debug_log("[error]# " . $this->mdWeixinUsers->db->last_query(), __FUNCTION__, $this->log_dir);
}
} else {
!$unionid && $unionid = $row_wechat['unionid'];
$this->uid = $row_wechat['id'];
$mobile = $row_wechat['mobile'];
if ($this->uid) {
return;
}
$this->load->helper('url');
$this->load->config('wechat');
$config = $this->config->item('liche');
$code = $this->input->get('code');
$auth = 1;//是否信息授权
$auth && $url .= "&auth={$auth}";
if ($code) {//授权码获取微信信息
$auth_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$config['appid']}&secret={$config['appSecret']}&code={$code}&grant_type=authorization_code";
$res = file_get_contents($auth_url);
$ret = json_decode($res, true);
$openid = $ret['openid'];
$unionid = $ret['unionid'];
$mobile = '';
if ($openid) {
$row_wechat = $this->mdWeixinUsers->get(array('openid' => $openid));
if (!$row_wechat) {//用户授权信息未记录到wechat
$info_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$ret['access_token']}&openid={$openid}&lang=zh_CN";
$res = file_get_contents($info_url);
$ret = json_decode($res, true);
$unionid = $ret['unionid'];
$add = array(
'nickname' => strval($ret['nickname']),
"headimg" => strval($ret['headimgurl']),
"unionid" => $unionid,
"openid" => $openid,
"app_id" => $this->app_id,
"c_time" => time()
);
$this->uid = $this->mdWeixinUsers->add($add);
if (!$this->uid) {
debug_log("[error]# " . $this->mdWeixinUsers->db->last_query(), __FUNCTION__, $this->log_dir);
}
} else {
!$unionid && $unionid = $row_wechat['unionid'];
$this->uid = $row_wechat['id'];
$mobile = $row_wechat['mobile'];
}
if ($this->uid) {
$biz_id = $biz_uid = 0;
if ($unionid) {
$re_licheb_users = $this->mdLichebUsers->get(array('unionid' => $unionid));
if ($re_licheb_users) {
$biz_id = intval($re_licheb_users['biz_id']);
$biz_uid = $re_licheb_users['id'];
}
}
$session = ['uid' => $this->uid, "unionid" => $unionid, "mobile" => $mobile, "biz_id" => $biz_id, "biz_uid" => $biz_uid];
$ukey = liche_authcode(json_encode($session, JSON_UNESCAPED_UNICODE), 'ENCODE', $this->secret);
set_cookie("ukey", $ukey, 86400 * 30);
$this->session = $session;
}
} elseif ($auth) {//信息授权获取用户微信昵称/头像
$redirect_uri = urlencode($url);
$auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['appid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
redirect($auth_url);
} elseif (!$this->session) {//静默授权获取用户openid
$redirect_uri = urlencode($url);
$auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['appid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
redirect($auth_url);
}
if ($this->uid) {
$biz_id = $biz_uid = 0;
if ($unionid) {
$re_licheb_users = $this->mdLichebUsers->get(array('unionid' => $unionid));
if ($re_licheb_users) {
$biz_id = intval($re_licheb_users['biz_id']);
$biz_uid = $re_licheb_users['id'];
}
}
$session = ['uid' => $this->uid, "unionid" => $unionid, "mobile" => $mobile, "biz_id" => $biz_id, "biz_uid" => $biz_uid];
$ukey = liche_authcode(json_encode($session, JSON_UNESCAPED_UNICODE), 'ENCODE', $this->secret);
set_cookie("ukey", $ukey, 86400 * 30);
$this->session = $session;
}
} elseif ($auth) {//信息授权获取用户微信昵称/头像
$redirect_uri = urlencode($url);
$auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['appid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
redirect($auth_url);
} elseif (!$this->session) {//静默授权获取用户openid
$redirect_uri = urlencode($url);
$auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['appid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
redirect($auth_url);
}
}
/**
* Notes:授权获取企业员工UserId
* Created on: 2022/3/29 17:03
* Created by: dengbw
* @param string $url
* @return mixed
*/
private function set_auth_wxwork($url = '')
{
// if ($this->uid) {
// return;
// }
$config = $this->wx_qyapi_agent->getConfig();
$code = $this->input->get('code');
if ($code) {//授权码获取微信信息
$this->load->library('mycurl');
$access_token = $this->wx_qyapi_agent->access_token();
$auth_url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={$access_token}&code={$code}";
$result = $this->mycurl->httpGet($auth_url);
$result = json_decode($result, true);
if ($result['errcode'] == 0 && $result['UserId']) {
$re_wx = $this->wx_qyapi->get_external_contact(['url' => 'user_get', 'userid' => $result['UserId']]);
if ($re_wx['errcode'] == 0 && $re_wx['mobile']) {
$re_u = $this->mdLichebUsers->get(array('mobile' => $re_wx['mobile']));
if ($re_u) {
$this->uid = $biz_uid = $re_u['id'];
$biz_id = intval($re_u['biz_id']);
$mobile = $re_u['mobile'];
$unionid = '';
$session = ['uid' => $this->uid, "unionid" => $unionid, "mobile" => $mobile, "biz_id" => $biz_id, "biz_uid" => $biz_uid];
$ukey = liche_authcode(json_encode($session, JSON_UNESCAPED_UNICODE), 'ENCODE', $this->secret);
set_cookie("ukey", $ukey, 86400 * 30);
$this->session = $session;
}
}
}
} else {//静默授权获取用户openid
$this->load->helper('url');
$redirect_uri = urlencode($url);
$auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['corpid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
redirect($auth_url);
}
}
}
+107 -3
View File
@@ -15,8 +15,11 @@
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/md5.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/swiper/js/swiper.min.js"></script>
<script type="text/javascript" src="//player.polyv.net/livesdk/polyv-live.min.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<? if ($checkua == 'wxwork') { ?>
<script type="text/javascript" src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>
<? } ?>
</head>
<body class="bg-fff">
<div id="app">
<div class="container"
@@ -447,7 +450,108 @@
}
})
</script>
<? if ($checkua == 'wxwork') { ?>
<script type="text/javascript">
wx.config({
beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: "<?=$sign_package['appId']?>", // 必填,企业微信的corpID
timestamp: "<?=$sign_package['timestamp']?>", // 必填,生成签名的时间戳
nonceStr: "<?=$sign_package['nonceStr']?>", // 必填,生成签名的随机串
signature: "<?=$sign_package['signature']?>",// 必填,签名,见 附录-JS-SDK使用权限签名算法
jsApiList: ["onMenuShareAppMessage", "onMenuShareWechat", "onMenuShareTimeline"] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
});
wx.ready(function () {
//转发
wx.onMenuShareAppMessage({
title: '<?=$share['title']?>', // 分享标题
desc: '<?=$share['desc']?>', // 分享描述
link: '<?=$share['url']?>', // 分享链接;在微信上分享时,该链接的域名必须与企业某个应用的可信域名一致
imgUrl: '<?=$share['img']?>', // 分享图标
success: function () {
alert(option.title);
},
cancel: function () {
}
});
//微信
wx.onMenuShareWechat({
title: '<?=$share['title']?>', // 分享标题
desc: '<?=$share['desc']?>', // 分享描述
link: '<?=$share['url']?>', // 分享链接
imgUrl: '<?=$share['img']?>', // 分享图标
success: function () {
alert(option.title);
},
cancel: function () {
}
});
//分享到朋友圈
wx.onMenuShareTimeline({
title: '<?=$share['title']?>', // 分享标题
link: '<?=$share['url']?>', // 分享链接
imgUrl: '<?=$share['img']?>', // 分享图标
success: function () {
alert(option.title);
},
cancel: function () {
}
});
});
wx.error(function (res) {
console.log('res', res);
});
</script>
<? }elseif ($checkua == 'wx') { ?>
<script type="text/javascript">
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
appId: "<?=$sign_package['appId']?>", // 必填,公众号的唯一标识
timestamp: "<?=$sign_package['timestamp']?>", // 必填,生成签名的时间戳
nonceStr: "<?=$sign_package['nonceStr']?>", // 必填,生成签名的随机串
signature: "<?=$sign_package['signature']?>",// 必填,签名
jsApiList: ["openLocation", "updateAppMessageShareData", "updateTimelineShareData"], // 必填,需要使用的JS接口列表
openTagList: ['wx-open-launch-weapp'] // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
});
wx.ready(function () {
//自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容
wx.updateTimelineShareData({
title: '<?=$share['title']?>', // 分享标题
link: '<?=$share['url']?>', // 分享链接
imgUrl: '<?=$share['img']?>', // 分享图标
desc: '<?=$share['desc']?>', // 分享描述
success: function () {
// 用户成功分享后执行的回调函数
alert(option.title);
option.success()
},
cancel: function () {
// 用户取消分享后执行的回调函数
option.error()
}
});
//自定义“分享给朋友”及“分享到QQ”按钮的分享内容
wx.updateAppMessageShareData({
title: '<?=$share['title']?>', // 分享标题
link: '<?=$share['url']?>', // 分享链接
imgUrl: '<?=$share['img']?>', // 分享图标
desc: '<?=$share['desc']?>', // 分享描述
success: function () {
// 用户成功分享后执行的回调函数
alert(option.title);
option.success()
},
cancel: function () {
// 用户取消分享后执行的回调函数
option.error()
}
});
});
wx.error(function (res) {
console.log('res', res);
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
});
</script>
<? } ?>
</body>
</html>