微信小程序浮标,可以拖动,自动靠边隐藏一半客服图标功能

devtools/2024/9/25 23:22:04/

不多说,直接上代码。全屏拖动无抖动,中间停留自动靠边,拖动隐藏一半,可自己根据代码改动为自己想要的效果

js代码

import { tpStaticUrl,basictpStaticUrl } from "../../../envConfig";
let app = getApp();
Component({ properties: { },data: {windowWidth: 0, // 手机宽度windowHeight:0, // 手机高度touX: 0,  // 拖动后的X坐标touY: 0, // 拖动后的Y坐标x: 250,//定位X轴位置y: 250, //定位Y轴位置icon_xiaodangjia: tpStaticUrl+'/web/wxapp/bxsc/icon_xiaodangjia.png', // },pageLifetimes: {  // 初始化show: function() { var that = this;// console.log('222222222')wx.getSystemInfo({ success: function(res) { console.log(res)that.setData({windowWidth: res.windowWidth, // 手机宽度 windowHeight: res.windowHeight, // 手机高度x: res.windowWidth - 50,y: res.windowHeight /2 - 20})},fail: function(res) { },complete: function(res) {  },})},hide: function() { },resize: function() { },},methods: { serviceClick(){ // chelink + '/xiaoDj/index.html?wxtoken=' + rInfo.wxtoken + '&openId=' + uidapp.globalData.webviewSrc = basictpStaticUrl + '/web/xiaoDj/index.html?wxtoken=' + app.globalData.userInfo.xtoken + '&openId=' + app.globalData.userInfo.gwOpenId + '&unionId=' + app.globalData.userInfo.unionId;wx.navigateTo({  //  reLaunch关闭所有页面跳转  关闭当前页面--跳转 redirectTo    navigateTo不关闭页面跳转url: "/pages/page/webView/webView"})},bindchange(e){this.setData({ touX: e.detail.x,touY: e.detail.y})//  console.log(e.detail)},bindtouchend(e){let _this = this;// console.log('停止',_this.data.touY,e)// setTimeout(function(){if(_this.data.touX + 50 > _this.data.windowWidth && _this.data.touY+50 < _this.data.windowHeight){ // 移动右边超过了边距_this.setData({ x: _this.data.windowWidth - 25,y: e.changedTouches[0].pageY-20// y: Number(JSON.parse(JSON.stringify(_this.data.touY)))})}if(_this.data.touX + 50 < _this.data.windowWidth && _this.data.touY+50 < _this.data.windowHeight){  // 没有超过的时候,自动在右边_this.setData({ x: _this.data.windowWidth - 50,y: e.changedTouches[0].pageY-20// y: Number(JSON.parse(JSON.stringify(_this.data.touY)))})}if(_this.data.touY+50 > _this.data.windowHeight){ // 滑到底部的时候_this.setData({x: _this.data.windowWidth-50, y: _this.data.windowHeight- 100// y: Number(JSON.parse(JSON.stringify(_this.data.touY)))})}// },1000)} }});

wxml 代码

<movable-area><movable-view x='{{x}}' y='{{y}}' direction="all" style="pointer-events: auto;" bindchange="bindchange" bindtouchend="bindtouchend"><div bindtap="serviceClick" class="kefu"><image src="{{icon_xiaodangjia}}" class="kefuIcon"></image></div></movable-view>
</movable-area>

wxss 代码

movable-area{ width: 100%;height:100%;/*设置透明不影响后面的操作*/pointer-events: none;position:fixed;text-align: center;right:0px;top:0px;background: none;z-index: 9999;}.kefu, .kefuIcon { /* width: 45px;height: 45px; */border: none;padding: 0;background: none;}.kefu image {display: inline-block;width: 96rpx;height: 100rpx;}/* .kefu image { max-width: 100%;max-height: 100%;} */.kefu button::after { border: none;}

http://www.ppmy.cn/devtools/4302.html

相关文章

nginx-http-flv配置

hls配置 hls配置放在 http.server里面 http {server {# HTTP监听端口listen 8002;location /hls {types {application/vnd.apple.mpegurl m3u8;video/mp2t ts;}alias ./temp/hls; # HLS文件存放路径&#xff0c;请替换为你实际的路径expires -1;add_header Cache-Control no…

软考系统架构设计师考试论文应试技巧

写论文是你展示系统分析水平的最佳时机&#xff0c;如果您面对三个论文问题的阐述&#xff0c;怎么才能让人相信你有项目实践经验&#xff0c;有较强的分析问题、解决问题的能力&#xff0c;怎么才能让你的论文就很有说服力呢&#xff1f;下面是湖北软考网小编总结出来的几条系…

Qt 6子窗口全屏显示

一、全屏显示效果 二、全屏相关函数 1,全屏显示函数 QWidget::showFullScreen(); // 此方法只对顶级窗口有效&#xff0c;对子窗口无效 2&#xff0c;恢复显示函数 QWidget::showNormal(); // 此方法也只对顶级窗口有效&#xff0c;对子窗口无效 3&#xff0c;最小化显示函…

中科亿海微-CL1656功能验证开发板

I. 引言 A. 研究背景与意义 CL1656是一款精度高、功耗低、成本低的5V单片低功耗运放&#xff0c;由核心互联公司研发制造&#xff0c;CL1656 是一个 16-bit、快速、低功耗逐次逼近型 ADC&#xff0c;吞吐速率高达 250 kSPS&#xff0c;并且内置低噪声、宽 带宽采样保持放大器。…

【Go语言基础面试题】

1.基础语法篇 1.1 和:的区别 是赋值:是声明赋值 1.2. 指针的作用&#xff1f; 指针用来保存变量的地址 解引用运算符*用于访问地址中的值地址运算符&用于返回变量的地址 1.3. Go允许多个返回值吗&#xff1f; 允许&#xff0c;返回两个string。func swap(x, y strin…

边缘计算网关有哪些用途及使用方法?-天拓四方

在数字化日益深入的今天&#xff0c;边缘计算网关作为一种重要的设备&#xff0c;正在越来越多地被应用于各种场景中。它不仅能够提升数据处理的速度和效率&#xff0c;还能在降低网络延迟的同时确保数据的安全性。本文将详细介绍边缘计算网关的用途及其使用方法&#xff0c;帮…

软考128-上午题-【软件工程】-白盒测试

一、白盒测试&#xff08;结构测试&#xff09; 白盒测试也称为结构测试&#xff0c;根据程序的内部结构和逻辑来设计测试用例&#xff0c;对程序的路径和过程进行测试&#xff0c;检查是否满足设计的需要。 白盒测试常用的技术是&#xff1a;逻辑覆盖、循环覆盖和基本路径测…

Labview2024安装包(亲测可用)

目录 一、软件简介 二、软件下载 一、软件简介 LabVIEW是一种由美国国家仪器&#xff08;NI&#xff09;公司开发的程序开发环境&#xff0c;它显著区别于其他计算机语言&#xff0c;如C和BASIC。传统的计算机语言是基于文本的语言来产生代码&#xff0c;而LabVIEW则采用图形化…