diff --git a/README.md b/README.md index 2f95b5855..c0265f295 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,21 @@ ThinkAdmin for PHP -- +## 大道至简 · 悟在天成 + * ThinkAdmin 是一个基于 Thinkphp 5.1.x 开发的后台管理系统,集成后台系统常用功能。 * 项目安装及二次开发请参考 ThinkPHP 官方文档及下面的服务环境说明,数据库 sql 文件存放于项目根目录下。 >* 注意:项目测试请另行搭建环境并创建数据库(数据库配置 config/database.php), 切勿直接使用测试环境数据! ->* 如果系统提示“测试系统禁止操作等字样”,可以修改项目路由配置(route/route.php),清空里面的路由记录。 ->* 当前版本使用ThinkPHP5.1.x版本,对PHP版本要求不低于php5.6,具体请查阅ThinkPHP官方文档。 +>* 如果系统提示“测试系统禁止操作等字样”,可以修改项目路由配置(route/route.php), 清空里面的路由记录。 +>* 当前版本使用 ThinkPHP 5.1.x 版本,对PHP版本要求不低于php5.6,具体请查阅ThinkPHP官方文档。 Documentation -- +认真看看文档可能会对你的开发有所帮助哦! + +文档地址:[ThinkAdmin 开发文档](https://www.kancloud.cn/zoujingli/thinkadmin/content) + + PHP开发技术交流(QQ群 513350915) [![PHP微信开发群 (SDK)](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=ae25cf789dafbef62e50a980ffc31242f150bc61a61164458216dd98c411832a) @@ -17,11 +24,12 @@ PHP开发技术交流(QQ群 513350915) Repositorie -- ThinkAdmin 为开源项目,允许把它用于任何地方,不受任何约束,欢迎 fork 项目。 ->* GitHub 托管地址:https://github.com/zoujingli/ThinkAdmin ->* OSChina 托管地址:http://git.oschina.net/zoujingli/Think.Admin +* GitHub 托管地址:https://github.com/zoujingli/ThinkAdmin +* Gitee 托管地址:https://gitee.com/zoujingli/Think.Admin 对于新版本的微信模块使用的是授权模式,需要用到 ThinkService 项目。 * GitHub 托管地址:https://github.com/zoujingli/ThinkService +* Gitee 托管地址:https://gitee.com/zoujingli/ThinkService 其安装与 ThinkAdmin 相似,这里就不多说了。具体可以参见微信开放平台官网 https://open.weixin.qq.com ,ThinkService 后台具体可以配置对应参数。 @@ -37,7 +45,6 @@ Module * `Http`服务组件(原生`CURL`封装,兼容PHP多版本) * 微信公众号服务组件(基于[WeChatDeveloper](https://github.com/zoujingli/WeChatDeveloper),微信网页授权获取用户信息、已关注粉丝管理、自定义菜单管理等等) * 微信商户支付服务组件(基于[WeChatDeveloper](https://github.com/zoujingli/WeChatDeveloper),支持JSAPI支付、扫码模式一支付、扫码模式二支付) -* 测试公众号名称:思过崖思过 (大家可以关注它来进行简单的测试) * 更多组件开发中... diff --git a/admin_v3.sql b/admin_v3.sql index 1bf788e61..813b0704b 100644 --- a/admin_v3.sql +++ b/admin_v3.sql @@ -10,11 +10,131 @@ Target Server Type : MYSQL Target Server Version : 50559 File Encoding : 65001 -Date: 2018-03-13 15:44:55 +Date: 2018-03-23 17:07:39 */ SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for goods +-- ---------------------------- +DROP TABLE IF EXISTS `goods`; +CREATE TABLE `goods` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `brand_id` bigint(20) unsigned DEFAULT '0' COMMENT '品牌ID', + `cate_id` bigint(20) unsigned DEFAULT '0' COMMENT '商品分类id', + `unit_id` bigint(20) DEFAULT NULL COMMENT '商品单位ID', + `spec_id` bigint(20) unsigned DEFAULT '0' COMMENT '规格ID', + `tags_id` varchar(255) DEFAULT '' COMMENT '商品标签ID', + `is_code` bigint(1) DEFAULT '1' COMMENT '是否有码商品', + `goods_title` varchar(255) DEFAULT '' COMMENT '商品标签', + `goods_content` text COMMENT '商品内容', + `goods_logo` varchar(255) DEFAULT '' COMMENT '商品LOGO', + `goods_image` text COMMENT '商品图片地址', + `goods_video` varchar(500) DEFAULT '' COMMENT '商品视频URL', + `goods_desc` varchar(500) DEFAULT '' COMMENT '商品描述', + `package_stock` bigint(20) unsigned DEFAULT '0' COMMENT '总库存数量', + `package_sale` bigint(20) unsigned DEFAULT '0' COMMENT '已销售数量', + `favorite_num` bigint(20) unsigned DEFAULT '0' COMMENT '收藏次数', + `sort` bigint(20) unsigned DEFAULT '0' COMMENT '数据排序', + `status` bigint(1) unsigned DEFAULT '1' COMMENT '商品状态(1有效,0无效)', + `is_deleted` bigint(1) unsigned DEFAULT '0' COMMENT '删除状态(1删除,0未删除)', + `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商城商品主表'; + +-- ---------------------------- +-- Records of goods +-- ---------------------------- + +-- ---------------------------- +-- Table structure for goods_brand +-- ---------------------------- +DROP TABLE IF EXISTS `goods_brand`; +CREATE TABLE `goods_brand` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `brand_logo` varchar(1024) DEFAULT '' COMMENT '品牌logo', + `brand_cover` varchar(1024) DEFAULT '' COMMENT '品牌封面', + `brand_title` varchar(255) DEFAULT '' COMMENT '商品品牌名称', + `brand_desc` text COMMENT '商品品牌描述', + `brand_detail` text COMMENT '品牌图文信息', + `sort` int(11) unsigned DEFAULT '0' COMMENT '商品分类排序', + `status` tinyint(1) unsigned DEFAULT '1' COMMENT '商品状态(1有效,0无效)', + `is_deleted` tinyint(1) unsigned DEFAULT '0' COMMENT '删除状态(1删除,0未删除)', + `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商品产品品牌'; + +-- ---------------------------- +-- Records of goods_brand +-- ---------------------------- + +-- ---------------------------- +-- Table structure for goods_cate +-- ---------------------------- +DROP TABLE IF EXISTS `goods_cate`; +CREATE TABLE `goods_cate` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `pid` bigint(20) unsigned DEFAULT '0' COMMENT '上级分类编号', + `brand_id` bigint(20) DEFAULT '0' COMMENT '品牌ID', + `cate_title` varchar(255) DEFAULT '' COMMENT '商品分类名称', + `cate_desc` text COMMENT '商品分类', + `sort` bigint(20) unsigned DEFAULT '0' COMMENT '商品分类排序', + `status` bigint(1) unsigned DEFAULT '1' COMMENT '商品状态(1有效,0无效)', + `is_deleted` bigint(1) unsigned DEFAULT '0' COMMENT '删除状态(1删除,0未删除)', + `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商城商品分类'; + +-- ---------------------------- +-- Records of goods_cate +-- ---------------------------- + +-- ---------------------------- +-- Table structure for goods_list +-- ---------------------------- +DROP TABLE IF EXISTS `goods_list`; +CREATE TABLE `goods_list` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `goods_id` bigint(20) unsigned DEFAULT '0' COMMENT '商品ID', + `goods_spec` varchar(255) DEFAULT '' COMMENT '商品规格名称', + `goods_number` bigint(20) unsigned DEFAULT '0' COMMENT '商品礼品-商品数量', + `market_price` decimal(20,2) unsigned DEFAULT '0.00' COMMENT '销售价格', + `selling_price` decimal(20,2) unsigned DEFAULT '0.00' COMMENT '商品价格', + `goods_stock` bigint(20) unsigned DEFAULT '0' COMMENT '商品库存统计', + `goods_sale` bigint(20) unsigned DEFAULT '0' COMMENT '已销售数量', + `status` bigint(1) unsigned DEFAULT '1' COMMENT '商品状态(1有效,0无效)', + `is_deleted` bigint(1) unsigned DEFAULT '0' COMMENT '删除状态(1删除,0未删除)', + `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商城商品列表'; + +-- ---------------------------- +-- Records of goods_list +-- ---------------------------- + +-- ---------------------------- +-- Table structure for goods_spec +-- ---------------------------- +DROP TABLE IF EXISTS `goods_spec`; +CREATE TABLE `goods_spec` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `mch_id` bigint(20) unsigned DEFAULT '0' COMMENT '商户ID', + `spec_title` varchar(255) DEFAULT '' COMMENT '商品规格名称', + `spec_param` varchar(255) DEFAULT '' COMMENT '商品规格参数', + `spec_desc` varchar(255) DEFAULT '' COMMENT '商品规格描述', + `sort` bigint(20) unsigned DEFAULT '0' COMMENT '商品规格排序', + `status` bigint(1) unsigned DEFAULT '1' COMMENT '商品状态(1有效,0无效)', + `is_deleted` bigint(1) unsigned DEFAULT '0' COMMENT '删除状态(1删除,0未删除)', + `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `index_store_goods_spec_mch_id` (`mch_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商城商品规格'; + +-- ---------------------------- +-- Records of goods_spec +-- ---------------------------- + -- ---------------------------- -- Table structure for system_auth -- ---------------------------- @@ -63,7 +183,7 @@ CREATE TABLE `system_config` ( `value` varchar(500) DEFAULT NULL COMMENT '配置值', PRIMARY KEY (`id`), KEY `index_system_config_name` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='系统参数配置'; +) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='系统参数配置'; -- ---------------------------- -- Records of system_config @@ -86,6 +206,15 @@ INSERT INTO `system_config` VALUES ('15', 'storage_oss_endpoint', 'oss-cn-beijin INSERT INTO `system_config` VALUES ('16', 'storage_oss_domain', 'cuci.oss-cn-beijing.aliyuncs.com'); INSERT INTO `system_config` VALUES ('17', 'storage_oss_keyid', '用你自己的吧'); INSERT INTO `system_config` VALUES ('18', 'storage_oss_secret', '用你自己的吧'); +INSERT INTO `system_config` VALUES ('34', 'wechat_appid', 'wx60a43dd8161666d4'); +INSERT INTO `system_config` VALUES ('35', 'wechat_appkey', '9890a0d7c91801a609d151099e95b61a'); +INSERT INTO `system_config` VALUES ('36', 'storage_oss_is_https', 'http'); +INSERT INTO `system_config` VALUES ('37', 'wechat_type', 'api'); +INSERT INTO `system_config` VALUES ('38', 'wechat_token', 'test'); +INSERT INTO `system_config` VALUES ('39', 'wechat_appsecret', 'a041bec98ed015d52b99acea5c6a16ef'); +INSERT INTO `system_config` VALUES ('40', 'wechat_encodingaeskey', 'BJIUzE0gqlWy0GxfPp4J1oPTBmOrNDIGPNav1YFH5Z5'); +INSERT INTO `system_config` VALUES ('41', 'wechat_thr_appid', 'wx60a43dd8161666d4'); +INSERT INTO `system_config` VALUES ('42', 'wechat_thr_appkey', '05db2aa335382c66ab56d69b1a9ad0ee'); -- ---------------------------- -- Table structure for system_log @@ -100,13 +229,11 @@ CREATE TABLE `system_log` ( `content` text NOT NULL COMMENT '操作内容描述', `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='系统操作日志表'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统操作日志表'; -- ---------------------------- -- Records of system_log -- ---------------------------- -INSERT INTO `system_log` VALUES ('1', '113.106.73.138', 'admin/login/index', 'admin', '系统管理', '用户登录系统成功', '2018-03-13 15:42:15'); -INSERT INTO `system_log` VALUES ('2', '115.229.46.40', 'admin/login/index', 'admin', '系统管理', '用户登录系统成功', '2018-03-13 15:43:48'); -- ---------------------------- -- Table structure for system_menu @@ -127,7 +254,7 @@ CREATE TABLE `system_menu` ( `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`), KEY `index_system_menu_node` (`node`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8 COMMENT='系统菜单表'; +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COMMENT='系统菜单表'; -- ---------------------------- -- Records of system_menu @@ -172,7 +299,7 @@ CREATE TABLE `system_node` ( `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`), KEY `index_system_node_node` (`node`) -) ENGINE=InnoDB AUTO_INCREMENT=322 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='系统节点表'; +) ENGINE=InnoDB AUTO_INCREMENT=230 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='系统节点表'; -- ---------------------------- -- Records of system_node @@ -188,7 +315,6 @@ INSERT INTO `system_node` VALUES ('8', 'admin/auth/resume', '启用权限', '0', INSERT INTO `system_node` VALUES ('9', 'admin/auth/del', '删除权限', '0', '1', '1', '2018-01-23 12:39:25'); INSERT INTO `system_node` VALUES ('10', 'admin/config/index', '系统参数', '1', '1', '1', '2018-01-23 12:39:25'); INSERT INTO `system_node` VALUES ('11', 'admin/config/file', '文件存储', '0', '1', '1', '2018-01-23 12:39:26'); -INSERT INTO `system_node` VALUES ('12', 'admin/config/sms', '短信接口', '0', '1', '1', '2018-01-23 12:39:28'); INSERT INTO `system_node` VALUES ('13', 'admin/log/index', '日志记录', '1', '1', '1', '2018-01-23 12:39:28'); INSERT INTO `system_node` VALUES ('14', 'admin/log/sms', '短信记录', '0', '1', '1', '2018-01-23 12:39:29'); INSERT INTO `system_node` VALUES ('15', 'admin/log/del', '日志删除', '0', '1', '1', '2018-01-23 12:39:29'); @@ -300,7 +426,7 @@ CREATE TABLE `system_user` ( -- ---------------------------- -- Records of system_user -- ---------------------------- -INSERT INTO `system_user` VALUES ('10000', 'admin', '21232f297a57a5a743894a0e4a801fc3', '', '', '', '', '22409', '2018-03-13 15:43:48', '1', '1', '0', null, '2015-11-13 15:14:22'); +INSERT INTO `system_user` VALUES ('10000', 'admin', '21232f297a57a5a743894a0e4a801fc3', '22222222', '', '18993368867', '', '23296', '2018-03-23 17:05:40', '1', '2,4', '0', null, '2015-11-13 15:14:22'); -- ---------------------------- -- Table structure for wechat_fans diff --git a/application/admin/view/auth/form.html b/application/admin/view/auth/form.html index 5ca12242d..874a0732e 100644 --- a/application/admin/view/auth/form.html +++ b/application/admin/view/auth/form.html @@ -1,4 +1,4 @@ -
+
diff --git a/application/admin/view/index/main.html b/application/admin/view/index/main.html index abd045bdc..d5e62ca14 100644 --- a/application/admin/view/index/main.html +++ b/application/admin/view/index/main.html @@ -2,41 +2,6 @@ {block name="content"} - - @@ -68,7 +33,7 @@ @@ -115,31 +80,4 @@
{:php_uname('s')} 产品DEMO体验 - http://service.thinkadmin.top + http://demo.thinkadmin.top
-{/block} - -{block name='style'} - {/block} \ No newline at end of file diff --git a/application/admin/view/log/index.html b/application/admin/view/log/index.html index 55813eee8..090ce1b34 100644 --- a/application/admin/view/log/index.html +++ b/application/admin/view/log/index.html @@ -60,6 +60,9 @@ + +

没 有 记 录 哦!

+ @@ -92,5 +95,6 @@
{if isset($page)}

{$page|raw}

{/if} + {/block} \ No newline at end of file diff --git a/application/admin/view/login/index.html b/application/admin/view/login/index.html index 42c4069a8..2b0374bb5 100644 --- a/application/admin/view/login/index.html +++ b/application/admin/view/login/index.html @@ -38,16 +38,14 @@ @@ -55,15 +53,12 @@ - {if sysconf('site_copy')} + - {/if} +
diff --git a/application/admin/view/menu/form.html b/application/admin/view/menu/form.html index 86196980f..9008d90ba 100644 --- a/application/admin/view/menu/form.html +++ b/application/admin/view/menu/form.html @@ -1,4 +1,4 @@ -
+
diff --git a/application/admin/view/menu/index.html b/application/admin/view/menu/index.html index 863fe5336..f34799631 100644 --- a/application/admin/view/menu/index.html +++ b/application/admin/view/menu/index.html @@ -43,7 +43,7 @@ - {$vo.spl|raw}{$vo.title} + {$vo.spl|raw}{$vo.title} {$vo.url} {if $vo.status eq 0}已禁用{elseif $vo.status eq 1}使用中{/if} @@ -53,7 +53,7 @@ {if auth("$classuri/add")} | - 添加下级 + 添加下级 添加下级 @@ -61,7 +61,7 @@ {if auth("$classuri/edit")} | - 编辑 + 编辑 {/if} {if $vo.status eq 1 and auth("$classuri/forbid")} diff --git a/application/admin/view/node/index.html b/application/admin/view/node/index.html index 671d68bc7..99e99b451 100644 --- a/application/admin/view/node/index.html +++ b/application/admin/view/node/index.html @@ -28,7 +28,7 @@ - {$vo.spl|raw} {$vo.node} + {$vo.spl|raw} {$vo.node} {if auth("$classuri/save")} {/if} @@ -46,36 +46,36 @@ {/if} {if auth("$classuri/save") and $vo.spt eq 2} -  ├─ +   ├─  -       ├─ +      ├─  -       ├─ +      ├─  {/if} - + diff --git a/application/admin/view/plugs/upfile.html b/application/admin/view/plugs/upfile.html index 3f4f80530..0f816b963 100644 --- a/application/admin/view/plugs/upfile.html +++ b/application/admin/view/plugs/upfile.html @@ -47,35 +47,34 @@ top.$('[name="{$field}"]').map(function () { top.$(this).attr('data-srcs', ret.url).attr('data-md5', file.md5).val(url).trigger('change'); }); - var index = top.layer.getFrameIndex(window.name); - top.layer.close(index); - /*{/if} {$mode}*/ + top.layer.close(top.layer.getFrameIndex(window.name)); + /*{/if}*/ } - function confirmSelected() { - var srcs = new Array(), md5s = new Array(); - $('[data-md5] .success').map(function () { - var $li = $(this).parents('[data-md5]'); - md5s.push($li.attr('data-md5')); - srcs.push($li.attr('data-src')); - }); - if (srcs.length < 1) { - return top.$.msg.tips('还没有选择文件,请勾选需要使用的文件!'); - } - top.$('[name="{$field}"]').map(function () { - top.$(this).attr('data-srcs', srcs.join('|')).attr('data-md5', md5s.join('|')).val(srcs.join('|')).trigger('change'); - }); - var index = top.layer.getFrameIndex(window.name); - top.layer.close(index); - } + var isSuccessState = false; function completed() { var btnHTML = '完成上传'; - $('.uploadBtn').on('click', function () { - if (this.innerHTML === btnHTML) { - confirmSelected.call(this); + $('.uploadBtn').html(btnHTML).on('click', successSelected); + + function successSelected() { + if (!isSuccessState && this.innerHTML === btnHTML) { + isSuccessState = true; + var srcs = [], md5s = []; + $('[data-md5] .success').map(function () { + var $li = $(this).parents('[data-md5]'); + md5s.push($li.attr('data-md5')); + srcs.push($li.attr('data-src')); + }); + if (srcs.length < 1) { + return top.$.msg.tips('还没有选择文件,请勾选需要使用的文件!'); + } + top.$('[name="{$field}"]').map(function () { + top.$(this).attr('data-srcs', srcs.join('|')).attr('data-md5', md5s.join('|')).val(srcs.join('|')).trigger('change'); + }); + top.layer.close(top.layer.getFrameIndex(window.name)); } - }).html(btnHTML); + } } // 当domReady的时候开始初始化 diff --git a/application/admin/view/user/auth.html b/application/admin/view/user/auth.html index d448eccee..427dac275 100644 --- a/application/admin/view/user/auth.html +++ b/application/admin/view/user/auth.html @@ -1,4 +1,4 @@ - +
diff --git a/application/admin/view/user/form.html b/application/admin/view/user/form.html index 00d5a90e8..24ce246f6 100644 --- a/application/admin/view/user/form.html +++ b/application/admin/view/user/form.html @@ -1,4 +1,4 @@ - +
diff --git a/application/admin/view/user/index.html b/application/admin/view/user/index.html index 63962e01e..c0cb84164 100644 --- a/application/admin/view/user/index.html +++ b/application/admin/view/user/index.html @@ -45,7 +45,7 @@
- + + + + + + + + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ {if !empty($vo.id)}{/if} + + +
+
+ + + + + + +{/block} \ No newline at end of file diff --git a/application/goods/view/brand/index.html b/application/goods/view/brand/index.html new file mode 100644 index 000000000..9f993f7d8 --- /dev/null +++ b/application/goods/view/brand/index.html @@ -0,0 +1,108 @@ +{extend name='admin@public/content'} + +{block name="button"} + + + + + + + + + +{/block} + +{block name="content"} + + + + + + + +
+ {if empty($list)} +

没 有 记 录 哦!

+ {else} + + + + + + + + + + + + + + {foreach $list as $key=>$vo} + + + + + + + + + {/foreach} + +
+ + + + 产品品牌添加时间品牌状态
+ + + + {$vo.brand_title}{$vo.create_at|format_datetime} + {if $vo.status eq 0}已禁用{elseif $vo.status eq 1}使用中{/if} + + + {if auth("$classuri/edit")} + | + 编辑 + {/if} + + {if $vo.status eq 1 and auth("$classuri/forbid")} + | + 禁用 + {elseif auth("$classuri/resume")} + | + 启用 + {/if} + + {if auth("$classuri/del")} + | + 删除 + {/if} + +
+ {if isset($page)}

{$page|raw}

{/if} + {/if} +
+{/block} \ No newline at end of file diff --git a/application/goods/view/cate/form.html b/application/goods/view/cate/form.html new file mode 100644 index 000000000..bfbac66e6 --- /dev/null +++ b/application/goods/view/cate/form.html @@ -0,0 +1,39 @@ + diff --git a/application/goods/view/cate/index.html b/application/goods/view/cate/index.html new file mode 100644 index 000000000..3aec38b2e --- /dev/null +++ b/application/goods/view/cate/index.html @@ -0,0 +1,83 @@ +{extend name='admin@public/content'} + +{block name="button"} + + + + + + +{/block} + +{block name="content"} +
+ +

没 有 记 录 哦!

+ + + + + + + + + + + + + + + + {foreach $list as $key=>$vo} + + + + + + + + + + {/foreach} + +
+ + + + 产品分类分类描述添加时间分类状态
+ + + + + {$vo.spl|raw} {$vo.cate_title} + + {$vo.cate_desc|default='未设置分类描述'|raw} + + {$vo.create_at|format_datetime} + + {if $vo.status eq 0}已禁用{elseif $vo.status eq 1}使用中{/if} + + + {if auth("$classuri/edit")} + | + 编辑 + {/if} + + {if $vo.status eq 1 and auth("$classuri/forbid")} + | + 禁用 + {elseif auth("$classuri/resume")} + | + 启用 + {/if} + + {if auth("$classuri/del")} + | + 删除 + {/if} + +
+ {if isset($page)}

{$page|raw}

{/if} + +
+{/block} \ No newline at end of file diff --git a/application/goods/view/product/form.html b/application/goods/view/product/form.html new file mode 100644 index 000000000..4c1d45af6 --- /dev/null +++ b/application/goods/view/product/form.html @@ -0,0 +1,357 @@ +{extend name='admin@public/content'} + +{block name="content"} +
+ + +
+ +
+ +
+
+ + + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + {if !empty($tags)} +
+ +
+
+ {foreach $tags as $tag} + + {/foreach} +
+
+
+ {/if} + +
+ +
+ + + + + + + + + + + + + +
产品LOGO产品图片
+ + + +
+
+
+ + +
+ +
+ + + + + + + + + + +
可选规格规格内容
+ +
+ + + + + + + + + + + + + + + + + +
产品规格市场价格销售价格规格状态
+ + + + + + + + + + + +
+
+
+ + +
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ {if !empty($vo.id)}{/if} + + +
+
+ +
+ + +{/block} + +{block name="style"} + +{/block} \ No newline at end of file diff --git a/application/goods/view/product/index.html b/application/goods/view/product/index.html new file mode 100644 index 000000000..f3cf5e250 --- /dev/null +++ b/application/goods/view/product/index.html @@ -0,0 +1,189 @@ +{extend name='admin@public/content'} + +{block name="button"} + + + + + + + + + + + + + + + + + +{/block} + +{block name="content"} + + + + + +
+ +

没 有 记 录 哦!

+ + + + + + + + + + + + + + + {foreach $list as $key=>$vo} + + + + + + + + + + {/foreach} + +
+ + + + 品牌分类 + + + + + + + +
产品信息售价 ( 标价 ) / 库存 ( 剩余, 已售 )
+
添加时间 / 状态
+ + + + + 品牌:{$vo.brand.brand_title|default='未配置品牌'|raw}
+ 分类:{if empty($vo.cate)}未配置分类{else} + {foreach $vo.cate as $k=>$cate}{$cate.cate_title} + {if $k+1 < count($vo.cate)}{/if} + {/foreach} + {/if} +
+ + + + + {foreach $vo.spec as $spec} + + + + + {/foreach} +
+ [{$spec.goods_id}] {$spec.goods_title|default=''|raw} + {$spec.goods_spec_alias|raw} + + 售 {$spec.selling_price} ( 市 {$spec.market_price} ) + 存 {$spec.goods_stock} ( 剩 {$spec.goods_stock-$spec.goods_sale}, 售 {$spec.goods_sale} ) +
+
+ {$vo.create_at|format_datetime|str_replace=' ','
',###|raw} + {if $vo.status eq '0'}已下架{elseif $vo.status eq '1'}销售中{/if} +
+ + + | + 编辑 + + + + | + 下架 + + | + 上架 + + + + | + 删除 + + +
+ {if isset($page)}

{$page|raw}

{/if} + +
+ +{/block} \ No newline at end of file diff --git a/application/goods/view/spec/form.html b/application/goods/view/spec/form.html new file mode 100644 index 000000000..9d60ff2e2 --- /dev/null +++ b/application/goods/view/spec/form.html @@ -0,0 +1,200 @@ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ + + + + + + + +
+ + + + + 删除 + 删除 + 上移 + 上移 + 下移 + 下移 +
+
+ + + + +
+ +
+

设置多个内容值时请使用空格键或英文逗号隔开。

+
+
+ +
+ +
+ +
+
+ +
+ +
+ {if isset($vo['id'])}{/if} + + +
+ + + + +
diff --git a/application/goods/view/spec/index.html b/application/goods/view/spec/index.html new file mode 100644 index 000000000..a55ff4855 --- /dev/null +++ b/application/goods/view/spec/index.html @@ -0,0 +1,116 @@ +{extend name='admin@public/content'} + +{block name="button"} + + + + + + + + + +{/block} + +{block name="content"} + + + + + + + +
+ {if empty($list)} +

没 有 记 录 哦!

+ {else} + + + + + + + + + + + + + + + {foreach $list as $key=>$vo} + + + + + + + + + + {/foreach} + +
+ + + + 规格分组规格内容添加时间标签状态
+ + + + {$vo.spec_title} + {foreach $vo.spec_param as $param} +

{$param.name} : {$param.value}

+ {/foreach} +
+ {$vo.create_at|format_datetime|raw} + + {if $vo.status eq 0}已禁用{elseif $vo.status eq 1}使用中{/if} + + + + | + 编辑 + + + + | + 禁用 + + | + 启用 + + + + | + 删除 + + +
+ {if isset($page)}

{$page|raw}

{/if} + {/if} +
+{/block} \ No newline at end of file diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index e9653a2c4..9398d3aa4 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -14,13 +14,13 @@ namespace app\index\controller; -use controller\BasicAdmin; +use think\Controller; /** * 应用入口控制器 * @author Anyon */ -class Index extends BasicAdmin +class Index extends Controller { public function index() @@ -28,5 +28,4 @@ class Index extends BasicAdmin $this->redirect('@admin/login'); } - } diff --git a/application/wechat/controller/Block.php b/application/wechat/controller/Block.php index 333622c8f..fc8be81ef 100644 --- a/application/wechat/controller/Block.php +++ b/application/wechat/controller/Block.php @@ -18,7 +18,6 @@ use controller\BasicAdmin; use service\ToolsService; use service\WechatService; use think\Db; -use think\Exception; /** * 微信粉丝管理 diff --git a/application/wechat/controller/Config.php b/application/wechat/controller/Config.php index caacc43ee..7a332a595 100644 --- a/application/wechat/controller/Config.php +++ b/application/wechat/controller/Config.php @@ -17,6 +17,7 @@ namespace app\wechat\controller; use controller\BasicAdmin; use service\LogService; use service\WechatService; +use think\Exception; /** * 微信配置管理 @@ -42,24 +43,41 @@ class Config extends BasicAdmin */ public function index() { + $thrNotifyUrl = url('@wechat/api.push', '', true, true); if ($this->request->isGet()) { $code = encode(url('@admin', '', true, true) . '#' . $this->request->url()); - $assign = [ + $data = [ 'title' => '微信接口配置', - 'appuri' => url("@wechat/api.push", '', true, true), - 'appid' => $this->request->get('appid', sysconf('wechat_appid')), - 'appkey' => $this->request->get('appkey', sysconf('wechat_appkey')), - 'authurl' => "http://wm.cuci.cc/wechat/api.push/auth/{$code}.html", - 'wechat' => WechatService::instance('config')->getConfig(), + 'appid' => $this->request->get('appid', sysconf('wechat_thr_appid')), + 'appkey' => $this->request->get('appkey', sysconf('wechat_thr_appkey')), + 'authurl' => config('wechat.service_url') . "/wechat/api.push/auth/{$code}.html", ]; - return $this->fetch('', $assign); + if ($this->request->get('appid', false)) { + sysconf('wechat_thr_appid', $data['appid']); + sysconf('wechat_thr_appkey', $data['appkey']); + WechatService::config()->setApiNotifyUri($thrNotifyUrl); + } + try { + $data['wechat'] = WechatService::config()->getConfig(); + } catch (Exception $e) { + $data['wechat'] = []; + } + return $this->fetch('', $data); } try { + // 接口对接类型 + sysconf('wechat_type', $this->request->post('wechat_type')); + // 直接参数对应 + sysconf('wechat_token', $this->request->post('wechat_token')); sysconf('wechat_appid', $this->request->post('wechat_appid')); - sysconf('wechat_appkey', $this->request->post('wechat_appkey')); - $apiurl = $this->request->post('wechat_appurl'); - if (!empty($apiurl)) { - if (!WechatService::instance('config')->setApiNotifyUri($apiurl)) { + sysconf('wechat_appsecret', $this->request->post('wechat_appsecret')); + sysconf('wechat_encodingaeskey', $this->request->post('wechat_encodingaeskey')); + // 第三方平台配置 + sysconf('wechat_thr_appid', $this->request->post('wechat_thr_appid')); + sysconf('wechat_thr_appkey', $this->request->post('wechat_thr_appkey')); + // 第三方平台时设置远程平台通知接口 + if ($this->request->post('wechat_type') === 'thr') { + if (!WechatService::config()->setApiNotifyUri($thrNotifyUrl)) { $this->error('远程服务端接口更新失败,请稍候再试!'); } } @@ -67,7 +85,7 @@ class Config extends BasicAdmin } catch (\Exception $e) { $this->error('微信授权保存失败 , 请稍候重试 ! ' . $e->getMessage()); } - $this->success('微信授权数据修改成功!', ''); + $this->success('微信授权数据修改成功!', url('@admin') . "#" . url('@wechat/config/index')); } } diff --git a/application/wechat/controller/Fans.php b/application/wechat/controller/Fans.php index fb1d51775..5c502eab0 100644 --- a/application/wechat/controller/Fans.php +++ b/application/wechat/controller/Fans.php @@ -179,11 +179,10 @@ class Fans extends BasicAdmin { try { Db::name($this->table)->where('1=1')->delete(); - FansService::sync(); - TagsService::sync(); + [FansService::sync(), TagsService::sync()]; LogService::write('微信管理', '同步全部微信粉丝成功'); } catch (\Exception $e) { - $this->error('同步粉丝记录失败,请稍候再试!'); + $this->error('同步粉丝记录失败,请稍候再试!' . $e->getMessage()); } $this->success('同步获取所有粉丝成功!', ''); } diff --git a/application/wechat/controller/Keys.php b/application/wechat/controller/Keys.php index a1b5a7d9d..d4f1d71e3 100644 --- a/application/wechat/controller/Keys.php +++ b/application/wechat/controller/Keys.php @@ -47,14 +47,12 @@ class Keys extends BasicAdmin { $this->assign('title', '微信关键字'); $db = Db::name($this->table)->whereNotIn('keys', ['subscribe', 'default']); - return $this->_list($db->order('id desc')); + return $this->_list($db->order('sort asc,id desc')); } /** * 列表数据处理 * @param array $data - * @throws \WeChat\Exceptions\InvalidResponseException - * @throws \WeChat\Exceptions\LocalCacheException */ protected function _index_data_filter(&$data) { @@ -62,11 +60,15 @@ class Keys extends BasicAdmin 'keys' => '关键字', 'image' => '图片', 'news' => '图文', 'music' => '音乐', 'text' => '文字', 'video' => '视频', 'voice' => '语音', ]; - $wechat = WechatService::qrcode(); - foreach ($data as &$vo) { - $result = $wechat->create($vo['keys']); - $vo['qrc'] = $wechat->url($result['ticket']); - $vo['type'] = isset($types[$vo['type']]) ? $types[$vo['type']] : $vo['type']; + try { + $wechat = WechatService::qrcode(); + foreach ($data as &$vo) { + $result = $wechat->create($vo['keys']); + $vo['qrc'] = $wechat->url($result['ticket']); + $vo['type'] = isset($types[$vo['type']]) ? $types[$vo['type']] : $vo['type']; + } + } catch (\Exception $e) { + $this->error($e->getMessage()); } } @@ -178,7 +180,6 @@ class Keys extends BasicAdmin if ($this->request->isPost() && isset($data['keys'])) { $db = Db::name($this->table)->where('keys', $data['keys']); !empty($data['id']) && $db->where('id', 'neq', $data['id']); - $data['content'] = htmlspecialchars_decode($data['content']); $db->count() > 0 && $this->error('关键字已经存在,请使用其它关键字!'); } } diff --git a/application/wechat/controller/News.php b/application/wechat/controller/News.php index 48766ad3e..a34397874 100644 --- a/application/wechat/controller/News.php +++ b/application/wechat/controller/News.php @@ -172,7 +172,6 @@ class News extends BasicAdmin foreach ($data as &$vo) { $vo['create_by'] = session('user.id'); $vo['create_at'] = date('Y-m-d H:i:s'); - $vo['content'] = htmlspecialchars_decode($vo['content']); if (empty($vo['digest'])) { $vo['digest'] = mb_substr(strip_tags(str_replace(["\s", ' '], '', $vo['content'])), 0, 120); } @@ -280,7 +279,7 @@ class News extends BasicAdmin $article['content'] = preg_replace_callback("//i", function ($matches) { $src = MediaService::uploadImage($matches[2]); return ""; - }, htmlspecialchars_decode($article['content'])); + }, $article['content']); } $wechat = WechatService::media(); // 如果已经上传过,先删除之前的历史记录 diff --git a/application/wechat/controller/Review.php b/application/wechat/controller/Review.php index c656e4021..f84c20024 100644 --- a/application/wechat/controller/Review.php +++ b/application/wechat/controller/Review.php @@ -48,7 +48,6 @@ class Review extends Controller if (!empty($article['content_source_url'])) { $this->redirect($article['content_source_url']); } - $article['content'] = htmlspecialchars_decode($article['content']); $this->assign('vo', $article); } $this->assign('type', $type); diff --git a/application/wechat/controller/api/Js.php b/application/wechat/controller/api/Js.php new file mode 100644 index 000000000..033fb4bc9 --- /dev/null +++ b/application/wechat/controller/api/Js.php @@ -0,0 +1,50 @@ +server('HTTP_REFERER', $result->url(true), null); + $wechat = WechatService::webOauth($url, $result->get('mode', 1), false); + $assign = [ + 'jssdk' => WechatService::webJsSDK($url), + 'openid' => $wechat['openid'], 'fansinfo' => $wechat['fansinfo'], + ]; + return Response::create(env('APP_PATH') . 'wechat/view/api/script/index.js', 'view', 200, [ + 'Content-Type' => 'application/x-javascript', + 'Cache-Control' => 'no-cache', 'Pragma' => 'no-cache', 'Expires' => '0', + ])->assign($assign); + } +} \ No newline at end of file diff --git a/application/wechat/controller/api/Push.php b/application/wechat/controller/api/Push.php index c1a847b49..ee0d400da 100644 --- a/application/wechat/controller/api/Push.php +++ b/application/wechat/controller/api/Push.php @@ -49,36 +49,70 @@ class Push protected $receive; /** - * 微信消息接口 + * 微信消息接口(通过ThinkService推送) + * @return string * @throws \think\Exception * @throws \think\exception\PDOException */ - public function __construct() + public function index() { $request = app('request'); $this->appid = $request->post('appid', '', null); $this->openid = $request->post('openid', '', null); $this->receive = unserialize($request->post('receive', '', null)); - p($this->receive); if (empty($this->appid) || empty($this->openid) || empty($this->receive)) { throw new Exception('微信API实例缺失必要参数[appid,openid,event].'); } - if ($this->appid !== sysconf('wechat_appid')) { + return $this->call($this->appid, $this->openid, $this->receive); + } + + /** + * 公众号直接对接(通过参数对接推送) + * @return string + * @throws \think\Exception + * @throws \think\exception\PDOException + */ + public function notify() + { + $wechat = WechatService::receive(); + return $this->call(WechatService::getAppid(), $wechat->getOpenid(), $wechat->getReceive()); + } + + /** + * 初始化接口 + * @param string $appid 公众号APPID + * @param string $openid 公众号OPENID + * @param array $revice 消息对象 + * @return string + * @throws \think\Exception + * @throws \think\exception\PDOException + */ + protected function call($appid, $openid, $revice) + { + list($this->appid, $this->openid, $this->receive) = [$appid, $openid, $revice]; + if ($this->appid !== WechatService::getAppid()) { throw new Exception('微信API实例APPID验证失败.'); } // text,event,image,location if (method_exists($this, ($method = $this->receive['MsgType']))) { - $this->$method(); + if (is_string(($result = $this->$method()))) { + return $result; + } } + return 'success'; } /** * 文件消息处理 * @return bool - * @throws \Exception + * @throws \WeChat\Exceptions\InvalidDecryptException + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException + * @throws \think\exception\PDOException */ protected function text() { @@ -88,7 +122,9 @@ class Push /** * 事件消息处理 * @return bool|string - * @throws \Exception + * @throws \WeChat\Exceptions\InvalidDecryptException + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException @@ -132,24 +168,27 @@ class Push * 关键字处理 * @param string $rule 关键字规则 * @param bool $isLastReply 强制结束 - * @return bool - * @throws \Exception + * @return bool|string + * @throws \WeChat\Exceptions\InvalidDecryptException + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException + * @throws \think\exception\PDOException */ protected function keys($rule, $isLastReply = false) { list($table, $field, $value) = explode('#', $rule . '##'); $info = Db::name($table)->where($field, $value)->find(); - p($info); if (empty($info['type']) || (array_key_exists('status', $info) && empty($info['status']))) { // 切换默认回复 return $isLastReply ? false : $this->keys('wechat_keys#keys#default', true); } switch ($info['type']) { case 'customservice': - return $this->sendMessage('text', ['content' => $info['content']]); + return $this->sendMessage('customservice', ['content' => $info['content']]); case 'keys': $content = empty($info['content']) ? $info['name'] : $info['content']; return $this->keys("wechat_keys#keys#{$content}"); @@ -202,13 +241,42 @@ class Push * @param string $type 消息类型(text|image|voice|video|music|news|mpnews|wxcard) * @param array $data 消息内容 * @return array|bool - * @throws \Exception + * @throws \WeChat\Exceptions\InvalidDecryptException + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + * @throws \think\Exception + * @throws \think\exception\PDOException */ protected function sendMessage($type, $data) { $msgData = ['touser' => $this->openid, 'msgtype' => $type, "{$type}" => $data]; - p($msgData); - return WechatService::custom()->send($msgData); + switch (strtolower(sysconf('wechat_type'))) { + case 'api': // 参数对接,直接回复XML来实现消息回复 + $wechat = WechatService::receive(); + switch (strtolower($type)) { + case 'text': + return $wechat->text($data['content'])->reply([], true); + case 'image': + return $wechat->image($data['media_id'])->reply([], true); + case 'video': + return $wechat->video($data['media_id'], $data['title'], $data['description'])->reply([], true); + case 'voice': + return $wechat->voice($data['media_id'])->reply([], true); + case 'music': + return $wechat->music($data['title'], $data['description'], $data['musicurl'], $data['hqmusicurl'], $data['thumb_media_id'])->reply([], true); + case 'news': + return $wechat->news($data['articles'])->reply([], true); + case 'customservice': + WechatService::custom()->send(['touser' => $this->openid, 'msgtype' => 'text', "text" => $data['content']]); + return $wechat->transferCustomerService()->reply([], true); + default: + return 'success'; + } + case 'thr': // 第三方平台,使用客服消息来实现 + return WechatService::custom()->send($msgData); + default: + return 'success'; + } } /** @@ -238,7 +306,8 @@ class Push * 同步粉丝状态 * @param bool $subscribe 关注状态 * @return string - * @throws \Exception + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException * @throws \think\Exception * @throws \think\exception\PDOException */ diff --git a/application/wechat/controller/api/Tools.php b/application/wechat/controller/api/Tools.php index 644c52a24..aeef924d1 100644 --- a/application/wechat/controller/api/Tools.php +++ b/application/wechat/controller/api/Tools.php @@ -33,7 +33,7 @@ class Tools extends BasicAdmin */ public function oauth() { - $fans = WechatService::webOauth(1); + $fans = WechatService::webOauth($this->request->url(true), 1); return $this->fetch('', ['fans' => $fans]); } @@ -53,12 +53,14 @@ class Tools extends BasicAdmin /** * JSSDK测试 * @return string + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + * @throws \think\Exception + * @throws \think\exception\PDOException */ public function jssdk() { - $wechat = WechatService::wechat(); - $options = $wechat->jsSign($this->request->url(true)); - return $this->fetch('', ['options' => $options]); + return $this->fetch('', ['options' => WechatService::webJsSDK()]); } /** diff --git a/application/wechat/service/FansService.php b/application/wechat/service/FansService.php index d7732cbb7..3c3b565b0 100644 --- a/application/wechat/service/FansService.php +++ b/application/wechat/service/FansService.php @@ -35,7 +35,7 @@ class FansService */ public static function set(array $user) { - $user['appid'] = sysconf('wechat_appid'); + $user['appid'] = WechatService::getAppid(); if (!empty($user['subscribe_time'])) { $user['subscribe_at'] = date('Y-m-d H:i:s', $user['subscribe_time']); } @@ -58,7 +58,7 @@ class FansService */ public static function get($openid) { - $map = ['openid' => $openid, 'appid' => sysconf('wechat_appid')]; + $map = ['openid' => $openid, 'appid' => WechatService::getAppid()]; $user = Db::name('WechatFans')->where($map)->find(); foreach (['country', 'province', 'city', 'nickname', 'remark'] as $k) { isset($user[$k]) && $user[$k] = ToolsService::emojiDecode($user[$k]); diff --git a/application/wechat/service/MediaService.php b/application/wechat/service/MediaService.php index 888f9caec..2a8a452da 100644 --- a/application/wechat/service/MediaService.php +++ b/application/wechat/service/MediaService.php @@ -14,6 +14,8 @@ namespace app\wechat\service; +use service\DataService; +use service\FileService; use service\WechatService; use think\Db; @@ -56,18 +58,21 @@ class MediaService * @return string * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException + * @throws \think\Exception + * @throws \think\exception\PDOException */ public static function uploadImage($local_url) { - $media_url = Db::name('WechatNewsImage')->where(['md5' => md5($local_url)])->value('media_url'); - if (!empty($media_url)) { + $map = ['md5' => md5($local_url)]; + if (!($media_url = Db::name('WechatNewsImage')->where($map)->value('media_url'))) { return $media_url; } - $result = WechatService::wechat()->upFile(base64_encode(file_get_contents($local_url)), $local_url); - $info = WechatService::media()->uploadImg($result['file']); - WechatService::wechat()->rmFile($local_url); - $data = ['local_url' => $local_url, 'media_url' => $info['url'], 'md5' => md5($local_url)]; - Db::name('WechatNewsImage')->insert($data); + $info = WechatService::media()->uploadImg(self::getServerPath($local_url)); + if (strtolower(sysconf('wechat_type')) === 'thr') { + WechatService::wechat()->rmFile($local_url); + } + $data = ['local_url' => $local_url, 'media_url' => $info['url'], 'md5' => $map['md5']]; + DataService::save('WechatNewsImage', $data, 'md5', ['type' => 'image']); return $info['url']; } @@ -84,17 +89,40 @@ class MediaService */ public static function uploadForeverMedia($local_url, $type = 'image', $video_info = []) { - $map = ['md5' => md5($local_url), 'appid' => sysconf('wechat_appid')]; + $map = ['md5' => md5($local_url), 'appid' => WechatService::getAppid()]; if (($media_id = Db::name('WechatNewsMedia')->where($map)->value('media_id'))) { return $media_id; } - $result = WechatService::wechat()->upFile(base64_encode(file_get_contents($local_url)), $local_url); - $result = WechatService::media()->addMaterial($result['file'], $type, $video_info); - WechatService::wechat()->rmFile($local_url); + $result = WechatService::media()->addMaterial(self::getServerPath($local_url), $type, $video_info); + if (strtolower(sysconf('wechat_type')) === 'thr') { + WechatService::wechat()->rmFile($local_url); + } $data = ['md5' => $map['md5'], 'type' => $type, 'appid' => $map['appid'], 'media_id' => $result['media_id'], 'local_url' => $local_url]; isset($result['url']) && $data['media_url'] = $result['url']; - Db::name('WechatNewsMedia')->insert($data); + DataService::save('WechatNewsMedia', $data, 'md5', ['appid' => $map['appid'], 'type' => $type]); return $data['media_id']; } + /** + * 文件位置处理 + * @param string $local + * @return string + * @throws \think\Exception + * @throws \think\exception\PDOException + */ + protected static function getServerPath($local) + { + switch (strtolower(sysconf('wechat_type'))) { + case 'api': + if (file_exists($local)) { + return $local; + } + return FileService::download($local)['file']; + case 'thr': + return WechatService::wechat()->upFile(base64_encode(file_get_contents($local)), $local)['file']; + default: + return $local; + } + } + } \ No newline at end of file diff --git a/application/wechat/service/TagsService.php b/application/wechat/service/TagsService.php index 52ec49ffc..327884afe 100644 --- a/application/wechat/service/TagsService.php +++ b/application/wechat/service/TagsService.php @@ -54,7 +54,7 @@ class TagsService */ public static function sync() { - $appid = sysconf('wechat_appid'); + $appid = WechatService::getAppid(); $result = WechatService::tags()->getTags(); Db::name('WechatFansTags')->where(['appid' => $appid])->delete(); foreach (array_chunk($result['tags'], 100) as $list) { diff --git a/application/wechat/view/api/script/index.js b/application/wechat/view/api/script/index.js new file mode 100644 index 000000000..5fb7b054f --- /dev/null +++ b/application/wechat/view/api/script/index.js @@ -0,0 +1,10 @@ +if (typeof wx === 'object') { + wx.openid = '{$fansinfo.openid|default=""}'; + wx.unionid = '{$fansinfo.unionid|default=""}'; + wx.fansinfo = eval('({$fansinfo|default=[]|json_encode=###,256|raw})'); + wx.config(eval('({$jssdk|default=[]|json_encode=###,256|raw})')); + wx.ready(function () { + wx.hideOptionMenu(); + wx.hideAllNonBaseMenuItem(); + }); +} diff --git a/application/wechat/view/api/tools/jssdk.html b/application/wechat/view/api/tools/jssdk.html index c18a560e4..4c592a2aa 100644 --- a/application/wechat/view/api/tools/jssdk.html +++ b/application/wechat/view/api/tools/jssdk.html @@ -26,7 +26,6 @@ $.toptip(err.errMsg, 100000, 'error'); }); wx.ready(function () { - $.toptip('JSSDK 初始化成功...', 'success'); $('#show-alert').removeClass('weui-btn_disabled').on('click', function () { wx.scanQRCode({ needResult: 1, diff --git a/application/wechat/view/block/index.html b/application/wechat/view/block/index.html index f79abcfc8..220b24181 100644 --- a/application/wechat/view/block/index.html +++ b/application/wechat/view/block/index.html @@ -1,15 +1,12 @@ {extend name='admin@public/content'} {block name="button"} - - - {/block} {block name="content"} @@ -94,12 +91,12 @@

没 有 记 录 哦!

- + @@ -113,10 +110,10 @@ {foreach $list as $key=>$vo}
- + 用户昵称 性别
- + - + {$vo.nickname|default='未设置微信昵称'} diff --git a/application/wechat/view/config/index.html b/application/wechat/view/config/index.html index 3b67f7d96..026fb0652 100644 --- a/application/wechat/view/config/index.html +++ b/application/wechat/view/config/index.html @@ -3,79 +3,154 @@ {block name="content"}
- -
-
-
-
- -
-
-

微信昵称:{$wechat.nick_name}

-

微信类型:{$wechat.service_type_info == 2 ? '服务号' : '订阅号'} / - {$wechat.verify_type_info == -1 ? '未认证' : '已认证'}

-

注册公司:{$wechat.principal_name}

-

授权绑定:{$wechat.create_at|format_datetime}

-
+
+ +
+ {php} + $wechat_type=sysconf('wechat_type')?sysconf('wechat_type'):'api'; + $wechat_type=request()->get('appkey')?'thr':$wechat_type; + {/php} + {foreach ['api'=>'普通接口参数','thr'=>'第三方授权对接'] as $k=>$v} + + {/foreach} +

如果使用第三方授权对接,需要 ThinkService 项目的支持。

+ +
+
-
-
-

------- 公众号功能测试 -------

+
WxTest
功能测试
+
- +

网页授权

- +

JSSDK签名

-
- - -
- -
- -

点击连接将跳转到微信第三方平台进行公众号授权。

-
-
-
- -
- -

公众号 appid 通过微信第三方授权自动获取. 若没有值请进行微信第三方授权。

+
+
+ +
+ +

公众号平台与系统对接认证Token,请优先填写此参数并保存,然后再在微信公众号平台操作对接。

+
+
+ +
+ +

公众号应用ID是所有接口必要参数,可以在公众号平台 [ 开发 > 基本配置 ] 页面获取。

+
+
+
+ +
+ +

公众号应用密钥是所有接口必要参数,可以在公众号平台 [ 开发 > 基本配置 ] 页面授权后获取。

+
+
+
+ +
+ +

公众号平台接口设置为加密模式,消息加密密钥必需填写并保持与公众号平台一致。

+
+
+
+ +
+ +

公众号服务平台接口通知URL, 公众号消息接收与回复等。

+
+
+
-
- -
- -

公众号服务平台接口密钥, 通过微信第三方授权自动获取, 若没有值请进行微信第三方授权。

+ +
+ +
+
QRCode
公众号二维码
+
+
+ +
+
+

微信昵称:{$wechat.nick_name}

+

微信类型:{$wechat.service_type_info == 2 ? '服务号' : '订阅号'} / + {$wechat.verify_type_info == -1 ? '未认证' : '已认证'}

+

注册公司:{$wechat.principal_name}

+

授权绑定:{$wechat.create_at|format_datetime}

+
+
+
+ +
+ +
+ +

点击连接将跳转到微信第三方平台进行公众号授权。

+
+
+
+
+ +
+ +

公众号 appid 通过微信第三方授权自动获取. 若没有值请进行微信第三方授权。

+
+
+
+ +
+ +

公众号服务平台接口密钥, 通过微信第三方授权自动获取, 若没有值请进行微信第三方授权。

+
+
+
+ +
+ +

公众号服务平台接口通知URL, 公众号消息接收与回复等。

+
+
+
-
- -
- -

公众号服务平台接口通知URL, 公众号消息接收与回复等。

+
+
+
-
- -
- -
- + + {/block} diff --git a/application/wechat/view/fans/index.html b/application/wechat/view/fans/index.html index c3cffc4dc..2a5dad7dd 100644 --- a/application/wechat/view/fans/index.html +++ b/application/wechat/view/fans/index.html @@ -1,15 +1,12 @@ {extend name='admin@public/content'} {block name="button"} - - - {/block} {block name="content"} diff --git a/application/wechat/view/keys/form.html b/application/wechat/view/keys/form.html index cf6d79adf..b45e7b8b3 100644 --- a/application/wechat/view/keys/form.html +++ b/application/wechat/view/keys/form.html @@ -2,47 +2,19 @@ {block name="style"} {/block} {block name="content"} -
+
公众号
@@ -52,154 +24,153 @@
-
+
{$title} -
- -
- -
- -
+ +
+ +
+
- - - -
- -
-
- {foreach ['1'=>'启用','0'=>'禁用'] as $k=>$v} - - {/foreach} -
-
-
-
- -
- {foreach ['text'=>'文字','news'=>'图文','image'=>'图片','music'=>'音乐','video'=>'视频'] as $k=>$v} +
+ + + +
+ +
+
+ {foreach ['1'=>'启用','0'=>'禁用'] as $k=>$v} - {/foreach} + {/foreach}
- -
- -
- -
-
- -
- -
- 选择图文 - -
-
- -
- -
- -

文件最大2Mb,支持bmp/png/jpeg/jpg/gif格式

- - 上传图片 -
-
- -
- -
-
- - -
-

文件最大2Mb,播放长度不超过60s,mp3/wma/wav/amr格式

-
-
- -
- -
- -
-
-
- -
-
- - -
-
-
-
- -
- -
-
-
- -
- -

文件最大64KB,只支持JPG格式

- - 上传图片 -
-
- -
- -
- -
-
-
- -
-
- - -
-

文件最大10MB,只支持MP4格式

-
-
-
- -
- -
-
- -
-
- - - - -
- {if isset($vo['id'])}{/if}
+
+ +
+ {foreach ['text'=>'文字','news'=>'图文','image'=>'图片','music'=>'音乐','video'=>'视频'] as $k=>$v} + + {/foreach} +
+
+ +
+ +
+ +
+
+ +
+ +
+ 选择图文 + +
+
+ +
+ +
+ +

文件最大2Mb,支持bmp/png/jpeg/jpg/gif格式

+ + 上传图片 +
+
+ +
+ +
+
+ + +
+

文件最大2Mb,播放长度不超过60s,mp3/wma/wav/amr格式

+
+
+ +
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +

文件最大64KB,只支持JPG格式

+ + 上传图片 +
+
+ +
+ +
+ +
+
+
+ +
+
+ + +
+

文件最大10MB,只支持MP4格式

+
+
+
+ +
+ +
+
+ +
+
+ + + + +
+ {if isset($vo['id'])}{/if} +
@@ -209,42 +180,42 @@ {block name="script"}