国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序

這篇具有很好參考價值的文章主要介紹了uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

??

uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序,uniapp,vue2,前端,uni-app,小程序,通訊,聊天,消息列表,對話

??

???江城開朗的豌豆:個人主頁

????個人專欄?:《 VUE 》?《 javaScript 》

????個人網(wǎng)站?:《 江城開朗的豌豆?? 》?

???生活的理想,就是為了理想的生活?!

uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序,uniapp,vue2,前端,uni-app,小程序,通訊,聊天,消息列表,對話

目錄

??? 文章簡介(效果圖展示)????????

? ???插件傳送門:聊天消息列表

???? 文章背景

?????平臺兼容性

???? 功能實現(xiàn)

廢話不說直接上代碼

????用戶列表完整代碼

????單人對話框?完整代碼?

???文章總結(jié)

???隱私、權(quán)限聲明

1. 本插件需要申請的系統(tǒng)權(quán)限列表:

2. 本插件采集的數(shù)據(jù)、發(fā)送的服務(wù)器地址、以及數(shù)據(jù)用途說明:

3. 本插件是否包含廣告,如包含需詳細說明廣告表達方式、展示頻率:


??? 文章簡介(效果圖展示)

??????在現(xiàn)代社交互動中,聊天消息列表是應(yīng)用程序中的關(guān)鍵組成部分。它不僅僅是一種通信工具,更是人們?nèi)粘I钪羞B接感情、分享信息的重要方式之一。隨著移動互聯(lián)網(wǎng)的發(fā)展,用戶在不同平臺上(如App、H5、小程序等)進行聊天的需求也愈發(fā)增加。因此,設(shè)計并實現(xiàn)一個支持多平臺、多種形式的聊天消息列表成為了開發(fā)者們的挑戰(zhàn)之一。

uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序,uniapp,vue2,前端,uni-app,小程序,通訊,聊天,消息列表,對話uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序,uniapp,vue2,前端,uni-app,小程序,通訊,聊天,消息列表,對話

????????

? ? ???插件傳送門:聊天消息列表

uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序,uniapp,vue2,前端,uni-app,小程序,通訊,聊天,消息列表,對話

???? 文章背景

????????

? ? ? ?最近我專注于優(yōu)化我們聊天消息列表的交互體驗。現(xiàn)在,我們的消息列表頁面上有多個標簽,每個標簽對應(yīng)著不同的聊天會話。當(dāng)用戶點擊某個標簽時,頁面會流暢地滾動到相應(yīng)的聊天記錄位置,這樣用戶就可以更方便地查看他們感興趣的對話內(nèi)容。

? ? ? 今天下午,我花了些時間在消息列表的交互功能上進行調(diào)整和改進。經(jīng)過一番努力,我成功地實現(xiàn)了這一功能!在這個過程中,我逐步解決了各種技術(shù)挑戰(zhàn),體驗著一個個問題被一一擊破的成就感。這種改進用戶體驗的過程真是讓人感到無比滿足!

?????平臺兼容性

Vue2 Vue3
App 快應(yīng)用 微信小程序 支付寶小程序 百度小程序 字節(jié)小程序 QQ小程序
HBuilderX 3.6.11 app-vue app-nvue
釘釘小程序 快手小程序 飛書小程序 京東小程序
H5-Safari Android Browser 微信瀏覽器(Android) QQ瀏覽器(Android) Chrome IE Edge Firefox PC-Safari

???? 功能實現(xiàn)

廢話不說直接上代碼

????用戶列表完整代碼

uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序,uniapp,vue2,前端,uni-app,小程序,通訊,聊天,消息列表,對話

<template>
	<view class="page">
		<view class="list-item" v-for="(item,index) in users" :key="index" @click="connect(item)">
			<view class="avatar">
				<text class="round" v-if="item.read"></text>
				<image :src="item.avatar" mode="widthFix"></image>
			</view>
			<view class="content">
				<view class="title">
					<text class="name">{{ item.name }}</text>
					<text class="time">{{ item.time }}</text>
				</view>
				<view class="txt">{{ item.msg }}</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				options: [{
					text: '取消',
					style: {
						backgroundColor: '#007aff'
					}
				}, {
					text: '確認',
					style: {
						backgroundColor: '#dd524d'
					}
				}],
				users: [{
						avatar: '/static/avatar/avatar1.png',
						name: '楊濤',
						read: 1,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					},
					{
						avatar: '/static/avatar/avatar2.jpg',
						name: '雨中漫步',
						read: 1,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					},
					{
						avatar: '/static/avatar/avatar3.jpeg',
						name: '糖果夢境',
						read: 1,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					},
					{
						avatar: '/static/avatar/avatar4.png',
						name: '海上日落',
						read: 1,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					},
					{
						avatar: '/static/avatar/avatar6.png',
						name: '男朋友',
						read: 1,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					},
					{
						avatar: '/static/avatar/avatar8.png',
						name: '女朋友',
						read: 1,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					},
					{
						avatar: '/static/avatar/avatar5.jpeg',
						name: '靜謐之夜',
						read: 1,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					},
					{
						avatar: '/static/avatar/avatar1.png',
						name: '風(fēng)吹麥浪',
						read: 0,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					},
					{
						avatar: '/static/avatar/avatar1.png',
						name: '路過歲月',
						read: 0,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					},
					{
						avatar: '/static/avatar/avatar1.png',
						name: '繁星點點',
						read: 0,
						time: '23:59',
						msg: '沒有消息就是最好的消息'
					}
				]
			};
		},
		methods: {
			onClick(e) {
				console.log('點擊了' + (e.position === 'left' ? '左側(cè)' : '右側(cè)') + e.content.text + '按鈕')
			},
			swipeChange(e, index) {
				console.log('當(dāng)前狀態(tài):' + e + ',下標:' + index)
			},
			connect(item) {
				uni.navigateTo({
					url: `/pages/message/message?name=${item.name}&avatar=${item.avatar}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		padding: 0 32rpx;
		color: #333;
	}

	.list-item {
		display: flex;
		padding: 30rpx 0;
		border-bottom: 1px solid #ccced3;

		.avatar {
			width: 90rpx;
			height: 90rpx;
			border-radius: 10rpx;
			margin-right: 20rpx;
			position: relative;

			.round {
				position: absolute;
				width: 14rpx;
				height: 14rpx;
				border-radius: 50%;
				background: #ef5656;
				top: -4rpx;
				right: -4rpx;
				z-index: 1;
			}

			image {
				width: 100%;
				height: 100%;
				border-radius: 10rpx;
			}
		}

		.content {
			flex: 1;

			.title {
				display: flex;
				justify-content: space-between;

				.name {
					font-weight: bold;
				}

				.time {
					color: #999;
					font-size: 24rpx;
				}
			}

			.txt {
				margin-top: 10rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
				text-align: left;
				color: #999;
				font-size: 26rpx;
			}
		}
	}
</style>
????單人對話框?完整代碼

uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序,uniapp,vue2,前端,uni-app,小程序,通訊,聊天,消息列表,對話

<template>
	<view class="page">
		<scroll-view class="scroll-view" scroll-y scroll-with-animation :scroll-top="top">
			<view style="padding: 30rpx 30rpx 240rpx;">
				<view class="message" :class="[item.userType]" v-for="(item,index) in list" :key="index">
					<image :src="item.avatar" v-if="item.userType === 'friend'" class="avatar" mode="widthFix"></image>
					<view class="content" v-if="item.messageType === 'image'">
						<image :src="item.content" mode="widthFix"></image>
					</view>
					<view class="content" v-else>
						{{ item.content }}
					</view>
					<image :src="item.avatar" v-if="item.userType === 'self'" class="avatar" mode="widthFix"></image>
				</view>
			</view>
		</scroll-view>
		<view class="tool">
			<input type="text" v-model="content" class="input" @confirm="send" />
			<image src="/static/photo.png" mode="widthFix" class="thumb" @click="chooseImage"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: '',
				list: [],
				top: 0
			};
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title: options.name
			})
			this._friendAvatar = options.avatar
			this._selfAvatar = '/static/avatar/avatar5.jpeg'
			this.list = [
				{
					content: '對方歷史回復(fù)消息',
					userType: 'friend',
					avatar: this._friendAvatar
				},
				{
					content: '歷史消息',
					userType: 'self',
					avatar: this._selfAvatar
				}
			]
		},
		methods: {
			send() {
				this.list.push({
					content: this.content,
					userType: 'self',
					avatar: this._selfAvatar
				})
				this.content = ''
				this.scrollToBottom()
				// 模擬對方回復(fù)
				setTimeout(()=>{
					this.list.push({
						content: '周末什么安排',
						userType: 'friend',
						avatar: this._friendAvatar
					})
					this.scrollToBottom()
				}, 1500)
			},
			chooseImage() {
				uni.chooseImage({
					// sourceType: 'album',
					success: (res) => {
						this.list.push({
							content: res.tempFilePaths[0],
							userType: 'self',
							messageType: 'image',
							avatar: this._selfAvatar
						})
						this.scrollToBottom()
						// 模擬對方回復(fù)
						setTimeout(()=>{
							this.list.push({
								content: '你好呀,朋友~',
								userType: 'friend',
								avatar: this._friendAvatar
							})
							this.scrollToBottom()
						}, 1500)
					}
				})
			},
			scrollToBottom() {
				this.top = this.list.length * 1000
			}
		}
	}
</script>

<style lang="scss" scoped>
	.scroll-view {
		/* #ifdef H5 */
		height: calc(100vh - 44px);
		/* #endif */
		/* #ifndef H5 */
		height: 100vh;
		/* #endif */
		background: #eee;
		box-sizing: border-box;
	}
	.message {
		display: flex;
		align-items: flex-start;
		margin-bottom: 30rpx;
		
		.avatar {
			width: 80rpx;
			height: 80rpx;
			border-radius: 10rpx;
			margin-right: 30rpx;
		}
		.content {
			min-height: 80rpx;
			max-width: 60vw;
			box-sizing: border-box;
			font-size: 28rpx;
			line-height: 1.3;
			padding: 20rpx;
			border-radius: 10rpx;
			background: #fff;
			image {
				width: 200rpx;
			}
		}
		&.self {
			justify-content: flex-end;
			.avatar {
				margin: 0 0 0 30rpx;
			}
			.content {
				position: relative;
				&::after {
					position: absolute;
					content: '';
					width: 0;
					height: 0;
					border: 16rpx solid transparent;
					border-left: 16rpx solid #fff;
					right: -28rpx;
					top: 24rpx;
				}
			}
		}
		&.friend {
			.content {
				position: relative;
				&::after {
					position: absolute;
					content: '';
					width: 0;
					height: 0;
					border: 16rpx solid transparent;
					border-right: 16rpx solid #fff;
					left: -28rpx;
					top: 24rpx;
				}
			}
		}
	}

	.tool {
		position: fixed;
		width: 100%;
		min-height: 120rpx;
		left: 0;
		bottom: 0;
		background: #fff;
		display: flex;
		align-items: flex-start;
		box-sizing: border-box;
		padding: 20rpx 24rpx 20rpx 40rpx;
		padding-bottom: calc(20rpx + constant(safe-area-inset-bottom)/2) !important;
		padding-bottom: calc(20rpx + env(safe-area-inset-bottom)/2) !important;
		.input {
			background: #eee;
			border-radius: 10rpx;
			height: 70rpx;
			margin-right: 30rpx;
			flex: 1;
			padding: 0 20rpx;
			box-sizing: border-box;
			font-size: 28rpx;
		}
		.thumb {
			width: 64rpx;
		}
	}
</style>

?

???文章總結(jié)

???隱私、權(quán)限聲明

?? ? ? ? 如說明表達還不夠清楚,不清楚怎么使用可導(dǎo)入完整示例項目運行體驗和希望對大家有幫助!

1. 本插件需要申請的系統(tǒng)權(quán)限列表:

無,開箱即用

2. 本插件采集的數(shù)據(jù)、發(fā)送的服務(wù)器地址、以及數(shù)據(jù)用途說明:

插件不采集任何數(shù)據(jù)

3. 本插件是否包含廣告,如包含需詳細說明廣告表達方式、展示頻率:

沒有任何廣告,純分享,方便自己,同時也方便其他能用的的前端好朋友

uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序,uniapp,vue2,前端,uni-app,小程序,通訊,聊天,消息列表,對話

請大家不吝賜教,在下方評論或者私信我,十分感謝??????.

使用插件有任何問題歡迎加入QQ討論群:

作者QQ群:906392632(未滿)

? 認為我某個部分的設(shè)計過于繁瑣,有更加簡單或者更高逼格的封裝方式

? 認為我部分代碼過于老舊,可以提供新的API或最新語法

? 對于文章中部分內(nèi)容不理解

? 解答我文章中一些疑問

? 認為某些交互,功能需要優(yōu)化,發(fā)現(xiàn)BUG

? 想要添加新功能,對于整體的設(shè)計,外觀有更好的建議

最后感謝各位的耐心觀看,既然都到這了,點個 ??贊再走吧!

uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序,uniapp,vue2,前端,uni-app,小程序,通訊,聊天,消息列表,對話文章來源地址http://www.zghlxwxcb.cn/news/detail-851802.html

到了這里,關(guān)于uniapp:聊天消息列表(好友列表+私人單聊)支持App、H5、小程序的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包