问题修复
This commit is contained in:
@@ -8,8 +8,12 @@
|
||||
backgroundColor: btnColor,
|
||||
width: `${btnSize}px`,
|
||||
height: `${btnSize}px`,
|
||||
transform: `translateX(${currentOffsetX}px) translateY(${currentOffsetY}px)`,
|
||||
}"
|
||||
:class="{ active: isPopupVisible }"
|
||||
@touchstart="touchstart"
|
||||
@touchmove="touchmove"
|
||||
@touchend="touchend"
|
||||
>
|
||||
<up-icon
|
||||
name="plus"
|
||||
@@ -20,7 +24,14 @@
|
||||
</view>
|
||||
|
||||
<!-- 操作弹窗 -->
|
||||
<view class="popup" v-if="isPopupVisible" :class="{ show: isPopupVisible }">
|
||||
<view
|
||||
class="popup"
|
||||
v-if="isPopupVisible"
|
||||
:class="{ show: isPopupVisible }"
|
||||
:style="{
|
||||
transform: `translateX(${currentOffsetX}px) translateY(${currentOffsetY}px)`,
|
||||
}"
|
||||
>
|
||||
<view class="popup-arrow"></view>
|
||||
<view class="popup-content">
|
||||
<view
|
||||
@@ -40,14 +51,57 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, defineProps, defineEmits,computed } from "vue";
|
||||
const show=computed(()=>{
|
||||
const sysInfo=uni.getAccountInfoSync();
|
||||
if(sysInfo&&sysInfo.miniProgram && (sysInfo.miniProgram.envVersion == 'release'||sysInfo.miniProgram.envVersion == 'develop')) {
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
})
|
||||
import { ref, defineProps, defineEmits, computed } from "vue";
|
||||
const show = computed(() => {
|
||||
// trial
|
||||
const sysInfo = uni.getAccountInfoSync();
|
||||
if (
|
||||
sysInfo &&
|
||||
sysInfo.miniProgram &&
|
||||
(
|
||||
sysInfo.miniProgram.envVersion == "develop")
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// 核心修改1:新增“历史累积偏移量”变量(保存上一次拖拽后的最终位置)
|
||||
const lastOffsetX = ref(0); // 历史X偏移累积值
|
||||
const lastOffsetY = ref(0); // 历史Y偏移累积值
|
||||
const currentOffsetX = ref(0); // 当前拖拽的实时偏移(基于历史值)
|
||||
const currentOffsetY = ref(0); // 当前拖拽的实时偏移(基于历史值)
|
||||
|
||||
const startX = ref(0);
|
||||
const startY = ref(0);
|
||||
|
||||
// 核心修改2:touchstart - 基于历史偏移量初始化当前拖拽起点
|
||||
function touchstart(e) {
|
||||
const touch = e.touches[0];
|
||||
startX.value = touch.clientX;
|
||||
startY.value = touch.clientY;
|
||||
// 关键:当前拖拽的起点 = 上一次拖拽的终点(历史累积偏移量)
|
||||
currentOffsetX.value = lastOffsetX.value;
|
||||
currentOffsetY.value = lastOffsetY.value;
|
||||
}
|
||||
|
||||
// 核心修改3:touchmove - 实时计算“历史偏移量 + 当前拖拽距离”
|
||||
function touchmove(e) {
|
||||
const touch = e.touches[0];
|
||||
// 当前拖拽的相对距离 = 现在触摸点 - 拖拽起点
|
||||
const moveX = touch.clientX - startX.value;
|
||||
const moveY = touch.clientY - startY.value;
|
||||
// 实时偏移 = 历史累积偏移 + 当前相对移动距离(位置连续)
|
||||
currentOffsetX.value = lastOffsetX.value + moveX;
|
||||
currentOffsetY.value = lastOffsetY.value + moveY;
|
||||
}
|
||||
|
||||
// 核心修改4:touchend - 保存当前拖拽终点为历史偏移量(供下次使用)
|
||||
function touchend() {
|
||||
// 关键:将本次拖拽的最终位置保存为历史值
|
||||
lastOffsetX.value = currentOffsetX.value;
|
||||
lastOffsetY.value = currentOffsetY.value;
|
||||
}
|
||||
|
||||
// 定义组件属性
|
||||
const props = defineProps({
|
||||
@@ -133,45 +187,43 @@ const closePopup = () => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
async function getWxloginCode(){
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
resolve(res.code);
|
||||
} else {
|
||||
console.log("获取登录凭证(code)失败!" + res.errMsg);
|
||||
reject(res.errMsg);
|
||||
}
|
||||
},
|
||||
});
|
||||
async function getWxloginCode() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
resolve(res.code);
|
||||
} else {
|
||||
console.log("获取登录凭证(code)失败!" + res.errMsg);
|
||||
reject(res.errMsg);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
// 处理操作选择
|
||||
const handleOperation = async (action) => {
|
||||
let data='';
|
||||
let data = "";
|
||||
if (action == "token") {
|
||||
data=uni.cache.get("token");
|
||||
|
||||
data = uni.cache.get("token");
|
||||
}
|
||||
if (action == "userInfo") {
|
||||
data=JSON.stringify(uni.cache.get("userInfo"));
|
||||
data = JSON.stringify(uni.cache.get("userInfo"));
|
||||
}
|
||||
if(action == "getLoginCode"){
|
||||
data=await getWxloginCode();
|
||||
if (action == "getLoginCode") {
|
||||
data = await getWxloginCode();
|
||||
}
|
||||
if(action == "copyStoreInfo"){
|
||||
data=JSON.stringify(uni.cache.get("shopInfo"));
|
||||
if (action == "copyStoreInfo") {
|
||||
data = JSON.stringify(uni.cache.get("shopInfo"));
|
||||
}
|
||||
if(action == "copyStoreUserInfo"){
|
||||
data=JSON.stringify(uni.cache.get("shopUserInfo"));
|
||||
if (action == "copyStoreUserInfo") {
|
||||
data = JSON.stringify(uni.cache.get("shopUserInfo"));
|
||||
}
|
||||
console.log('data',data)
|
||||
console.log("data", data);
|
||||
uni.setClipboardData({
|
||||
data: data,
|
||||
success: function () {},
|
||||
});
|
||||
data: data,
|
||||
success: function () {},
|
||||
});
|
||||
emit("onOperation", action);
|
||||
closePopup();
|
||||
};
|
||||
@@ -198,7 +250,7 @@ const handleOperation = async (action) => {
|
||||
linear-gradient(259deg, #fe6d11 50.14%, #ffd1b4 114.93%);
|
||||
box-shadow: 0 0.4375rem 0.95rem 0 #fe8b435e;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
/*transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); */
|
||||
z-index: 1001;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user