亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

三十三章 小程序筆記(三)留言板

標簽:
PHP

配置文件1.app.json
{
"pages":[
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "留言板",
"navigationBarTextStyle":"black"
}
}
视图文件2.index.wxml
<view class="page">

<view class="body">

<view class="list" wx:for="{{array}}" >
<view class="item">
<view class="left" >
 <image  class="pic" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="{{item.pic}}" ></image>
 </view>
 <view class="right">
 <view class="name">
 {{item.name}}
 </view>
 <view class="note">
<text> {{item.content}}</text>
 </view>
 </view>
 </view>
</view>

<view class="bottom">
<!--写留言-->
<view class="input">
  <input bindinput="confirm"  placeholder="留言内容" />
</view>
<view class="btn">
  <button bindtap="click" >发送</button>
</view>

</view>

</view>
</view>
样式文件3.index.wxss
.page {
margin: 0rpx 50rpx 50rpx 50rpx;
}

.item {
margin: 25rpx 0rpx 25rpx 0rpx;
display: flex;
flex-direction: row;
background-color: lightblue;
align-items: center;
}

.left {
flex: 1;
}

.right {
flex: 3;
display: flex;
flex-direction: column;
}

.name {
flex: 1;
font-size: 30rpx;
}

.note {
flex: 1;
}

.note text {
background-color: lightgreen;
font-size: 70rpx;
color: blue;
}

.pic {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}

.bottom {
display: flex;
flex-direction: row;
background-color: yellow;
}

.input {
flex: 4;
text-align: left;
}

.btn {
flex: 1;
}
逻辑层文件4.index.js
var newnote
var nickName
var imageurl
Page({
data: {
},
onLoad: function (options) {
var that = this
//微信登录授权,获取用户信息
wx.login({
success: function () {
wx.getUserInfo({
success: function (res) {
nickName = res.userInfo.nickName
imageurl = res.userInfo.avatarUrl
}
})
}
}),
wx.request({
url: 'https://79966767.qcloud.la/xcx/list.php', //服务器列表地址
success: function (res) {
that.setData({
array: res.data
})
}
})
},

// 输入完成
confirm: function (e) {
newnote = e.detail.value
},
//留言
click: function (e) {
var that = this
wx.request({
url: 'https://79966767.qcloud.la/xcx/note.php', //服务器留言地址
data: {
name: nickName,
content: newnote,
imageurl: imageurl
},
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: function (res) {
wx.request({
url: 'https://79966767.qcloud.la/xcx/list.php', //上线换为为https
success: function (res) {
that.setData({
array: res.data
})
}
})
}
})
}
})
后台文件略

點擊查看更多內容
2人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消