123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <?php
- # 定义几个常用的选项
- $option = array
- (
- 1 => '开启',
- 2 => '关闭',
- );
- $menu = function()
- {
- $array = array(-1 => array('name' => '父级菜单'));
- $data = Dever::load('weixin/menu-main');
- if($data)
- {
- $array += $data;
- }
- return $array;
- };
- $message = function()
- {
- $array = array(-1 => array('name' => '不选择消息'));
- $data = Dever::load('weixin/content-get_2');
- if($data)
- {
- $array += $data;
- }
- return $array;
- };
- # 菜单类型
- $type = array
- (
- 'click' => '点击推事件',
- 'view' => '跳转url',
- 'scancode_push' => '扫码推事件',
- 'scancode_waitmsg' => '扫码推事件且弹出“消息接收中”提示框',
- 'pic_sysphoto' => '弹出系统拍照发图',
- 'pic_photo_or_album' => '弹出拍照或者相册发图',
- 'pic_weixin' => '弹出微信相册发图器',
- 'location_select' => '弹出地理位置选择器',
- //'media_id' => '下发消息(除文本消息)',
- //'view_limited' => '跳转图文消息URL',
- );
- return array
- (
- # 表名
- 'name' => 'menu',
- # 显示给用户看的名称
- 'lang' => '自定义菜单',
- 'order' => 17,
- # 数据结构
- 'struct' => array
- (
- 'id' => array
- (
- 'type' => 'int-11',
- 'name' => 'ID',
- 'default' => '',
- 'desc' => '',
- 'match' => 'is_numeric',
- 'search' => 'order',
- //'list' => true,
- ),
-
- 'site' => array
- (
- 'type' => 'int-11',
- 'name' => '站点',
- 'default' => '',
- 'desc' => '请输入站点',
- 'match' => 'is_numeric',
- //'search' => 'order,fulltext',
- //'update' => 'text',
- //'list' => true,
- ),
-
- 'name' => array
- (
- 'type' => 'varchar-24',
- 'name' => '菜单名称',
- 'default' => '',
- 'desc' => '请输入菜单名称',
- 'match' => 'is_string',
- 'update' => 'text',
- 'search' => 'order,fulltext',
- 'list' => true,
- ),
-
- 'menu_id' => array
- (
- 'type' => 'int-11',
- 'name' => '上级菜单',
- 'default' => '-1',
- 'desc' => '请选择上级菜单',
- 'match' => 'is_numeric',
- 'update' => 'select',
- 'search' => 'order,select',
- 'list' => '{menu_id} > 0 ? Dever::load("weixin/menu-one#name", {menu_id}) : "父级菜单"',
- 'option' => $menu,
- ),
-
- 'type' => array
- (
- 'type' => 'varchar-10',
- 'name' => '菜单类型',
- 'default' => 'click',
- 'desc' => '请选择菜单类型',
- 'match' => 'is_string',
- 'option' => $type,
- 'update' => 'radio',
- 'list' => true,
- # 开启显示控制,可以控制下边的表单
- 'show' => 'type',
- ),
-
- 'message' => array
- (
- 'type' => 'int-11',
- 'name' => '回复消息',
- 'default' => '',
- 'desc' => '回复消息',
- 'match' => 'is_numeric',
- 'update' => 'select',
- 'list' => '{message} > 0 ? Dever::load("weixin/content-one#keywords", {message}) : "未选择消息"',
- 'option' => $message,
- 'show' => array('type_click'),
- ),
-
- 'url' => array
- (
- 'type' => 'varchar-100',
- 'name' => '网页链接',
- 'default' => '',
- 'desc' => '请输入网页链接',
- 'match' => 'option',
- 'update' => 'text',
- 'show' => array('type_view'),
- ),
-
- 'reorder' => array
- (
- 'type' => 'int-11',
- 'name' => '排序(数值越大越靠前)',
- 'default' => '1',
- 'desc' => '请输入排序',
- 'match' => 'option',
- 'update' => 'text',
- 'search' => 'order',
- 'list' => true,
- 'order' => 'desc',
- ),
- 'state' => array
- (
- 'type' => 'tinyint-1',
- 'name' => '状态',
- 'default' => '1',
- 'desc' => '请选择状态',
- 'match' => 'is_numeric',
- 'option' => $option,
- 'update' => 'radio',
- ),
-
- 'cdate' => array
- (
- 'type' => 'int-11',
- 'name' => '录入时间',
- 'match' => array('is_numeric', time()),
- 'desc' => '',
- # 只有insert时才生效
- 'insert' => true,
- 'list' => 'date("Y-m-d H:i:s", {cdate})',
- ),
- ),
- # 更新表结构
- 'alter' => array
- (
- 1 => array
- (
- array('update', 'url', 'url', 'text-255 头部菜单'),
- ),
- 'version' => 1,
- ),
-
- 'manage' => array
- (
- # 不允许编辑
- //'edit' => false,
- //
- //# 列表页的类型
- 'list_type' => 'parent',
-
- # 按钮
- 'button' => array
- (
- '发布菜单' => 'weixin/menu.create',
- '删除菜单' => 'weixin/data.menu_del',
- ),
-
- # 可以删除
- //1 => array('同步', '"javascript:load(\'".Dever::url("weixin/menu.test?id={id}")."\')"')
- 'list_button' => array(6 => '删除'),
-
- 'desc' => '注意:除了点击推事件和跳转URL,其他类型的菜单,仅支持微信iPhone5.4.1以上版本,和Android5.4以上版本的微信用户,旧版本微信用户点击后将没有回应,开发者也不能正常接收到事件推送。',
- ),
-
- 'auth' => 'site',
-
- # request 请求接口定义
- 'request' => array
- (
- # main 取所有主栏目
- 'main' => array
- (
- 'where' => array
- (
- 'menu_id' => -1,
- 'state' => 1,
- 'site' => 'yes',
- ),
- 'type' => 'all',
- 'order' => array('reorder` desc,`id', 'desc'),
- 'col' => '*|id',
- ),
-
- # 取所有下级栏目
- 'child' => array
- (
- 'where' => array
- (
- 'menu_id' => array('1', '>='),
- 'state' => 1,
- 'site' => 'yes',
- ),
- 'type' => 'all',
- 'order' => array('reorder` desc,`id', 'desc'),
- 'col' => '*|menu_id|id|',
- ),
-
- # 取所有菜单
- 'all' => array
- (
- 'where' => array
- (
- 'state' => 1,
- 'site' => 'yes',
- ),
- 'type' => 'all',
- 'order' => array('reorder` desc,`id', 'desc'),
- 'col' => '*|menu_id|id|',
- ),
- ),
- );
|