ZLW-PC\Administrator
7 years ago
13 changed files with 890 additions and 73 deletions
-
169app/Common/WechatCallbackApi.php
-
76app/Common/WechatMenu.php
-
203app/Http/Controllers/Admin/WeixinMenuController.php
-
8app/Http/Controllers/Weixin/UserController.php
-
2app/Http/Model/Arctype.php
-
181app/Http/Model/WeixinMenu.php
-
79public/css/weixin/style.css
-
86resources/views/admin/WeixinMenu/add.blade.php
-
82resources/views/admin/WeixinMenu/edit.blade.php
-
32resources/views/admin/WeixinMenu/index.blade.php
-
31resources/views/weixin/goods/goodsDetail.blade.php
-
6resources/views/weixin/user/index.blade.php
-
8routes/web.php
@ -0,0 +1,169 @@ |
|||
<?php |
|||
namespace App\Common; |
|||
|
|||
/** |
|||
* 微信自定义菜单-响应菜单点击事件 |
|||
*/ |
|||
class WechatCallbackApi |
|||
{ |
|||
public function valid() |
|||
{ |
|||
$echoStr = $_GET["echostr"]; |
|||
if($this->checkSignature()) |
|||
{ |
|||
echo $echoStr; |
|||
exit; |
|||
} |
|||
} |
|||
|
|||
private function checkSignature() |
|||
{ |
|||
$signature = $_GET["signature"]; |
|||
$timestamp = $_GET["timestamp"]; |
|||
$nonce = $_GET["nonce"]; |
|||
|
|||
$token = TOKEN; |
|||
$tmpArr = array($token, $timestamp, $nonce); |
|||
sort($tmpArr); |
|||
$tmpStr = implode( $tmpArr ); |
|||
$tmpStr = sha1( $tmpStr ); |
|||
|
|||
if( $tmpStr == $signature ) |
|||
{ |
|||
return true; |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public function responseMsg() |
|||
{ |
|||
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; |
|||
if (!empty($postStr)) |
|||
{ |
|||
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); |
|||
$RX_TYPE = trim($postObj->MsgType); |
|||
|
|||
switch ($RX_TYPE) |
|||
{ |
|||
case "text": |
|||
$resultStr = $this->receiveText($postObj); |
|||
break; |
|||
case "event": |
|||
$resultStr = $this->receiveEvent($postObj); |
|||
break; |
|||
default: |
|||
$resultStr = ""; |
|||
break; |
|||
} |
|||
|
|||
echo $resultStr; |
|||
} |
|||
else |
|||
{ |
|||
echo ""; |
|||
exit; |
|||
} |
|||
} |
|||
|
|||
private function receiveText($object) |
|||
{ |
|||
$funcFlag = 0; |
|||
$contentStr = "你发送的内容为:".$object->Content; |
|||
$resultStr = $this->transmitText($object, $contentStr, $funcFlag); |
|||
return $resultStr; |
|||
} |
|||
|
|||
private function receiveEvent($object) |
|||
{ |
|||
$contentStr = ""; |
|||
switch ($object->Event) |
|||
{ |
|||
case "subscribe": |
|||
$contentStr = "欢迎洋洋博客"; |
|||
case "unsubscribe": |
|||
break; |
|||
case "CLICK": |
|||
switch ($object->EventKey) |
|||
{ |
|||
case "company": |
|||
$contentStr[] = array("Title" =>"公司简介", |
|||
"Description" =>"洋洋的博客", |
|||
"PicUrl" =>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg", |
|||
"Url" =>"weixin://addfriend/pondbaystudio"); |
|||
break; |
|||
default: |
|||
$contentStr[] = array("Title" =>"默认菜单回复", |
|||
"Description" =>"您正在使用的是<span style="font-family: Arial, Helvetica, sans-serif;">洋洋的博客</span><span style="font-family: Arial, Helvetica, sans-serif;">", </span> |
|||
"PicUrl" =>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg", |
|||
"Url" =>"weixin://addfriend/pondbaystudio"); |
|||
break; |
|||
} |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
|
|||
if (is_array($contentStr)) |
|||
{ |
|||
$resultStr = $this->transmitNews($object, $contentStr); |
|||
} |
|||
else |
|||
{ |
|||
$resultStr = $this->transmitText($object, $contentStr); |
|||
} |
|||
|
|||
return $resultStr; |
|||
} |
|||
|
|||
private function transmitText($object, $content, $funcFlag = 0) |
|||
{ |
|||
$textTpl = "<xml>
|
|||
<ToUserName><![CDATA[%s]]></ToUserName> |
|||
<FromUserName><![CDATA[%s]]></FromUserName> |
|||
<CreateTime>%s</CreateTime> |
|||
<MsgType><![CDATA[text]]></MsgType> |
|||
<Content><![CDATA[%s]]></Content> |
|||
<FuncFlag>%d</FuncFlag> |
|||
</xml>";
|
|||
|
|||
$resultStr = sprintf($textTpl, $object->FromUserName, $object->ToUserName, time(), $content, $funcFlag); |
|||
|
|||
return $resultStr; |
|||
} |
|||
|
|||
private function transmitNews($object, $arr_item, $funcFlag = 0) |
|||
{ |
|||
//首条标题28字,其他标题39字
|
|||
if(!is_array($arr_item)) |
|||
return; |
|||
|
|||
$itemTpl = "<item>
|
|||
<Title><![CDATA[%s]]></Title> |
|||
<Description><![CDATA[%s]]></Description> |
|||
<PicUrl><![CDATA[%s]]></PicUrl> |
|||
<Url><![CDATA[%s]]></Url> |
|||
</item> |
|||
";
|
|||
$item_str = ""; |
|||
foreach ($arr_item as $item) |
|||
$item_str .= sprintf($itemTpl, $item['Title'], $item['Description'], $item['PicUrl'], $item['Url']); |
|||
|
|||
$newsTpl = "<xml>
|
|||
<ToUserName><![CDATA[%s]]></ToUserName> |
|||
<FromUserName><![CDATA[%s]]></FromUserName> |
|||
<CreateTime>%s</CreateTime> |
|||
<MsgType><![CDATA[news]]></MsgType> |
|||
<Content><![CDATA[]]></Content> |
|||
<ArticleCount>%s</ArticleCount> |
|||
<Articles> |
|||
$item_str</Articles> |
|||
<FuncFlag>%s</FuncFlag> |
|||
</xml>";
|
|||
|
|||
$resultStr = sprintf($newsTpl, $object->FromUserName, $object->ToUserName, time(), count($arr_item), $funcFlag); |
|||
return $resultStr; |
|||
} |
|||
} |
@ -0,0 +1,76 @@ |
|||
<?php |
|||
namespace App\Common; |
|||
|
|||
/** |
|||
* 微信自定义菜单 |
|||
*/ |
|||
class WechatMenu |
|||
{ |
|||
//高级功能->开发者模式->获取
|
|||
private $app_id; |
|||
private $app_secret; |
|||
private $access_token; |
|||
private $expires_in; |
|||
|
|||
public function __construct($app_id, $app_secret) |
|||
{ |
|||
$this->app_id = $app_id; |
|||
$this->app_secret = $app_secret; |
|||
|
|||
$token = $this->get_access_token(); |
|||
$this->access_token = $token['access_token']; |
|||
$this->expires_in = $token['expires_in']; |
|||
} |
|||
|
|||
/** |
|||
* 获取授权access_token |
|||
* |
|||
*/ |
|||
public function get_access_token() |
|||
{ |
|||
$token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$this->app_id}&secret={$this->app_secret}"; |
|||
$token_data = $this->http($token_url); |
|||
|
|||
return json_decode($token_data, true); |
|||
} |
|||
|
|||
//获取关注者列表
|
|||
public function get_user_list($next_openid = NULL) |
|||
{ |
|||
$url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=".$this->access_token."&next_openid=".$next_openid; |
|||
$res = $this->http($url); |
|||
return json_decode($res, true); |
|||
} |
|||
|
|||
/** |
|||
* 自定义菜单创建 |
|||
* |
|||
* @param string $jsonmenu |
|||
*/ |
|||
public function create_menu($jsonmenu) |
|||
{ |
|||
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$this->access_token; |
|||
return $this->http($url, $jsonmenu); |
|||
} |
|||
|
|||
// cURL函数简单封装
|
|||
public function http($url, $data = null) |
|||
{ |
|||
$curl = curl_init(); |
|||
curl_setopt($curl, CURLOPT_URL, $url); |
|||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); |
|||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); |
|||
|
|||
if (!empty($data)) |
|||
{ |
|||
curl_setopt($curl, CURLOPT_POST, 1); |
|||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); |
|||
} |
|||
|
|||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); |
|||
$output = curl_exec($curl); |
|||
curl_close($curl); |
|||
|
|||
return $output; |
|||
} |
|||
} |
@ -0,0 +1,203 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Admin; |
|||
|
|||
use App\Http\Controllers\Admin\CommonController; |
|||
use DB; |
|||
use App\Http\Model\WeixinMenu; |
|||
use App\Common\WechatMenu; |
|||
|
|||
class WeixinMenuController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
public function index() |
|||
{ |
|||
$catlist = WeixinMenu::getList(array('is_show'=>-1)); |
|||
|
|||
$data['catlist'] = $catlist; |
|||
return view('admin.WeixinMenu.index', $data); |
|||
} |
|||
|
|||
public function add() |
|||
{ |
|||
if(!empty($_GET["reid"])) |
|||
{ |
|||
$id = $_GET["reid"]; |
|||
if(preg_match('/[0-9]*/',$id)){}else{exit;} |
|||
if($id!=0) |
|||
{ |
|||
$data['postone'] = object_to_array(DB::table("weixin_menu")->where('id', $id)->first(), 1); |
|||
} |
|||
|
|||
$data['id'] = $id; |
|||
} |
|||
else |
|||
{ |
|||
$data['id'] = 0; |
|||
} |
|||
|
|||
return view('admin.WeixinMenu.add', $data); |
|||
} |
|||
|
|||
public function doadd() |
|||
{ |
|||
if(!empty($_POST["prid"])){if($_POST["prid"]=="top"){$_POST['pid']=0;}else{$_POST['pid'] = $_POST["prid"];}}//父级栏目id
|
|||
$_POST['addtime'] = time();//添加时间
|
|||
unset($_POST["prid"]); |
|||
unset($_POST["_token"]); |
|||
|
|||
if(DB::table('weixin_menu')->insert(array_filter($_POST))) |
|||
{ |
|||
success_jump('添加成功!'); |
|||
} |
|||
else |
|||
{ |
|||
error_jump('添加失败!请修改后重新添加'); |
|||
} |
|||
} |
|||
|
|||
public function edit() |
|||
{ |
|||
$id = $_GET["id"];if(preg_match('/[0-9]*/',$id)){}else{exit;} |
|||
|
|||
$data['id'] = $id; |
|||
$post = object_to_array(DB::table('weixin_menu')->where('id', $id)->first(), 1); |
|||
$reid = $post['pid']; |
|||
if($reid!=0){$data['postone'] = object_to_array(DB::table('weixin_menu')->where('id', $reid)->first());} |
|||
|
|||
$data['post'] = $post; |
|||
|
|||
return view('admin.WeixinMenu.edit', $data); |
|||
} |
|||
|
|||
public function doedit() |
|||
{ |
|||
if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} |
|||
$_POST['addtime'] = time(); //添加时间
|
|||
unset($_POST["_token"]); |
|||
|
|||
if(DB::table('weixin_menu')->where('id', $id)->update(array_filter($_POST))) |
|||
{ |
|||
success_jump('修改成功!', route('admin_weixinmenu')); |
|||
} |
|||
else |
|||
{ |
|||
error_jump('修改失败!请修改后重新添加'); |
|||
} |
|||
} |
|||
|
|||
public function del() |
|||
{ |
|||
if(!empty($_REQUEST["id"])){$id = $_REQUEST["id"];}else{error_jump('删除失败!请重新提交');} //if(preg_match('/[0-9]*/',$id)){}else{exit;}
|
|||
|
|||
if(DB::table('weixin_menu')->where('pid', $id)->first()) |
|||
{ |
|||
error_jump('删除失败!请先删除子栏目'); |
|||
} |
|||
else |
|||
{ |
|||
if(DB::table('weixin_menu')->where('id', $id)->delete()) |
|||
{ |
|||
success_jump('删除成功'); |
|||
} |
|||
else |
|||
{ |
|||
error_jump('删除失败!请重新提交'); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public function createmenu() |
|||
{ |
|||
$catlist = WeixinMenu::getList(array('is_show'=>-1)); |
|||
|
|||
$wechat_menu = new WechatMenu(sysconfig('CMS_WX_APPID'),sysconfig('CMS_WX_APPSECRET')); |
|||
|
|||
/* $menu = array( |
|||
'button'=>array(); |
|||
); */ |
|||
|
|||
$jsonmenu = ' |
|||
{ |
|||
"button":[ |
|||
{ |
|||
"name":"篮球", |
|||
"sub_button":[ |
|||
{ |
|||
"type":"click", |
|||
"name":"nba", |
|||
"key":"V1001_NBA" |
|||
}, |
|||
{ |
|||
"type":"click", |
|||
"name":"cba", |
|||
"key":"V1001_CBA" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"name":"体育", |
|||
"sub_button":[ |
|||
{ |
|||
"type":"view", |
|||
"name":"url", |
|||
"url":"http://m.hao123.com/a/tianqi" |
|||
}, |
|||
{ |
|||
"type":"click", |
|||
"name":"排球", |
|||
"key":"V1001_PAIQIU" |
|||
}, |
|||
{ |
|||
"type":"click", |
|||
"name":"网球", |
|||
"key":"V1001_WANGQIU" |
|||
}, |
|||
{ |
|||
"type":"click", |
|||
"name":"乒乓球", |
|||
"key":"V1001_PPQ" |
|||
}, |
|||
{ |
|||
"type":"click", |
|||
"name":"台球", |
|||
"key":"V1001_TAIQIU" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"name":"新闻", |
|||
"sub_button":[ |
|||
{ |
|||
"type":"click", |
|||
"name":"国内新闻", |
|||
"key":"V1001_GNNEWS" |
|||
}, |
|||
{ |
|||
"type":"click", |
|||
"name":"国际新闻", |
|||
"key":"V1001_GJNEWS" |
|||
}, |
|||
{ |
|||
"type":"click", |
|||
"name":"地方新闻", |
|||
"key":"V1001_AREANEWS" |
|||
}, |
|||
{ |
|||
"type":"click", |
|||
"name":"家庭新闻", |
|||
"key":"V1001_HOMENEWS" |
|||
} |
|||
] |
|||
} |
|||
] |
|||
}'; |
|||
|
|||
$wechat_menu->create_menu($jsonmenu); |
|||
|
|||
success_jump('修改菜单,生成后,不会立即显示,有24小时的缓存,除非你取消关注,然后重新关注!', route('admin_weixinmenu'),5); |
|||
} |
|||
} |
@ -0,0 +1,181 @@ |
|||
<?php |
|||
namespace App\Http\Model; |
|||
use App\Common\ReturnData; |
|||
|
|||
/** |
|||
* 微信自定义菜单 |
|||
* 1、自定义菜单最多包括3个一级菜单,每个一级菜单最多包含5个二级菜单。 |
|||
* 2、一级菜单最多4个汉字,二级菜单最多7个汉字,多出来的部分将会以“...”代替。 |
|||
* 3、创建自定义菜单后,菜单的刷新策略是,在用户进入公众号会话页或公众号profile页时,如果发现上一次拉取菜单的请求在5分钟以前,就会拉取一下菜单,如果菜单有更新,就会刷新客户端的菜单。测试时可以尝试取消关注公众账号后再次关注,则可以看到创建后的效果。 |
|||
*/ |
|||
class WeixinMenu extends BaseModel |
|||
{ |
|||
protected $table = 'weixin_menu'; |
|||
public $timestamps = false; |
|||
|
|||
/** |
|||
* 不能被批量赋值的属性 |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $guarded = array(); |
|||
|
|||
const IS_SHOW = 0; |
|||
|
|||
//获取列表
|
|||
public static function getList(array $param) |
|||
{ |
|||
extract($param); //参数:limit,offset
|
|||
|
|||
if(isset($is_show) && $is_show!=-1){$where['is_show'] = $is_show;} //-1表示获取所有
|
|||
$where['pid'] = 0; |
|||
|
|||
$list = self::where($where)->orderBy('listorder', 'asc')->get(); |
|||
|
|||
if($list) |
|||
{ |
|||
foreach($list as $k=>$v) |
|||
{ |
|||
$res[] = $v; |
|||
$child = self::where(array('pid'=>$list[$k]->id,'is_show'=>self::IS_SHOW))->orderBy('listorder', 'asc')->get(); |
|||
|
|||
if($child) |
|||
{ |
|||
foreach($child as $key=>$value) |
|||
{ |
|||
$res[] = $value; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
public static function getOne($where) |
|||
{ |
|||
return self::where($where)->first(); |
|||
} |
|||
|
|||
public static function add(array $data) |
|||
{ |
|||
if ($id = self::insertGetId($data)) |
|||
{ |
|||
return $id; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public static function modify($where, array $data) |
|||
{ |
|||
if (self::where($where)->update($data) === false) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
//删除一条记录
|
|||
public static function remove($id) |
|||
{ |
|||
if (!self::whereIn('id', explode(',', $id))->delete()) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
//删除一条记录
|
|||
public static function getWeixinMenuJson() |
|||
{ |
|||
$where['pid'] = 0; |
|||
$where['is_show'] = self::IS_SHOW; |
|||
$list = self::where($where)->orderBy('listorder', 'asc')->get(); |
|||
|
|||
$res=''; |
|||
if($list) |
|||
{ |
|||
foreach($list as $k=>$v) |
|||
{ |
|||
$child = self::where(array('pid'=>$list[$k]->id,'is_show'=>self::IS_SHOW))->orderBy('listorder', 'asc')->get(); |
|||
|
|||
if($child) |
|||
{ |
|||
$temp_child=''; |
|||
foreach($child as $key=>$value) |
|||
{ |
|||
if($value->type == 'click') |
|||
{ |
|||
$temp_child[] = array( |
|||
'type'=>$value->type, |
|||
'name'=>$value->name, |
|||
'key'=>$value->key |
|||
); |
|||
} |
|||
elseif($value->type == 'view') |
|||
{ |
|||
$temp_child[] = array( |
|||
'type'=>$value->type, |
|||
'name'=>$value->name, |
|||
'url'=>$value->key |
|||
); |
|||
} |
|||
elseif($value->type == 'miniprogram') |
|||
{ |
|||
$temp_child[] = array( |
|||
'type'=>$value->type, |
|||
'name'=>$value->name, |
|||
'url'=>$value->key, |
|||
'appid'=>$value->appid, |
|||
'pagepath'=>$value->pagepath |
|||
); |
|||
} |
|||
} |
|||
|
|||
$res[] = array( |
|||
'name'=>$value->name, |
|||
'sub_button'=>$temp_child |
|||
); |
|||
} |
|||
else |
|||
{ |
|||
if($v->type == 'click') |
|||
{ |
|||
$res[] = array( |
|||
'type'=>$v->type, |
|||
'name'=>$v->name, |
|||
'key'=>$v->key |
|||
); |
|||
} |
|||
elseif($v->type == 'view') |
|||
{ |
|||
$res[] = array( |
|||
'type'=>$v->type, |
|||
'name'=>$v->name, |
|||
'url'=>$v->key |
|||
); |
|||
} |
|||
elseif($v->type == 'miniprogram') |
|||
{ |
|||
$res[] = array( |
|||
'type'=>$v->type, |
|||
'name'=>$v->name, |
|||
'url'=>$v->key, |
|||
'appid'=>$v->appid, |
|||
'pagepath'=>$v->pagepath |
|||
); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
return json_encode($res); |
|||
} |
|||
} |
@ -0,0 +1,86 @@ |
|||
@extends('admin.layouts.app') |
|||
@section('title', '栏目添加') |
|||
|
|||
@section('content') |
|||
<h5 class="sub-header"><a href="/fladmin/weixinmenu">栏目管理</a> > 栏目添加</h5> |
|||
|
|||
<form method="post" action="/fladmin/weixinmenu/doadd" role="form" id="addcat" class="table-responsive">{{ csrf_field() }} |
|||
<table class="table table-striped table-bordered"> |
|||
<tbody> |
|||
<tr> |
|||
<td align="right">名称:</td> |
|||
<td><input name="name" type="text" id="name" size="30" class="required"></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">上级菜单:</td> |
|||
<td><?php if($id==0){echo "顶级栏目";}else{echo $postone["name"];} ?><input style="display:none;" type="text" name="prid" id="prid" value="<?php if($id==0){echo "top";}else{echo $id;} ?>"></td>
|
|||
</tr> |
|||
<tr> |
|||
<td align="right">菜单的响应动作类型:</td> |
|||
<td><input name="type" type="text" value="" id="type" style="width:30%"> <small>(view表示网页,click表示点击,miniprogram表示小程序)</small></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">菜单KEY值:</td> |
|||
<td><input name="key" id="key" type="text" value="" size="30"> <small>(click等点击类型必须)</small></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">网页链接:</td> |
|||
<td><input name="url" id="url" type="text" value="" size="50"> <small>(view、miniprogram类型必须)</small></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">media_id:</td> |
|||
<td><input name="media_id" type="text" style="width:70%" id="media_id" class="alltxt" value=""></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">appid:</td> |
|||
<td><input name="appid" type="text" style="width:50%" id="appid" class="alltxt" value=""></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">pagepath:</td> |
|||
<td><input name="pagepath" type="text" style="width:50%" id="pagepath" class="alltxt" value=""></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">是否显示:</td> |
|||
<td> |
|||
<input type="radio" value='0' name="is_show" checked /> 是 |
|||
<input type="radio" value='1' name="is_show" /> 否 |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="2"><input type="submit" class="btn btn-success" value="保存(Submit)"> <input type="reset" class="btn btn-default" value="重置(Reset)"></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</form><!-- 表单结束 --> |
|||
<script> |
|||
$(function(){ |
|||
$(".required").blur(function(){ |
|||
var $parent = $(this).parent(); |
|||
$parent.find(".formtips").remove(); |
|||
|
|||
if(this.value=="") |
|||
{ |
|||
$parent.append(' <small class="formtips onError"><font color="red">不能为空!</font></small>'); |
|||
} |
|||
else |
|||
{ |
|||
$parent.append(' <small class="formtips onSuccess"><font color="green">OK</font></small>'); |
|||
} |
|||
}); |
|||
|
|||
//重置
|
|||
$('#addcat input[type="reset"]').click(function(){ |
|||
$(".formtips").remove(); |
|||
}); |
|||
}); |
|||
|
|||
$('#addcat input[type="submit"]').click(function(){ |
|||
$(".required").trigger('blur'); |
|||
var numError = $('#addcat .onError').length; |
|||
|
|||
if(numError){ |
|||
return false; |
|||
} |
|||
}); |
|||
</script> |
|||
@endsection |
@ -0,0 +1,82 @@ |
|||
@extends('admin.layouts.app') |
|||
@section('title', '菜单修改') |
|||
|
|||
@section('content') |
|||
<h5 class="sub-header"><a href="/fladmin/weixinmenu">菜单管理</a> > 菜单修改</h5> |
|||
|
|||
<form method="post" action="/fladmin/weixinmenu/doedit" role="form" id="addcat" class="table-responsive">{{ csrf_field() }} |
|||
<table class="table table-striped table-bordered"> |
|||
<tbody> |
|||
<tr> |
|||
<td align="right">名称:</td> |
|||
<td><input name="name" type="text" value="<?php echo $post["name"]; ?>" id="name" size="30" class="required"><input style="display:none;" type="text" name="id" id="id" value="<?php echo $id; ?>"></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">菜单的响应动作类型:</td> |
|||
<td><input name="type" type="text" value="<?php echo $post["type"]; ?>" id="type" style="width:30%"> <small>(view表示网页,click表示点击,miniprogram表示小程序)</small></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">菜单KEY值:</td> |
|||
<td><input name="key" id="key" type="text" value="<?php echo $post["key"]; ?>" size="30"> <small>(click等点击类型必须)</small></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">网页链接:</td> |
|||
<td><input name="url" id="url" type="text" value="<?php echo $post["url"]; ?>" size="50"> <small>(view、miniprogram类型必须)</small></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">media_id:</td> |
|||
<td><input name="media_id" type="text" style="width:70%" id="media_id" class="alltxt" value="<?php echo $post["media_id"]; ?>"></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">appid:</td> |
|||
<td><input name="appid" type="text" style="width:50%" id="appid" class="alltxt" value="<?php echo $post["appid"]; ?>"></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">pagepath:</td> |
|||
<td><input name="pagepath" type="text" style="width:50%" id="pagepath" class="alltxt" value="<?php echo $post["pagepath"]; ?>"></td> |
|||
</tr> |
|||
<tr> |
|||
<td align="right">是否显示:</td> |
|||
<td> |
|||
<input type="radio" value='0' name="is_show" <?php if(isset($post['is_show']) && $post['is_show']==0){echo 'checked';} ?> /> 是
|
|||
<input type="radio" value='1' name="is_show" <?php if(isset($post['is_show']) && $post['is_show']==1){echo 'checked';} ?> /> 否
|
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="2"><input type="submit" class="btn btn-success" value="保存(Submit)"> <input type="reset" class="btn btn-default" value="重置(Reset)"></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</form><!-- 表单结束 --> |
|||
<script> |
|||
$(function(){ |
|||
$(".required").blur(function(){ |
|||
var $parent = $(this).parent(); |
|||
$parent.find(".formtips").remove(); |
|||
|
|||
if(this.value=="") |
|||
{ |
|||
$parent.append(' <small class="formtips onError"><font color="red">不能为空!</font></small>'); |
|||
} |
|||
else |
|||
{ |
|||
$parent.append(' <small class="formtips onSuccess"><font color="green">OK</font></small>'); |
|||
} |
|||
}); |
|||
|
|||
//重置
|
|||
$('#addcat input[type="reset"]').click(function(){ |
|||
$(".formtips").remove(); |
|||
}); |
|||
}); |
|||
|
|||
$('#addcat input[type="submit"]').click(function(){ |
|||
$(".required").trigger('blur'); |
|||
var numError = $('#addcat .onError').length; |
|||
|
|||
if(numError){ |
|||
return false; |
|||
} |
|||
}); |
|||
</script> |
|||
@endsection |
@ -0,0 +1,32 @@ |
|||
@extends('admin.layouts.app') |
|||
@section('title', '微信公众号自定义菜单列表') |
|||
|
|||
@section('content') |
|||
<h2 class="sub-header">微信自定义菜单</h2>[ <a href="/fladmin/weixinmenu/add">增加顶级菜单</a> ] [ <a onclick="createmenu_confirm('/fladmin/weixinmenu/createmenu')" href="javascript:;">生成菜单</a> ]<br><br> |
|||
|
|||
<form name="listarc"><div class="table-responsive"> |
|||
<table class="table table-striped table-hover"> |
|||
<thead><tr><th>ID</th><th>名称</th><th>菜单动作类型</th><th>是否显示</th><th>更新时间</th><th>操作</th></tr></thead> |
|||
<tbody id="cat-list"> |
|||
<?php if($catlist){foreach($catlist as $row){ ?>
|
|||
<tr id="cat-<?php echo $row["id"]; ?>"> |
|||
<td><?php echo $row["id"]; ?></td>
|
|||
<td><?php if($row["pid"]!=0){echo "— ";}echo $row["name"]; ?></td><td><?php echo $row["type"]; ?></td><td><?php if($row["is_show"]==0){echo '是';}else{echo '<font color="red">否</font>';} ?></td><td><?php echo date('Y-m-d',$row["addtime"]); ?></td>
|
|||
<td><?php if($row["pid"]==0){ ?><a href="/fladmin/weixinmenu/add?reid=<?php echo $row["id"]; ?>">增加子类</a> | <?php } ?><a href="/fladmin/weixinmenu/edit?id=<?php echo $row["id"]; ?>">更改</a> | <a onclick="delconfirm('/fladmin/weixinmenu/del?id=<?php echo $row["id"]; ?>')" href="javascript:;">删除</a></td>
|
|||
</tr><?php }} ?>
|
|||
</tbody></table></div><!-- 表格结束 --></form><!-- 表单结束 --> |
|||
|
|||
<script> |
|||
function createmenu_confirm(url) |
|||
{ |
|||
if(confirm("确定要重新生成微信自定义菜单吗?")) |
|||
{ |
|||
location.href= url; |
|||
} |
|||
else |
|||
{ |
|||
|
|||
} |
|||
} |
|||
</script> |
|||
@endsection |
Write
Preview
Loading…
Cancel
Save
Reference in new issue