From f0bb174fec74d94a78f2a4b53439717703438db9 Mon Sep 17 00:00:00 2001 From: wuxw <928255095@qq.com> Date: Thu, 26 Dec 2019 00:30:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=20=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/comment/comment.js | 171 ------------------------- pages/comment/comment.json | 1 - pages/comment/comment.wxml | 21 --- pages/comment/comment.wxss | 15 --- pages/enterCommunity/enterCommunity.js | 25 ++-- 5 files changed, 8 insertions(+), 225 deletions(-) delete mode 100644 pages/comment/comment.js delete mode 100644 pages/comment/comment.json delete mode 100644 pages/comment/comment.wxml delete mode 100644 pages/comment/comment.wxss diff --git a/pages/comment/comment.js b/pages/comment/comment.js deleted file mode 100644 index d76d16f..0000000 --- a/pages/comment/comment.js +++ /dev/null @@ -1,171 +0,0 @@ -/** pages/comment/comment.js **/ - -// 获取服务器接口地址 -const api = require('../../config/config.js'); -// 获取app应用实例 -const app = getApp(); - -Page({ - - /** - * 页面的初始数据 - */ - data: { - bookInfo: {}, - comment: '' - }, - - /** - * 用户输入评论 - */ - inputComment: function(ev) { - let that = this; - that.setData({ - comment: ev.detail.value - }); - }, - - /** - * 检查输入是否为空 - */ - checkEmpty: function(input) { - return input === ''; - }, - - /** - * 检查用户是否输入了非法字符 - */ - checkIllegal: function(input) { - let patern = /[`#^<>:"?{}\/;'[\]]/im; - let _result = patern.test(input); - return _result; - }, - - /** - * 检查用户输入 - */ - checkUserInput: function() { - /* - * 检测用户输入 - * 1. 是否包含非法字符 - * 2. 是否为空 - * 3. 是否超出长度限制 - */ - let that = this; - let comment = that.data.comment; - let showToastFlag = false; - let toastWording = ''; - - if (that.checkEmpty(comment)) { - showToastFlag = true; - toastWording = '输入不能为空'; - } else if (that.checkIllegal(comment)) { - showToastFlag = true; - toastWording = '含有非法字符'; - } else if (comment.length > 140) { - showToastFlag = true; - toastWording = '长度超出限制'; - } - - if (showToastFlag) { - that.showInfo(toastWording); - return false; - } else { - return true; - } - }, - - /** - * 提交评论内容 - */ - submitComment: function(ev) { - - let that = this; - - let formId = ev.detail.formId; - - if (that.checkUserInput()) { - - console.log('submit!'); - - let requestData = { - skey: app.getLoginFlag(), - content: that.data.comment, - bookid: that.data.bookInfo.id, - formid: formId - }; - - wx.request({ - url: api.commentUrl, - method: 'POST', - data: requestData, - success: function(res) { - // 接口返回成功 - if (res.data.result == 0) { - that.showInfo('评论成功', 'success', function() { - wx.setStorageSync('isFromBack', '1'); - setTimeout(function() { - wx.navigateBack({ - delta: 1 - }); - }, 1500); - }); - } else { - console.log(res.data); - that.showInfo(res.data.errmsg); - } - - }, - fail: function(error) { - that.showInfo('请求失败'); - } - }); - } - }, - - - /** - * 封装 wx.showToast - */ - showInfo: function(info, icon = 'none', callback = () => {}) { - wx.showToast({ - title: info, - icon: icon, - duration: 1500, - mask: true, - success: callback - }); - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function(options) { - let _bookInfo = {}; - - for (let key in options) { - _bookInfo[key] = decodeURIComponent(options[key]); - } - - console.log(_bookInfo); - - this.setData({ - bookInfo: _bookInfo - }); - }, - - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function() { - console.log('current page is onReady'); - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function() { - console.log('current page is onShow'); - } -}); \ No newline at end of file diff --git a/pages/comment/comment.json b/pages/comment/comment.json deleted file mode 100644 index 9e26dfe..0000000 --- a/pages/comment/comment.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/pages/comment/comment.wxml b/pages/comment/comment.wxml deleted file mode 100644 index a2ed350..0000000 --- a/pages/comment/comment.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - {{bookInfo.name}} - - - - - - - - -
- - - -
- -
diff --git a/pages/comment/comment.wxss b/pages/comment/comment.wxss deleted file mode 100644 index 67164e1..0000000 --- a/pages/comment/comment.wxss +++ /dev/null @@ -1,15 +0,0 @@ -/* pages/comment/comment.wxss */ -.comment-container { - display: flex; - flex-direction: column; - padding: 20rpx 0; -} - -.book-name { - padding: 10rpx 30rpx; -} - -.comment-area { - margin-top: 20rpx; - padding: 20rpx 30rpx; -} \ No newline at end of file diff --git a/pages/enterCommunity/enterCommunity.js b/pages/enterCommunity/enterCommunity.js index 049ac00..561ee00 100644 --- a/pages/enterCommunity/enterCommunity.js +++ b/pages/enterCommunity/enterCommunity.js @@ -16,11 +16,11 @@ Page({ areas:[], currentArea:{}, - communityName:'', - ownerName:'', - idCard:'', - tel:'', - validateCode:'' + "communityName":"", + "ownerName": "", + "idCard": "", + "tel": "", + "validateCode": "" }, @@ -29,10 +29,7 @@ Page({ */ onLoad: function (options) { //查询省级地区 - let pros = this._loadArea('',''); - - - + let pros = this._loadArea('',''); }, /** @@ -49,13 +46,7 @@ Page({ let curLocation = wx.getStorageSync("currentLocation"); this.setData({ province: curLocation.province, - city: curLocation.city, - - communityName: '', - ownerName: '', - idCard: '', - tel: '', - validateCode: '' + city: curLocation.city }) }, @@ -229,7 +220,7 @@ Page({ this.setData(data); }, enterCommunity:function(e){ - this.data.areaCode = this.data.currentArea.areaCode; + //this.data.areaCode = this.data.currentArea.areaCode; console.log("提交数据",this.data); } }) \ No newline at end of file