加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

微信小程序实现聊天对话(文本、图片)功能

发布时间:2020-12-14 20:06:59 所属栏目:资源 来源:网络整理
导读:本文实例为大家分享了微信小程序实现聊天对话功能的具体代码,供大家参考,具体内容如下 这是我实际项目线上的代码,或许有些不足 || 和你的需求不符合。 上图: to_news.wxml {{tabdata.title}} {{tabdata.attribute_attribute}} {{tabdata.num}} 发布时间: {

本文实例为大家分享了微信小程序实现聊天对话功能的具体代码,供大家参考,具体内容如下

这是我实际项目线上的代码,或许有些不足 || 和你的需求不符合。

上图:

to_news.wxml

{{tabdata.title}} {{tabdata.attribute_attribute}} {{tabdata.num}} 发布时间: {{tabdata.time_agree}} 您正在与{{tabdata.nickname}}进行沟通 {{item.time}} {{item.content}} {{item.content}}

to_news.js

},// 获取hei的id节点然后屏幕焦点调转到这个节点
bottom: function () {
var query = wx.createSelectorQuery()
query.select('#hei').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec(function (res) {
wx.pageScrollTo({
scrollTop: res[0].bottom // #the-id节点的下边界坐标
})
res[1].scrollTop // 显示区域的竖直滚动位置
})
},// 选择图片并把图片保存
upimg1: function () {
var that = this;
wx.chooseImage({
success: function (res) {
var data = {
program_id: app.jtappid,}
var tempFilePaths = res.tempFilePaths
wx.uploadFile({
url: 'pg.php/ZXinfo/session_submit',//提交信息至后台
filePath: tempFilePaths[0],name: 'content',//文件对应的参数名字(key)
formData: data,//其它的表单信息
success: function (res) {
var a = true;
that.loaddata(a);
message = ''
}
})
}
})
}
})

to_news.wxss

page {
background-color: #f7f7f7;
}

.tab {
padding: 20rpx 20rpx 40rpx 50rpx;
height: 20%;
background-color: white;
}

.tab .tent {
font-size: 33rpx;
margin-bottom: 30rpx;
}
.jia_img{
height: 80rpx;
width: 90rpx;
}
.new_imgtent{
height: 180rpx;
width: 190rpx;
}
.tab .fabu {
font-size: 33rpx;
margin-top: 30rpx;
margin-bottom: 30rpx;
}

.xiahuaxia {
width: 80%;
text-align: center;
margin: 0 auto;
position: relative;
top: 60rpx;
}

.time {
text-align: center;
padding: 5rpx 20rpx 5rpx 20rpx;
width: 200rpx;
font-size: 26rpx;
background-color: #E8E8E8;
}

.new_top_txt {
width: 50%;
position: relative;
top: 38rpx;
text-align: center;
margin: 0 auto;
font-size: 30rpx;
color: #787878;
background-color: #f7f7f7;
}

/ 聊天内容 /

.news {
margin-top: 30rpx;
text-align: center;
margin-bottom: 150rpx;
}

.img_null {
height: 60rpx;
}

.l {
height: 5rpx;
width: 20%;
margin-top: 30rpx;
color: #000;
}

/ 聊天 /

.my_right {
float: right;
position: relative;
right: 40rpx;
}

.you_left {
float: left;
position: relative;
left: 5rpx;
}

.new_img {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
}

.new_txt {
width: 380rpx;
border-radius: 7px;
background-color: #95d4ff;
padding: 0rpx 30rpx 0rpx 30rpx;
}

.sanjiao {
top: 20rpx;
position: relative;
width: 0px;
height: 0px;
border-width: 10px;
border-style: solid;
}

.my {
border-color: transparent transparent transparent #95d4ff;
}

.you {
border-color: transparent #95d4ff transparent transparent;
}

.sendmessage {
background-color: white;
width: 100%;
position: fixed;
bottom: 0rpx;
display: flex;
flex-direction: row;
}

.sendmessage input {
width: 80%;
height: 40px;
background-color: white;
line-height: 40px;
font-size: 14px;
border: 1px solid #d0d0d0;
padding-left: 10px;
}

.sendmessage button {
border: 1px solid white;
width: 18%;
height: 40px;
background: #fff;
color: #000;
line-height: 40px;
font-size: 14px;
}

.historycon {
height: 90%;
width: 100%;
flex-direction: column;
display: flex;
margin-top: 100rpx;
border-top: 0px;
}
.hei{
margin-top: 50px;
height: 20rpx;
}
.history {
height: 100%;
margin-top: 15px;
margin: 10px;
font-size: 14px;
line-height: 40px;
word-break: break-all;
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读