微信小程序实现聊天界面,发送功能
创始人
2024-12-15 18:36:58
0

在这里插入图片描述

.wxml

{windowHeight}}px;">   {chatList}}" wx:for-index="index" wx:for-item="item" style="padding-top:{{index==0?30:0}}rpx">          {item.id != userInfo.id}}">                {item.url}}" style="width: 35px; height: 35px; border-radius: 10px;">                       {{item.content}}                                       {{item.content}}                       {item.url}}" style="width: 35px; height: 35px; border-radius: 10px;">                      {bottomJP}}px; width: 100%; background-color: #fff; padding:  0 10rpx; box-shadow: 0 -2px 4px rgba(202, 202, 202, 0.1);height: 130rpx;display: flex;justify-content: space-around;align-items: center;padding-bottom: 30rpx;">          {false}}" bindfocus="getTelIptHeight" bindblur="getTelIptHeight" bindconfirm="sendContent" value="{{inputValue}}"/>                    

.js

const app = getApp() Page({    /**    * 页面的初始数据    */   data: {     tips: null,     windowHeight: 0,     windowWidtth: 0,     bottomJP: 0,     userInfo: {},     inputValue: '',     chatList: [{         createTime: '2024-07-24 09:10:00',         url: '/images/baochang.png',         content: '哈哈哈',         id: 8       },       {         createTime: '2024-07-24 11:15:30',         url: '/images/baochang.png',         content: '你好啊',         id: 9       },       {         createTime: '2024-07-24 11:15:30',         url: '/images/baochang.png',         content: '你好啊',         id: 9       },     ]   },   getTelIptHeight(e) {     console.log("height---------", e);     if (e.type == 'blur') {       this.setData({         bottomJP: 0       })     } else {       this.setData({         bottomJP: e.detail.height       })     }    },   onLoad(options) {     let that = this     that.setData({       userInfo: wx.getStorageSync("userInfo")     })     wx.getSystemInfo({       success: function (res) {         console.log(res)         that.setData({           windowHeight: res.windowHeight,           windowWidtth: res.windowWidth,         });       }     });     wx.setNavigationBarTitle({       title: '动态获取用户昵称',     })   },   send() {     let info = {       senderId: wx.getStorageSync("userInfo").id,       recipientId: 100,       chatContent: '你好啊~',       chatContentType: 'text'     }     let that = this     app.globalData.ws.send({       data: JSON.stringify(info),       success: (res) => {         console.log(res)         that.setData({           tips: "发送信息成功"         })       }     })   },   sendContent(e) {     let message = {       createTime: '2024-07-24 11:15:30',       url: '/images/baochang.png',       content: e.detail.value,       id: 9     }     let list = this.data.chatList     list.push(message)     this.setData({       chatList: list,       inputValue: ''     })   } }) 

.wxss

page {   background-color: #f4f5f7; } 

.json

{   "usingComponents": {},   "navigationBarTitleText": "" } 

相关内容

热门资讯

第4分钟开挂!杭州边锋网络游戏... 第4分钟开挂!杭州边锋网络游戏辅助,微信小程序辅助器,必胜教程-2026最新版本在进入杭州边锋网络游...
一分钟关于!中至余干麻将有没有... 一分钟关于!中至余干麻将有没有挂(辅助挂)切实存在有挂,科技教程(有挂神器)-哔哩哔哩1、在中至余干...
八分钟开挂!新星游挂多少钱,小... 八分钟开挂!新星游挂多少钱,小闲川南手游辅助器,线上教程-2026最新版本1、首先打开小闲川南手游辅...
两分钟详细!斗城麻将辅助器有开... 两分钟详细!斗城麻将辅助器有开挂(辅助挂)一直有挂,透视教程(果真有挂)-哔哩哔哩1、不需要AI权限...
7分钟开挂!椰子大厅辅助脚本,... 7分钟开挂!椰子大厅辅助脚本,战皇大厅辅助排行,AA德州教程-2026最新版本1、打开软件启动之后找...
第7分钟解迷!新天道联盟辅助器... 第7分钟解迷!新天道联盟辅助器(辅助挂)竟然真的有挂,详细教程(有挂功能)-哔哩哔哩1、任何新天道联...
四分钟开挂!新海贝之城辅助,陕... 四分钟开挂!新海贝之城辅助,陕麻圈有辅助吗,曝光教程-2026最新版本1、金币登录送、破产送、升级送...
十分钟揭露!微乐游戏兑换码大全... 十分钟揭露!微乐游戏兑换码大全(辅助挂)果然真的有挂,黑科技教程(有挂秘诀)-哔哩哔哩1、全新机制【...
第6分钟开挂!蘑菇云辅助,微乐... 第6分钟开挂!蘑菇云辅助,微乐陕西三代自建房怎么提高胜率,技巧教程-2026最新版本1、用户打开应用...
7分钟解密!兴动海满麻浆辅助(... 7分钟解密!兴动海满麻浆辅助(辅助挂)好像有挂,技巧教程(有挂细节)-哔哩哔哩1、完成兴动海满麻浆辅...