6170分享设备页面功能开发

This commit is contained in:
fengerli
2025-07-19 10:22:48 +08:00
parent bc3bea6df0
commit 1663ae75e4
9 changed files with 321 additions and 89 deletions

40
api/6170/share.js Normal file
View File

@ -0,0 +1,40 @@
import request from '@/utils/request'
// 新增设备分享
export function deviceShareAdd(data) {
return request({
url: '/app/deviceShare/deviceShare',
method: 'post',
data: data
})
}
// 获取设备分享详细信息
export function deviceShareId(id) {
return request({
url: `/app/deviceShare/${id}`,
method: 'get',
})
}
// 分享短信验证码
export function deviceShareCode(params) {
return request({
url: '/app/deviceShare/sms/code',
method: 'get',
data:params
})
}
//设备管理列表
export function deviceShareList(params) {
return request({
url: '/app/deviceShare/deviceShareList',
method: 'get',
data: params
})
}
// 移除设备管理
export function deviceShareDelete(ids) {
return request({
url: `/app/deviceShare/${ids}`,
method: 'DELETE',
})
}

View File

@ -8,11 +8,11 @@ export function login(data) {
}) })
} }
// 注册发送验证码 // 注册发送验证码
export function sendRegisterSms(data) { export function resourceSmsCode(params) {
return request({ return request({
url: '/api/appUser/sendRegisterSms', //发送验证码注册 url: '/resource/sms/code', //发送验证码注册
method: 'POST', method: 'GET',
data: data data: params
}) })
} }
// 退出登录 // 退出登录

View File

@ -325,9 +325,17 @@
this.lightModeB = false this.lightModeB = false
}, },
// 分享 // 分享
shareUp(){ shareUp() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/6170/share/index' url: '/pages/6170/share/index',
events: {
ack: function(data) {}
},
success: (res) => {
res.eventChannel.emit('share', {
data: this.itemInfo,
});
}
}) })
}, },
@ -482,6 +490,7 @@
width: 204rpx; width: 204rpx;
height: 144rpx; height: 144rpx;
margin-top: 30rpx; margin-top: 30rpx;
object-fit: contain;
} }
.dlIMG { .dlIMG {
@ -646,7 +655,7 @@
.example-body { .example-body {
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 60%; top: 70%;
width: 100%; width: 100%;
transform: translate(-10%, -100%); transform: translate(-10%, -100%);

View File

@ -6,7 +6,6 @@
<view class="section" @click="shareDevice"> <view class="section" @click="shareDevice">
<text class="section-title">分享设备</text> <text class="section-title">分享设备</text>
</view> </view>
<!-- 分享管理 --> <!-- 分享管理 -->
<view class="section" @click="shareManagement"> <view class="section" @click="shareManagement">
<text class="section-title">分享管理</text> <text class="section-title">分享管理</text>
@ -19,14 +18,22 @@
export default { export default {
data() { data() {
return { return {
itemInfo:""
} }
}, },
methods: { methods: {
// 分享设备 // 分享设备
shareDevice(){ shareDevice(){
uni.navigateTo({ uni.navigateTo({
url: '/pages/6170/shareDevices/index' url: '/pages/6170/shareDevices/index',
events: {
ack: function(data) {}
},
success: (res) => {
res.eventChannel.emit('shareDevice', {
data: this.itemInfo,
});
}
}); });
}, },
// 分享管理 // 分享管理
@ -35,7 +42,14 @@
url: '/pages/6170/shareManagement/index' url: '/pages/6170/shareManagement/index'
}); });
} }
},
onLoad() {
const eventChannel = this.getOpenerEventChannel();
// 监听 'shareDevice' 事件,获取传过来的数据
eventChannel.on('share', (data) => {
console.log(data,'datat');
this.itemInfo = data.data;
})
} }
} }
</script> </script>

View File

@ -1,17 +1,16 @@
<template> <template>
<view class="container"> <view class="container">
<!-- 设备信息 --> <!-- 设备信息 -->
<view class="device-info" v-for="(item, index) in deviceList" :key="index"> <view class="device-info">
<view class="device-header"> <view class="device-header">
<view class="deviceIMG"> <view class="deviceIMG">
<image :src="item.devicePic" mode="" class="IMG"></image> <image :src="itemInfo.devicePic" mode="" class="IMG"></image>
</view> </view>
<view class="device-name"> <view class="device-name">
<view>设备:{{item.deviceName}}</view> <view>设备:{{itemInfo.deviceName}}</view>
<view class="ID"> <view class="ID">
<view class="ID">ID:{{item.deviceImei}} <view class="ID">ID: {{itemInfo.deviceImei}}
</view> </view>
</view> </view>
</view> </view>
</view> </view>
@ -35,10 +34,11 @@
<!-- 被分享人信息 --> <!-- 被分享人信息 -->
<view class="recipient-info"> <view class="recipient-info">
<view class="recipient-title">被分享人信息</view> <view class="recipient-title">被分享人信息</view>
<input type="number" placeholder="输入手机号" class="phone-input" :maxlength="11" /> <input type="number" v-model="phone" placeholder="输入手机号" class="phone-input" :maxlength="11" />
<view class="verification-code"> <view class="verification-code">
<input type="number" placeholder="短信验证码" class="code-input" /> <input type="number" v-model="code" placeholder="短信验证码" class="code-input" :maxlength="6" />
<view class="get-code-btn">获取验证码</view> <view class="get-code-btn" :class="showView?' get_phone_number blue':'get_phone_number grad'"
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</view>
</view> </view>
</view> </view>
@ -64,48 +64,59 @@
</template> </template>
<script> <script>
import {
deviceShareId,
deviceShareCode,
deviceShareAdd
} from '@/api/6170/share.js'
export default { export default {
data() { data() {
return { return {
allSelected: false, allSelected: false,
shareShow: false, shareShow: false,
showView: false,
isCounting: false,
countdown: 0,
permissions: [{ permissions: [{
value: "light-mode", value: "1",
label: "灯光模式", label: "灯光模式",
checked: false checked: false
}, },
{ {
value: "laser-mode", value: "2",
label: "激光模式", label: "激光模式",
checked: false checked: false
}, },
{ {
value: "startup-image", value: "3",
label: "开机画面", label: "开机画面",
checked: false checked: false
}, },
{ {
value: "person-registration", value: "4",
label: "人员信息登记", label: "人员信息登记",
checked: false checked: false
}, },
{ {
value: "send-message", value: "5",
label: "发送信息", label: "发送信息",
checked: false checked: false
}, },
{ {
value: "product-info", value: "6",
label: "产品信息", label: "产品信息",
checked: false checked: false
} }
], ],
deviceList: [{}] deviceInfo: {},
phone: '13058067817',
code: '123456',
itemInfo: ''
}; };
}, },
methods: { methods: {
closePopup(){ closePopup() {
this.shareShow=false this.shareShow = false
}, },
toggleAllSelection() { toggleAllSelection() {
this.allSelected = !this.allSelected; this.allSelected = !this.allSelected;
@ -115,15 +126,118 @@
this.$set(this.permissions[index], 'checked', !this.permissions[index].checked); this.$set(this.permissions[index], 'checked', !this.permissions[index].checked);
this.allSelected = this.permissions.every(permission => permission.checked); this.allSelected = this.permissions.every(permission => permission.checked);
}, },
shareUp() {
// const selectedPermissions = this.permissions.filter(permission => permission.checked).map(permission => // 获取验证码
// permission.value); async getPhoneCode() {
// console.log('Selected Permissions:', selectedPermissions); const phoneNumber = this.phone
this.shareShow=true const myreg = /^1[3456789]\d{9}$/;
if (!phoneNumber) {
uni.showToast({
title: '手机号不能为空',
icon: 'none',
duration: 1000
});
return false;
} else if (!myreg.test(phoneNumber)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none',
duration: 1000
});
return false;
}
try {
await deviceShareCode({
phonenumber: this.phone
})
// 更新倒计时状态
this.isCounting = true;
this.showView = true;
this.countdown = 60
const timer = setInterval(() => {
this.countdown--
if (this.countdown <= 0) {
clearInterval(timer)
this.isCounting = false;
this.showView = false;
}
}, 1000)
uni.showToast({
title: '验证码已发送',
icon: 'none'
})
} catch (error) {}
}, },
handleBtn(){ // 分享按钮提交
this.shareShow=false async shareUp() {
} if (this.phone == '') {
uni.showToast({
title: '手机号不能为空',
icon: 'none',
duration: 1000
})
return false
} else if (this.code == '') {
uni.showToast({
title: '验证码不能为空',
icon: 'none',
duration: 1000
})
return false
}else if (!this.permissions.some(permission => permission.checked)) {
uni.showToast({
title: '请选择至少一个功能权限',
icon: 'none',
duration: 1000
});
return false;
}
try {
uni.showLoading({
title: '分享中'
})
const selectedPermissions = this.permissions.filter(permission => permission.checked).map(
permission =>
permission.value);
const res = await deviceShareAdd({
phonenumber: this.phone,
smsCode: this.code,
deviceId: this.itemInfo.id,
permission: selectedPermissions.join(',')
})
if (res.code == 200) {
this.shareShow = true
uni.hideLoading()
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
} catch (error) {
uni.showToast({
title: error.msg,
icon: 'none'
});
}
},
handleBtn() {
this.shareShow = false
uni.navigateTo({
url: '/pages/6170/shareManagement/index'
})
},
},
onLoad() {
const eventChannel = this.getOpenerEventChannel();
// 监听 'shareDevice' 事件,获取传过来的数据
eventChannel.on('shareDevice', (data) => {
console.log(data, 'data1t111');
this.itemInfo = data.data;
})
} }
}; };
</script> </script>
@ -290,6 +404,7 @@
border-radius: 91rpx; border-radius: 91rpx;
background: rgba(187, 230, 0, 1); background: rgba(187, 230, 0, 1);
} }
/* 遮罩层 */ /* 遮罩层 */
.agreement-mask { .agreement-mask {
position: fixed; position: fixed;
@ -303,11 +418,13 @@
align-items: center; align-items: center;
z-index: 9999; z-index: 9999;
} }
.popup-Title { .popup-Title {
color: rgba(255, 255, 255, 0.86); color: rgba(255, 255, 255, 0.86);
text-align: center; text-align: center;
padding: 30rpx 0rpx; padding: 30rpx 0rpx;
} }
.popup-buttons { .popup-buttons {
display: flex; display: flex;
text-align: center; text-align: center;
@ -322,6 +439,7 @@
text-align: center; text-align: center;
border: 1px solid rgba(187, 230, 0, 0.3); border: 1px solid rgba(187, 230, 0, 0.3);
} }
.svg { .svg {
width: 58rpx; width: 58rpx;
height: 62rpx; height: 62rpx;

View File

@ -7,14 +7,14 @@
<image :src="item.devicePic" mode="" class="IMG"></image> <image :src="item.devicePic" mode="" class="IMG"></image>
</view> </view>
<view class="device-name"> <view class="device-name">
<view>{{item.deviceName}}rr32r23r23</view> <view>{{item.deviceName}}</view>
<view class="ID"> <view class="ID">
<view class="ID">ID:{{item.deviceImei}}ererer <view class="ID">ID:{{item.id}}
</view> </view>
</view> </view>
</view> </view>
<view class="device-delete" @click="handleDelete"> <view class="device-delete" >
<text class="delete">移除</text> <text class="delete" @click="handleDelete(item)">移除</text>
</view> </view>
</view> </view>
</view> </view>
@ -38,22 +38,55 @@
</template> </template>
<script> <script>
import {deviceShareList,deviceShareDelete} from '@/api/6170/share.js'
export default { export default {
data() { data() {
return { return {
deviceList: [{}], deviceList: [],
deleteShow:false deleteShow:false,
delelteItemInfo:''
} }
}, },
methods: { methods: {
// 删除 // 删除
handleDelete() { handleDelete(item) {
console.log(item,'www');
this.deleteShow=true this.deleteShow=true
this.delelteItemInfo=item
}, },
handleBtn(){ handleBtn(){
this.deleteShow=false let allId=this.delelteItemInfo.id
deviceShareDelete(allId).then((res)=>{
if (res.code=200) {
uni.showToast({
title:res.msg,
icon:'none'
})
this.deleteShow=false
this.getData()
} else{
uni.showToast({
title:res.msg,
icon:'none'
})
}
})
//
},
getData(){
let data ={
}
deviceShareList(data).then((res)=>{
if (res.code==200) {
this.deviceList=res.rows
}
})
} }
},
onLoad() {
this.getData()
} }
} }
</script> </script>
@ -74,6 +107,7 @@
color: rgba(255, 255, 255, 0.87); color: rgba(255, 255, 255, 0.87);
padding-top: 10rpx; padding-top: 10rpx;
position: relative; position: relative;
margin-bottom: 20rpx;
} }
.device-header { .device-header {

View File

@ -21,39 +21,46 @@
<scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100" <scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
style="height:80vh;"> style="height:80vh;">
<uni-swipe-action ref="swipeAction"> <view v-if="deviceList.length>0">
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index"> <uni-swipe-action ref="swipeAction">
<uni-swipe-action-item :right-options="Options" @click="handleSwipeClick($event, item, index)" <block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
class="device-card"> <uni-swipe-action-item :right-options="Options"
<view @click.stop="handleFile(item)"> @click="handleSwipeClick($event, item, index)" class="device-card">
<view class="device-header"> <view @click.stop="handleFile(item)">
<view class="deviceIMG"> <view class="device-header">
<image :src="item.devicePic" class="IMG"></image> <view class="deviceIMG">
</view> <image :src="item.devicePic" class="IMG"></image>
<view class="device-name"> </view>
<view>设备:{{item.deviceName}}</view> <view class="device-name">
<view class="ID"> <view>设备:{{item.deviceName}}</view>
<view class="ID" v-if="item.communicationMode==0">ID:{{item.deviceImei}} <view class="ID">
<view class="ID" v-if="item.communicationMode==0">ID:{{item.deviceImei}}
</view>
<view class="ID" v-else>ID:{{item.deviceMac}}</view>
<view class="onlines" v-if="item.communicationMode==0">在线</view>
<view>电量90%</view>
</view> </view>
<view class="ID" v-else>ID:{{item.deviceMac}}</view>
<view class="onlines" v-if="item.communicationMode==0">在线</view>
<view>电量90%</view>
</view> </view>
</view> </view>
<view class="" v-if="item.communicationMode==1">
<view class="device-status online">已连接</view>
<view class="device-status unline">未连接</view>
</view>
</view> </view>
<view class="" v-if="item.communicationMode==1"> <image src="/static/images/cires.png" class="circle"></image>
<view class="device-status online">已连接</view> </uni-swipe-action-item>
<view class="device-status unline">未连接</view> </block>
</view> </uni-swipe-action>
</view> <!-- 加载状态提示 -->
<image src="/static/images/cires.png" class="circle"></image> <view class="loading-status">
</uni-swipe-action-item> <text v-if="loading">加载中...</text>
</block> <text v-if="finished">没有更多数据了</text>
</uni-swipe-action> </view>
<!-- 加载状态提示 --> </view>
<view class="loading-status"> <view v-else class="noDATA">
<text v-if="loading">加载中...</text> <view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
<text v-if="finished">没有更多数据了</text> </view>
暂无数据
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
@ -420,6 +427,7 @@
// 绑定页面做了监听,新增成功,刷新页面 // 绑定页面做了监听,新增成功,刷新页面
uni.$on('refreshDeviceList', () => { uni.$on('refreshDeviceList', () => {
this.getTab() // 刷新数据 this.getTab() // 刷新数据
this.onIntall()
}); });
}, },
beforeDestroy() { beforeDestroy() {
@ -592,6 +600,7 @@
width: 68rpx; width: 68rpx;
height: 50rpx; height: 50rpx;
margin-left: 17%; margin-left: 17%;
object-fit: contain;
} }
.onlines { .onlines {
@ -625,6 +634,11 @@
padding: 20rpx; padding: 20rpx;
font-size: 22rpx; font-size: 22rpx;
} }
.noDATA{
text-align: center;
color: rgba(255, 255, 255, 0.87);
transform: translate(-0%,100%);
}
/* 遮罩层 */ /* 遮罩层 */
.agreement-mask { .agreement-mask {

View File

@ -55,15 +55,14 @@
<script> <script>
import { import {
login, login,
sendRegisterSms resourceSmsCode
} from '@/api/common/login.js'; } from '@/api/common/login.js';
export default { export default {
data() { data() {
return { return {
showView: false, showView: false,
//codebtn: '获取验证码',
phone: '13058067817', //手机号码 phone: '13058067817', //手机号码
code: "123456", //验证码 code: "", //验证码
agreed: false, agreed: false,
isCounting: false, isCounting: false,
countdown: 0, countdown: 0,
@ -92,15 +91,20 @@
return false; return false;
} }
try { try {
// 调用发送验证码接口 await resourceSmsCode({
await sendRegisterSms({ phonenumber: this.phone
phoneNumber: this.phone
}) })
//倒计时 // 更新倒计时状态
this.isCounting = true;
this.showView = true;
this.countdown = 60 this.countdown = 60
const timer = setInterval(() => { const timer = setInterval(() => {
this.countdown-- this.countdown--
if (this.countdown <= 0) clearInterval(timer) if (this.countdown <= 0) {
clearInterval(timer)
this.isCounting = false;
this.showView = false;
}
}, 1000) }, 1000)
uni.showToast({ uni.showToast({
title: '验证码已发送', title: '验证码已发送',
@ -146,7 +150,7 @@
tenantId: '894078' //租户ID tenantId: '894078' //租户ID
}) })
if (res.code == 200) { if (res.code == 200) {
console.log(res,'ressss'); console.log(res, 'ressss');
uni.hideLoading() uni.hideLoading()
uni.setStorageSync('token', res.data.access_token) // 缓存token uni.setStorageSync('token', res.data.access_token) // 缓存token
uni.setStorageSync('clientID', res.data.client_id) // 缓存token uni.setStorageSync('clientID', res.data.client_id) // 缓存token
@ -257,7 +261,7 @@
} }
.blue { .blue {
color: rgba(255, 255, 255, 0.6); color: rgb(187, 230, 0);
} }
.agreement { .agreement {

View File

@ -1,7 +1,6 @@
<template> <template>
<view class="page-section page-section-gap"> <view class="page-section page-section-gap">
<map class="map" :latitude="latitude" :longitude="longitude":show-location="true" <map class="map" :latitude="latitude" :longitude="longitude":show-location="true">
:markers="covers">
</map> </map>
</view> </view>
</template> </template>