封装聊天组件(fang微信聊天)

用法 图 文 视频还没写好,后期补上,因为基于微博本身的ui框架,所以有的样式会有一些问题,可能跟普通写法有一点不同,但是修改一点就可以

//自己做的假数据
<template><wbx-view style="" @click="losingFocus"><wbx-view:style="{transform: transformNum,transition: 'transform 0.3s',}"><wbx-listclass="scroller"style="width: 100vw;height: 90vh;box-sizing: border-box;box-sizing: border-box;background-color: #f6f6f8;"><wbx-cell v-for="(item, index) in dataSource" :key="index"><!-- 文本消息类型 --><text-messagev-if="item.type == 'text'":dataSource="item"></text-message><!-- 图片消息类型 --><pic-messagev-if="item.type == 'pic'":dataSource="item"></pic-message><!-- <video-messagev-if="item.type == 'video'":dataSource="item"></video-message> --></wbx-cell></wbx-list><wbx-viewstyle="height: 10vh;background-color: #fff;display: flex;flex-direction: row;justify-content: center;align-items: center;"><wbx-imagestyle="width: 30px; height: 30px; margin-right: 20px"mode="aspectFit"src="res/login.png"/><wbx-textareastyle="border: 1px solid #000; width: 200px; height: 40px"maxlength="100"placeholder="最多能输入100个字"returnkeytype="send"v-wbox-model:input.value.domProps="textareaValue"@keyboardheightchange="keyboardChangesTextarea"v-wbox-model:focus.focus="textareaFocused"></wbx-textarea><wbx-imagestyle="width: 30px; height: 30px; margin-left: 20px"mode="aspectFit"src="res/login.png"/><wbx-imagestyle="width: 30px; height: 30px; margin-left: 20px"mode="aspectFit"src="res/login.png"/></wbx-view></wbx-view></wbx-view>
</template><script>
import textMessage from "./messageType/text-message/index.vue";
import picMessage from "./messageType/pic-message/index.vue";
import videoMessage from "./messageType/video-message/index.vue";
/*** @type WBXAppOption*/
const pageOptions = {components: {textMessage,picMessage,videoMessage,},data() {return {dataSource: [{id: 1,title: "我我我",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: true,type: "pic",coverPicUrl:"https://img0.baidu.com/it/u=3693498673,388481603&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=1082",},{id: 1,title: "你快瞅瞅好看不!",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: true,type: "text",coverPicUrl: "",},{id: 1,title: "我觉的不咋地!啥玩应儿啊,还没我的好看呢!",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: false,type: "text",coverPicUrl: "",},{id: 1,title: "我我我我嚄我我我我",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: false,type: "pic",coverPicUrl:"https://vimimg-int-alicdn.softsugar.com/VME/int/users/687254816/figure/USNWXGCH/tmp_0d67a505007700275e7860e69904cfb3.jpg?auth_key=1724601600-0-0-d091d25b4081283ccd771125050e362d",},{id: 1,title: "你快拉到吧你,老弟啊你不懂欣赏!",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: true,type: "text",coverPicUrl: "",},{id: 1,title: "我我我我我我我我",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: true,type: "pic",coverPicUrl:"https://vimimg-int-alicdn.softsugar.com/VME/int/users/687254816/figure/NUBOVIEU/tmp_f37d3589f0ae36025d0dc6bae84c34c4.jpg?auth_key=1724601600-0-0-94c9964f5c3c2a8773919a964d24284f",},{id: 1,title: "这也不好看啊,什么审美",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: false,type: "text",coverPicUrl: "",},{id: 1,title: "这也不好看啊,什么审美",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: false,type: "pic",coverPicUrl:"https://img2.baidu.com/it/u=1718761759,369021576&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=1083",},{id: 1,title: "这也不好看啊,什么审美",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: false,type: "video",coverVideoUrl: {oid: "3911557709",src: "res/2.mp4",},coverPicUrl:"https://img0.baidu.com/it/u=3693498673,388481603&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=1082",},{id: 1,title: "这也不好看啊,什么审美",time: "2023-04-03 10:39:00",pirce: 128,sendMessage: false,type: "video",coverVideoUrl: {oid: "3911557708",src: "res/video.mp4",},coverPicUrl:"https://img0.baidu.com/it/u=3693498673,388481603&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=1082",},],transformNum: "translateY(0)",loadinging: false,showLoading: false,refreshing: false,showLoadMore: true,textareaValue: "",textareaFocused: false,};},methods: {losingFocus() {this.textareaFocused = false;},keyboardChangesTextarea(e) {const { height, isShow } = e.detail;this.transformNum = isShow? `translateY(-${height - 40}px)`: "translateY(0)";},},wbox: {onLoad() {},onShow() {// 页面显示/切入前台时触发},onHide() {// 页面隐藏时触发},onUnload() {// 页面退出时触发},},mounted() {},
};
export default pageOptions;
</script><style>
.scroller {
}
</style>

文本类型的组件:

//文本的组件
<template><wbx-view><!-- 左边 --><wbx-viewv-if="dataSource.sendMessage == false"style="margin-top: 20px;margin-bottom: 20px;margin-left: 10px;display: flex;justify-content: flex-start;flex-direction: row;"><wbx-imagestyle="width: 40px; height: 40px;border-radius: 5px;"mode="aspectFit"src="res/login.png"/><wbx-view><wbx-viewstyle="margin-left: 10px;display: flex;flex-wrap: wrap;border-radius: 5px;background-color: pink;"><wbx-textstyle="max-width: 55vw; margin: 10px 10px; display: inline-block">{{ dataSource.title }}</wbx-text></wbx-view></wbx-view></wbx-view><!-- 右边 --><wbx-viewv-if="dataSource.sendMessage == true"style="margin-top: 20px;margin-bottom: 20px;margin-right: 10px;display: flex;justify-content: flex-end;flex-direction: row;"><wbx-view style="position: relative"><wbx-viewstyle="position: relative;margin-right: 10px;display: flex;flex-wrap: wrap;background-color: pink;border-radius: 5px;"><wbx-textstyle="max-width: 55vw; margin: 10px 10px; display: inline-block">{{ dataSource.title }}</wbx-text></wbx-view><!-- 箭头位置 --><!-- <wbx-viewstyle="background-color: red;position: absolute;right: 0;top: 10px;width: 10px;height: 10px;border-top: 100px solid transparent;border-right: 100px solid transparent;border-left: 100px solid transparent;border-bottom: 100px solid red;"></wbx-view> --></wbx-view><wbx-imagestyle="width: 40px; height: 40px;border-radius: 5px;"mode="aspectFit"src="res/login.png"/></wbx-view></wbx-view>
</template><script>
/*** @type WBXAppOption*/
const pageOptions = {props: {dataSource: {type: Object,required: true,},},data() {return {};},methods: {},wbox: {onLoad() {},onShow() {// 页面显示/切入前台时触发},onHide() {// 页面隐藏时触发},onUnload() {// 页面退出时触发},},mounted() {},
};
export default pageOptions;
</script><style></style>

图文类型的组件

<template><wbx-view><!-- 左边 --><wbx-viewv-if="dataSource.sendMessage == false"style="margin-top: 20px;margin-bottom: 20px;margin-left: 10px;display: flex;justify-content: flex-start;flex-direction: row;align-items: flex-start;"><wbx-imagestyle="width: 40px; height: 40px; flex-shrink: 0; border-radius: 5px"mode="aspectFit"src="res/login.png"/><wbx-image@load="loadFn"@click="preview(dataSource.coverPicUrl)"style="margin-left: 10px; border-radius: 5px":style="{ height: heightImg, width: widthImg }"mode="aspectFill":src="dataSource.coverPicUrl"/></wbx-view><!-- 右边 --><wbx-viewv-if="dataSource.sendMessage == true"style="margin-top: 20px;margin-bottom: 20px;margin-right: 10px;display: flex;justify-content: flex-end;flex-direction: row;align-items: flex-start;"><wbx-view style="margin-right: 10px"><wbx-image@load="loadFn"@click="preview(dataSource.coverPicUrl)"style="margin-left: 10px; border-radius: 5px":style="{ height: heightImg, width: widthImg }"mode="aspectFill":src="dataSource.coverPicUrl"/></wbx-view><wbx-imagestyle="width: 40px; height: 40px; flex-shrink: 0; border-radius: 5px"mode="aspectFit"src="res/login.png"/></wbx-view></wbx-view>
</template><script>
/*** @type WBXAppOption*/
const pageOptions = {props: {dataSource: {type: Object,required: true,},},data() {return {heightImg: "",widthImg: "",imgList: [],};},methods: {resizeImage(originalWidth, originalHeight, maxWidth, maxHeight) {let ratio = Math.min(maxWidth / originalWidth,maxHeight / originalHeight);return {width: originalWidth * ratio + "px",height: originalHeight * ratio + "px",};},loadFn(e) {const { height, width } = e.detail;const maxWidth = 200; // 设定图片容器的最大宽度const maxHeight = 200; // 设定图片容器的最大高度const { width: resizedWidth, height: resizedHeight } = this.resizeImage(width,height,maxWidth,maxHeight);this.widthImg = resizedWidth;this.heightImg = resizedHeight;},preview(coverPicUrl) {const coverPicUrls = this.$parent.dataSource.map((item) => item.coverPicUrl);let coverPicUrlIndex = this.$parent.dataSource.findIndex((item) => item.coverPicUrl === this.dataSource.coverPicUrl);let imglist = this.$parent.dataSource.filter((item) => item.coverPicUrl !== "" && item.type === "pic").map((item) => item.coverPicUrl);let index = imglist.indexOf(coverPicUrls[coverPicUrlIndex]);wbx.previewImage({urls: imglist,index,success: function (res) {console.log("---- previewImage success: " + JSON.stringify(res));},failure: function (res) {console.log("---- previewImage failure: " + JSON.stringify(res.errMsg));},complete: function (res) {console.log("---- previewImage complete: " + JSON.stringify(res));},});},},wbox: {onLoad() {},onShow() {// 页面显示/切入前台时触发},onHide() {// 页面隐藏时触发},onUnload() {// 页面退出时触发},},mounted() {},
};
export default pageOptions;
</script><style></style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/1543947.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

Springcloud框架-能源管理系统-能源管理系统源码-能源在线监测平台-双碳平台

一、介绍 基于SpringCloud的能管管理系统-能源管理平台源码-能源在线监测平台-双碳平台源码-SpringCloud全家桶-能管管理系统源码 有需者咨询&#xff0c;非诚勿扰&#xff1b; 二、软件架构 二、功能介绍 三、数字大屏展示 四、数据采集原理 五、软件截图

Windows11系统安装,配置CUDA、cuDNN等

已经有大几年没有安装过 Windows 的系统了&#xff0c;今天因为黑神话悟空&#xff0c;准备把 Win 11 装一台&#xff0c;玩玩游戏&#xff0c;顺便把一些 CUDA 相关的异步解析项目也安装到 Window 上。 下载安装 PE 因为十几年前&#xff0c;只会用 PE 装系统&#xff0c;所…

XSS闯关小游戏(前13关)

挖掘思路 1.存在可控参数 2.页面存在回显 3.使用带有特殊字符的语句去测试&#xff0c;网站是否进行了实例化 ( 例如 ">123 ) 4.构造闭合&#xff0c;实现payload的逃逸 1 name处参数可控&#xff0c;直接打即可 2 这里知道<>被实体编码了 再测试">1…

DANN GRL

域自适应是指在目标域与源域的数据分布不同但任务相同下的迁移学习&#xff0c;从而将模型在源域上的良好性能迁移到目标域上&#xff0c;极大地缓解目标域标签缺失严重导致模型性能受损的问题。 介绍一篇经典工作 DANN &#xff1a; 模型结构 在训练阶段需要预测如下两个任务…

langchain的构成

1.简介 langchain的构成其包含langchain-core,langchain-community,langchain,langgraph,langserve,langSmith。 2&#xff0c;构件的详解 ‌LangChain Core‌ ‌LangChain Core‌是LangChain框架的核心组成部分&#xff0c;它包含了不同组件的基本抽象以及将它们组合在一起…

【每天学个新注解】Day 4 Lombok注解简解(三)—@NonNull

我们在之前的三天学了Lombok常用的注解&#xff1a; 【每天学个新注解】Day 1 Lombok注解简解&#xff08;〇&#xff09;—Getter、Setter、ToString、EqualsAndHashCode、Constructor 【每天学个新注解】Day 2 Lombok注解简解&#xff08;一&#xff09;—Data、Build、Value…

Kubernetes调度单位Pod

Kubernetes调度单位Pod 1 Pod简介 不直接操作容器container。 一个 pod 可包含一或多个容器&#xff08;container&#xff09;&#xff0c;它们共享一个 namespace&#xff08;用户&#xff0c;网络&#xff0c;存储等&#xff09;&#xff0c;其中进程之间通过 localhost 本地…

iOS 巨魔技巧:一键汉化巨魔商店

嘿&#xff0c;这是黑猫。iOS 巨魔商店一直都有个严重的问题&#xff1a;界面纯英文&#xff0c;不支持简体中文。 当然了&#xff0c;在IT行业&#xff0c;英语是通用语言。但是&#xff0c;既然巨魔/越狱面向普罗大众的技术&#xff0c;那么做好语言适配&#xff0c;还是很关…

idea插件开发系列1-环境搭建

前言 还记着10多年前有幸接触了eclipse插件开发&#xff0c;10多年后的今天有开发了idea的插件&#xff0c;真是一个轮回&#xff01; 为什么要学习idea插件开发呢&#xff1f; 目前公司使用自己的MVC框架&#xff0c;没有相应的idea插件支持&#xff08;如类似mybatis插件可…

Redis简单介绍与安装应用

在当今的互联网时代&#xff0c;数据的快速存取和处理变得至关重要。Redis&#xff0c;作为一种高性能的键值存储系统&#xff0c;已经成为许多开发者和企业的首选。本文将简要介绍Redis的基本概念、工作原理以及其在实际应用中的一些典型用例。 一、简介 1&#xff09;概念 …

centos7 docker部署nacos

1. 一行代码安装git yum -y install git 2. 下载最新版nacos源码&#xff1a; git clone https://github.com/nacos-group/nacos-docker.git 进入nacos-docker文件 cd nacos-docker 3.docker安装数据库Mysql8 按这个来就行&#xff0c;非常好 Docker安装mysql8-超详细、每…

记某学校小程序漏洞挖掘

前言&#xff1a; 遇到一个学校小程序的站点&#xff0c;只在前端登录口做了校验&#xff0c;后端没有任何校验&#xff0c;奇葩弱口令离谱进去&#xff0c;站点里面越权泄露敏感信息&#xff0c;接管账号等漏洞&#xff01;&#xff01;&#xff01; 渗透思路 1.绕过前端 …

docker 创建showdoc服务 showdoc容器部署教程

1. 下载最新版本镜像 # 按照最新版本 docker pull star7th/showdoc 2. 创建映射文件夹&#xff1a; # 创建文件夹 mkdir -p /data/showdoc_data# 可写权限 chmod 777 /data/showdoc_data 3.创建容器命令&#xff1a; docker run -d --name showdoc --userroot --privileged…

DoppelGanger++:面向数据库重放的快速依赖关系图生成

doi&#xff1a;DoppelGanger: Towards Fast Dependency Graph Generation for Database Replay&#xff0c;点击前往 文章目录 1 简介2 架构概述3 依赖关系图3.1 符号和问题定义3.2 无 IT(k) 图3.3 无 OT 图表3.4 无 OTIT 图表3.5 无 IT[OT] 图表3.6 输出确定性保证 4 重复向后…

go-admin-ui的菜单分割线设计思路和代码实现

在菜单管理添加分割线&#xff0c;类似这种&#xff1a; 思路&#xff1a;利用空间结构和数据特点来唯一区分出分割线&#xff0c;来划分业务区域 <template><div><h1>Split Line Controller</h1><ul><li v-for"route in displayedRout…

Thinkphp5x远程命令执行 靶场攻略

环境配置 靶场&#xff1a;vulhub/thinkphp/5-rce docker-compose up -d #启动环境 漏洞复现 1.访问靶场&#xff1a;http://172.16.1.198:8080/ 2.远程命令执⾏ POC&#xff1a; ?sindex/think\app/invokefunction&functioncall_user_func_array&vars[0]system…

网安新声 | 黎巴嫩BP机爆炸事件带来的安全新挑战与反思

网安加社区【网安新声】栏目&#xff0c;汇聚网络安全领域的权威专家与资深学者&#xff0c;紧跟当下热点安全事件、剖析前沿技术动态及政策导向&#xff0c;以专业视野和前瞻洞察&#xff0c;引领行业共同探讨并应对新挑战的策略与可行路径。 9月17日&#xff0c;黎巴嫩境内发…

项目实战:lngress搭建Nginx+WP论坛+MariaDB

1. 网站架构 本次部署形式完全舍弃 Docker&#xff0c;将所有应用都置于Kubernetes&#xff0c;采用 Deployment 而非单 Pod 部署&#xff0c;稳定性得到升级。 2. 部署 MariaDB [rootk8s-master ~]# mkdir tdr [rootk8s-master ~]# cd tdr/ &#xff08;1&#xff09;定义 …

YOLOv8改进,YOLOv8添加STA注意机制(超级令牌注意力机制,CVPR2023),并二次创新C2f结构,助力涨点

改进前训练结果: 改进后训练结果: 摘要 在Transformer架构引入“超级令牌”(Super Token)的机制,旨在解决浅层网络中过多冗余的局部特征捕捉问题。传统的Transformer在捕捉长程依赖性方面表现出色,但在浅层网络中,由于局部特征冗余,导致了计算效率的低下。为了解决…

Nginx基础详解1(单体部署与集群部署、负载均衡、正反代理、nginx安装)

本阶段的任务 1.学会集群的操作概念 2.完成对Nginx的入门操作 3.使用Nginx实现集群和负载均衡 4.使用Nginx实现高可用的方案 目录 1.单体部署与集群部署 1.1单体部署的概念 1.2单体部署的优缺点 1.3集群部署的概念 1.4集群部署的优缺点 1.5集群部署需要注意的点 1.…