mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]添加粉丝标签设置
This commit is contained in:
parent
1dafee3acd
commit
75db3a05d5
@ -67,11 +67,8 @@ class Fans extends BasicAdmin {
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assign('alert', [
|
||||
'type' => 'success',
|
||||
'title' => '开发中',
|
||||
'content' => '请稍候...'
|
||||
]);
|
||||
$this->assign('tags', $tags);
|
||||
$this->assign('alert', ['type' => 'success', 'title' => '开发中', 'content' => '请稍候...']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,6 +100,27 @@ class Fans extends BasicAdmin {
|
||||
$this->error("设备黑名单失败,请稍候再试!{$wechat->errMsg}[{$wechat->errCode}]");
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签选择
|
||||
*/
|
||||
public function tagset() {
|
||||
$tags = $this->request->post('tags', '');
|
||||
$fans_id = $this->request->post('fans_id', '');
|
||||
$fans = Db::name('WechatFans')->where('id', $fans_id)->find();
|
||||
empty($fans) && $this->error('需要操作的数据不存在!');
|
||||
$wechat = & load_wechat('User');
|
||||
foreach (explode(',', $fans['tagid_list']) as $tagid) {
|
||||
is_numeric($tagid) && $wechat->batchDeleteUserTag($tagid, [$fans['openid']]);
|
||||
}
|
||||
foreach (explode(',', $tags) as $tagid) {
|
||||
is_numeric($tagid) && $wechat->batchAddUserTag($tagid, [$fans['openid']]);
|
||||
}
|
||||
if (false !== Db::name('WechatFans')->where('id', $fans_id)->setField('tagid_list', $tags)) {
|
||||
$this->success('粉丝标签成功!', '');
|
||||
}
|
||||
$this->error('粉丝标签设置失败, 请稍候再试!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消黑名
|
||||
*/
|
||||
|
@ -98,17 +98,10 @@
|
||||
</td>
|
||||
<td class='text-left'>{$vo.sex==1?'男':($vo.sex==2?'女':'未知')}</td>
|
||||
<td>
|
||||
{if count($vo.tags_list) < 3}
|
||||
<span>
|
||||
<a data-add-tag='{$vo.id}' data-used-id='{:join(",",array_keys($vo.tags_list))}' data-tips-text='添加标签'
|
||||
href='javascript:void(0)' style='font-size:12px;font-weight:400;border-radius:50%;background:#9f9f9f' class='label label-default'>+</a>
|
||||
<a data-add-tag='{$vo.id}' data-used-id='{:join(",",array_keys($vo.tags_list))}' id="tag-fans-{$vo.id}" href='javascript:void(0)'
|
||||
style='font-size:12px;font-weight:400;border-radius:50%;background:#9f9f9f' class='label label-default'>+</a>
|
||||
</span>
|
||||
{else}
|
||||
<span>
|
||||
<a data-tips-text='最多三个标签' href='javascript:void(0)'
|
||||
style='font-size:12px;font-weight:400;border-radius:50%;background:#dfdfdf' class='label label-default'>+</a>
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
{if empty($vo.tags_list)}
|
||||
<span style='color:#999'>尚未设置标签</span>
|
||||
@ -133,15 +126,63 @@
|
||||
</table>
|
||||
{if isset($page)}<p>{$page}</p>{/if}
|
||||
</form>
|
||||
|
||||
<div id="tags-box" class="hide">
|
||||
<form>
|
||||
<div class="row">
|
||||
{foreach $tags as $key=>$tag}
|
||||
<div class="col-xs-6">
|
||||
<label><input value="{$key}" type="checkbox" /> {$tag}</label>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="hr-line-dashed"></div>
|
||||
<button type="button" data-event="confirm" class="layui-btn layui-btn-small">保存数据</button>
|
||||
<button type="button" data-event="cancel" class="layui-btn layui-btn-danger layui-btn-small" type='button'>取消编辑</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
<script>
|
||||
// 添加标签
|
||||
$('body').on('click', '[data-add-tag]', function () {
|
||||
$('body').find('[data-add-tag]').map(function () {
|
||||
var self = this;
|
||||
var fans_id = this.getAttribute('data-add-tag');
|
||||
var used_id = this.getAttribute('data-used-id');
|
||||
alert(used_id);
|
||||
var used_ids = (this.getAttribute('data-used-id') || '').split(',');
|
||||
var $content = $(document.getElementById('tags-box').innerHTML);
|
||||
for (var i in used_ids) {
|
||||
$content.find('[value="' + used_ids[i] + '"]').attr('checked', 'checked');
|
||||
}
|
||||
$content.attr('fans_id', fans_id);
|
||||
// 标签面板关闭
|
||||
$content.on('click', '[data-event="cancel"]', function () {
|
||||
$(self).popover('hide');
|
||||
});
|
||||
// 标签面板确定
|
||||
$content.on('click', '[data-event="confirm"]', function () {
|
||||
var tags = [];
|
||||
$content.find('input:checked').map(function () {
|
||||
tags.push(this.value);
|
||||
});
|
||||
$.form.load('{:url("tagset")}', {fans_id: $content.attr('fans_id'), 'tags': tags.join(',')}, 'post');
|
||||
});
|
||||
// 限制每个表单最多只能选择三个
|
||||
$content.on('click', 'input', function () {
|
||||
($content.find('input:checked').size() > 3) && (this.checked = false);
|
||||
});
|
||||
// 标签选择面板
|
||||
$(this).data('content', $content).on('shown.bs.popover', function () {
|
||||
$('[data-add-tag]').not(this).popover('hide');
|
||||
}).popover({
|
||||
html: true,
|
||||
trigger: 'click',
|
||||
content: $content,
|
||||
title: '标签编辑(最多选择三个标签)',
|
||||
template: '<div class="popover" style="max-width:500px" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content" style="width:500px"></div></div>'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
|
Loading…
x
Reference in New Issue
Block a user