首页 > 编程语言 >uniapp小程序客服拖拽+左右吸附

uniapp小程序客服拖拽+左右吸附

时间:2023-07-19 09:13:56浏览次数:34  
标签:uniapp rotate 客服 100% move transform res webkit 拖拽

<template>
	<view class="" v-if="x != 0 && y != 0">
		<movable-area class="movableArea">
			<movable-view class="movableView" :position="position" :x="x" :y="y" :direction="direction" :damping="damping"
			 @change="onChange" @touchend="onTouchend">
				<image src="../../../../static/images/kefu.png" mode="widthFix" class="iconImage"></image>
				<button open-type='contact' session-from='' class="contact">联系我们</button>
			</movable-view>
		</movable-area>
	</view>
</template>

<script>
	export default {
			data() {
				return {
					x: 0,
					y: 0,
					x1: 0,
					x2: 0,
					y1: 0,
					y2: 0,
					move: {
						x: 0,
						y: 0
					}
				};
			},
			props: {
				damping: {
					type: Number,
					default: 10
				},
				direction: {
					type: String,
					default: "all"
				},
				position: {
					type: Number,
					default: 4
				}
			},
			mounted() {
				uni.getSystemInfo({
					success: (res) => {
						this.x = res.safeArea.right-60;
						this.y = res.safeArea.bottom-280;
						this.x1 = 10;
						this.x2 = parseInt(res.windowWidth) - 60;
					}
				})
			},
			methods: {
				onChange(e) {
					if (e.detail.source === "touch") {
						this.move.x = e.detail.x;
						this.move.y = e.detail.y;
					}
				},
				onTouchend() {
					this.x = this.move.x;
					this.y = this.move.y;
					setTimeout(() => {
						if (this.move.x < this.x2 / 2){
							this.x = this.x1;
						}else{
							this.x = this.x2;
							console.log(this.x, this.y)
						}
					}, 100)
				},
			}
		}
</script>

<style>
	.movableArea {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		pointer-events: none; //设置area元素不可点击,则事件便会下移至页面下层元素
		z-index: 999;
	}
	.movableArea .movableView {
		pointer-events: auto; //可以点击
		width: 80rpx;
		height: 80rpx;
		padding: 8rpx;
		border-radius: 100%;
		border: 1px solid #4BE0C7;
	}
	.movableArea .movableView .iconImage {
		display: block;
		width: 80rpx;
		height: 80rpx;
		// animation: iconImage 5s linear infinite;
	}
	@keyframes iconImage{
	  0%{-webkit-transform:rotate(0deg);}
	  25%{-webkit-transform:rotate(90deg);}
	  50%{-webkit-transform:rotate(180deg);}
	  75%{-webkit-transform:rotate(270deg);}
	  100%{-webkit-transform:rotate(360deg);}
	}
	
	// 客服
	.movableArea .movableView .contact {
		width: 50px;
		height: 50px;
		overflow: hidden;
		position: absolute;
		left: 0px;
		top: 0px;
		border-radius: 100%;
		opacity: 0;
	}
</style>

参考文章:https://www.aliyue.net/10333.html

标签:uniapp,rotate,客服,100%,move,transform,res,webkit,拖拽
From: https://www.cnblogs.com/douyuanjun/p/17564648.html

相关文章

  • 宝塔 30分钟部署免费在线客服系统
    客服系统发布以来,一直有朋友询问如何在宝塔面板中安装部署,开始我一直认为参考Linux版的安装教程就可以了,一直没有专门写宝塔环境的教程。这段时间来咨询的朋友越来越多,经过了解,我才知道宝塔面板的普及率有多高,好吧,那我就认真对待一下这个问题,详细编写了基于宝塔安装部署升讯威在......
  • 介绍社交论坛问答发帖系统源码-java+vue+uniapp开发前后端
    前后端分离社交论坛问答发帖BBS源码,社交论坛小程序|H5论坛|,app论坛是java+vue+uniapp开发的前后端分离社交论坛问答发帖/BBS项目,包括论坛图文帖,视频,圈子,IM私聊,微信支付,付费贴,积分签到,钱包充值等论坛小程序论坛app完整功能演示地址:www.runruncode.com/java/19462.html ......
  • 客服
    import{useEffect,useState}from'react';import'./index.less';import{membersList,messageList}from'@/services/info/info-api';exportdefaultfunctionInfo(){const[membersLeft,setMembersLeft]=useState<any......
  • iOS 苹果授权登录(Sign in with Apple)系列之uniapp篇
    官方网址https://uniapp.dcloud.net.cn/tutorial/app-oauth.html# 代码集成1、在 template 添加以下代码, 苹果授权登录(SigninwithApple)是 iOS13 才有的,做下系统版本判断<template><viewclass="content"><!--苹果登录--><viewclass="......
  • uniapp H5 解决跨域
    1、请求地址:http://192.168.1.216:8080/renren-api/api/getUserInfo2、修改 manifest.json "h5":{"devServer":{"port":5173,//端口号"disableHostCheck":true,"proxy":{&quo......
  • Eolink Apikit,0 代码可拖拽的自动化测试神器
    大家好,我是哪吒。传统的自动化测试方法需要编写大量的代码和脚本,对于非开发人员来说具有一定门槛,本文将以EolinkApikit为例,探讨图形化操作、可拖拽的自动化测试工作流,如何快速构建复杂的测试流程。一、从测试到可拖拽的自动化测试传统的测试需要测试人员逐步执行测试用例,手动输......
  • uniapp中使用openlayers
    相关链接 https://codeleading.com/article/25216143964/#google_vignette例子<template><viewid="map-id"class="map-class"></view></template><script>exportdefault{data(){return{m......
  • uniapp云发布时自有证书的生成
    1.需要java环境2.生成签名:keytool-genkey-aliasmytest-keyalgRSA-keysize2048-validity36500-keystoremytest.keystore(mytest表示签名文件的名称)3.查看签名:keytool-list-v-keystoretest.keystore原文链接:https://www.cnblogs.com/plBlog/p/13066644.html ......
  • 直播app开发搭建,uniapp中微信小程序账号登录
    直播app开发搭建,uniapp中微信小程序账号登录<template><view>    <!--登录适配-->       <!--最新版登录方法--><button             type='primary'@tap="getUserProfile">新      </button>      <......
  • CentOS 30分钟部署免费在线客服系统
    前段时间我发表了一系列文章,开始介绍基于.netcore的在线客服系统开发过程。期间有一些朋友希望能够给出Linux环境的安装部署指导,本文基于CentOS7.9来安装部署。我详细列出了需要执行的命令的全过程,跟随本文可以在30分钟内完成部署。简介升讯威在线客服与营销系统是基......