mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-02-24 05:46:04 +08:00
加入 入驻小区功能
This commit is contained in:
parent
38da74d1e5
commit
f0bb174fec
@ -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');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
<!--pages/comment/comment.wxml-->
|
|
||||||
<view class="comment-container">
|
|
||||||
|
|
||||||
<!-- book name -->
|
|
||||||
<view class="book-name">
|
|
||||||
<text>{{bookInfo.name}}</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- comment area -->
|
|
||||||
<view class="comment-area bg-white">
|
|
||||||
<textarea placeholder="关于这本书的看法..." maxlength="140" value="{{comment}}" bindinput="inputComment"></textarea>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- bottom button -->
|
|
||||||
<form report-submit bindsubmit="submitComment">
|
|
||||||
<view class="fixed-bottom block-full-width flex-container bg-white">
|
|
||||||
<button class="full-button" type="primary" form-type="submit"> 提交评论 </button>
|
|
||||||
</view>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</view>
|
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
@ -16,11 +16,11 @@ Page({
|
|||||||
areas:[],
|
areas:[],
|
||||||
currentArea:{},
|
currentArea:{},
|
||||||
|
|
||||||
communityName:'',
|
"communityName":"",
|
||||||
ownerName:'',
|
"ownerName": "",
|
||||||
idCard:'',
|
"idCard": "",
|
||||||
tel:'',
|
"tel": "",
|
||||||
validateCode:''
|
"validateCode": ""
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -29,10 +29,7 @@ Page({
|
|||||||
*/
|
*/
|
||||||
onLoad: function (options) {
|
onLoad: function (options) {
|
||||||
//查询省级地区
|
//查询省级地区
|
||||||
let pros = this._loadArea('','');
|
let pros = this._loadArea('','');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,13 +46,7 @@ Page({
|
|||||||
let curLocation = wx.getStorageSync("currentLocation");
|
let curLocation = wx.getStorageSync("currentLocation");
|
||||||
this.setData({
|
this.setData({
|
||||||
province: curLocation.province,
|
province: curLocation.province,
|
||||||
city: curLocation.city,
|
city: curLocation.city
|
||||||
|
|
||||||
communityName: '',
|
|
||||||
ownerName: '',
|
|
||||||
idCard: '',
|
|
||||||
tel: '',
|
|
||||||
validateCode: ''
|
|
||||||
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -229,7 +220,7 @@ Page({
|
|||||||
this.setData(data);
|
this.setData(data);
|
||||||
},
|
},
|
||||||
enterCommunity:function(e){
|
enterCommunity:function(e){
|
||||||
this.data.areaCode = this.data.currentArea.areaCode;
|
//this.data.areaCode = this.data.currentArea.areaCode;
|
||||||
console.log("提交数据",this.data);
|
console.log("提交数据",this.data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Loading…
Reference in New Issue
Block a user