Skip to content

Commit

Permalink
add: 微信菜单增加小程序配置 & 模板消息支持小程序
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizzercn committed Mar 28, 2017
1 parent 00cbb7b commit 381be79
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cn.wizzer</groupId>
<artifactId>nutzwk</artifactId>
<version>3.3.6</version>
<version>3.3.8</version>
<packaging>war</packaging>
<name>NutzWk</name>
<url>http://www.wizzer.cn</url>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/wizzer/common/base/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public Pagination listPage(Integer pageNumber, int pageSize, Sql sql) {
pageNumber = getPageNumber(pageNumber);
pageSize = getPageSize(pageSize);
Pager pager = this.dao().createPager(pageNumber, pageSize);
pager.setRecordCount((int) Daos.queryCount(this.dao(), sql.toString()));// 记录数需手动设置
pager.setRecordCount((int) Daos.queryCount(this.dao(), sql));// 记录数需手动设置
sql.setPager(pager);
sql.setCallback(Sqls.callback.records());
dao().execute(sql);
Expand Down Expand Up @@ -565,7 +565,7 @@ public NutMap data(int length, int start, int draw, List<DataTableOrder> orders,
public NutMap data(int length, int start, int draw, Sql countSql, Sql orderSql) {
NutMap re = new NutMap();
Pager pager = new OffsetPager(start, length);
pager.setRecordCount((int) Daos.queryCount(this.dao(), countSql.toString()));// 记录数需手动设置
pager.setRecordCount((int) Daos.queryCount(this.dao(), countSql));// 记录数需手动设置
orderSql.setPager(pager);
orderSql.setCallback(Sqls.callback.records());
this.dao().execute(orderSql);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public Object index(@Param("action") String action, HttpServletRequest req) {
@At
@Ok("json")
@RequiresAuthentication
@SuppressWarnings("deprecation")
public Object uploadimage(@Param("Filedata") TempFile tf, HttpServletRequest req, AdaptorErrorContext err) {
String wxid = Strings.sBlank(req.getSession().getAttribute("wxid"));
NutMap nutMap = new NutMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public Object newsDetail(String id, HttpServletRequest req) {
@At("/uploadThumb/?")
@Ok("json")
@RequiresAuthentication
@SuppressWarnings("deprecation")
//AdaptorErrorContext必须是最后一个参数
public Object uploadThumb(String wxid, @Param("Filedata") TempFile tf, HttpServletRequest req, AdaptorErrorContext err) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ public Object pushMenu(String wxid, HttpServletRequest req) {
xm2.setType(secondMenu.getMenuType());
xm2.setKey(secondMenu.getMenuKey());
xm2.setName(secondMenu.getMenuName());
} else if ("miniprogram".equals(secondMenu.getMenuType())) {
xm2.setType(secondMenu.getMenuType());
xm2.setName(secondMenu.getMenuName());
xm2.setUrl(secondMenu.getUrl());
xm2.setAppid(secondMenu.getAppid());
xm2.setPagepath(secondMenu.getPagepath());
} else {
xm2.setName(secondMenu.getMenuName());
xm2.setType("click");
Expand All @@ -235,6 +241,12 @@ public Object pushMenu(String wxid, HttpServletRequest req) {
xm2.setType(firstMenu.getMenuType());
xm2.setKey(firstMenu.getMenuKey());
xm2.setName(firstMenu.getMenuName());
} else if ("miniprogram".equals(firstMenu.getMenuType())) {
xm2.setType(firstMenu.getMenuType());
xm2.setName(firstMenu.getMenuName());
xm2.setUrl(firstMenu.getUrl());
xm2.setAppid(firstMenu.getAppid());
xm2.setPagepath(firstMenu.getPagepath());
} else {
xm2.setName(firstMenu.getMenuName());
xm2.setType("click");
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/cn/wizzer/modules/models/wx/Wx_menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public class Wx_menu extends Model implements Serializable {
@ColDefine(type = ColType.VARCHAR, width = 255)
private String url;

@Column
@Comment("小程序appid")
@ColDefine(type = ColType.VARCHAR, width = 255)
private String appid;

@Column
@Comment("小程序入口页")
@ColDefine(type = ColType.VARCHAR, width = 255)
private String pagepath;

@Column
@Comment("排序字段")
@Prev({
Expand Down Expand Up @@ -156,4 +166,20 @@ public Wx_config getWxConfig() {
public void setWxConfig(Wx_config wxConfig) {
this.wxConfig = wxConfig;
}

public String getAppid() {
return appid;
}

public void setAppid(String appid) {
this.appid = appid;
}

public String getPagepath() {
return pagepath;
}

public void setPagepath(String pagepath) {
this.pagepath = pagepath;
}
}
63 changes: 58 additions & 5 deletions src/main/webapp/WEB-INF/views/platform/wx/menu/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
action="${base}/platform/wx/conf/menu/addDo" method="post">
<input id="wxid" name="wxid" type="hidden" value="${wxid!}">

<div class="row mb10">
<div class="row mb10 mt10">
<div class="col-lg-12">
<div class="form-group">
<label for="parentId" class="col-sm-2 control-label">上级菜单</label>
Expand Down Expand Up @@ -51,15 +51,16 @@
<div class="radio"><label><input onclick="clickRadio('')" type="radio" name="menuType" value="" checked></label></div>
<div class="radio"><label><input onclick="clickRadio('view')" type="radio" name="menuType" value="view">链接</label></div>
<div class="radio"><label><input onclick="clickRadio('click')" type="radio" name="menuType" value="click">事件</label></div>
<div class="radio"><label><input onclick="clickRadio('miniprogram')" type="radio" name="menuType" value="miniprogram">小程序</label></div>
</div>
</div>
<div id="div_url" class="form-group" style="display: none">
<label for="url" class="col-sm-2 control-label">URL</label>

<div class="col-sm-8">
<div class="input-group">
<input id="url" name="url" type="text" class="form-control">
<span class="input-group-btn">
<input id="url" name="url" type="text" class="form-control">
<span class="input-group-btn">
<a class="btn btn-primary current-time" href="${base}/platform/wx/conf/menu/cms/channel" data-toggle="modal" data-target="#dialogSelect">选择栏目</a>
<a class="btn btn-info current-time" href="${base}/platform/wx/conf/menu/cms/article" data-toggle="modal" data-target="#dialogSelect">选择文章</a>

Expand All @@ -69,14 +70,32 @@
<input type="checkbox" id="btnUrl2">应用oauth2.0
</div>
</div>
<div id="div_appurl" class="form-group" style="display: none">
<label for="appid" class="col-sm-2 control-label">URL</label>
<div class="col-sm-8">
<input id="appurl" name="appurl" type="text" class="form-control">
</div>
</div>
<div id="div_appid" class="form-group" style="display: none">
<label for="appid" class="col-sm-2 control-label">appid</label>
<div class="col-sm-8">
<input id="appid" name="appid" type="text" class="form-control">
</div>
</div>
<div id="div_pagepath" class="form-group" style="display: none">
<label for="pagepath" class="col-sm-2 control-label">pagepath</label>
<div class="col-sm-8">
<input id="pagepath" name="pagepath" type="text" class="form-control">
</div>
</div>
<div id="div_key" class="form-group" style="display: none">
<label for="menuKey" class="col-sm-2 control-label">事件Key</label>

<div class="col-sm-8">
<div class="input-group">
<input id="menuKey" name="menuKey" type="text" class="form-control"
data-parsley-maxlength="20">
<span class="input-group-btn">
<span class="input-group-btn">
<button class="btn btn-color current-time" type="button" onclick="selKeyword()">选择关键词</button>
</span>
</div>
Expand All @@ -93,7 +112,7 @@
<label></label>

<div>
<button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交..." id="submit">提 交
<button type="button" class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交..." id="submit">提 交
</button>
</div>
</div>
Expand Down Expand Up @@ -124,16 +143,41 @@
if (type == 'click') {
$("#div_url").hide();
$("#div_key").show();
$("#div_appurl").hide();
$("#div_appid").hide();
$("#div_pagepath").hide();
$("#url").val("");
$("#appurl").val("");
$("#appid").val("");
$("#pagepath").val("");
} else if (type == 'view') {
$("#div_key").hide();
$("#div_url").show();
$("#div_appurl").hide();
$("#div_appid").hide();
$("#div_pagepath").hide();
$("#key").val("");
$("#appurl").val("");
$("#appid").val("");
$("#pagepath").val("");
} else if (type == 'miniprogram') {
$("#div_key").hide();
$("#div_url").hide();
$("#div_appurl").show();
$("#div_appid").show();
$("#div_pagepath").show();
$("#key").val("");
} else {
$("#div_key").hide();
$("#div_url").hide();
$("#div_appurl").hide();
$("#div_appid").hide();
$("#div_pagepath").hide();
$("#key").val("");
$("#url").val("");
$("#appurl").val("");
$("#appid").val("");
$("#pagepath").val("");
}
}
function selKeyword(){
Expand Down Expand Up @@ -193,13 +237,22 @@
$("#dialogSelect").on("hidden.bs.modal", function () {
$(this).removeData("bs.modal");
});
$("#submit").on("click",function () {
if($("input[type='radio']:checked").val()=="miniprogram"){
$("#url").val($("#appurl").val());
}
$('#addForm').submit();
});
$('#addForm').ajaxForm({
dataType: 'json',
beforeSubmit: function (arr, form, options) {
if($("#errMsg").val()=='true')
{
return false;
}
if($("input[type='radio']:checked").val()=="miniprogram"){
$("#url").val($("#appurl").val());
}
},
success: function (data, statusText, xhr, form) {
if (data.code == 0) {
Expand Down
62 changes: 56 additions & 6 deletions src/main/webapp/WEB-INF/views/platform/wx/menu/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<input id="wxid" name="wxid" type="hidden" value="${obj.wxid!}">
<input type="hidden" id="hasChildren" name="hasChildren" value="${obj.hasChildren!}">
<input type="hidden" id="parentId" name="parentId" value="${obj.parentId!}">
<div class="row mb10">
<div class="row mb10 mt10">
<div class="col-lg-12">
<div class="form-group">
<label for="menuName" class="col-sm-2 control-label">菜单名称</label>
Expand All @@ -35,6 +35,7 @@
<div class="radio"><label><input onclick="clickRadio('')" type="radio" name="menuType" value="" <%if(isEmpty(obj.menuType)){%>checked<%}%>></label></div>
<div class="radio"><label><input onclick="clickRadio('view')" type="radio" name="menuType" value="view" <%if('view'==obj.menuType){%>checked<%}%>>链接</label></div>
<div class="radio"><label><input onclick="clickRadio('click')" type="radio" name="menuType" value="click" <%if('click'==obj.menuType){%>checked<%}%>>事件</label></div>
<div class="radio"><label><input onclick="clickRadio('miniprogram')" type="radio" name="menuType" value="miniprogram" <%if('miniprogram'==obj.menuType){%>checked<%}%>>小程序</label></div>
</div>
</div>
<div id="div_url" class="form-group" style="display: <%if('view'==obj.menuType){%>block<%}else{%>none<%}%>">
Expand All @@ -43,7 +44,7 @@
<div class="col-sm-8">
<div class="input-group">
<input id="url" name="url" value="${obj.url!}" type="text" class="form-control">
<span class="input-group-btn">
<span class="input-group-btn">
<a class="btn btn-primary current-time" href="${base}/platform/wx/conf/menu/cms/channel" data-toggle="modal" data-target="#dialogSelect">选择栏目</a>
<a class="btn btn-info current-time" href="${base}/platform/wx/conf/menu/cms/article" data-toggle="modal" data-target="#dialogSelect">选择文章</a>

Expand All @@ -54,14 +55,32 @@

</div>
</div>
<div id="div_appurl" class="form-group" style="display: <%if('miniprogram'==obj.menuType){%>block<%}else{%>none<%}%>">
<label for="appid" class="col-sm-2 control-label">URL</label>
<div class="col-sm-8">
<input id="appurl" name="appurl" type="text" class="form-control" value="${obj.url!}" >
</div>
</div>
<div id="div_appid" class="form-group" style="display: <%if('miniprogram'==obj.menuType){%>block<%}else{%>none<%}%>">
<label for="appid" class="col-sm-2 control-label">appid</label>
<div class="col-sm-8">
<input id="appid" name="appid" type="text" class="form-control" value="${obj.appid!}" >
</div>
</div>
<div id="div_pagepath" class="form-group" style="display: <%if('miniprogram'==obj.menuType){%>block<%}else{%>none<%}%>">
<label for="pagepath" class="col-sm-2 control-label">pagepath</label>
<div class="col-sm-8">
<input id="pagepath" name="pagepath" type="text" class="form-control" value="${obj.pagepath!}" >
</div>
</div>
<div id="div_key" class="form-group" style="display: <%if('click'==obj.menuType){%>block<%}else{%>none<%}%>">
<label for="menuKey" class="col-sm-2 control-label">事件Key</label>

<div class="col-sm-8">
<div class="input-group">
<input id="menuKey" name="menuKey" type="text" class="form-control"
data-parsley-maxlength="20" value="${obj.menuKey!}" >
<span class="input-group-btn">
<span class="input-group-btn">
<button class="btn btn-color current-time" type="button" onclick="selKeyword()">选择关键词</button>
</span>
</div>
Expand All @@ -78,7 +97,7 @@
<label></label>

<div>
<button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交..." id="submit">提 交
<button type="button" class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交..." id="submit">提 交
</button>
</div>
</div>
Expand Down Expand Up @@ -108,16 +127,41 @@
if (type == 'click') {
$("#div_url").hide();
$("#div_key").show();
$("#div_appurl").hide();
$("#div_appid").hide();
$("#div_pagepath").hide();
$("#url").val("");
$("#appurl").val("");
$("#appid").val("");
$("#pagepath").val("");
} else if (type == 'view') {
$("#div_key").hide();
$("#div_url").show();
$("#menuKey").val("");
$("#div_appurl").hide();
$("#div_appid").hide();
$("#div_pagepath").hide();
$("#key").val("");
$("#appurl").val("");
$("#appid").val("");
$("#pagepath").val("");
} else if (type == 'miniprogram') {
$("#div_key").hide();
$("#div_url").hide();
$("#div_appurl").show();
$("#div_appid").show();
$("#div_pagepath").show();
$("#key").val("");
} else {
$("#div_key").hide();
$("#div_url").hide();
$("#menuKey").val("");
$("#div_appurl").hide();
$("#div_appid").hide();
$("#div_pagepath").hide();
$("#key").val("");
$("#url").val("");
$("#appurl").val("");
$("#appid").val("");
$("#pagepath").val("");
}
}
function selKeyword(){
Expand Down Expand Up @@ -177,6 +221,12 @@
$("#dialogSelect").on("hidden.bs.modal", function () {
$(this).removeData("bs.modal");
});
$("#submit").on("click",function () {
if($("input[type='radio']:checked").val()=="miniprogram"){
$("#url").val($("#appurl").val());
}
$('#addForm').submit();
});
$('#addForm').ajaxForm({
dataType: 'json',
beforeSubmit: function (arr, form, options) {
Expand Down

0 comments on commit 381be79

Please sign in to comment.