From 8aca6a3e0c08b91961896b4ce0ded4fde19d8ec5 Mon Sep 17 00:00:00 2001 From: usgeek <940208412@qq.com> Date: Tue, 28 Aug 2018 14:09:53 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AC=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- litemall-admin/src/router/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litemall-admin/src/router/index.js b/litemall-admin/src/router/index.js index 8447285c..d4fed927 100644 --- a/litemall-admin/src/router/index.js +++ b/litemall-admin/src/router/index.js @@ -65,7 +65,7 @@ export const asyncRouterMap = [ { path: 'address', component: _import('user/address'), name: 'address', meta: { title: '收货地址', noCache: true }}, { path: 'collect', component: _import('user/collect'), name: 'collect', meta: { title: '会员收藏', noCache: true }}, { path: 'footprint', component: _import('user/footprint'), name: 'footprint', meta: { title: '会员足迹', noCache: true }}, - { path: 'history', component: _import('user/history'), name: 'history', meta: { title: '搜索历史', noCache: true }}, + { path: 'history', component: _import('user/history'), name: 'history', meta: { title: '搜索历史', noCache: true }}, { path: 'feedback', component: _import('user/feedback'), name: 'feedback', meta: { title: '意见反馈', noCache: true }} ] }, From a2373ae21aec61fa3a8a71cf1d6dad6c1a6644a3 Mon Sep 17 00:00:00 2001 From: youc <357649470@qq.com> Date: Tue, 28 Aug 2018 18:21:21 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E7=BB=91=E5=AE=9A=E6=89=8B=E6=9C=BA=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- litemall-wx/pages/ucenter/index/index.wxss | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/litemall-wx/pages/ucenter/index/index.wxss b/litemall-wx/pages/ucenter/index/index.wxss index a9b4317f..ae6cb812 100644 --- a/litemall-wx/pages/ucenter/index/index.wxss +++ b/litemall-wx/pages/ucenter/index/index.wxss @@ -175,21 +175,16 @@ page { } .user_tool_item_phone { - background: none !important; - font-size: 32rpx; - color: #fff !important; - border-radius: 0%; - width: 187.5rpx; - height: 142rpx; - /* border: 1px solid #757575; */ - text-align: center; - display: flex; - justify-content: center; - align-items: center; - flex-wrap: wrap; - float: left; - background: #fff; - border-bottom: 0px solid #fafafa; + width:187.5rpx; + height:142rpx; + text-align:center; + display:flex; + justify-content:center; + align-items:center; + flex-wrap:wrap; + float:left; + background:#fff; + border-bottom:1px solid #fafafa; } .user_tool_item_phone::after{ border: none; From 229207f9426414e351ca02a5cf3f3ccc79aba814 Mon Sep 17 00:00:00 2001 From: usgeek <940208412@qq.com> Date: Tue, 28 Aug 2018 23:12:39 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=BC=8F=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=9A=84=E6=84=8F=E8=A7=81=E5=8F=8D=E9=A6=88=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- litemall-wx/config/api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/litemall-wx/config/api.js b/litemall-wx/config/api.js index dea7c5a8..bdc0c732 100644 --- a/litemall-wx/config/api.js +++ b/litemall-wx/config/api.js @@ -75,6 +75,7 @@ module.exports = { OrderConfirm: WxApiRoot + 'order/confirm', //确认收货 OrderComment: WxApiRoot + 'order/comment', // 代评价商品信息 + FeedbackAdd: WxApiRoot + 'feedback/submit', //添加反馈 FootprintList: WxApiRoot + 'footprint/list', //足迹列表 FootprintDelete: WxApiRoot + 'footprint/delete', //删除足迹 From 6883686d0b5331b5f2733c9e6a8bbe386f18181a Mon Sep 17 00:00:00 2001 From: Junling Bu Date: Wed, 29 Aug 2018 00:11:45 +0800 Subject: [PATCH 04/11] =?UTF-8?q?chore[litemall-wx,=20litemall-wx-api]:=20?= =?UTF-8?q?=E6=84=8F=E8=A7=81=E5=8F=8D=E9=A6=88=E7=BB=84=E4=BB=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=201.=20=E5=88=A0=E9=99=A4fastjson=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=BA=93=202.=20=E6=94=AF=E6=8C=81=E5=9B=BE=E7=89=87=E9=80=89?= =?UTF-8?q?=E6=8B=A9=203.=20=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=AB=AF=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E7=94=A8=E6=88=B7=E6=89=8B=E6=9C=BA=E5=8F=B7=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- litemall-wx-api/pom.xml | 6 - .../litemall/wx/web/WxFeedbackController.java | 74 ++------- .../pages/ucenter/feedback/feedback.js | 155 +++++++++++++----- .../pages/ucenter/feedback/feedback.json | 2 +- .../pages/ucenter/feedback/feedback.wxml | 20 ++- .../pages/ucenter/feedback/feedback.wxss | 76 ++++++++- litemall-wx/project.config.json | 11 +- 7 files changed, 226 insertions(+), 118 deletions(-) diff --git a/litemall-wx-api/pom.xml b/litemall-wx-api/pom.xml index 5148b3a7..51849a25 100644 --- a/litemall-wx-api/pom.xml +++ b/litemall-wx-api/pom.xml @@ -49,12 +49,6 @@ weixin-java-miniapp - - com.alibaba - fastjson - 1.2.45 - - diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFeedbackController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFeedbackController.java index 66c220d4..c8e2b0dc 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFeedbackController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFeedbackController.java @@ -1,6 +1,6 @@ package org.linlinjava.litemall.wx.web; -import com.alibaba.fastjson.JSONObject; +import org.linlinjava.litemall.core.util.JacksonUtil; import org.linlinjava.litemall.core.util.RegexUtil; import org.linlinjava.litemall.core.util.ResponseUtil; import org.linlinjava.litemall.db.domain.LitemallFeedback; @@ -12,17 +12,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; -import java.io.BufferedReader; -import java.io.IOException; import java.time.LocalDateTime; - /** * @author Yogeek * @date 2018/8/25 14:10 @@ -36,67 +30,33 @@ public class WxFeedbackController { @Autowired private LitemallFeedbackService feedbackService; @Autowired - protected HttpServletRequest request; - @Autowired private LitemallUserService userService; /** * 意见反馈 */ @PostMapping("submit") - @ResponseBody - public Object save(@LoginUser Integer userId){ - if(userId == null){ + public Object submit(@LoginUser Integer userId, @RequestBody LitemallFeedback feedback) { + if (userId == null) { return ResponseUtil.unlogin(); } + // 测试手机号码是否正确 + if (!RegexUtil.isMobileExact(feedback.getMobile())) { + return ResponseUtil.badArgument(); + } + LitemallUser user = userService.findById(userId); String username = user.getUsername(); - //获取客户端对象 - JSONObject feedbackJson = this.getJsonRequest(); + feedback.setId(null); + feedback.setUserId(userId); + feedback.setUsername(username); + feedback.setAddTime(LocalDateTime.now()); + //状态默认是0,1表示状态已发生变化 + feedback.setStatus(1); + feedbackService.add(feedback); - if (null != feedbackJson) { - LitemallFeedback feedback = new LitemallFeedback(); - - String mobile = feedbackJson.getString("mobile"); - // 测试手机号码是否正确 - if (!RegexUtil.isMobileExact(mobile)) { - return ResponseUtil.badArgument(); - } - String[] feedType = new String [] {"请选择反馈类型", "商品相关", "功能异常", "优化建议", "其他"}; - int index = feedbackJson.getInteger("index"); - String content = feedbackJson.getString("content"); - - feedback.setUserId(userId); - feedback.setUsername(username); - feedback.setMobile(mobile); - feedback.setAddTime(LocalDateTime.now()); - feedback.setFeedType(feedType[index]); - //状态默认是0,1表示状态已发生变化 - feedback.setStatus(1); - feedback.setContent(content); - feedbackService.add(feedback); - - return ResponseUtil.ok("感谢您的反馈"); - } - return ResponseUtil.badArgument(); - } - - private JSONObject getJsonRequest() { - JSONObject result = null; - StringBuilder sb = new StringBuilder(); - try (BufferedReader reader = request.getReader();) { - char[] buff = new char[1024]; - int len; - while ((len = reader.read(buff)) != -1) { - sb.append(buff, 0, len); - } - result = JSONObject.parseObject(sb.toString()); - } catch (IOException e) { - e.printStackTrace(); - } - - return result; + return ResponseUtil.ok(); } } diff --git a/litemall-wx/pages/ucenter/feedback/feedback.js b/litemall-wx/pages/ucenter/feedback/feedback.js index b2e277e6..e860e864 100644 --- a/litemall-wx/pages/ucenter/feedback/feedback.js +++ b/litemall-wx/pages/ucenter/feedback/feedback.js @@ -1,47 +1,108 @@ var util = require('../../../utils/util.js'); +var check = require('../../../utils/check.js'); var api = require('../../../config/api.js'); - - var app = getApp(); Page({ data: { array: ['请选择反馈类型', '商品相关', '功能异常', '优化建议', '其他'], index: 0, - content:'', - contentLength:0, - mobile:'' + content: '', + contentLength: 0, + mobile: '', + hasPicture: false, + picUrls: [], + files: [] }, - bindPickerChange: function (e) { - console.log('picker发送选择改变,携带值为', e.detail.value); + chooseImage: function (e) { + if (this.data.files.length >= 5) { + util.showErrorToast('只能上传五张图片') + return false; + } + + var that = this; + wx.chooseImage({ + count: 1, + sizeType: ['original', 'compressed'], + sourceType: ['album', 'camera'], + success: function (res) { + that.setData({ + files: that.data.files.concat(res.tempFilePaths) + }); + that.upload(res); + } + }) + }, + upload: function (res) { + var that = this; + const uploadTask = wx.uploadFile({ + url: api.StorageUpload, + filePath: res.tempFilePaths[0], + name: 'file', + success: function (res) { + var _res = JSON.parse(res.data); + if (_res.errno === 0) { + var url = _res.data.url + that.data.picUrls.push(url) + that.setData({ + hasPicture: true, + picUrls: that.data.picUrls + }) + } + }, + fail: function (e) { + wx.showModal({ + title: '错误', + content: '上传失败', + showCancel: false + }) + }, + }) + + uploadTask.onProgressUpdate((res) => { + console.log('上传进度', res.progress) + console.log('已经上传的数据长度', res.totalBytesSent) + console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend) + }) + + }, + previewImage: function (e) { + wx.previewImage({ + current: e.currentTarget.id, // 当前显示图片的http链接 + urls: this.data.files // 需要预览的图片http链接列表 + }) + }, + bindPickerChange: function(e) { this.setData({ index: e.detail.value }); }, - mobileInput: function (e) { - let that = this; + mobileInput: function(e) { this.setData({ - mobile: e.detail.value, + mobile: e.detail.value }); - console.log(that.data.mobile); }, - contentInput: function (e) { - - let that = this; + contentInput: function(e) { this.setData({ contentLength: e.detail.cursor, content: e.detail.value, }); - console.log(that.data.content); }, - cleanMobile:function(){ - let that = this; + clearMobile: function(e) { + this.setData({ + mobile: '' + }); + }, + submitFeedback: function(e) { + if (!app.globalData.hasLogin) { + wx.navigateTo({ + url: "/pages/auth/login/login" + }); + } - }, - sbmitFeedback : function(e){ let that = this; - if (that.data.index == 0){ + if (that.data.index == 0) { util.showErrorToast('请选择反馈类型'); return false; } @@ -55,55 +116,69 @@ Page({ util.showErrorToast('请输入手机号码'); return false; } + + if (!check.isValidPhone(this.data.mobile)) { + this.setData({ + mobile: '' + }); + util.showErrorToast('请输入手机号码'); + return false; + } + wx.showLoading({ title: '提交中...', - mask:true, - success: function () { + mask: true, + success: function() { } }); - console.log(that.data); + util.request(api.FeedbackAdd, { + mobile: that.data.mobile, + feedType: that.data.array[that.data.index], + content: that.data.content, + hasPicture: that.data.hasPicture, + picUrls: that.data.picUrls + }, 'POST').then(function(res) { + wx.hideLoading(); - util.request(api.FeedbackAdd, { mobile: that.data.mobile, index: that.data.index, content: that.data.content},'POST').then(function (res) { if (res.errno === 0) { - console.log(res.data); - - wx.hideLoading(); - wx.showToast({ - title: res.data, + title: '感谢您的反馈!', icon: 'success', duration: 2000, - complete: function () { - console.log('重新加载'); + complete: function() { that.setData({ index: 0, content: '', contentLength: 0, - mobile: '' + mobile: '', + hasPicture: false, + picUrls: [], + files: [] }); } }); } else { - util.showErrorToast(res.data); + util.showErrorToast(res.errmsg); } - + }); }, - onLoad: function (options) { - }, - onReady: function () { + onLoad: function(options) { }, - onShow: function () { + onReady: function() { }, - onHide: function () { + onShow: function() { + + }, + onHide: function() { // 页面隐藏 }, - onUnload: function () { + onUnload: function() { // 页面关闭 } }) \ No newline at end of file diff --git a/litemall-wx/pages/ucenter/feedback/feedback.json b/litemall-wx/pages/ucenter/feedback/feedback.json index 0e0dcd23..fc30db1c 100644 --- a/litemall-wx/pages/ucenter/feedback/feedback.json +++ b/litemall-wx/pages/ucenter/feedback/feedback.json @@ -1,3 +1,3 @@ { - + "navigationBarTitleText": "意见反馈" } \ No newline at end of file diff --git a/litemall-wx/pages/ucenter/feedback/feedback.wxml b/litemall-wx/pages/ucenter/feedback/feedback.wxml index 81e91665..75dc62ce 100644 --- a/litemall-wx/pages/ucenter/feedback/feedback.wxml +++ b/litemall-wx/pages/ucenter/feedback/feedback.wxml @@ -10,18 +10,26 @@ -