Browse Source

帮助中心-表单-提交建议

chao 4 years ago
parent
commit
cc7f54ce45

+ 14 - 1
src/main/java/com/caimei/www/controller/unlimited/HelpPageController.java

@@ -1,13 +1,17 @@
 package com.caimei.www.controller.unlimited;
 
 import com.caimei.www.controller.BaseController;
+import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.page.PageContent;
+import com.caimei.www.pojo.save.Suggestion;
 import com.caimei.www.service.page.HelpService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 /**
  * Description
@@ -42,5 +46,14 @@ public class HelpPageController extends BaseController {
         return HELP_PAGE_PATH;
     }
 
-
+    /**
+     * 保存投诉建议
+     * @param suggestion
+     * @return
+     */
+    @PostMapping("/help/suggestion")
+    @ResponseBody
+    public JsonModel suggestion(Suggestion suggestion) {
+        return helpService.suggestionSave(suggestion);
+    }
 }

+ 13 - 0
src/main/java/com/caimei/www/mapper/SinglePageDao.java

@@ -1,8 +1,10 @@
 package com.caimei.www.mapper;
 
+import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.page.ImageLink;
 import com.caimei.www.pojo.page.PageContent;
 import com.caimei.www.pojo.page.PageFloor;
+import com.caimei.www.pojo.save.Suggestion;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -68,4 +70,15 @@ public interface SinglePageDao {
      * @return
      */
     PageContent getHelpPageById(Integer id);
+
+
+    /**
+     * 保存投诉建议
+     * @param suggestion
+     * @return
+     */
+    void suggestionSave(Suggestion suggestion);
+    Integer getMaxSuggestionId();
+
+
 }

+ 25 - 0
src/main/java/com/caimei/www/pojo/save/Suggestion.java

@@ -0,0 +1,25 @@
+package com.caimei.www.pojo.save;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2020/9/1
+ */
+@Data
+public class Suggestion implements Serializable {
+	private Integer suggestionID;
+	private Integer suggestionTypeID;
+	private Integer userID;
+	private String addTime;
+	private String title;
+	private String content;
+	private String linkMan;
+	private String mobile;
+	private String replyContent;
+	private String status;
+}

+ 9 - 0
src/main/java/com/caimei/www/service/page/HelpService.java

@@ -1,6 +1,8 @@
 package com.caimei.www.service.page;
 
+import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.page.PageContent;
+import com.caimei.www.pojo.save.Suggestion;
 
 /**
  * Description
@@ -11,4 +13,11 @@ import com.caimei.www.pojo.page.PageContent;
 public interface HelpService {
     /** 根据ID查找帮助页 */
     PageContent getHelpPageById(Integer id);
+
+    /**
+     * 保存投诉建议
+     * @param suggestion
+     * @return
+     */
+    JsonModel suggestionSave(Suggestion suggestion);
 }

+ 23 - 0
src/main/java/com/caimei/www/service/page/impl/HelpServiceImpl.java

@@ -1,12 +1,18 @@
 package com.caimei.www.service.page.impl;
 
 import com.caimei.www.mapper.SinglePageDao;
+import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.page.PageContent;
+import com.caimei.www.pojo.save.Suggestion;
 import com.caimei.www.service.page.HelpService;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.xml.crypto.Data;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 /**
  * Description
@@ -31,4 +37,21 @@ public class HelpServiceImpl implements HelpService {
     public PageContent getHelpPageById(Integer id) {
         return singlePageDao.getHelpPageById(id);
     }
+
+    /**
+     * 保存投诉建议
+     *
+     * @param suggestion
+     * @return
+     */
+    @Override
+    public JsonModel suggestionSave(Suggestion suggestion) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String format = sdf.format(new Date());
+        Integer maxId = singlePageDao.getMaxSuggestionId();
+        suggestion.setAddTime(format);
+        suggestion.setSuggestionID(maxId+1);
+        singlePageDao.suggestionSave(suggestion);
+        return JsonModel.success("投诉建议成功!","");
+    }
 }

+ 15 - 1
src/main/resources/mapper/SinglePageMapper.xml

@@ -69,6 +69,20 @@
         where helpPageID=#{id}
         and validFlag=1 and showFlag=1
     </select>
-
+    <select id="getMaxSuggestionId" resultType="java.lang.Integer">
+        select MAX(suggestionID) from suggestion
+    </select>
+    <insert id="suggestionSave" parameterType="com.caimei.www.pojo.save.Suggestion">
+        insert into suggestion
+        (suggestionID, suggestionTypeID, userID, title, content, linkMan, mobile, addTime)
+        values (#{suggestionID,jdbcType=INTEGER},
+                #{suggestionTypeID,jdbcType=INTEGER},
+                #{userID,jdbcType=INTEGER},
+                #{title,jdbcType=VARCHAR},
+                #{content,jdbcType=VARCHAR},
+                #{linkMan,jdbcType=VARCHAR},
+                #{mobile,jdbcType=VARCHAR},
+                #{addTime,jdbcType=VARCHAR})
+    </insert>
 
 </mapper>

+ 21 - 3
src/main/resources/static/css/help/help.css

@@ -18,9 +18,23 @@ li{list-style:none}
 .navLayout .navList .con a.on{color:#e15616;background-color:#ffe6dc}
 .navLayout .right{float:right;width:968px}
 .pageContent{background:#FFF;padding:16px}
-
-
-
+.pageContent form{
+    width: 498px;
+    margin: 0 auto;
+    padding: 50px 0;
+}
+/*.pageContent form button{
+    display: block;
+    margin: 0 auto;
+    width: 200px;
+    height: 50px;
+    line-height: 50px;
+    background-color: #e15616;
+    border-radius: 2px;
+    text-align: center;
+    font-size: 18px;
+    color: #FFF;
+}*/
 
 
 
@@ -43,6 +57,10 @@ li{list-style:none}
 .navLayout .right{width:70.5vw}
 .pageContent{padding:3.3vw}
 
+.pageContent .formLine .diyBox {
+    width: 24vw;
+}
+
 
 
 

+ 57 - 1
src/main/resources/static/js/help/help.js

@@ -1,3 +1,59 @@
+;
+jqMultipleShow("click", ".navList", ".tab", ".con");
 
+var helpSuggestion = new Vue({
+    el: "#suggestion",
+    data: {
+        btnLoading: false,
+        userId: 0,
+        suggestion: {
+            type: 1,
+            title: "",
+            content: "",
+            name: "",
+            phone: ""
+        },
+        rule:{
+            name: '^[a-zA-Z\\u4e00-\\u9fa5]{2,}$',
+            phone: '^\\d{6,12}$'
+        }
+    },
+    methods: {
+        blurHandle: function(event) { // 失去焦点校验
+            var el = event.currentTarget;
+            verifyHandle(el);
+        },
+        postSuggestion: function () {  // 账号登录
+            var _self = this;
+            var pass = verifyForm();
+            if (this.btnLoading) {
+                return false;
+            }
+            this.$nextTick(function () {
+                if (!pass) {
+                    return false;
+                }
+                _self.btnLoading = true;
+                var params = {
+	                suggestionTypeID: _self.suggestion.type,
+	                userID: _self.userId,
+	                title: _self.suggestion.title,
+	                content: _self.suggestion.content,
+	                linkMan: _self.suggestion.name,
+	                mobile: _self.suggestion.phone
+                };
+                console.log(JSON.stringify(params));
+                $.post("/help/suggestion", params, function(res){
+                    alertInfo(res.msg);
+                    _self.btnLoading = false;
+                });
+            });
+        }
 
-jqMultipleShow("click", ".navList", ".tab", ".con");
+    },
+    mounted: function () {
+        if(globalUserData){
+            this.userId = globalUserData.userId;
+        }
+    }
+});

+ 37 - 6
src/main/resources/templates/help/help.html

@@ -4,6 +4,7 @@
 <head>
     <title>采美365网-中国美业全方位线上交易服务互动平台,做美业,上采美</title>
     <template th:replace="components/head-link"></template>
+    <link th:if="${pageId==1026}" th:href="@{/css/base/form.css(v=${version})}" rel="stylesheet" type="text/css">
     <link th:href="@{/css/help/help.css(v=${version})}" rel="stylesheet" type="text/css">
 </head>
 <body>
@@ -29,14 +30,44 @@
             </div>
         </div>
         <div class="right">
-            <div class="pageContent" th:utext="${pageInfo?.content}"></div>
+            <div th:if="${pageId!=1026}" class="pageContent" th:utext="${pageInfo?.content}"></div>
+            <div th:if="${pageId==1026}" class="pageContent">
+                <form id="suggestion">
+                    <div class="formLine">
+                        <p><em>*</em>类型:</p>
+                        <label class="diyBox"><input type="radio" name="suggestionType" v-model="suggestion.type" value="1" ><i class="icon mIcon">投诉</i></label>
+                        <label class="diyBox"><input type="radio" name="suggestionType" v-model="suggestion.type" value="2" checked><i class="icon mIcon">建议</i></label>
+                        <span class="errTips icon mIcon mIcon" tips="请选择类型"></span>
+                    </div>
+                    <div class="formLine">
+                        <p><em>*</em>标题:</p>
+                        <input type="text" v-model.trim="suggestion.title" placeholder="请输入标题" maxlength="50" @blur="blurHandle($event)" needverify>
+                        <i class="checked icon mIcon"></i>
+                        <span class="errTips icon mIcon" tips="请输入标题"></span>
+                    </div>
+                    <div class="formLine">
+                        <p><em>*</em>内容:</p>
+                        <textarea v-model.trim="suggestion.content" placeholder="请输入投诉/建议内容(建议输入10-500个字)" maxlength="500" @blur="blurHandle($event)" needverify></textarea>
+                        <i class="checked icon mIcon"></i>
+                        <span class="errTips icon mIcon" tips="请输入投诉/建议内容(建议输入10-500个字)"></span>
+                    </div>
+                    <div class="formLine">
+                        <p><em>*</em>联系人:</p>
+                        <input type="text" v-model.trim="suggestion.name" placeholder="请输入您的姓名" :rule="rule.name" maxlength="50" @blur="blurHandle($event)" needverify>
+                        <i class="checked icon mIcon"></i>
+                        <span class="errTips icon mIcon" tips="请输入正确的联系人姓名"></span>
+                    </div>
+                    <div class="formLine">
+                        <p><em>*</em>手机号:</p>
+                        <input type="text" v-model.trim="suggestion.phone" placeholder="请输入您的常用手机号" :rule="rule.phone" maxlength="12" @blur="blurHandle($event)" needverify>
+                        <i class="checked icon mIcon"></i>
+                        <span class="errTips icon mIcon" tips="请输入有效电话号码"></span>
+                    </div>
+                    <div class="subLine"><button type="button" class="btn" @click="postSuggestion()">提交</button></div>
+                </form>
+            </div>
         </div>
     </div>
-
-
-
-
-
 </div>
 
 <!-- 引入底部 -->