lichene_325
This commit is contained in:
@@ -21,6 +21,20 @@ Class Lichene extends HD_Controller
|
||||
echo 'index';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* https://liche-api-dev.xiaoyu.com/wechat/lichene/temp
|
||||
* https://api.liche.cn/wechat/lichene/temp
|
||||
* Created on: 2022/3/25 17:37
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function temp()
|
||||
{
|
||||
$this->load->library('wx_qyapi', ['app' => 'lichene']);
|
||||
$re_wx = $this->wx_qyapi->getSignPackage();
|
||||
echo json_encode($re_wx, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:企业微信接收事件
|
||||
* https://liche-api-dev.xiaoyu.com/wechat/lichene/get_qymsg
|
||||
@@ -72,11 +86,13 @@ Class Lichene extends HD_Controller
|
||||
if ($errCode == 0) {
|
||||
$this->load->model('app/app_lichene_qy_model', 'mdWechatqy');
|
||||
$re_msg = (array)simplexml_load_string($sMsg, 'SimpleXMLElement', LIBXML_NOCDATA);//xml转json
|
||||
debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
exit;
|
||||
$ExternalUserID = $re_msg['ExternalUserID'];
|
||||
$ChangeType = $re_msg['ChangeType'];
|
||||
debug_log('qymsg_ChangeType:' . $ChangeType, $this->log_file);
|
||||
$this->load->library('wx_qyapi', ['app' => 'lichene']);
|
||||
if ($ChangeType == 'add_external_contact') {//添加企业客户事件
|
||||
if ($ChangeType == 'add_external_contact' || $ChangeType == 'edit_external_contact') {//添加/修改企业客户事件
|
||||
$re = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $ExternalUserID));
|
||||
//debug_log('qymsg_external_errcode:' . $re['errcode'] . '&external_userid=' . $re['external_contact']['external_userid'], $this->log_file);
|
||||
if ($re['errcode'] == 0) {
|
||||
@@ -86,17 +102,24 @@ Class Lichene extends HD_Controller
|
||||
$jsondata['external_contact'] = $re['external_contact'] ? $re['external_contact'] : '';
|
||||
$jsondata['follow_user'] = $re['follow_user'] ? $re['follow_user'] : '';
|
||||
$tags_ary = $re['follow_user'][0]['tags'];
|
||||
$tags = '';
|
||||
$remark_mobiles = $re['follow_user'][0]['remark_mobiles'];
|
||||
$tags = $mobile = '';
|
||||
$tag_ids = [];
|
||||
if ($tags_ary && $tags_ary != '[]' && is_array($tags_ary)) {
|
||||
$tags = implode(',', array_column($tags_ary, 'tag_id'));
|
||||
$tags = implode(',', array_column($tags_ary, 'tag_name'));
|
||||
$tag_ids = array_column($tags_ary, 'tag_id');
|
||||
}
|
||||
if ($remark_mobiles && $remark_mobiles != '[]' && is_array($remark_mobiles)) {
|
||||
$mobile = $remark_mobiles[0];//取第一个手机号
|
||||
}
|
||||
$addData = array(
|
||||
'external_userid' => $re['external_contact']['external_userid'],
|
||||
'name' => $re['external_contact']['name'],
|
||||
'avatar' => $re['external_contact']['avatar'],
|
||||
'name' => $re['external_contact']['name'] ? $re['external_contact']['name'] : '',
|
||||
'avatar' => $re['external_contact']['avatar'] ? $re['external_contact']['avatar'] : '',
|
||||
'unionid' => $re['external_contact']['unionid'] ? $re['external_contact']['unionid'] : '',
|
||||
'userid' => $re['follow_user'][0]['userid'] ? $re['follow_user'][0]['userid'] : '',
|
||||
'remark' => $re['follow_user'][0]['remark'] ? $re['follow_user'][0]['remark'] : '',
|
||||
'mobile' => $mobile,
|
||||
'tags' => $tags,
|
||||
'c_time' => $re['follow_user'][0]['createtime'] ? $re['follow_user'][0]['createtime'] : time(),
|
||||
'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
|
||||
@@ -105,17 +128,15 @@ Class Lichene extends HD_Controller
|
||||
if (!$re_qy) {
|
||||
$this->mdWechatqy->add($addData);
|
||||
} else {
|
||||
$this->mdWechatqy->update($addData, array('external_userid' => $external_userid));
|
||||
$this->mdWechatqy->update($addData, array('id' => $re_qy['id']));
|
||||
}
|
||||
//debug_log('qymsg_get2:' . json_encode($re, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
$this->set_customers(['name' => $addData['name'], 'mobile' => $addData['mobile'], 'unionid' => $addData['unionid']
|
||||
, 'userid' => $addData['userid'], 'tag' => $tag_ids]);
|
||||
//debug_log('qymsg_addData:' . json_encode($addData, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
}
|
||||
}
|
||||
debug_log('qymsg_get:' . json_encode($re, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
} else if ($ChangeType == 'update') {//修改企业客户事件
|
||||
debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
// $re = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $ExternalUserID));
|
||||
// debug_log('qymsg_external_errcode:' . $re['errcode'] . '&external_userid=' . $re['external_contact']['external_userid'], $this->log_file);
|
||||
// debug_log('qymsg_get:' . json_encode($re, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
} else if ($ChangeType == 'del_follow_user') {//删除企业客户事件
|
||||
if ($ExternalUserID) {
|
||||
$re_qy = $this->mdWechatqy->get(array('external_userid' => $ExternalUserID));
|
||||
@@ -123,12 +144,153 @@ Class Lichene extends HD_Controller
|
||||
$this->mdWechatqy->update(array('status' => -1), array('id' => $re_qy['id']));
|
||||
}
|
||||
}
|
||||
} else if ($ChangeType == 'update') {
|
||||
debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
// $re = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $ExternalUserID));
|
||||
// debug_log('qymsg_external_errcode:' . $re['errcode'] . '&external_userid=' . $re['external_contact']['external_userid'], $this->log_file);
|
||||
// debug_log('qymsg_get:' . json_encode($re, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
} else if ($ChangeType == 'delete') {
|
||||
debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
} else if ($ChangeType == 'shuffle') {
|
||||
debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
}
|
||||
//debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:新增/修改门店客户
|
||||
* Created on: 2022/3/25 10:06
|
||||
* Created by: dengbw
|
||||
* @param $param
|
||||
*/
|
||||
private function set_customers($param)
|
||||
{
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
$this->load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag');
|
||||
$this->load->model('receiver/receiver_customer_tagdata_model', 'mdCustomerTagdata');
|
||||
$re_cus = $this->mdCustomers->get(['unionid' => $param['unionid'], 'status<>' => -1]);
|
||||
if ($re_cus) {//修改
|
||||
$c_id = $re_cus['id'];
|
||||
if ($param['mobile']) {
|
||||
if (!$re_cus['mobile']) {//更新手机
|
||||
$re_cus2 = $this->mdCustomers->get(['biz_id' => $re_cus['biz_id'], 'mobile' => $param['mobile'], 'stats<>' => -1]);
|
||||
if ($re_cus2) {//合并用户
|
||||
$this->mdCustomers->update(['stats' => -1], ['id' => $re_cus['id']]);//删除原有数据
|
||||
$c_id = $re_cus2['id'];
|
||||
$this->mdCustomers->update(['unionid' => $param['unionid']], ['id' => $re_cus2['id']]);//合并到现有手机
|
||||
} else {
|
||||
$this->mdCustomers->update(['mobile' => $param['mobile']], ['id' => $re_cus['id']]);//更新手机
|
||||
}
|
||||
} else if ($re_cus['mobile'] != $param['mobile']) {//更改手机了 暂不处理
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$biz_id = $city_id = $county_id = 0;
|
||||
if ($param['userid']) {//读取成员
|
||||
$this->load->library('wx_qyapi', ['app' => 'lichene']);
|
||||
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'user_get', 'userid' => $param['userid']));
|
||||
if ($re_wx['errcode'] == 0 && $re_wx['mobile']) {
|
||||
$this->load->model('app/licheb/App_licheb_users_model', 'mdUsers');
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$re_u = $this->mdUsers->get(array('mobile' => $re_wx['mobile']));
|
||||
if ($re_u['biz_id']) {
|
||||
$biz_id = $re_u['biz_id'];
|
||||
$re_biz = $this->mdBiz->get(['id' => $re_u['biz_id'], 'status' => 1]);
|
||||
if ($re_biz) {
|
||||
$city_id = $re_biz['city_id'];
|
||||
$county_id = $re_biz['county_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$add_data = [
|
||||
'name' => $param['name'],
|
||||
'mobile' => $param['mobile'],
|
||||
'biz_id' => $biz_id,
|
||||
'city_id' => $city_id,
|
||||
'county_id' => $county_id,
|
||||
'unionid' => $param['unionid'],
|
||||
'cf_title' => '自有资源',
|
||||
'p_time' => date('Y-m-d H:i:s'),
|
||||
'c_time' => time()
|
||||
];
|
||||
if (!$param['mobile']) {
|
||||
$c_id = $this->mdCustomers->add($add_data);
|
||||
} else {
|
||||
$re_cus2 = $this->mdCustomers->get(['biz_id' => $biz_id, 'mobile' => $add_data['mobile'], 'status<>' => -1]);
|
||||
if ($re_cus2) {//合并用户
|
||||
$c_id = $re_cus2['id'];
|
||||
$this->mdCustomers->update(['unionid' => $param['unionid']], ['id' => $re_cus2['id']]);//合并到现有手机
|
||||
} else {
|
||||
$c_id = $this->mdCustomers->add($add_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($param['tag'] && count($param['tag'])) {//加标签
|
||||
//查找已加入标签
|
||||
$res_td = $this->mdCustomerTagdata->select(['c_id' => $c_id], 'id desc', 0, 0, 't_id');
|
||||
$tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : '';
|
||||
$add_tag = $tag_data_new = [];
|
||||
//选择现有标签
|
||||
foreach ($param['tag'] as $key => $val) {
|
||||
$re_tag = $this->mdCustomerTag->get(['qy_id' => $val, 'status' => 1], 'id');
|
||||
if ($re_tag) {
|
||||
$tag_data_new[] = $re_tag['id'];
|
||||
if (!$tag_data || !in_array($re_tag['id'], $tag_data)) {//未加标签,新增
|
||||
$add_tag[] = ['c_id' => $c_id, 't_id' => $re_tag['id'], 'c_time' => time()];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($tag_data) {//删除标签
|
||||
foreach ($tag_data as $key => $val) {
|
||||
if (!in_array($val, $tag_data_new)) {//未选择,删除标签
|
||||
$this->mdCustomerTagdata->delete(['c_id' => $c_id, 't_id' => $val]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($add_tag && count($add_tag)) {
|
||||
$this->mdCustomerTagdata->add_batch($add_tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:添加企业客户标签
|
||||
* Created on: 2022/3/24 15:01
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/wechat/lichene/add_corp_tag
|
||||
* https://api.liche.cn/wechat/lichene/add_corp_tag
|
||||
*/
|
||||
public function add_corp_tag()
|
||||
{
|
||||
$this->load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag');
|
||||
$this->load->library('wx_qyapi', ['app' => 'lichene']);
|
||||
$res = $this->mdCustomerTag->select(["status" => 1, 'pid' => 0], "sort desc,id desc", 0, 0);
|
||||
$addTag = [];
|
||||
foreach ($res as $key => $value) {
|
||||
$add_corp_tag = ['url' => 'add_corp_tag', 'group_id' => '', 'group_name' => $value['name'], 'order' => $value['sort']];
|
||||
$res_tag = $this->mdCustomerTag->select(["status" => 1, 'pid' => $value['id']], "sort desc,id desc", 0, 0, 'name,sort');
|
||||
$tag = [];
|
||||
foreach ($res_tag as $key2 => $value2) {
|
||||
$tag[] = ['name' => $value2['name'], 'order' => $value2['sort']];
|
||||
}
|
||||
$add_corp_tag['tag'] = count($tag) > 0 ? $tag : '';
|
||||
$re_yq = $this->wx_qyapi->get_external_contact($add_corp_tag);
|
||||
if ($re_yq['errcode'] == 0 && $re_yq['tag_group']['group_id']) {//更新企微id
|
||||
$this->mdCustomerTag->update(['qy_id' => $re_yq['tag_group']['group_id']], ['id' => $value['id']]);
|
||||
foreach ($re_yq['tag_group']['tag'] as $key3 => $value3) {
|
||||
if ($value3['id']) {//更新企微id
|
||||
$this->mdCustomerTag->update(['qy_id' => $value3['id']], ['pid' => $value['id'], 'name' => $value3['name']]);
|
||||
}
|
||||
}
|
||||
$addTag[] = $re_yq;
|
||||
}
|
||||
}
|
||||
echo json_encode($addTag, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:临时更新用户客户id
|
||||
* Created on: 2021/03/01 17:02
|
||||
@@ -143,7 +305,10 @@ Class Lichene extends HD_Controller
|
||||
$param = $this->input->get();
|
||||
$param['page'] = intval($param['page']);
|
||||
//获取配置了客户联系功能的成员列表
|
||||
$re = $this->wx_qyapi->get_external_contact(array('url' => 'get_follow_user_list'));
|
||||
//$re = $this->wx_qyapi->get_external_contact(array('url' => 'get_follow_user_list'));
|
||||
//echo json_encode($re, JSON_UNESCAPED_UNICODE);
|
||||
//读取成员
|
||||
$re = $this->wx_qyapi->get_external_contact(array('url' => 'user_get', 'userid' => 'DengBingWen'));
|
||||
echo json_encode($re, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
//用户分页分别获取避免超时
|
||||
|
||||
@@ -139,6 +139,9 @@ class Wx_qyapi
|
||||
if ($param['url'] == 'get_follow_user_list') {//获取配置了客户联系功能的成员列表
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_follow_user_list?access_token={$access_token}";
|
||||
$res = $this->ci->mycurl->httpGet($url);
|
||||
} else if ($param['url'] == 'user_get') {//读取成员 https://developer.work.weixin.qq.com/document/path/90196
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={$access_token}&userid={$param['userid']}";
|
||||
$res = $this->ci->mycurl->httpGet($url);
|
||||
} else if ($param['url'] == 'list') {//获取客户列表
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token={$access_token}&userid={$param['userid']}";
|
||||
$res = $this->ci->mycurl->httpGet($url);
|
||||
@@ -156,18 +159,73 @@ class Wx_qyapi
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/mark_tag?access_token={$access_token}";
|
||||
$res = $this->ci->mycurl->httpPost($url, array('userid' => $param['userid'], 'external_userid' => $param['external_userid']
|
||||
, 'add_tag' => $param['add_tag']), 'is_json');
|
||||
} else if ($param['url'] == 'add_corp_tag') {//添加企业客户标签 https://work.weixin.qq.com/api/doc/90001/90143/92696#添加企业客户标签
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_corp_tag?access_token={$access_token}&debug=1";
|
||||
$res = $this->ci->mycurl->httpPost($url, array('group_id' => $param['group_id'], 'tag' => array(array('name' => $param['name']))), 'is_json');
|
||||
} else if ($param['url'] == 'remark') {//修改客户备注信息 https://work.weixin.qq.com/api/doc/90001/90143/92694
|
||||
} else if ($param['url'] == 'add_corp_tag') {//添加企业客户标签 https://developer.work.weixin.qq.com/document/path/92117#
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_corp_tag?access_token={$access_token}";
|
||||
$res = $this->ci->mycurl->httpPost($url, array('group_id' => $param['group_id'], 'group_name' => $param['group_name'], 'order' => $param['order'],
|
||||
'tag' => $param['tag']), 'is_json');
|
||||
} else if ($param['url'] == 'mark_tag') {//编辑客户企业标签 https://developer.work.weixin.qq.com/document/path/92118
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/mark_tag?access_token={$access_token}";
|
||||
$res = $this->ci->mycurl->httpPost($url, array('userid' => $param['userid'], 'external_userid' => $param['external_userid'], 'add_tag' => $param['add_tag'],
|
||||
'remove_tag' => $param['remove_tag']), 'is_json');
|
||||
} else if ($param['url'] == 'remark') {//修改客户备注信息 https://developer.work.weixin.qq.com/document/path/92115
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remark?access_token={$access_token}";
|
||||
$res = $this->ci->mycurl->httpPost($url, array('userid' => $param['userid'], 'external_userid' => $param['external_userid']
|
||||
, 'description' => $param['description']), 'is_json');
|
||||
, 'remark_mobiles' => $param['remark_mobiles']), 'is_json');
|
||||
}
|
||||
$data = trim($res, chr(239) . chr(187) . chr(191));
|
||||
$result = json_decode($data, true);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSignPackage()
|
||||
{
|
||||
$jsapiTicket = $this->getJsApiTicket();
|
||||
$url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
||||
$timestamp = time();
|
||||
$nonceStr = $this->createNonceStr();
|
||||
// 这里参数的顺序要按照 key 值 ASCII 码升序排序
|
||||
$string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr×tamp=$timestamp&url=$url";
|
||||
$signature = sha1($string);
|
||||
$signPackage = array(
|
||||
"appId" => $this->corpid,
|
||||
"nonceStr" => $nonceStr,
|
||||
"timestamp" => $timestamp,
|
||||
"url" => $url,
|
||||
"signature" => $signature,
|
||||
"rawString" => $string,
|
||||
'jsapi_ticket' => $jsapiTicket
|
||||
);
|
||||
return $signPackage;
|
||||
}
|
||||
|
||||
public function getJsApiTicket()
|
||||
{
|
||||
$jsapi_ticket = $this->redis->get('jsapi_ticket_' . $this->corpsecret);
|
||||
if (!$jsapi_ticket) {
|
||||
//获取企业的jsapi_ticket https://developer.work.weixin.qq.com/document/path/90506#14924
|
||||
$access_token = $this->access_token();
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token={$access_token}";
|
||||
$res = $this->ci->mycurl->httpGet($url);
|
||||
$result = json_decode($res);
|
||||
if ($result->errcode) {
|
||||
debug_log('error:__FUNCTION__:' . $res, $this->log_file);
|
||||
} else {
|
||||
$jsapi_ticket = $result->ticket;
|
||||
$this->redis->save('jsapi_ticket_' . $this->corpsecret, $result->ticket, $result->expires_in);
|
||||
}
|
||||
}
|
||||
return $jsapi_ticket;
|
||||
}
|
||||
|
||||
private function createNonceStr($length = 16)
|
||||
{
|
||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
$str = "";
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Lichene extends CI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:客户画像
|
||||
* https://liche-dev.xiaoyu.com/h5/lichene
|
||||
* https://www.liche.cn/h5/lichene
|
||||
* Created on: 2022/3/25 11:19
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->library('wx_qyapi', ['app' => 'lichene']);
|
||||
$sign_package = $this->wx_qyapi->getSignPackage();
|
||||
echo json_encode($sign_package, JSON_UNESCAPED_UNICODE);
|
||||
$data = ['_title' => '客户画像', 'sign_package' => $sign_package];
|
||||
$this->load->view('/h5/lichene/index', $data);
|
||||
}
|
||||
|
||||
public function get_user()
|
||||
{
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
$this->load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag');
|
||||
$this->load->model('receiver/receiver_customer_tagdata_model', 'mdCustomerTagdata');
|
||||
$id = 0;
|
||||
$tagList = $res_td = $sources = [];
|
||||
//标签
|
||||
$res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0], 'sort desc,id desc', 0, 0, 'id,name,type');
|
||||
if ($res) {
|
||||
$id && $res_td = $this->mdCustomerTagdata->select(['c_id' => $id], 'id desc', 0, 0, 't_id');//查找用户选择
|
||||
$tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : '';
|
||||
foreach ($res as $key => $val) {
|
||||
$list = [];
|
||||
$value = '';
|
||||
$res2 = $this->mdCustomerTag->select(['status' => 1, 'pid' => $val['id']], 'sort desc,id desc', 0, 0, 'id,name');
|
||||
foreach ($res2 as $key2 => $val2) {
|
||||
//检查是否选中标签
|
||||
$setValue = ['id' => $val2['id'], 'name' => $val2['name']];
|
||||
if ($val['type'] == 'checkbox') {
|
||||
$setValue['checked'] = $tag_data && in_array($val2['id'], $tag_data) ? true : false;
|
||||
} else {
|
||||
$checked = false;
|
||||
if ($tag_data && in_array($val2['id'], $tag_data)) {
|
||||
!$value && $checked = true;
|
||||
$value = $val2['id'];
|
||||
}
|
||||
$setValue['checked'] = $checked;
|
||||
}
|
||||
$list[] = $setValue;
|
||||
}
|
||||
$tagList[] = ['id' => $val['id'], 'name' => $val['name'], 'type' => $val['type'], 'list' => $list];
|
||||
}
|
||||
}
|
||||
//线索来源
|
||||
$status = 0;
|
||||
$offline_sources = $this->mdCustomers->offlineSources();
|
||||
if (strlen($status) && $status == 0) {//未见客户
|
||||
unset($offline_sources[1]);
|
||||
}
|
||||
foreach ($offline_sources as $key => $val) {
|
||||
$list = [];
|
||||
foreach ($val['list'] as $key2 => $val2) {
|
||||
$list[] = ['id' => $key2, 'name' => $val2];
|
||||
}
|
||||
$sources[] = ['id' => $key, 'name' => $val['name'], 'list' => $list];
|
||||
}
|
||||
$data['tagList'] = $tagList;
|
||||
$data['sources'] = $sources;
|
||||
$this->show_json(200, '获取用户信息成功', $data);
|
||||
}
|
||||
|
||||
private function show_json($code, $msg, $info = [])
|
||||
{
|
||||
$data['code'] = $code;
|
||||
$data['msg'] = $msg;
|
||||
$data['data'] = $info;
|
||||
die(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title><?= $_title ?></title>
|
||||
<link rel="stylesheet" href="/css/h5/lichene/h5.css?v=1">
|
||||
<script src="https://qs.haodian.cn/web/javascript/jquery.3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/vue.2.6.10.min.js"></script>
|
||||
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/qs.js"></script>
|
||||
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/mDialog.js"></script>
|
||||
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
|
||||
</head>
|
||||
|
||||
<body class="bg-f7">
|
||||
<div id="app">
|
||||
<div class="container">
|
||||
<div class="inner30">
|
||||
<div class="inner30 bg-fff ulib-r10">
|
||||
<div class="relative">
|
||||
<img class="block imgsize-90X90 ulib-r5" :src="userInfo.headimg" alt="#"/>
|
||||
<div class="absolute pl100 box-middle font-30">
|
||||
<span class="text-middle">{{userInfo.nickname}}</span>
|
||||
<i class="text-middle iconfont icon-nanxing color-2b78f5" v-if="userInfo.sex==1"></i>
|
||||
<i class="text-middle iconfont icon-nvshangjia color-fb3aab" v-if="userInfo.sex==2"></i>
|
||||
<span class="text-middle color-36b229">{{userInfo.source}}</span>
|
||||
</div>
|
||||
<div class="absolute right-0 box-middle bg-3f91fd font-30 color-fff pt15 pb15 pl30 pr30 ulib-r10">
|
||||
到店
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="bg-f7 mt30 pt20 pb20 pl30 pr30 font-30 color-2b78f5 ulib-r10">点击关联企业</div> -->
|
||||
<div class="mt20 pl140 relative bbs-1-eee last-b-none">
|
||||
<div class="absolute left-0 box-middle font-28 color-666">手机号</div>
|
||||
<input class="wp100 pl20 pr20 pt30 pb30 font-28 bds-1-ddd bds-none text-right" type="tel"
|
||||
placeholder="请输入客户手机号" v-model="userInfo.mobile"/>
|
||||
</div>
|
||||
<div class="mt20 pl140 relative bbs-1-eee last-b-none">
|
||||
<div class="absolute left-0 box-middle font-28 color-666">线索来源</div>
|
||||
<div class="pt10 pb10 text-right">
|
||||
<select :class="'bds-none font-28 bg-fff ' + [of_id == 0 ? 'color-ccc' : 'color-333']"
|
||||
v-model="of_id" @change="changeOf1">
|
||||
<option :value="0">请选择</option>
|
||||
<option :value="item.id" v-for="item in sources">{{item.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt20 pl140 relative bbs-1-eee last-b-none"
|
||||
v-if="of_id_index>-1&&sources[of_id_index].list.length>0">
|
||||
<div class="absolute left-0 box-middle font-28 color-666">{{sources[of_id_index].name}}</div>
|
||||
<div class="pt10 pb10 text-right">
|
||||
<select :class="'bds-none font-28 bg-fff ' + [of2_id == 0 ? 'color-ccc' : 'color-333']"
|
||||
v-model="of2_id">
|
||||
<option :value="0">请选择</option>
|
||||
<option :value="item.id" v-for="item in sources[of_id_index].list">{{item.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt30 inner30 pb50 bg-fff ulib-r10">
|
||||
<div class="mt20 font-36 text-center text-bold">客户画像</div>
|
||||
<div class="relative mt40" v-for="(list,i) in taglList">
|
||||
<div class="font-28">
|
||||
<span class="text-middle">{{list.name}}</span>
|
||||
<span class="text-middle font-24" v-if="list.type=='radio'">(单选)</span>
|
||||
<span class="text-middle font-24" v-if="list.type=='checkbox'">(多选)</span>
|
||||
</div>
|
||||
<div class="fn-clear" v-if="list.type=='radio'">
|
||||
<div v-for="(option,j) in list.list"
|
||||
:class="'inline-block space-nowrap mt20 mr20 pt15 pb15 pl30 pr30 font-22 ulib-r10 ' + [option.checked ? 'bg-3f91fd color-fff' : 'bg-f6 color-666']"
|
||||
@click="radioPicker(i,j)">{{option.name}}
|
||||
</div>
|
||||
</div>
|
||||
<vdiv class="fn-clear" v-if="list.type=='checkbox'">
|
||||
<div v-for="(option,j) in list.list"
|
||||
:class="'inline-block space-nowrap mt20 mr20 pt15 pb15 pl30 pr30 font-22 ulib-r10 ' + [option.checked ? 'bg-3f91fd color-fff' : 'bg-f6 color-666']"
|
||||
@click="checkPicker(i,j)">{{option.name}}
|
||||
</div>
|
||||
</vdiv>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt50 pb50 pl60 pr60">
|
||||
<button :class="'wp100 btn pt30 pb30 text-center font-32 color-fff ulib-r750 ' + [submitFlag?'bg-b5':'bg-3f91fd']"
|
||||
:disabled="submitFlag" @click="postbaseinfo()">确认保存
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let hostUrl = ''
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
submitFlag: false,
|
||||
userInfo: {
|
||||
headimg: "https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTL6WOjISfSibY4gSp9RTbkUOYsrxwyOClnExCvLzVEoFt6KWvadiabGTQd0ib5ttz43USVPQq20qiaNDQ/132",
|
||||
mobile: "15359333658",
|
||||
nickname: "老叶",
|
||||
sex: 1,//1男、/2女
|
||||
source: '@微信',
|
||||
},
|
||||
taglList: [],
|
||||
of_id_index: -1,
|
||||
of_id: 0,
|
||||
of2_id: 0,
|
||||
sources: [],
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
computed: {},
|
||||
mounted() {
|
||||
this.getUser();
|
||||
},
|
||||
methods: {
|
||||
getUser() {
|
||||
let that = this;
|
||||
$.ajax({
|
||||
url: '/h5/lichene/get_user',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: 1
|
||||
},
|
||||
beforeSend: function () {
|
||||
},
|
||||
success: function (re) {
|
||||
if (re.code == 200) {
|
||||
that.taglList = re.data['tagList'];
|
||||
that.sources = re.data['sources'];
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//选择一级线索来源
|
||||
changeOf1() {
|
||||
if (this.of_id > 0) {
|
||||
this.sources.forEach((item, index) => {
|
||||
if (item.id == this.of_id) {
|
||||
this.of_id_index = index
|
||||
this.of2_id = 0
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.of_id_index = -1;
|
||||
}
|
||||
},
|
||||
|
||||
//提交基础数据
|
||||
postbaseinfo() {
|
||||
let that = this
|
||||
mDialog.load()
|
||||
let params = {};
|
||||
if (that.userInfo.mobile) {
|
||||
params['mobile'] = that.userInfo.mobile;
|
||||
}
|
||||
if (that.of_id != 0) {
|
||||
params['of_id'] = that.of_id;
|
||||
}
|
||||
if (that.of2_id != 0) {
|
||||
params['of2_id'] = that.of2_id;
|
||||
}
|
||||
params['tag'] = that.taglList;
|
||||
// axios({
|
||||
// method: 'post',
|
||||
// url: 'https://liche.cn/chechedai/api/kehulist.php',
|
||||
// transformRequest: [function (data) {
|
||||
// // 对 data 进行任意转换处理
|
||||
// return Qs.stringify(data)
|
||||
// }],
|
||||
// responseType: 'json',
|
||||
// data: params,
|
||||
// }).then(function (res) {
|
||||
// mDialog.closeAll()
|
||||
// })
|
||||
},
|
||||
//单选
|
||||
radioPicker(i, j) {
|
||||
let taglList = this.taglList
|
||||
taglList[i].list.forEach(item => {
|
||||
item.checked = false
|
||||
})
|
||||
taglList[i].list[j].checked = true
|
||||
this.taglList = taglList
|
||||
},
|
||||
//多选
|
||||
checkPicker(i, j) {
|
||||
this.taglList[i].list[j].checked = !this.taglList[i].list[j].checked
|
||||
},
|
||||
}
|
||||
});
|
||||
wx.config({
|
||||
beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
|
||||
debug: true, // 开启调试模式,调用的所有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: ["invoke"] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
|
||||
});
|
||||
wx.ready(function(){
|
||||
wx.invoke('getContext', {}, function(res){
|
||||
console.log(res);
|
||||
if(res.err_msg == "getContext:ok"){
|
||||
entry = res.entry ; //返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools、chat_attachment
|
||||
shareTicket = res.shareTicket; //可用于调用getShareInfo接口
|
||||
}else {
|
||||
//错误处理
|
||||
}
|
||||
});
|
||||
});
|
||||
wx.error(function(res){
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user