[更新]微信关键字管理

This commit is contained in:
邹景立 2017-04-21 15:46:34 +08:00
parent b33f471992
commit 57e8652824
6 changed files with 3551 additions and 7 deletions

View File

@ -11,14 +11,52 @@
// | github开源项目https://github.com/zoujingli/Think.Admin
// +----------------------------------------------------------------------
namespace app\wechat\controller;
class Review {
use think\Controller;
use think\Db;
class Review extends Controller {
/**
* 显示手机预览
* @return string
*/
public function index() {
return '222';
$get = $this->request->get();
// 内容
$content = $this->request->get('content', '');
$this->assign('content', $content);
// 类型
$type = $this->request->get('type', 'text');
$this->assign('type', $type);
// 图文处理
if ($type === 'news' && is_numeric($content) && !empty($content)) {
$news = News::get($content, ['appid' => $this->real_appid]);
$this->assign('articles', $news['articles']);
}
// 文章预览
if ($type === 'article' && is_numeric($content) && !empty($content)) {
$article = Db::name('WechatNewsArticle')->where('id', $content)->find();
$this->assign('vo', $article);
}
$this->assign($get);
// 渲染模板并显示
return view();
}
/**
* 微信图片显示
*/
public function wechatImage() {
$url = input('get.url', '');
$filename = 'upload/tmp/' . join('/', str_split(md5($url), 16));
$realfile = ROOT_PATH . 'public/' . $filename;
file_exists(dirname($realfile)) || mkdir(dirname($realfile), 0755, true);
if (!file_exists($realfile)) {
file_put_contents($realfile, file_get_contents($url));
}
$this->redirect(pathinfo($this->requestbaseFile(true), PATHINFO_DIRNAME) . '/' . $filename);
}
}

View File

@ -26,11 +26,11 @@
<td class="text-center">{$vo.type}</td>
<td class="text-center">
{if $vo.type eq '音乐'}
<a data-phone-view='{:url("@wechat/review")}?type=music&title={$vo.music_title}&desc={$vo.music_desc}'
<a data-phone-view='{:url("@wechat/review")}?type=music&title={$vo.music_title|urlencode}&desc={$vo.music_desc|urlencode}'
class="btn btn-link"><i class="fa fa-eye"></i> 预览
</a>
{elseif $vo.type eq '图片'}
<a data-phone-view='{:url("@wechat/review")}?type=image&title={$vo.image_url}'
<a data-phone-view='{:url("@wechat/review")}?type=image&content={$vo.image_url|urlencode}'
class="btn btn-link"><i class="fa fa-eye"></i> 预览
</a>
{elseif $vo.type eq '图文'}
@ -38,7 +38,7 @@
class="btn btn-link"><i class="fa fa-eye"></i> 预览
</a>
{elseif $vo.type eq '视频'}
<a data-phone-view='{:url("@wechat/review")}?type=video&title={$vo.video_title}&desc={$vo.video_desc}&url={$vo.video_url}'
<a data-phone-view='{:url("@wechat/review")}?type=video&title={$vo.video_title|urlencode}&desc={$vo.video_desc|urlencode}&url={$vo.video_url|urlencode}'
class="btn btn-link"><i class="fa fa-eye"></i> 预览
</a>
{else}

View File

@ -0,0 +1,231 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Wechat Preview</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="__ROOT__/static/plugs/aui/aui.css">
<style>
* {
font-family: "Microsoft YaHei" !important;
letter-spacing: .01rem
}
.aui-chat .time {
color: #f5f5f5;
background: rgba(0, 0, 0, .3);
padding: .1rem .3rem;
border-radius: .2rem;;
border-radius: .2rem;
font-size: .6rem;
font-size: .5rem;
}
.aui-chat .aui-chat-media img {
border-radius: 0
}
.aui-chat .bg-white {
background: #f5f5f5 !important;
border: 1px solid #ccc;
}
.aui-chat .aui-chat-content .aui-chat-arrow.one {
top: .7rem !important;
background: #f5f5f5 !important;
border: 1px solid #ccc !important;
left: -0.28rem !important;
}
.aui-chat .aui-chat-content .aui-chat-arrow.two {
top: .7rem !important;
background: #f5f5f5 !important;
left: -0.2rem !important;
}
</style>
</head>
<body>
{if ($type eq 'text') or ($type eq 'image') or ($type eq 'music')}
<section class="aui-chat">
<div class="aui-chat-header"><span class="time">{:date('H:i')}</span></div>
<div class="aui-chat-item aui-chat-left">
<div class="aui-chat-media">
<img src="__ROOT__/static/theme/default/img/head.gif"/>
</div>
<div class="aui-chat-inner">
{if $type eq 'text'}
<div class="aui-chat-content bg-white">
<div class="aui-chat-arrow one"></div>
<div class="aui-chat-arrow two"></div>
{$content|default=''}
</div>
{elseif $type eq 'image'}
<div class="aui-chat-content bg-white">
<div class="aui-chat-arrow one"></div>
<div class="aui-chat-arrow two"></div>
<img src='{$content|default="__PUBLIC__/static/theme/default/img/image.png"}'/>
</div>
{elseif $type eq 'music'}
<div class="aui-chat-content" style='background:#080;border:1px solid #ccc;'>
<div class="aui-chat-arrow one"></div>
<div class="aui-chat-arrow two"></div>
<table>
<tr>
<td style='overflow:hidden;white-space:nowrap;color:#f5f5f5;min-width:100%'>
{$title|default=''}
</td>
<td style='overflow:hidden;white-space:nowrap;color:#f5f5f5;max-width:100%;' rowspan="2">
<div style='position:absolute;right:0;top:0;bottom:0;width:2.5rem;background: #080'></div>
<div style='width:1.5rem;height:1.5rem;background:#0a0;padding:.1rem;text-align:center;position:absolute;right:.5rem;top:1rem'>
<i style='font-size:1rem' class='aui-iconfont aui-icon-video'></i>
</div>
</td>
</tr>
<tr>
<td style='overflow:hidden;white-space:nowrap;color:#f5f5f5;font-size:.3rem;'>
{$desc|default=''}          
</td>
</tr>
</table>
</div>
{/if}
</div>
</div>
</section>
{elseif $type eq 'article'}
{* 文章显示 *}
<section class="aui-content">
<div class="aui-card-list aui-border-t aui-border-b">
{if $vo.show_cover_pic neq 0}
<div class="aui-card-list-content">
<img src="{$vo.local_url}"/>
</div>
{/if}
<div class="aui-card-list-header aui-padded-t-5 aui-padded-b-5">
{$vo.title|default=''}
</div>
<div class="aui-info aui-padded-l-15 aui-padded-r-15">
<div class="aui-info-item aui-font-size-12">
<span class="aui-margin-l-5">{date('Y-m-d',strtotime($vo['create_at']))}</span>
<span class="aui-margin-l-5" style='color:#0099CC'>{$vo.author|default=''}</span>
</div>
</div>
<div class="aui-card-list-content-padded aui-padded-t-0 aui-padded-b-0" style="color:#666;">
{$vo.content|default=''}
</div>
<style>
.aui-card-list-content-padded img {
max-width: 100% !important;
}
</style>
<div class="aui-card-list-footer aui-font-size-12" style="color:#999;">
<div>
<a style='color:#0099CC' target='_blank' href='__SELF__'>阅读原文</a> <span>阅读 88</span> <span><i
class='aui-iconfont aui-icon-laud'></i> 8</span>
</div>
</div>
</div>
</section>
{elseif $type eq 'video'}
{* 视频显示 *}
<section class="aui-chat">
<div class="aui-chat-header"><span class="time">{date('H:i')}</span></div>
<div class="aui-chat-item">
<div class="aui-chat-content"
style='background: #fff;border:1px solid #ccc;width:100%;max-width:100%;padding:0'>
<section class="aui-content">
<div class="aui-card-list" style='margin-bottom:0;background: none'>
<div class="aui-card-list-header"
style='padding:0 .3rem 0 .3rem;min-height:1.5rem;white-space:nowrap;overflow: hidden;text-overflow:ellipsis'>
{$title|default=''}
</div>
<div style='font-size:.5rem;padding:0 .3rem .3rem .3rem;color:#999'>{date('m月d日')}</div>
<div class="aui-card-list-content-padded aui-border-b" style='padding:0 .3rem'>
<video src="{$url|default=''}" width="100%" controls preload></video>
</div>
<div class="aui-card-list-footer" style='min-height:.8rem;padding:.2rem .3rem'>
<div style='font-size:.55rem;white-space:nowrap;overflow: hidden;text-overflow:ellipsis '>
{$desc|default=''}
</div>
</div>
</div>
</section>
</div>
</div>
</section>
{elseif $type eq 'news'}
{* 图文显示 *}
<section class="aui-chat">
<div class="aui-chat-header"><span class="time">{date('H:i')}</span></div>
<div class="aui-chat-item">
<div class="aui-chat-content"
style='background: #fff;border:1px solid #ccc;width:100%;max-width:100%;padding:0'>
<section class="aui-content">
{if !empty($articles)}
{foreach $articles as $key=>$vo}
{if $articles|count gt 1}
{if $key<1}
<div href="{'wechat/review/index'|app_url}&content={$vo.id}&type=article"
onclick="location.href = this.getAttribute('href')" class="aui-card-list"
style="margin:0;padding:.5rem .5rem .3rem .5rem;display:block;background:none">
<div class="aui-card-list-content" style='max-height:10rem;overflow:hidden;text-overflow:ellipsis'>
<img src="{$vo.local_url|default=''}"/>
</div>
<div class="aui-card-list-header"
style='padding:.5rem .2rem;left:.5rem;right:.5rem;position:absolute;margin-top:-2.2rem;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:rgba(0,0,0,.8);color:#fff'>
{$vo.title|default=''}
</div>
</div>
{else}
<table href="{:url('wechat/review/index')}&content={$vo.id}&type=article" class="aui-border-t"
onclick="location.href = this.getAttribute('href')"
style='width:100%;padding:0;margin:0;margin:0;padding:.3rem .5rem .5rem .5rem;'>
<tr style='width:100%;padding:0;margin:0;'>
<td style="text-overflow:ellipsis;overflow:hidden;display:inline-block;max-height:3rem">
{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}{$vo.title}
</td>
<td style='width:3rem;height:3rem;padding:0;margin:0'>
<img style="min-width:3rem;height:3rem;width:100%;padding:0;margin:0"
src="{$vo.local_url|default=''}"/>
</td>
</tr>
</table>
{/if}
{else}
<div class="aui-card-list"
style="margin:0;padding:.5rem .5rem .3rem .5rem;display:block;background:none">
<div class="aui-card-list-header"
style='padding:0;margin:0;min-height:1.2rem;display:block;max-height:2rem;overflow:hidden;text-overflow:ellipsis;'>
{$vo.title|default=''}
</div>
<div class="aui-font-size-12"
style="color:#999;min-height:1rem;display:block;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
{date('Y年m月d日')}
</div>
<div class="aui-card-list-content" style='max-height:10rem;overflow:hidden;text-overflow:ellipsis'>
<img src="{$vo.local_url|default=''}"/>
</div>
<div class="aui-card-list-content-padded"
style="color:#7b7b7b;padding:0;display:block;max-height:5rem;overflow:hidden;text-overflow:ellipsis">
{$vo.content}
</div>
</div>
<div class="aui-card-list-content-padded aui-border-t" style="padding-top:.3rem;margin-top:.3rem">
<a class="aui-list-item-arrow" style="color:#333;font-size:.6rem;display:block"
href="{:url('wechat/review/index')}&content={$vo.id}&type=article">阅读全文</a>
</div>
{/if}
{/foreach}
{/if}
</section>
</div>
</div>
</section>
{/if}
</body>
</html>

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB