怎么在微信小程序中實(shí)現(xiàn)留言板?相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。

新建網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站開發(fā)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營(yíng)維護(hù)。創(chuàng)新互聯(lián)2013年開創(chuàng)至今到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。
CSS:
/* pages/order/message2/message2.wxss */
.msg-box{
padding: 20px;
}
.send-box{
display: flex;
}
.input{
border: 1px solid #B0C4DE;
padding: 5px;
}
.msg-info{
display: block;
margin: 10px 0 0 0 ;
color: #339900;
}
.place-input{
color: salmon;
}
.list-view{
margin: 20px 0 0 0;
}
.item{
overflow: hidden;
border-bottom: 1px dashed #87CEFF;
height: 30px;
line-height: 30px;
}
.text1{
float: left;
}
.close-btn{
float: right;
margin: 5px 5px 0 0;
}js:
const app = getApp();
Page({
/**
* 頁(yè)面的初始數(shù)據(jù)
*/
data: {
msgData:
[
{
child_id: 1,
msg:
"我想做個(gè)眉毛,到店后求推薦。",
checked:''
},
{
child_id: 2,
msg:
"我只有2小時(shí),您看著安排吧。",
checked: ''
},
{
child_id: 3,
msg:
"我和朋友一起過來。",
checked: ''
},
{
child_id: 4,
msg:
"美甲樣式到店挑選。",
checked: ''
},
{
child_id: 5,
msg:
"給眉毛再補(bǔ)個(gè)顏色。",
checked: ''
},
{
child_id: 6,
msg:
"我要補(bǔ)睫毛哦。",
checked:''
}
],
message: '',
message_id:[],
},
bindTextAreaChange: function(e){
var that = this
that.setData({
message:e.detail.value
})
},
click:function(e){
var that = this;
let id = e.currentTarget.dataset.id;
let index = e.currentTarget.dataset.index;
var value = [];
value = this.data.message_id;
var array_i = this.in_array(id, value);
var chekeds = that.data.msgData;
var msg = chekeds[index].msg;
var message = that.data.message;
if (!e.currentTarget.dataset.checked){
chekeds[index].checked = true
that.setData({
message: message + msg
})
}else{
chekeds[index].checked = false
that.setData({
message: message.replace(msg, '')
})
}
that.setData({
msgData: chekeds
})
if (array_i) {
value.splice(array_i, 1);
} else {
value.push(id);
}
this.setData({
message_id: value,
})
},
in_array: function (search, array) {
for (var i in array) {
if (array[i] == search) {
return i;
}
}
return false;
},
submit:function(){
var value = [];
var message = this.data.message;
var msgData = this.data.msgData;
if (message == '' && !value.length) {
wx.showToast({
title: '暫無選擇項(xiàng)目',
icon:'none'
})
return;
}
app.globalData.message = message;
for (var i = 0; i < msgData.length; i++) {
if(message.indexOf(msgData[i].msg) > -1){
value[i] = msgData[i].child_id;
}
}
wx.request({
url: 'https://www.omeiclub.com/app/public/index.php/index/index/server',
method: 'POST',
data: { message_id: value, openId: app.globalData.openId, message: message, token: app.globalData.token},
header: {
'Accept': 'application/json'
},
success: function (res) {
if(res){
// wx.showToast({
// title: '捎話成功',
// success:function(){
// }
// })
wx.switchTab({
url: '/pages/order/order',
success: function (e) {
var page = getCurrentPages().pop();
if (page == undefined || page == null) return;
page.onLoad();
}
})
app.globalData.message = message;
}
console.log(res)
}
})
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面加載
*/
onLoad: function (options) {
var that = this;
wx.request({
url: 'https://www.omeiclub.com/app/public/index.php/index/index/serversle',
method: 'POST',
data: { openId: app.globalData.openId, token: app.globalData.token},
header: {
'Accept': 'application/json'
},
success: function (res) {
if (res.data){
var message_id = res.data.message_id;
var value = that.data.msgData;
var message = res.data.message;
that.setData({
message: message
});
for (var i = 0; i < value.length;i++) {
if (that.in_array(value[i].child_id, message_id)) {
value[i].checked = true;
that.setData({
msgData: value,
});
}
}
}
}
})
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面顯示
*/
onShow: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面隱藏
*/
onHide: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面卸載
*/
onUnload: function () {
},
/**
* 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動(dòng)作
*/
onPullDownRefresh: function () {
},
/**
* 頁(yè)面上拉觸底事件的處理函數(shù)
*/
onReachBottom: function () {
},
/**
* 用戶點(diǎn)擊右上角分享
*/
onShareAppMessage: function () {
}
})html
<!--pages/order/message/message.wxml-->
<view class='message_nav'>
<form bindsubmit='FormSubmit'>
<view class='section'>
<textarea class='message1' type='text' placeholder="請(qǐng)選擇或者輸入捎話(60字以內(nèi))" maxlength='80' bindinput='bindTextAreaChange' value="{{message}}"></textarea>
</view>
<view class='fast'>快速捎話:</view>
<checkbox-group class="checkboxChange">
<view wx:for="{{msgData}}" wx:key="{{index}}" data-index="{{index}}" data-id="{{item.child_id}}" data-checked='{{item.checked}}' bindtap='click' >
<checkbox value='{{item.msg}}' class='item' checked='{{item.checked}}' >{{item.msg}}</checkbox>
</view>
</checkbox-group>
<button class='submit' bindtap='submit'>捎話</button>
</form>
</view>看完上述內(nèi)容,你們掌握怎么在微信小程序中實(shí)現(xiàn)留言板的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
網(wǎng)站標(biāo)題:怎么在微信小程序中實(shí)現(xiàn)留言板
轉(zhuǎn)載源于:http://www.chinadenli.net/article30/iphpso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、面包屑導(dǎo)航、建站公司、外貿(mào)建站、App設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)