2 Commits d729b0fbe8 ... 6c88535268

Auteur SHA1 Message Date
  ningsy 6c88535268 Merge remote-tracking branch 'origin/master' il y a 4 ans
  ningsy b9f6b98dfd nsy update 添加磁贴类型 il y a 4 ans

+ 30 - 0
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/domain/WxMagnet.java

@@ -42,6 +42,20 @@ public class WxMagnet extends BaseEntity
     /** 背景图片 */
     private String bgUrl;
 
+    /**
+     * 磁贴应用类型
+     * 0:链接应用
+     * 1:小程序应用
+     * 2:内嵌应用
+     */
+    private String magnetType;
+
+    /**
+     * 小程序二维码url
+     */
+    private String appletQrUrl;
+
+
 
     public Long getMagnetId()
     {
@@ -120,7 +134,21 @@ public class WxMagnet extends BaseEntity
         this.bgUrl = bgUrl;
     }
 
+    public String getMagnetType() {
+        return magnetType;
+    }
 
+    public void setMagnetType(String magnetType) {
+        this.magnetType = magnetType;
+    }
+
+    public String getAppletQrUrl() {
+        return appletQrUrl;
+    }
+
+    public void setAppletQrUrl(String appletQrUrl) {
+        this.appletQrUrl = appletQrUrl;
+    }
 
     @Override
     public String toString() {
@@ -137,6 +165,8 @@ public class WxMagnet extends BaseEntity
             .append("updateBy", getUpdateBy())
             .append("updateTime", getUpdateTime())
             .append("remark", getRemark())
+            .append("magnetType", getMagnetType())
+            .append("appletQrUrl", getAppletQrUrl())
             .toString();
     }
 

+ 47 - 35
suishenbang-wxportal/suishenbang-wxportal-common/src/main/resources/mapper/wxportal/WxMagnetMapper.xml

@@ -1,33 +1,36 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-		PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-		"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.dgtly.wxportal.mapper.WxMagnetMapper">
 
-	<resultMap type="WxMagnet" id="WxMagnetResult">
-		<id     property="magnetId"       column="magnet_id"        />
-		<result property="magnetName"     column="magnet_name"      />
-		<result property="orderNum"       column="order_num"      />
-		<result property="url"            column="url"            />
-		<result property="visible"        column="visible"        />
+    <resultMap type="com.dgtly.wxportal.domain.WxMagnet" id="WxMagnetResult">
+        <id     property="magnetId"       column="magnet_id"        />
+        <result property="magnetName"     column="magnet_name"      />
+        <result property="orderNum"       column="order_num"      />
+        <result property="url"            column="url"            />
+        <result property="visible"        column="visible"        />
         <result property="magnetSize"     column="magnet_size"          />
-		<result property="bgUrl"          column="bg_url"           />
-		<result property="createBy"       column="create_by"      />
-		<result property="createTime"     column="create_time"    />
-		<result property="updateTime"     column="update_time"    />
-		<result property="updateBy"       column="update_by"      />
-		<result property="remark"         column="remark"         />
-	</resultMap>
-
-	<sql id="selectMagnetVo">
-        select magnet_id, magnet_name, order_num, url,  visible, magnet_size, bg_url ,create_by, create_time
+        <result property="bgUrl"          column="bg_url"           />
+        <result property="createBy"       column="create_by"      />
+        <result property="createTime"     column="create_time"    />
+        <result property="updateTime"     column="update_time"    />
+        <result property="updateBy"       column="update_by"      />
+        <result property="remark"         column="remark"         />
+        <result property="magnetType"     column="magnet_type"         />
+        <result property="appletQrUrl"    column="applet_qr_url"         />
+
+    </resultMap>
+
+    <sql id="selectMagnetVo">
+        select magnet_id, magnet_name, order_num, url,  visible, magnet_size, bg_url ,remark, magnet_type, applet_qr_url, create_by, create_time
 		from wx_magnet
     </sql>
 
 
-    <select id="selectMagnetList" parameterType="WxMagnet" resultMap="WxMagnetResult">
+    <select id="selectMagnetList" parameterType="com.dgtly.wxportal.domain.WxMagnet" resultMap="WxMagnetResult">
         select distinct m.magnet_id,  m.magnet_name, m.url, m.visible, m.magnet_size
-        , m.bg_url, m.order_num, m.create_time
+        , m.bg_url, m.order_num, m.create_time, m.magnet_type, m.applet_qr_url
         from wx_magnet m
         <where>
             <if test="magnetName != null and magnetName != ''">
@@ -37,7 +40,10 @@
                 AND m.visible = #{visible}
             </if>
             <if test="magnetSize != null and magnetSize != ''">
-                AND m.magnetSize = #{magnet_size}
+                AND m.magnet_size = #{magnetSize}
+            </if>
+            <if test="magnetType != null and magnetType != ''">
+                AND m.magnet_type = #{magnetType}
             </if>
             ${params.dataScope}
         </where>
@@ -55,15 +61,15 @@
 
     <select id="selectMagnetById" parameterType="Long" resultMap="WxMagnetResult">
         <include refid="selectMagnetVo"/>
-		where magnet_id = #{magnetId}
-	</select>
+        where magnet_id = #{magnetId}
+    </select>
 
     <select id="checkMagnetNameUnique"  resultMap="WxMagnetResult">
         <include refid="selectMagnetVo"/>
         where magnet_name=#{magnetName}
     </select>
 
-    <insert id="insertMagnet" parameterType="WxMagnet">
+    <insert id="insertMagnet" parameterType="com.dgtly.wxportal.domain.WxMagnet">
         insert into wx_magnet(
         <if test="magnetId != null and magnetId != 0">magnet_id,</if>
         <if test="magnetName != null and magnetName != ''">magnet_name,</if>
@@ -73,6 +79,8 @@
         <if test="magnetSize !=null and magnetSize != ''">magnet_size,</if>
         <if test="bgUrl != null and bgUrl != ''">bg_url,</if>
         <if test="remark != null and remark != ''">remark,</if>
+        <if test="magnetType != null and magnetType != ''">magnet_type,</if>
+        <if test="appletQrUrl != null and appletQrUrl != ''">applet_qr_url,</if>
         <if test="createBy != null and createBy != ''">create_by,</if>
         create_time
         )values(
@@ -84,12 +92,14 @@
         <if test="magnetSize !=null and magnetSize != ''">#{magnetSize},</if>
         <if test="bgUrl != null and bgUrl != ''">#{bgUrl},</if>
         <if test="remark != null and remark != ''">#{remark},</if>
+        <if test="magnetType != null and magnetType != ''">#{magnetType},</if>
+        <if test="appletQrUrl != null and appletQrUrl != ''">#{appletQrUrl},</if>
         <if test="createBy != null and createBy != ''">#{createBy},</if>
         sysdate()
         )
     </insert>
 
-    <update id="updateMagnet" parameterType="WxMagnet">
+    <update id="updateMagnet" parameterType="com.dgtly.wxportal.domain.WxMagnet">
         update wx_magnet
         <set>
             <if test="magnetName != null and magnetName != ''">magnet_name = #{magnetName},</if>
@@ -99,6 +109,8 @@
             <if test="magnetSize !=null">magnet_size = #{magnetSize},</if>
             <if test="bgUrl !=null and bgUrl != ''">bg_url = #{bgUrl},</if>
             <if test="remark != null and remark != ''">remark = #{remark},</if>
+            <if test="magnetType != null and magnetType != ''">magnet_type = #{magnetType},</if>
+            <if test="appletQrUrl != null">applet_qr_url = #{appletQrUrl},</if>
             <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
             update_time = sysdate()
         </set>
@@ -111,12 +123,12 @@
     </select>
 
     <select id="selectMagnetAllByUserId"  resultMap="WxMagnetResult">
-      select distinct m.magnet_id,  m.magnet_name, m.url, m.visible, m.magnet_size
-            , m.bg_url, m.order_num, m.create_time
-		from wx_magnet m
-         left join wx_role_magnet rm on m.magnet_id = rm.magnet_id
-         left join sys_user_role ur on rm.role_id = ur.role_id
-         LEFT JOIN sys_role ro on ur.role_id = ro.role_id
+        select distinct m.magnet_id,  m.magnet_name, m.url, m.visible, m.magnet_size
+        , m.bg_url, m.order_num, m.create_time, m.magnet_type, m.applet_qr_url
+        from wx_magnet m
+        left join wx_role_magnet rm on m.magnet_id = rm.magnet_id
+        left join sys_user_role ur on rm.role_id = ur.role_id
+        LEFT JOIN sys_role ro on ur.role_id = ro.role_id
         <where>
             ur.user_id = #{userId}
             <if test="wxMagnet.magnetName != null and wxMagnet.magnetName != ''">
@@ -130,8 +142,8 @@
             </if>
             ${wxMagnet.params.dataScope}
         </where>
-		order by  m.order_num
-	</select>
+        order by  m.order_num
+    </select>
 
     <select id="selectMagnetIdByRoleId" parameterType="Long" resultType="String">
 		select m.magnet_id
@@ -156,7 +168,7 @@
 
     <select id="selectMagnetByUserId" parameterType="String" resultMap="WxMagnetResult">
         select distinct m.magnet_id,  m.magnet_name, m.url, m.visible, m.magnet_size
-        , m.bg_url, m.order_num, m.create_time
+        , m.bg_url, m.order_num, m.create_time, m.magnet_type, m.applet_qr_url
         from wx_magnet m
         left join wx_role_magnet rm on m.magnet_id = rm.magnet_id
         left join sys_user_role ur on rm.role_id = ur.role_id
@@ -166,7 +178,7 @@
             and m.visible = "0"
         </where>
         order by  m.order_num
-	</select>
+    </select>
 
 
 </mapper> 

+ 215 - 117
suishenbang-wxportal/suishenbang-wxportal-manager/src/main/resources/templates/wxportal/magnet/add.html

@@ -1,31 +1,34 @@
 <!DOCTYPE html>
-<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
+<html lang="zh" xmlns:th="http://www.thymeleaf.org">
 <head>
-	<th:block th:include="include :: header('新增磁贴')" />
-    <th:block th:include="include :: cropbox-css" />
+    <th:block th:include="include :: header('新增磁贴')"/>
+    <th:block th:include="include :: cropbox-css"/>
     <style>
-        .bg-sm{
+        .bg-sm {
             width: 124px;
             height: 109px;
             font-size: 75px;
             color: black;
             text-align: center
         }
-        .bg-md{
+
+        .bg-md {
             width: 180px;
             height: 150px;
             font-size: 105px;
             color: black;
             text-align: center
-         }
-        .bg-lg{
+        }
+
+        .bg-lg {
             width: 365px;
             height: 160px;
             font-size: 115px;
             color: black;
             text-align: center
         }
-        .thumbBox_S{
+
+        .thumbBox_S {
             position: absolute;
             top: 50%;
             left: 50%;
@@ -38,20 +41,22 @@
             box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
             background: none repeat scroll 0% 0% transparent;
         }
-        .thumbBox_M{
+
+        .thumbBox_M {
             position: absolute;
             top: 50%;
             left: 50%;
             width: 360px;
             height: 300px;
-            margin-left:-180px;
+            margin-left: -180px;
             margin-top: -150px;
             box-sizing: border-box;
             border: 1px solid rgb(102, 102, 102);
             box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
             background: none repeat scroll 0% 0% transparent;
         }
-        .thumbBox_L{
+
+        .thumbBox_L {
             position: absolute;
             top: 50%;
             left: 50%;
@@ -64,130 +69,173 @@
             box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
             background: none repeat scroll 0% 0% transparent;
         }
-        .imageBox_S{
+
+        .imageBox_S {
             margin: 0 auto;
             width: 400px;
         }
-        .imageBox_M{
+
+        .imageBox_M {
             margin: 0 auto;
             width: 400px;
         }
-        .imageBox_L{
+
+        .imageBox_L {
             margin: 0 auto;
             width: 800px;
         }
     </style>
 </head>
 <body class="white-bg">
-	<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="div1">
-		<form class="form-horizontal m" id="form-magnet-add">
-
-			<div class="form-group">
-				<label class="col-sm-3 control-label"><span style="color: red; ">*</span>磁贴名称:</label>
-				<div class="col-sm-8">
-					<input class="form-control" type="text" name="magnetName" id="magnetName" required>
-				</div>
-			</div>
-			<div class="form-group">
-				<label class="col-sm-3 control-label"><span style="color: red; ">*</span>请求地址:</label>
-				<div class="col-sm-8">
-					<input id="url" name="url" class="form-control" type="text" required>
-				</div>
-			</div>
-
-			<div class="form-group">
-				<label class="col-sm-3 control-label">磁贴尺寸:</label>
-				<div class="col-sm-8">
-                   <select name="magnetSize" id="sel_magnetSize" class="form-control m-b" th:with="type=${@dict.getType('wx_magnet_size')}" onchange="javascript:sizeChange()">
+<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="div1">
+    <form class="form-horizontal m" id="form-magnet-add">
+        <div class="form-group">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>磁贴类型:</label>
+            <div class="col-sm-8">
+                <select name="magnetType" id="sel_magnetType" class="form-control m-b"
+                        th:with="type=${@dict.getType('sys_magnet_type')}"
+                        onchange="javascript:magnetTypeChange()">
+                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
+                </select>
+            </div>
+        </div>
+
+        <div class="form-group">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>磁贴名称:</label>
+            <div class="col-sm-8">
+                <input class="form-control" type="text" name="magnetName" id="magnetName" required>
+            </div>
+        </div>
+        <div class="form-group">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>显示排序:</label>
+            <div class="col-sm-8">
+                <input class="form-control" type="text" name="orderNum" required>
+            </div>
+        </div>
+        <div class="form-group">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>磁贴尺寸:</label>
+            <div class="col-sm-8">
+                <select name="magnetSize" id="sel_magnetSize" class="form-control m-b"
+                        th:with="type=${@dict.getType('wx_magnet_size')}" onchange="javascript:sizeChange()">
                     <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                 </select>
+            </div>
+        </div>
+        <div class="form-group" style="display: none;">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>请求地址:</label>
+            <div class="col-sm-8">
+                <input id="url" name="url" class="form-control" type="text" required>
+            </div>
+        </div>
+        <div class="form-group">
+            <label class="col-sm-3 control-label">背景图片:</label>
+            <div class="col-sm-8">
+                <input id="input_bgUrl" name="bgUrl" type="hidden"/>
+                <div class="thumbnail slideshow_span" id="div-bgUrl" onclick="javascript:bgUpload('bg')">
+                    <i class="fa fa-plus"></i>
                 </div>
-			</div>
-			<div class="form-group">
-				<label class="col-sm-3 control-label"><span style="color: red; ">*</span>显示排序:</label>
-				<div class="col-sm-8" >
-					<input class="form-control" type="text" name="orderNum" required>
-				</div>
-			</div>
-			<div class="form-group">
-				<label class="col-sm-3 control-label">背景图片:</label>
-				<div class="col-sm-8">
-                    <input id="input_bgUrl" name="bgUrl" type="hidden"/>
-                    <div class="thumbnail slideshow_span" id="div-bgUrl" onclick="javascript:bgUpload()">
-                        <i class="fa fa-plus"></i>
-                    </div>
-				</div>
-			</div>
-			<div class="form-group">
-				<label class="col-sm-3 control-label">菜单状态:</label>
-				<div class="col-sm-8">
-				    <div class="radio-box" th:each="dict : ${@dict.getType('sys_show_hide')}">
-						<input type="radio" th:id="${dict.dictCode}" name="visible" th:value="${dict.dictValue}" th:checked="${dict.default}">
-						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
-					</div>
-				</div>
-			</div>
-
-			<div class="form-group">
-				<label class="col-sm-3 control-label">备注:</label>
-				<div class="col-sm-8">
-					<textarea id="remark" name="remark" class="form-control" type="text"></textarea>
-				</div>
-			</div>
-		</form>
-	</div>
-
-    <div class="wrapper wrapper-content animated fadeInRight ibox-content" id="div2" style="display: none">
-        <div  id="imageBox" >
-            <div id="thumbBox" ></div>
-            <div class="spinner" style="display: none">Loading...</div>
+            </div>
         </div>
-        <div class="action" style="margin: 10px auto;">
-            <div class="new-contentarea tc">
-                <a href="javascript:void(0)" class="upload-img"> <label for="avatar">选择图片</label> </a>
-                <input type="file" class="" name="avatar" id="avatar" accept="image/*"/>
+        <div class="form-group" style="display: none">
+            <label class="col-sm-3 control-label">小程序二维码:</label>
+            <div class="col-sm-8">
+                <input id="input_appletQrUrl" name="appletQrUrl" type="hidden"/>
+                <div class="thumbnail slideshow_span" id="div-appletQrUrl" onclick="javascript:bgUpload('qr')">
+                    <i class="fa fa-plus"></i>
+                </div>
             </div>
-            <input type="button"  onclick="upBg()" class="btn-info Btnsty_peyton"  value="上传" />
-            <input type="button"  onclick="back()" class="btn-info Btnsty_peyton "  value="返回" />
         </div>
 
+        <div class="form-group">
+            <label class="col-sm-3 control-label">菜单状态:</label>
+            <div class="col-sm-8">
+                <div class="radio-box" th:each="dict : ${@dict.getType('sys_show_hide')}">
+                    <input type="radio" th:id="${dict.dictCode}" name="visible" th:value="${dict.dictValue}"
+                           th:checked="${dict.default}">
+                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
+                </div>
+            </div>
+        </div>
+
+        <div class="form-group">
+            <label class="col-sm-3 control-label">备注:</label>
+            <div class="col-sm-8">
+                <textarea id="remark" name="remark" class="form-control" type="text"></textarea>
+            </div>
+        </div>
+    </form>
+</div>
+
+<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="div2" style="display: none">
+    <div id="imageBox">
+        <div id="thumbBox"></div>
+        <div class="spinner" style="display: none">Loading...</div>
+    </div>
+    <div class="action" style="margin: 10px auto;">
+        <div class="new-contentarea tc">
+            <a href="javascript:void(0)" class="upload-img"> <label for="avatar">选择图片</label> </a>
+            <input type="file" class="" name="avatar" id="avatar" accept="image/*"/>
+        </div>
+        <input type="button" id="submitbuttonBg" onclick="upBg()" class="btn-info Btnsty_peyton" value="上传"/>
+        <input type="button" id="submitbuttonQr" onclick="upQr()" class="btn-info Btnsty_peyton" value="上传"/>
+        <input type="button" onclick="back()" class="btn-info Btnsty_peyton " value="返回"/>
     </div>
-	<th:block th:include="include :: footer" />
-    <th:block th:include="include :: cropbox-js" />
-    <script th:inline="javascript">
+
+</div>
+<th:block th:include="include :: footer"/>
+<th:block th:include="include :: cropbox-js"/>
+<script th:inline="javascript">
     var prefix = ctx + "wxportal/magnet";
     var cropper;
     var size = "S";
+    var magnet_type = "0";
     var options = {
-        thumbBox: '.thumbBox_'+size,
+        thumbBox: '.thumbBox_' + size,
         spinner: '.spinner',
         imgSrc: ctx + 'img/profile.jpg'
     }
-    $(function(){
+    $(function () {
+        var magnetType = $("#sel_magnetType").val();
+        var $appletQrUrl = $("#input_appletQrUrl").parents(".form-group");
+        var $url = $("#url").parents(".form-group");
+        if (magnetType == "1") {
+            $appletQrUrl.removeAttr('disabled');
+            $appletQrUrl.show();
+            $url.attr('disabled', 'disabled');
+            $url.hide();
+        } else {
+            $url.removeAttr('disabled');
+            $url.show();
+            $appletQrUrl.attr('disabled', 'disabled');
+            $appletQrUrl.hide();
+        }
         //form校验
         $("#form-magnet-add").validate({
             onkeyup: false,
-            rules:{
-                magnetName:{
+            rules: {
+                magnetName: {
                     remote: {
                         url: prefix + "/checkMagnetNameUnique",
                         type: "post",
                         dataType: "json",
                         data: {
-                            "magnetName" : function() {
+                            "magnetName": function () {
                                 return $.common.trim($("#magnetName").val());
                             }
                         },
-                        dataFilter: function(data, type) {
+                        dataFilter: function (data, type) {
                             return $.validate.unique(data);
                         }
                     }
                 },
-                orderNum:{
-                    digits:true
+                orderNum: {
+                    digits: true
+                },
+                url: {
+                    required: true
                 },
-                url:{
-                    required:true
+                magnetType: {
+                    required: true
                 },
             },
             messages: {
@@ -199,12 +247,12 @@
         });
 
 
-        $('#avatar').on('change', function() {
+        $('#avatar').on('change', function () {
             var reader = new FileReader();
-            reader.onload = function(e) {
+            reader.onload = function (e) {
                 options.imgSrc = e.target.result;
                 //根据MIME判断上传的文件是不是图片类型
-                if((options.imgSrc).indexOf("image/")==-1){
+                if ((options.imgSrc).indexOf("image/") == -1) {
                     $.modal.alertWarning("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
                 } else {
                     cropper = $('.imageBox').cropbox(options);
@@ -214,11 +262,11 @@
         })
 
 
-        $('#btnZoomIn').on('click', function(){
+        $('#btnZoomIn').on('click', function () {
             cropper.zoomIn();
         })
 
-        $('#btnZoomOut').on('click', function(){
+        $('#btnZoomOut').on('click', function () {
             cropper.zoomOut();
         })
 
@@ -232,27 +280,29 @@
             $.operate.save(prefix + "/add", $('#form-magnet-add').serialize());
         }
     }
+
     function back() {
         $("#div1").show();
         $("#div2").hide();
     }
 
 
-
     /*上传背景图片*/
-    function bgUpload() {
+    function bgUpload(value) {
+        if (value == 'bg') {
+            $("#submitbuttonQr").hide();
+            $("#submitbuttonBg").show();
+        } else if (value == 'qr') {
+            $("#submitbuttonBg").hide();
+            $("#submitbuttonQr").show();
+        }
         $("#div1").hide();
         $("#div2").show();
-        var imgUrl =$("#input_bgUrl").val();
-        if(imgUrl==null||imgUrl==''){
-            imgUrl =  ctx + 'img/profile.jpg';
-        }else{
-            imgUrl = ctx+$("#input_bgUrl").val();
-        }
-         options = {
-            thumbBox: '.thumbBox_'+size,
+        var imgUrl = ctx + 'img/profile.jpg';
+        options = {
+            thumbBox: '.thumbBox_' + size,
             spinner: '.spinner',
-            imgSrc:imgUrl
+            imgSrc: imgUrl
         }
         cropper = $('.imageBox').cropbox(options);
     }
@@ -267,13 +317,39 @@
             type: "post",
             processData: false,
             contentType: false,
-            success: function(result) {
-                if(result.code==0){
+            success: function (result) {
+                if (result.code == 0) {
                     $("#input_bgUrl").val(result.data.fileName);
-                    $("#div-bgUrl").html("<img src='"+result.data.url+"' style='width;100%;height:100%;'>");
+                    $("#div-bgUrl").html("<img src='" + result.data.url + "' style='width;100%;height:100%;'>");
+                    $("#div1").show();
+                    $("#div2").hide();
+                } else {
+                    $("#div1").show();
+                    $("#div2").hide();
+                    $.modal.alertWarning(result.msg);
+                }
+
+            }
+        })
+    }
+
+    function upQr() {
+        var img = cropper.getBlob();
+        var formdata = new FormData();
+        formdata.append("file", img);
+        $.ajax({
+            url: ctx + "common/upload",
+            data: formdata,
+            type: "post",
+            processData: false,
+            contentType: false,
+            success: function (result) {
+                if (result.code == 0) {
+                    $("#input_appletQrUrl").val(result.data.fileName);
+                    $("#div-appletQrUrl").html("<img src='" + result.data.url + "' style='width;100%;height:100%;'>");
                     $("#div1").show();
                     $("#div2").hide();
-                }else{
+                } else {
                     $("#div1").show();
                     $("#div2").hide();
                     $.modal.alertWarning(result.msg);
@@ -282,24 +358,25 @@
             }
         })
     }
-    function sizeChange(){
+
+    function sizeChange() {
         size = $("#sel_magnetSize").val();
         $("#div-bgUrl").removeClass("bg-sm");
         $("#div-bgUrl").removeClass("bg-md");
         $("#div-bgUrl").removeClass("bg-lg");
         $("#imageBox").removeClass();
         $("#thumbBox").removeClass();
-        if(size=="l"||size=="L"){
+        if (size == "l" || size == "L") {
             $("#div-bgUrl").addClass("bg-lg");
             size = "L";
             $("#imageBox").addClass("imageBox imageBox_L");
             $("#thumbBox").addClass("thumbBox_L");
-        }else if(size=="m"||size=="M"){
+        } else if (size == "m" || size == "M") {
             $("#div-bgUrl").addClass("bg-md");
             size = "M";
             $("#imageBox").addClass("imageBox imageBox_M");
             $("#thumbBox").addClass("thumbBox_M");
-        }else if(size=="s"||size=="S"){
+        } else if (size == "s" || size == "S") {
             $("#div-bgUrl").addClass("bg-sm");
             size = "S";
             $("#imageBox").addClass("imageBox imageBox_S");
@@ -307,7 +384,28 @@
         }
     }
 
+    function magnetTypeChange() {
+        magnet_type = $("#sel_magnetType").val();
+        var $appletQrUrl = $("#input_appletQrUrl").parents(".form-group");
+
+        var $url = $("#url").parents(".form-group");
+        if (magnet_type == "1") {
+            $("#div-appletQrUrl").addClass("bg-sm");
+            $("#imageBox").addClass("imageBox imageBox_S");
+            $("#thumbBox").addClass("thumbBox_S");
+            $appletQrUrl.removeAttr('disabled');
+            $appletQrUrl.show();
+            $url.attr('disabled', 'disabled');
+            $url.hide();
+        } else {
+            $appletQrUrl.attr('disabled', 'disabled');
+            $appletQrUrl.hide();
+            $("#input_appletQrUrl").val("");
+            $url.removeAttr('disabled');
+            $url.show();
+        }
+    }
 
-    </script>
+</script>
 </body>
 </html>

+ 299 - 205
suishenbang-wxportal/suishenbang-wxportal-manager/src/main/resources/templates/wxportal/magnet/edit.html

@@ -1,31 +1,31 @@
 <!DOCTYPE html>
-<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
+<html lang="zh" xmlns:th="http://www.thymeleaf.org">
 <head>
-	<th:block th:include="include :: header('修改磁贴')" />
-    <th:block th:include="include :: cropbox-css" />
+    <th:block th:include="include :: header('修改磁贴')"/>
+    <th:block th:include="include :: cropbox-css"/>
     <style>
-        .bg-sm{
+        .bg-sm {
             width: 124px;
             height: 109px;
             font-size: 75px;
             color: black;
             text-align: center
         }
-        .bg-md{
+        .bg-md {
             width: 180px;
             height: 150px;
             font-size: 105px;
             color: black;
             text-align: center
         }
-        .bg-lg{
+        .bg-lg {
             width: 365px;
             height: 160px;
             font-size: 115px;
             color: black;
             text-align: center
         }
-        .thumbBox_S{
+        .thumbBox_S {
             position: absolute;
             top: 50%;
             left: 50%;
@@ -38,20 +38,20 @@
             box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
             background: none repeat scroll 0% 0% transparent;
         }
-        .thumbBox_M{
+        .thumbBox_M {
             position: absolute;
             top: 50%;
             left: 50%;
             width: 360px;
             height: 300px;
-            margin-left:-180px;
+            margin-left: -180px;
             margin-top: -150px;
             box-sizing: border-box;
             border: 1px solid rgb(102, 102, 102);
             box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
             background: none repeat scroll 0% 0% transparent;
         }
-        .thumbBox_L{
+        .thumbBox_L {
             position: absolute;
             top: 50%;
             left: 50%;
@@ -64,252 +64,346 @@
             box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
             background: none repeat scroll 0% 0% transparent;
         }
-        .imageBox_S{
+        .imageBox_S {
             margin: 0 auto;
             width: 400px;
         }
-        .imageBox_M{
+        .imageBox_M {
             margin: 0 auto;
             width: 400px;
         }
-        .imageBox_L{
+        .imageBox_L {
             margin: 0 auto;
             width: 800px;
         }
     </style>
 </head>
 <body class="white-bg">
-	<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="div1">
-        <form class="form-horizontal m" id="form-magnet-edit"  th:object="${wxMagnet}">
-            <input type="hidden" name="magnetId" th:field="*{magnetId}">
-            <div class="form-group">
-                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>磁贴名称:</label>
-                <div class="col-sm-8">
-                    <input class="form-control" type="text" name="magnetName" id="magnetName" th:field="*{magnetName}" required>
-                </div>
+<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="div1">
+    <form class="form-horizontal m" id="form-magnet-edit" th:object="${wxMagnet}">
+        <input type="hidden" name="magnetId" th:field="*{magnetId}">
+
+        <div class="form-group">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>磁贴类型:</label>
+            <div class="col-sm-8">
+                <select name="magnetType" id="sel_magnetType" class="form-control m-b"
+                        th:with="type=${@dict.getType('sys_magnet_type')}"
+                        onchange="javascript:magnetTypeChange()">
+                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
+                            th:field="*{magnetType}"></option>
+                </select>
             </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>请求地址:</label>
-                <div class="col-sm-8">
-                    <input id="url" name="url" class="form-control" type="text" th:field="*{url}"  required>
-                </div>
+        </div>
+        <div class="form-group">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>磁贴名称:</label>
+            <div class="col-sm-8">
+                <input class="form-control" type="text" name="magnetName" id="magnetName" th:field="*{magnetName}"
+                       required>
             </div>
-
-            <div class="form-group">
-                <label class="col-sm-3 control-label">磁贴尺寸:</label>
-                <div class="col-sm-8">
-                    <select name="magnetSize" id="sel_magnetSize" class="form-control m-b"
-                            th:with="type=${@dict.getType('wx_magnet_size')}" onchange="javascript:sizeChange()">
-                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{magnetSize}"></option>
-                    </select>
-                </div>
+        </div>
+        <div class="form-group">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>显示排序:</label>
+            <div class="col-sm-8">
+                <input class="form-control" type="text" name="orderNum" th:field="*{orderNum}" required>
             </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>显示排序:</label>
-                <div class="col-sm-8" >
-                    <input class="form-control" type="text" name="orderNum" th:field="*{orderNum}" required>
-                </div>
+        </div>
+        <div class="form-group">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>磁贴尺寸:</label>
+            <div class="col-sm-8">
+                <select name="magnetSize" id="sel_magnetSize" class="form-control m-b"
+                        th:with="type=${@dict.getType('wx_magnet_size')}" onchange="javascript:sizeChange()">
+                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
+                            th:field="*{magnetSize}"></option>
+                </select>
             </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label">背景图片:</label>
-                <div class="col-sm-8">
-                    <input id="input_bgUrl" name="bgUrl" th:field="*{bgUrl}" type="hidden"/>
-                    <div class="thumbnail slideshow_span" id="div-bgUrl" onclick="javascript:bgUpload()">
-                        <img th:src="@{*{bgUrl}}" style="width;100%;height:100%;">
-                    </div>
-                </div>
+        </div>
+        <div class="form-group" style="display: none;">
+            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>请求地址:</label>
+            <div class="col-sm-8">
+                <input id="url" name="url" class="form-control" type="text" th:field="*{url}" required>
             </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label">菜单状态:</label>
-                <div class="col-sm-8">
-                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_show_hide')}">
-                        <input type="radio" th:id="${dict.dictCode}" name="visible" th:value="${dict.dictValue}"
-                              th:field="*{visible}" >
-                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
-                    </div>
+        </div>
+        <div class="form-group">
+            <label class="col-sm-3 control-label">背景图片:</label>
+            <div class="col-sm-8">
+                <input id="input_bgUrl" name="bgUrl" th:field="*{bgUrl}" type="hidden"/>
+                <div class="thumbnail slideshow_span" id="div-bgUrl" onclick="javascript:bgUpload('bg')">
+                    <img th:src="@{*{bgUrl}}" style="width:100%;height:100%;">
                 </div>
             </div>
+        </div>
 
-            <div class="form-group">
-                <label class="col-sm-3 control-label">备注:</label>
-                <div class="col-sm-8">
-                    <textarea id="remark" name="remark" class="form-control" type="text" th:field="*{remark}"></textarea>
+        <div class="form-group" style="display: none;">
+            <label class="col-sm-3 control-label">小程序二维码:</label>
+            <div class="col-sm-8">
+                <input id="input_appletQrUrl" name="appletQrUrl" th:field="*{appletQrUrl}" type="hidden"/>
+                <div class="thumbnail slideshow_span bg-sm" id="div-appletQrUrl" onclick="javascript:bgUpload('qr')">
+                    <img th:src="@{*{appletQrUrl}}" style="width:100%;height:100%;">
                 </div>
             </div>
-        </form>
-    </div>
+        </div>
 
-    <div class="wrapper wrapper-content animated fadeInRight ibox-content" id="div2" style="display: none">
-        <div  id="imageBox" >
-            <div id="thumbBox" ></div>
-            <div class="spinner" style="display: none">Loading...</div>
+        <div class="form-group">
+            <label class="col-sm-3 control-label">菜单状态:</label>
+            <div class="col-sm-8">
+                <div class="radio-box" th:each="dict : ${@dict.getType('sys_show_hide')}">
+                    <input type="radio" th:id="${dict.dictCode}" name="visible" th:value="${dict.dictValue}"
+                           th:field="*{visible}">
+                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
+                </div>
+            </div>
         </div>
-        <div class="action" style="margin: 10px auto;">
-            <div class="new-contentarea tc">
-                <a href="javascript:void(0)" class="upload-img"> <label for="avatar">选择图片</label> </a>
-                <input type="file" class="" name="avatar" id="avatar" accept="image/*"/>
+
+        <div class="form-group">
+            <label class="col-sm-3 control-label">备注:</label>
+            <div class="col-sm-8">
+                <textarea id="remark" name="remark" class="form-control" type="text" th:field="*{remark}"></textarea>
             </div>
-            <input type="button"  onclick="upBg()" class="btn-info Btnsty_peyton"  value="上传" />
-            <input type="button"  onclick="back()" class="btn-info Btnsty_peyton "  value="返回" />
         </div>
+    </form>
+</div>
 
+<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="div2" style="display: none">
+    <div id="imageBox">
+        <div id="thumbBox"></div>
+        <div class="spinner" style="display: none">Loading...</div>
     </div>
-	<th:block th:include="include :: footer" />
-    <th:block th:include="include :: cropbox-js" />
-	 <script th:inline="javascript">
-        var prefix = ctx + "wxportal/magnet";
-        var cropper;
-        var size = "S";
-        var options = {
-            thumbBox: '.thumbBox_'+size,
-            spinner: '.spinner',
-            imgSrc: ctx + 'img/profile.jpg'
+    <div class="action" style="margin: 10px auto;">
+        <div class="new-contentarea tc">
+            <a href="javascript:void(0)" class="upload-img"> <label for="avatar">选择图片</label> </a>
+            <input type="file" class="" name="avatar" id="avatar" accept="image/*"/>
+        </div>
+        <input type="button" id="submitbuttonBg" onclick="upBg()" class="btn-info Btnsty_peyton" value="上传"/>
+        <input type="button" id="submitbuttonQr" onclick="upQr()" class="btn-info Btnsty_peyton" value="上传"/>
+        <input type="button" onclick="back()" class="btn-info Btnsty_peyton " value="返回"/>
+    </div>
+
+</div>
+<th:block th:include="include :: footer"/>
+<th:block th:include="include :: cropbox-js"/>
+<script th:inline="javascript">
+    var prefix = ctx + "wxportal/magnet";
+    var cropper;
+    var size = "S";
+    var magnet_type = "0";
+    var options = {
+        thumbBox: '.thumbBox_' + size,
+        spinner: '.spinner',
+        imgSrc: ctx + 'img/profile.jpg'
+    }
+    $(function () {
+        var magnetType = $("#sel_magnetType").val();
+        var $appletQrUrl = $("#input_appletQrUrl").parents(".form-group");
+        var $url = $("#url").parents(".form-group");
+        if (magnetType == "1") {
+            $appletQrUrl.removeAttr('disabled');
+            $appletQrUrl.show();
+            $url.attr('disabled', 'disabled');
+            $url.hide();
+        } else {
+            $url.removeAttr('disabled');
+            $url.show();
+            $appletQrUrl.attr('disabled', 'disabled');
+            $appletQrUrl.hide();
         }
-        $(function() {
-            $("#form-magnet-edit").validate({
-                onkeyup: false,
-                rules: {
-                    url: {
-                        required: true,
-                    },
-                    magnetName: {
-                        remote: {
-                            url: prefix + "/checkMagnetNameUnique",
-                            type: "post",
-                            dataType: "json",
-                            data: {
-                                "magnetId": function () {
-                                    return $("#magnetId").val();
-                                },
-                                "magnetName": function () {
-                                    return $.common.trim($("#magnetName").val());
-                                }
+        $("#form-magnet-edit").validate({
+            onkeyup: false,
+            rules: {
+                url: {
+                    required: true,
+                },
+                magnetName: {
+                    remote: {
+                        url: prefix + "/checkMagnetNameUnique",
+                        type: "post",
+                        dataType: "json",
+                        data: {
+                            "magnetId": function () {
+                                return $("#magnetId").val();
                             },
-                            dataFilter: function (data, type) {
-                                return $.validate.unique(data);
+                            "magnetName": function () {
+                                return $.common.trim($("#magnetName").val());
                             }
+                        },
+                        dataFilter: function (data, type) {
+                            return $.validate.unique(data);
                         }
-                    },
-                    orderNum: {
-                        digits: true
-                    },
-
-                },
-                messages: {
-                    "magnetName": {
-                        remote: "菜单已经存在"
                     }
                 },
-                focusCleanup: true
-            });
+                orderNum: {
+                    digits: true
+                },
 
-            $('#avatar').on('change', function() {
-                var reader = new FileReader();
-                reader.onload = function(e) {
-                    options.imgSrc = e.target.result;
-                    //根据MIME判断上传的文件是不是图片类型
-                    if((options.imgSrc).indexOf("image/")==-1){
-                        $.modal.alertWarning("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
-                    } else {
-                        cropper = $('.imageBox').cropbox(options);
-                    }
+            },
+            messages: {
+                "magnetName": {
+                    remote: "菜单已经存在"
+                }
+            },
+            focusCleanup: true
+        });
+
+        $('#avatar').on('change', function () {
+            var reader = new FileReader();
+            reader.onload = function (e) {
+                options.imgSrc = e.target.result;
+                //根据MIME判断上传的文件是不是图片类型
+                if ((options.imgSrc).indexOf("image/") == -1) {
+                    $.modal.alertWarning("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
+                } else {
+                    cropper = $('.imageBox').cropbox(options);
                 }
-                reader.readAsDataURL(this.files[0]);
-            })
+            }
+            reader.readAsDataURL(this.files[0]);
+        })
 
 
-            $('#btnZoomIn').on('click', function(){
-                cropper.zoomIn();
-            })
+        $('#btnZoomIn').on('click', function () {
+            cropper.zoomIn();
+        })
 
-            $('#btnZoomOut').on('click', function(){
-                cropper.zoomOut();
-            })
+        $('#btnZoomOut').on('click', function () {
+            cropper.zoomOut();
+        })
 
 
-            sizeChange();
-        });
-        
-        function submitHandler() {
-	        if ($.validate.form()) {
-	            $.operate.save(prefix + "/edit", $('#form-magnet-edit').serialize());
-	        }
-	    }
+        sizeChange();
+    });
 
-        function back() {
-            $("#div1").show();
-            $("#div2").hide();
+    function submitHandler() {
+        if ($.validate.form()) {
+            $.operate.save(prefix + "/edit", $('#form-magnet-edit').serialize());
         }
+    }
 
-        /*上传背景图片*/
-        function bgUpload() {
-            $("#div1").hide();
-            $("#div2").show();
-            var imgUrl =$("#input_bgUrl").val();
-            if(imgUrl==null||imgUrl==''){
-                imgUrl =  ctx + 'img/profile.jpg';
-            }else{
-                imgUrl = ctx+$("#input_bgUrl").val();
-            }
-            options = {
-                thumbBox: '.thumbBox_'+size,
-                spinner: '.spinner',
-                imgSrc:imgUrl
-            }
-            cropper = $('.imageBox').cropbox(options);
+    function back() {
+        $("#div1").show();
+        $("#div2").hide();
+    }
+
+    /*上传背景图片*/
+    function bgUpload(value) {
+        var imgUrl = null;
+        if (value == 'bg') {
+            $("#submitbuttonQr").hide();
+            $("#submitbuttonBg").show();
+            imgUrl = ctx + $("#input_bgUrl").val();
+        } else if (value == 'qr') {
+            $("#submitbuttonBg").hide();
+            $("#submitbuttonQr").show();
+            imgUrl = ctx + $("#input_appletQrUrl").val();
         }
+        $("#div1").hide();
+        $("#div2").show();
 
-        function upBg() {
-            var img = cropper.getBlob();
-            var formdata = new FormData();
-            formdata.append("file", img);
-            $.ajax({
-                url: ctx + "common/upload",
-                data: formdata,
-                type: "post",
-                processData: false,
-                contentType: false,
-                success: function(result) {
-                    if(result.code==0){
-                        $("#input_bgUrl").val(result.data.fileName);
-                        $("#div-bgUrl").html("<img src='"+result.data.url+"' style='width;100%;height:100%;'>");
-                        $("#div1").show();
-                        $("#div2").hide();
-                    }else{
-                        $("#div1").show();
-                        $("#div2").hide();
-                        $.modal.alertWarning(result.msg);
-                    }
+        if (imgUrl == null || imgUrl == '') {
+            imgUrl = ctx + 'img/profile.jpg';
+        }
+        options = {
+            thumbBox: '.thumbBox_' + size,
+            spinner: '.spinner',
+            imgSrc: imgUrl
+        }
+        cropper = $('.imageBox').cropbox(options);
+    }
 
+    function upBg() {
+        var img = cropper.getBlob();
+        var formdata = new FormData();
+        formdata.append("file", img);
+        $.ajax({
+            url: ctx + "common/upload",
+            data: formdata,
+            type: "post",
+            processData: false,
+            contentType: false,
+            success: function (result) {
+                if (result.code == 0) {
+                    $("#input_bgUrl").val(result.data.fileName);
+                    $("#div-bgUrl").html("<img src='" + result.data.url + "' style='width:100%;height:100%;'>");
+                    $("#div1").show();
+                    $("#div2").hide();
+                } else {
+                    $("#div1").show();
+                    $("#div2").hide();
+                    $.modal.alertWarning(result.msg);
                 }
-            })
-        }
 
-        function sizeChange(){
-            size = $("#sel_magnetSize").val();
-            $("#div-bgUrl").removeClass("bg-sm");
-            $("#div-bgUrl").removeClass("bg-md");
-            $("#div-bgUrl").removeClass("bg-lg");
-            $("#imageBox").removeClass();
-            $("#thumbBox").removeClass();
-            if(size=="l"||size=="L"){
-                $("#div-bgUrl").addClass("bg-lg");
-                size = "L";
-                $("#imageBox").addClass("imageBox imageBox_L");
-                $("#thumbBox").addClass("thumbBox_L");
-            }else if(size=="m"||size=="M"){
-                $("#div-bgUrl").addClass("bg-md");
-                size = "M";
-                $("#imageBox").addClass("imageBox imageBox_M");
-                $("#thumbBox").addClass("thumbBox_M");
-            }else if(size=="s"||size=="S"){
-                $("#div-bgUrl").addClass("bg-sm");
-                size = "S";
-                $("#imageBox").addClass("imageBox imageBox_S");
-                $("#thumbBox").addClass("thumbBox_S");
             }
+        })
+    }
+
+    function upQr() {
+        var img = cropper.getBlob();
+        var formdata = new FormData();
+        formdata.append("file", img);
+        $.ajax({
+            url: ctx + "common/upload",
+            data: formdata,
+            type: "post",
+            processData: false,
+            contentType: false,
+            success: function (result) {
+                if (result.code == 0) {
+                    $("#input_appletQrUrl").val(result.data.fileName);
+                    $("#div-appletQrUrl").html("<img src='" + result.data.url + "' style='width:100%;height:100%;'>");
+                    $("#div1").show();
+                    $("#div2").hide();
+                } else {
+                    $("#div1").show();
+                    $("#div2").hide();
+                    $.modal.alertWarning(result.msg);
+                }
+
+            }
+        })
+    }
+
+    function sizeChange() {
+        size = $("#sel_magnetSize").val();
+        $("#div-bgUrl").removeClass("bg-sm");
+        $("#div-bgUrl").removeClass("bg-md");
+        $("#div-bgUrl").removeClass("bg-lg");
+        $("#imageBox").removeClass();
+        $("#thumbBox").removeClass();
+        if (size == "l" || size == "L") {
+            $("#div-bgUrl").addClass("bg-lg");
+            size = "L";
+            $("#imageBox").addClass("imageBox imageBox_L");
+            $("#thumbBox").addClass("thumbBox_L");
+        } else if (size == "m" || size == "M") {
+            $("#div-bgUrl").addClass("bg-md");
+            size = "M";
+            $("#imageBox").addClass("imageBox imageBox_M");
+            $("#thumbBox").addClass("thumbBox_M");
+        } else if (size == "s" || size == "S") {
+            $("#div-bgUrl").addClass("bg-sm");
+            size = "S";
+            $("#imageBox").addClass("imageBox imageBox_S");
+            $("#thumbBox").addClass("thumbBox_S");
+        }
+    }
+
+    function magnetTypeChange() {
+        magnet_type = $("#sel_magnetType").val();
+        var $appletQrUrl = $("#input_appletQrUrl").parents(".form-group");
+        var $url = $("#url").parents(".form-group");
+        if (magnet_type == "1") {
+            $("#imageBox").addClass("imageBox imageBox_S");
+            $("#thumbBox").addClass("thumbBox_S");
+            $appletQrUrl.removeAttr('disabled');
+            $appletQrUrl.show();
+            $url.attr('disabled', 'disabled');
+            $url.hide();
+        } else {
+            $appletQrUrl.attr('disabled', 'disabled');
+            $appletQrUrl.hide();
+            $("#input_appletQrUrl").val("");
+            $url.removeAttr('disabled');
+            $url.show();
         }
+    }
 
-    </script>
+</script>
 </body>
 </html>

+ 180 - 157
suishenbang-wxportal/suishenbang-wxportal-manager/src/main/resources/templates/wxportal/magnet/wxMagnet.html

@@ -2,172 +2,195 @@
 <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
 <head>
 	<th:block th:include="include :: header('磁贴列表')" />
-    <style>
-        .tableImage_s{
-            border-radius:2px;
-            width: 24px;
-            height: 22px;
-        }
-        .tableImage_m{
-            border-radius:2px;
-            width: 36px;
-            height: 30px;
-        }
-        .tableImage_l{
-            border-radius:2px;
-            width: 73px;
-            height: 32px;
-        }
-    </style>
+	<style>
+		.tableImage_s{
+			border-radius:2px;
+			width: 24px;
+			height: 22px;
+		}
+		.tableImage_m{
+			border-radius:2px;
+			width: 36px;
+			height: 30px;
+		}
+		.tableImage_l{
+			border-radius:2px;
+			width: 73px;
+			height: 32px;
+		}
+	</style>
 </head>
 <body class="gray-bg">
-    <div class="container-div">
-		<div class="row">
-			<div class="col-sm-12 search-collapse">
-				<form id="magnet-form">
-					<div class="select-list">
-						<ul>
-							<li>
-								磁贴名称:<input type="text" name="magnetName"/>
-							</li>
-							<li>
-								磁贴状态:<select name="visible" th:with="type=${@dict.getType('sys_show_hide')}">
-									<option value="">所有</option>
-									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
-								</select>
-							</li>
-							<li>
-								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
-								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
-							</li>
-						</ul>
-					</div>
-				</form>
-			</div>
-                
-            <div class="btn-group-sm" id="toolbar" role="group">
-		        <a class="btn btn-success" onclick="addNew()" shiro:hasPermission="wxportal:magnet:add">
-                    <i class="fa fa-plus"></i> 新增
-                </a>
-                <!--<a class="btn btn-primary" onclick="$.operate.editFull()" shiro:hasPermission="wxportal:magnet:edit">-->
-		            <!--<i class="fa fa-edit"></i> 修改-->
-		        <!--</a>-->
-	        </div>
-       		 <div class="col-sm-12 select-table table-striped">
-	            <table id="bootstrap-table"></table>
-	        </div>
-	    </div>
+<div class="container-div">
+	<div class="row">
+		<div class="col-sm-12 search-collapse">
+			<form id="magnet-form">
+				<div class="select-list">
+					<ul>
+						<li>
+							磁贴名称:<input type="text" name="magnetName"/>
+						</li>
+						<li>
+							磁贴状态:<select name="visible" th:with="type=${@dict.getType('sys_show_hide')}">
+							<option value="">所有</option>
+							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
+						</select>
+						</li>
+						<li>
+							磁贴类型:<select name="magnetType" th:with="type=${@dict.getType('sys_magnet_type')}">
+							<option value="">所有</option>
+							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
+						</select>
+						</li>
+						<li>
+							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
+							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
+						</li>
+					</ul>
+				</div>
+			</form>
+		</div>
+
+		<div class="btn-group-sm" id="toolbar" role="group">
+			<a class="btn btn-success" onclick="addNew()" shiro:hasPermission="wxportal:magnet:add">
+				<i class="fa fa-plus"></i> 新增
+			</a>
+			<!--<a class="btn btn-primary" onclick="$.operate.editFull()" shiro:hasPermission="wxportal:magnet:edit">-->
+			<!--<i class="fa fa-edit"></i> 修改-->
+			<!--</a>-->
+		</div>
+		<div class="col-sm-12 select-table table-striped">
+			<table id="bootstrap-table" style="table-layout: fixed;word-break:break-all; word-wrap:break-word;"></table>
+		</div>
 	</div>
-	
-	<th:block th:include="include :: footer" />
-	<script th:inline="javascript">
-		var editFlag = [[${@permission.hasPermi('wxportal:magnet:edit')}]];
-		var removeFlag = [[${@permission.hasPermi('wxportal:magnet:remove')}]];
-		var datas = [[${@dict.getType('sys_show_hide')}]];
-        var magnetSizeList = [[${@dict.getType('wx_magnet_size')}]];
-		var prefix = ctx + "wxportal/magnet";
+</div>
+
+<th:block th:include="include :: footer" />
+<script th:inline="javascript">
+	var editFlag = [[${@permission.hasPermi('wxportal:magnet:edit')}]];
+	var removeFlag = [[${@permission.hasPermi('wxportal:magnet:remove')}]];
+	var datas = [[${@dict.getType('sys_show_hide')}]];
+	var magnetSizeList = [[${@dict.getType('wx_magnet_size')}]];
+	var magnetTypeDatas = [[${@dict.getType('sys_magnet_type')}]];
+	var prefix = ctx + "wxportal/magnet";
 
-		$(function() {
-		    var options = {
-		        url: prefix + "/list",
-		        createUrl: prefix + "/add",
-		        updateUrl: prefix + "/edit/{id}",
-		        removeUrl: prefix + "/remove/{id}",
-                showColumns: false,
-                showToggle: false,
-		        modalName: "磁贴管理",
-		        columns: [{
-                    checkbox: true
-                },
-                {
-                    field : 'id',
-                    title : 'id',
-                    visible: false
-                },
-                {
-                    field: 'magnetName',
-                    title: '磁贴名称',
-                    width: '20%'
-                },
-		        {
-		            field: 'bgUrl',
-		            title: '背景图片',
-		            width: '10%',
-                    formatter: function(value, row, index) {
-                        var str="";
-                        if(ctx=="/"){
-                            str = value;
-                        }else{
-                            str = ctx+value;
-                        }
-                        if(row.magnetSize=="S"){
-                            return $.table.imageView(str,218,237,"tableImage_s img-view");
-                        }else if(row.magnetSize=="M"){
-                            return $.table.imageView(str,300,360,"tableImage_m img-view");
-                        }else if(row.magnetSize=="L"){
-                            return $.table.imageView(str,320,730,"tableImage_l img-view");
-                        }
-                    }
-		        },
-		        {
-		            field: 'url',
-		            title: '请求地址',
-		            width: '15%',
-		            align: "left"
-		        },
-		        {
-		            title: '磁贴尺寸',
-		            field: 'magnetType',
-		            width: '10%',
-		            align: "left",
-		            formatter: function(value, item, index) {
-                        return $.table.selectDictLabel(magnetSizeList, item.magnetSize);
-		            }
-		        },
-		        {
-		            field: 'visible',
-		            title: '可见',
-		            width: '10%',
-		            align: "left",
-		            formatter: function(value, row, index) {
-		            	if (row.magnetType == 'F') {
-		                    return '-';
-		                }
-		            	return $.table.selectDictLabel(datas, row.visible);
-		            }
-		        },
-                {
-                    field: 'orderNum',
-                    title: '排序',
-                    width: '10%',
-                    align: "left"
-                },
-		        {
-		            title: '操作',
-		            width: '20%',
-		            align: "left",
-		            formatter: function(value, row, index) {
-		                var actions = [];
-		                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editMagnet(\'' + row.magnetId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
-		                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.magnetId + '\')"><i class="fa fa-trash"></i>删除</a>');
-		                return actions.join('');
-		            }
-		        }]
-		    };
-		    $.table.init(options);
-		});
+	$(function() {
+		var options = {
+			url: prefix + "/list",
+			createUrl: prefix + "/add",
+			updateUrl: prefix + "/edit/{id}",
+			removeUrl: prefix + "/remove/{id}",
+			showColumns: false,
+			showToggle: false,
+			modalName: "磁贴管理",
+			columns: [{
+				checkbox: true
+			},
+				{
+					field : 'id',
+					title : 'id',
+					visible: false
+				},
+				{
+					field: 'magnetName',
+					title: '磁贴名称',
+					width: '15%'
+				},
+				{
+					field: 'bgUrl',
+					title: '背景图片',
+					width: '10%',
+					formatter: function(value, row, index) {
+						var str="";
+						if(ctx=="/"){
+							str = value;
+						}else{
+							str = ctx+value;
+						}
+						if(row.magnetSize=="S"){
+							return $.table.imageView(str,218,237,"tableImage_s img-view");
+						}else if(row.magnetSize=="M"){
+							return $.table.imageView(str,300,360,"tableImage_m img-view");
+						}else if(row.magnetSize=="L"){
+							return $.table.imageView(str,320,730,"tableImage_l img-view");
+						}
+					}
+				},
+				{
+					field: 'url',
+					title: '请求地址',
+					width: '30%',
+					align: "left",
+					formatter: function(value, item, index) {
+						if(item.magnetType =="1"){
+							return item.appletQrUrl;
+						}else {
+							return item.url;
+						}
+					}
+				},
+				{
+					title: '磁贴类型',
+					field: 'magnetType',
+					width: '10%',
+					align: "left",
+					formatter: function(value, item, index) {
+						return $.table.selectDictLabel(magnetTypeDatas, item.magnetType);
+					}
+				},
+				{
+					title: '磁贴尺寸',
+					field: 'magnetType',
+					width: '10%',
+					align: "left",
+					formatter: function(value, item, index) {
+						return $.table.selectDictLabel(magnetSizeList, item.magnetSize);
+					}
+				},
+				{
+					field: 'visible',
+					title: '可见',
+					width: '10%',
+					align: "left",
+					formatter: function(value, row, index) {
+						if (row.magnetType == 'F') {
+							return '-';
+						}
+						return $.table.selectDictLabel(datas, row.visible);
+					}
+				},
+				{
+					field: 'orderNum',
+					title: '排序',
+					width: '10%',
+					align: "left"
+				},
+				{
+					title: '操作',
+					width: '15%',
+					align: "left",
+					formatter: function(value, row, index) {
+						var actions = [];
+						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editMagnet(\'' + row.magnetId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
+						actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.magnetId + '\')"><i class="fa fa-trash"></i>删除</a>');
+						return actions.join('');
+					}
+				}]
+		};
+		$.table.init(options);
+	});
 
 
-        function addNew(){
-            $.modal.openFull("添加" + $.table._option.modalName, $.operate.addUrl(0));
+	function addNew(){
+		$.modal.openFull("添加" + $.table._option.modalName, $.operate.addUrl(0));
 
-        }
+	}
 
-        function editMagnet(id){
+	function editMagnet(id){
 
-            $.modal.openFull("修改" + $.table._option.modalName, $.operate.editUrl(id));
+		$.modal.openFull("修改" + $.table._option.modalName, $.operate.editUrl(id));
 
-        }
-	</script>
+	}
+</script>
 </body>
 </html>