1
0
forked from dyf/APP

018A初步完成

This commit is contained in:
liub
2026-04-14 15:19:05 +08:00
parent d82ae6445e
commit 01ff9c7a05
43 changed files with 2626 additions and 892 deletions

View File

@ -23,10 +23,11 @@
<view class="p100">
<view class="lblTitle">配对设备</view>
<view class="list" style="margin-bottom: 30rpx;">
<view class="item " @click.stop="disConnect(item,index)" v-for="item, index in PairEquip" v-show="PairEquip.length>0">
<view class="item " @click.stop="disConnect(item,index)" v-for="item, index in PairEquip"
v-show="PairEquip.length>0">
<view class="leftImg ">
<image src="/static/images/common/bluetooth.png" class="titleIco filterNone"
mode="heightFix">
@ -34,7 +35,7 @@
</view>
<view class="centertxt ">
<view class="name" v-text="item.name"></view>
</view>
<view class="rightIco center">
<image src="/static/images/BLEAdd/linked.png" class="img" mode="aspectFit">
@ -50,10 +51,8 @@
<text>发现设备:{{deviceCnt}}</text>
<view @click="refreshBleList()">刷新</view>
</view>
<view class="lblTitle">
<input class="uni-input" v-model="search" placeholder="名称筛选" />
<!-- <uni-easyinput :styles="{color:'#ffffffde',borderColor:'#cbcbcba8'}" :clearable="true" class="uni-mt-5" :trim="'both'"
prefixIcon="search" v-model="search" placeholder="名称筛选"></uni-easyinput> -->
<view class="">
<input class="uni-input" v-model="search" placeholder="名称筛选" />
</view>
<view class="list searchList">
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
@ -165,7 +164,7 @@
},
search: '', //筛选
PairEquip: [], //已配对设备
tmpLink:[],//本次已配对
tmpLink: [], //本次已配对
EquipMents: [], //搜索出来的设备
device: null,
item: {
@ -224,8 +223,8 @@
const systemInfo = uni.getSystemInfoSync();
// Ensure ble is initialized
// Ensure ble is initialized
if (systemInfo.uniPlatform == 'web') {
@ -253,15 +252,15 @@
];
console.error("1111111111")
this.PairEquip=[this.EquipMents[0]];
this.PairEquip = [this.EquipMents[0]];
return;
}
ble = bleTool.getBleTool();
this.refreshLinked();
this.refreshLinked();
let StartSubsrib = () => {
these.EquipMents = [];
if (!ble) {
ble = bleTool.getBleTool();
@ -366,31 +365,31 @@
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI); //信号好的排前面,一般信号好的是目标设备
}
}, pagePath);
//蓝牙连接已恢复的回调
ble.addRecoveryCallback(res => {
if (these.Status.isPageHidden) {
return;
}
these.refreshLinked();
// hideLoading(these);
if (!these.device) {
if (!these.device) {
hideLoading(these);
}else{
} else {
clearInterval(this.Status.intval);
these.DeviceVerdict(res.deviceId);
}
}, pagePath);
}
let startValidDevice = () => {
if (these.device) {
console.log("进入配对模式,启用连接恢复和验证逻辑。");
//收到设备的消息回调
ble.addReceiveCallback((receivData, f, path, arr) => {
@ -412,7 +411,7 @@
showLoading(these, {
text: '正在验证设备'
});
setTimeout(() => {
these.DeviceVerdict(f.deviceId);
}, 0);
@ -424,7 +423,7 @@
StartSubsrib();
},
@ -437,19 +436,19 @@
this.refreshLinked();
},
methods: {
refreshLinked(){
if(ble){
let arr=[];
arr=ble.data.LinkedList.filter(v=>{
refreshLinked() {
if (ble) {
let arr = [];
arr = ble.data.LinkedList.filter(v => {
return v.Linked;
});
this.PairEquip=arr;
this.PairEquip = arr;
}
},
checkAndRequestLocationPermission() {
return new Promise((resolve) => {
@ -500,7 +499,8 @@
}
const hasPermission = await this.checkAndRequestLocationPermission();
if (!hasPermission) {
console.log("缺少定位权限,已中止蓝牙扫描。");
MsgError('缺少定位权限,已中止蓝牙扫描', '', this);
return;
}
@ -524,19 +524,19 @@
time = setTimeout(() => {
these.EquipMents = [];
ble.StartSearch().then(result => {
// console.log("开始搜索成功", result);
these.Status.BottomMenu.show=false;
these.Status.BottomMenu.show = false;
}).catch(err => {
console.error("开始搜索失败:", err);
if (err.code === 10001) {
these.showOpenSetting();
} else {
MsgClear(these);
MsgError('出现错误:' + err.msg, '确定', these);
MsgError('出现错误:' + err.msg, '确定', these, () => {
MsgClear(these);
});
}
}).finally(() => {
@ -580,9 +580,9 @@
ble.showBlueSetting(false);
},
DeviceVerdict(deviceId) { //判断是否是目标设备
if (these.Status.isPageHidden) {
return;
}
if (these.Status.isPageHidden) {
return;
}
console.log("deviceid=", deviceId);
console.log("these.device=", these.device)
if (these.device) { //从设备详情过来的,回设备详情去
@ -681,7 +681,7 @@
text: "等待设备上报Mac地址," + these.Status.time + 's'
});
clearInterval(this.Status.intval);
this.Status.intval = null;
@ -708,7 +708,7 @@
}
updateLoading(these, {
text: "等待设备上报Mac地址," + these.Status.time + 's'
});
@ -729,7 +729,7 @@
let index = 1;
let total = 5;
let linkCallback = (res) => {
let linkCallback = (res) => {
console.log("连接成功", these.device);
if (!these.device) {
console.log("跳转到绑定")
@ -746,12 +746,12 @@
});
return;
}
}
let execLink = () => {
return new Promise((resolve, reject) => {
if (index > total) {
reject({
msg: "连接超时"
@ -759,7 +759,7 @@
return;
}
ble.LinkBlue(item.deviceId).then((res) => {
this.tmpLink=[item];
this.tmpLink = [item];
console.log("连接成功");
ble.StopSearch();
resolve(res);
@ -767,9 +767,9 @@
if (index == total) {
console.log("连接了N次都没连上");
reject(ex);
updateLoading(this, {
text: ex.msg
})
updateLoading(this, {
text: ex.msg
})
return;
}
index++;
@ -786,7 +786,7 @@
execLink().then((res) => {
console.log("res=", res);
if(this.Status.isPageHidden){
if (this.Status.isPageHidden) {
return;
}
linkCallback(res);
@ -802,21 +802,21 @@
},
disConnect:function(item,index){
disConnect: function(item, index) {
// #ifdef H5|WEB
this.PairEquip.splice(index,1);
this.PairEquip.splice(index, 1);
// #endif
// #ifdef APP|APP-PLUS
if(ble){
ble.disconnectDevice(item.deviceId).catch(ex=>{
console.error("无法断开连接",ex);
if (ble) {
ble.disconnectDevice(item.deviceId).catch(ex => {
console.error("无法断开连接", ex);
});
}
// #endif
}
}
}

View File

@ -486,13 +486,11 @@
MsgError('蓝牙不可用','',these);
these.EquipMents.filter((v, i) => {
these.$set(these.EquipMents[i], 'link', false);
});
these.EquipMents=[];
}, pagePath);
ble.addStateRecoveryCallback(() => {
these.ReSearch();
MsgSuccess('蓝牙恢复可用','',these,()=>{
MsgClear(these);
})
@ -557,6 +555,7 @@
setTimeout(()=>{
debugger;
MsgInfo("如需要在PC上查看此数据,请复制链接后通过微信发送到PC,在PC端打开然后点右上角扫码授权","复制链接",these,true,()=>{
console.log("执行复制");
uni.setClipboardData({
@ -566,10 +565,18 @@
title:'已复制链接'
});
// #ifdef APP
plus.runtime.openURL('weixin://', (err) => {
MsgError("打开微信失败,请手动打开微信,发送至'文件传输助手'");
});
// #endif
// #ifndef APP
MsgInfo("已复制链接,请打开浏览器查看","",these);
setTimeout(()=>{
MsgClear(these);
},1200)
// #endif
},
fail(ex){
console.error("无法复制",ex)
@ -878,9 +885,10 @@
},
ReSearch() {
if (!ble) {
MsgError('蓝牙模块未初始化','',this);
return;
}
showLoading(this,{text:'请稍候...'});
ble.disconnectDevice().finally(dis => {
ble.StopSearch().finally(res => {
@ -893,6 +901,8 @@
}).catch(err => {
console.error("err=", err);
MsgError("出现错误:" + err.msg, '', these);
}).finally(()=>{
hideLoading(these);
});
},200);

View File

@ -9,57 +9,64 @@
</view>
</view>
</scroll-view>
<scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
style="height:80vh">
<view v-if="deviceList.length>0">
<view v-for="(group, groupIndex) in groupedDevices" :key="groupIndex">
<view class="share-header">
<text>{{
<view style="height: calc(100% - 200rpx);">
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback"
:up="upOption" :down="downOption" :fixed="false">
<!-- <scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
style="height:80vh"> -->
<view v-if="deviceList.length>0">
<view v-for="(group, groupIndex) in groupedDevices" :key="groupIndex">
<view class="share-header">
<text>{{
tabs[activeTab].name === '我的分享'
? `分享给“${group.sharedTo}”的设备`
: `来自“${group.othersharedTo}”分享的设备`
}}</text>
<text class="edit-btn"
@click="toggleEdit(groupIndex)">{{editingGroup === groupIndex ? '完成' : '编辑'}}</text>
</view>
<block>
<text class="edit-btn"
@click="toggleEdit(groupIndex)">{{editingGroup === groupIndex ? '完成' : '编辑'}}</text>
</view>
<block>
<view class="device-card" v-for="(item, index) in group.devices" :key="index"
:ref="'swipeItem_' + index">
<view class="checkbox" v-if="editingGroup === groupIndex">
<uni-icons @click="handleDelete(item)" type="minus" size="20"
color="#FF4D4F"></uni-icons>
</view>
<view class="device-content" @click.stop="handleFile(item)">
<view class="device-header">
<view class="deviceIMG">
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
</view>
<view class="device-name">
<view>设备:{{item.deviceName}}</view>
<view class="ID">
<view class="device-card" v-for="(item, index) in group.devices" :key="index"
:ref="'swipeItem_' + index">
<view class="checkbox" v-if="editingGroup === groupIndex">
<uni-icons @click="handleDelete(item)" type="minus" size="20"
color="#FF4D4F"></uni-icons>
</view>
<view class="device-content" @click.stop="handleFile(item)">
<view class="device-header">
<view class="deviceIMG">
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
</view>
<view class="device-name">
<view>设备:{{item.deviceName}}</view>
<view class="ID">
ID:{{item.deviceImei}}</view>
<!-- 在线状态 -->
<view class="onlines" v-if="item.onlineStatus==1">在线</view>
<!-- 离线状态 -->
<view class="offlines" v-if="item.onlineStatus==0">离线</view>
<view>电量{{item.battery || '0'}}%</view>
<view class="ID">
ID:{{item.deviceImei}}</view>
<!-- 在线状态 -->
<view class="onlines" v-if="item.onlineStatus==1">在线</view>
<!-- 离线状态 -->
<view class="offlines" v-if="item.onlineStatus==0">离线</view>
<view>电量{{item.battery || '0'}}%</view>
</view>
</view>
</view>
</view>
</view>
</view>
</block>
</block>
</view>
</view>
</view>
<view v-else class="noDATA">
<!-- <view v-else class="noDATA">
<view>
<uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
</view>
暂无数据
</view>
</scroll-view>
</view> -->
<!-- </scroll-view> -->
</mescroll-uni>
</view>
</view>
<!-- 删除弹框 -->
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')">
@ -81,6 +88,7 @@
</template>
<script>
var timeout=null;
import {
deviceShareList,
otherDeviceShareList,
@ -89,6 +97,23 @@
export default {
data() {
return {
mescroll: null,
downOption: {
auto: true,
autoShowLoading: false,
},
upOption: {
auto: false,
noMoreSize: 0,
offset: 10,
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: '没有更多数据了'
},
deviceList: [],
tabs: [{
name: '我的分享',
@ -131,6 +156,28 @@
},
methods: {
mescrollInit(mescroll) {
this.mescroll = mescroll;
},
// 下拉刷新
downCallback() {
if (this.mescroll) {
this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0, 0);
}
this.getData();
},
// 上拉加载
upCallback() {
this.getData();
},
// 点击弹框外的区域关闭
closePopup(type) {
if (type === 'delete') {
@ -142,12 +189,13 @@
let url = item.detailPageUrl;
uni.navigateTo({
// url: "/pages/6170/deviceControl/index",
url:url,
url: url,
success: (res) => {
// 页面跳转成功后的回调函数
res.eventChannel.emit('detailData', {
data: item,
apiType:this.activeTab===0?'listA':'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
apiType: this.activeTab === 0 ? 'listA' :
'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
});
}
})
@ -200,43 +248,59 @@
},
// 获取设备列表
getData(tab) {
//console.log(tab.name, 'tab');
if (this.loading) return;
this.loading = true;
let data = {
pageNum: this.page,
pageSize: this.size,
}
// 根据当前tab决定调用哪个接口
const apiCall = tab.name === '我的分享' ? deviceShareList : otherDeviceShareList;
console.log('nihao');
apiCall(data).then((res) => {
if (res.code == 200) {
const newDevices = res.rows.map(device => ({
...device,
showConfirm: false,
sharedTo: device.phonenumber,
othersharedTo: device.otherPhonenumber
}));
// 分页处理
if (this.page === 1) {
this.deviceList = newDevices;
} else {
this.deviceList = [...this.deviceList, ...newDevices];
}
this.total = res.total;
// 判断是否已加载全部数据
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
this.finished = true;
} else {
this.page++;
}
let task = () => {
if (this.loading) return;
this.loading = true;
let data = {
pageNum: this.mescroll.num,
pageSize: this.size,
}
}).finally(() => {
this.loading = false;
});
if (!data.pageNum) {
this.mescroll.endSuccess(0, false);
return;
}
// 根据当前tab决定调用哪个接口
const apiCall = this.tabs[this.activeTab].name === '我的分享' ? deviceShareList : otherDeviceShareList;
console.log('nihao');
apiCall(data).then((res) => {
if (res.code == 200) {
const newDevices = res.rows.map(device => ({
...device,
showConfirm: false,
sharedTo: device.phonenumber,
othersharedTo: device.otherPhonenumber
}));
// 分页处理
if (this.page === 1) {
this.deviceList = newDevices;
} else {
this.deviceList = [...this.deviceList, ...newDevices];
}
this.total = res.total;
let hasNext = true;
// 判断是否已加载全部数据
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
this.finished = true;
hasNext = false;
} else {
this.page++;
hasNext = true;
}
this.mescroll.endSuccess(res.rows.length, hasNext);
}else{
this.mescroll.endSuccess(0, false);
}
}).finally(() => {
this.loading = false;
});
}
clearTimeout(timeout);
timeout = setTimeout(task, 50);
},
// 滚动触底事件处理
@ -254,7 +318,7 @@
},
beforeDestroy() {
// 组件销毁前移除监听器
},
}
</script>
@ -267,6 +331,9 @@
min-height: 100vh;
background-color: rgb(18, 18, 18);
padding: 30rpx;
width: 100%;
height: 100vh;
box-sizing: border-box;
}
.tab-bar {

View File

@ -196,7 +196,8 @@
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
hideScroll: false,
icon: '/static/images/common/empty.png'
}
},
page: 1, // 当前页码

View File

@ -117,6 +117,13 @@
sendApi: deviceSendAlarmMessage,
statusTypeName: '',
sendType: 'XSSend'
},
,
{
type: ['HBY018A'],
sendApi: deviceSendAlarmMessage,
statusTypeName: '',
sendType: 'CommonSend'
}
]
},
@ -134,7 +141,8 @@
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: '没有更多数据了'
},

View File

@ -29,10 +29,10 @@
<view v-if="deviceList.length>0">
<uni-swipe-action ref="swipeAction" >
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
<uni-swipe-action-item :right-options="Options"
<uni-swipe-action-item :right-options="Options" :show="item.showOption"
@click="handleSwipeClick($event, item, index)" class="device-card"
:style="{ border: item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
<view @click.stop="handleFile(item)">
<view @click.stop="handleFile(item,index)">
<view class="device-header">
<view class="deviceIMG">
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
@ -62,7 +62,7 @@
</view>
</view>
</view>
<image src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
<image @click.stop="swipeToggle(item,index)" src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
</uni-swipe-action-item>
</block>
</uni-swipe-action>
@ -242,7 +242,8 @@
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: '没有更多数据了'
},
@ -697,13 +698,20 @@
}
})
},
swipeToggle(item,index){
if(!item.showOption || item.showOption=='none'){
this.$set(this.deviceList[index],'showOption','right');
return;
}
this.$set(this.deviceList[index],'showOption','none');
},
// 列表跳转
handleFile(item) {
let url = item.detailPageUrl;
// url="/pages/6075/BJQ6075L";
// if(!url){
// url="/pages/6075/BJQ6075"
// }
handleFile(item,index) {
if(item.showOption=='right'){
this.$set(this.deviceList[index],'showOption','none');
return;
}
let url = item.detailPageUrl;
uni.navigateTo({
url: url,
events: {
@ -773,7 +781,7 @@
});
// 监听设备状态更新事件
uni.$on('deviceStatusUpdate', (data) => {
console.log('列表收到消息了么');
// console.log('列表收到消息了么');
this.downCallback();
});
ble = bleTool.getBleTool();
@ -805,9 +813,9 @@
//接收到消息的回调
ble.addReceiveCallback((receive, device, path, recArr) => {
console.error("首页收到消息了");
// console.error("首页收到消息了");
let json=recei.ReceiveData(receive, device, path, recArr);
console.error("消息内容",json);
// console.error("消息内容",json);
this.updateBleStatu();
}, pagePath);
@ -1148,7 +1156,7 @@
border-radius: 40rpx;
padding: 30rpx;
text-align: center;
border: 1px solid #E034344d;
border: 1px solid #E0343480;
}
@ -1161,7 +1169,7 @@
}
.agreement-popupC .cancelBtn{
border:1rpx solid #E034344d;
border:1rpx solid #E03434;
color:#E03434;
}

View File

@ -113,7 +113,8 @@
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: '没有更多数据了'
},

View File

@ -0,0 +1,398 @@
<template>
<view class="maincontent contentBg">
<view class='btnAdd' @click="showEdit(null,null)">添加</view>
<view class="clear"></view>
<view v-for="item,index in list" v-if="item" class="item">
<view class="itemTitle">紧急联系人{{index+1}}</view>
<view class="center main">
<view class="phone">{{item}}</view>
<view class="btns">
<view class="btnEdit" @click.stop="showEdit(item,index)">修改</view>
<view class="btnDrop" @click.stop="dropPerson(item,index)">删除</view>
</view>
</view>
<view class="line" v-if="index%2==0"></view>
</view>
<mescroll-empty v-show="calcList.length==0" :option="Status.optEmpty"></mescroll-empty>
<!-- 编辑弹窗 -->
<MsgBox ref="editPop">
<view>
修改紧急联系人
</view>
<view class="w60">
<input type="text" placeholder="输入手机号" class="uni-input" v-model="cEdit.txt" />
</view>
</MsgBox>
<MsgBox ref="msgPop" />
<global-loading ref="loading" />
</view>
</template>
<script>
import request from '@/utils/request.js';
import {
showLoading,
hideLoading,
updateLoading
} from '@/utils/loading.js';
import {
MsgSuccess,
MsgError,
MsgClose,
MsgWarning,
showPop,
MsgInfo,
MsgPrompt
} from '@/utils/MsgPops.js'
import Common from '@/utils/Common.js';
var these = null;
var eventChannel = null;
export default {
data() {
return {
list: ['', ''],
cEdit: {
txt: '',
index: -1
},
Status: {
optEmpty: {
tip: '暂无数据',
icon: '/static/images/common/empty.png'
}
},
device: {
id: "",
deviceName: "",
deviceImei: "",
deviceMac: "",
communicationMode: 0,
devicePic: "",
typeName: "",
bluetoothName: null,
deviceStatus: null,
bindingTime: "",
onlineStatus: 0,
battery: "0",
latitude: null,
longitude: null,
alarmStatus: null,
detailPageUrl: "/pages/650/HBY650",
showConfirm: false
}
}
},
computed: {
calcList() {
let f = this.list.filter((v, i) => {
return v;
});
return f;
}
},
onUnload() {
},
onShow() {
},
onHide: function() {
},
onLoad() {
these = this;
eventChannel = this.getOpenerEventChannel();
eventChannel.on('device', (data) => {
console.log("收到父页面的参数:" + JSON.stringify(data));
these.device = data;
this.list[0] = data.contact1Phone;
this.list[1] = data.contact2Phone;
});
},
methods: {
notifyPrevPage(){//通知上一个页面
if (eventChannel) {
eventChannel.emit('linkManOver', this.list);
}
},
saveData(json) {
return request({
url: "/app/hby018a/device/SetContactPhone",
method: 'POST',
data:json
});
},
dropPerson(item, index) {
showPop({
iconUrl: '/static/images/common/dell.png',
borderColor: "#e034344d",
buttonBgColor: "#E03434",
bgColor: '#383934cc',
buttonTextColor: '#FFFFFFde',
message: "确定删除紧急联系人" + (index + 1),
buttonText: '确定',
showSlot: false,
showCancel: true,
buttonCancelText: '取消',
okCallback: () => {
let url = '/app/hby018a/device/SetContactPhone';
if (!url) {
this.$set(this.list,index,"");
return;
}
let json = {
deviceId: this.device.id,
contact1Phone:index == 0 ? "" : this.list[0],
contact2Phone: index == 0 ? this.list[1] : ""
};
showLoading(these,{text:'请稍候...'});
this.saveData(json).then(res => {
if (res && res.code == 200) {
this.$set(this.list,index,"");
this.notifyPrevPage();
return;
}
MsgError(res.msg, '', these);
}).catch(ex => {
MsgError(ex.msg, '', these);
}).finally(() => {
hideLoading(these)
});
}
}, these, false);
},
showEdit(item, index) {
if (!item && this.calcList.length >= 2) {
MsgError('紧急联系人数量达到上限', '', these);
return;
}
if (item) {
this.cEdit.txt = item;
this.cEdit.index = index;
} else {
this.cEdit.index = this.calcList.length;
}
MsgPrompt(these, 'editPop', () => {
if (this.cEdit.txt.replace(/ /g, '') == '') {
MsgError('请输入联系人号码', '', these);
return true;
}
let reg = /^1\d{10}$/;
if (!reg.test(this.cEdit.txt)) {
MsgError('手机号格式不正确', '', these);
return true;
}
if (item) {
let f = this.list.find((v, i) => {
if (i == index) {
return false;
}
if (v == this.cEdit.txt) {
return true;
}
return false;
});
if (f) {
MsgError('已设置了相同的手机号', '', these);
return true;
}
}
let requestCall = () => {
this.$set(this.list, this.cEdit.index, this.cEdit.txt)
this.cEdit.txt = "";
this.cEdit.index = -1;
}
let url = '/app/hby018a/device/SetContactPhone';
if (!url) {
requestCall();
return;
}
let json = {
deviceId: this.device.id,
contact1Phone: this.cEdit.index == 0 ? this.cEdit.txt : this.list[0],
contact2Phone: this.cEdit.index == 0 ? this.list[1] : this.cEdit.txt
};
showLoading(these,{text:'请稍候...'});
this.saveData(json).then(res => {
if (res && res.code == 200) {
requestCall();
this.notifyPrevPage();
return;
}
MsgError(res.msg, '', these);
}).catch(ex => {
MsgError(ex.msg, '', these);
}).finally(() => {
hideLoading(these)
});
}, false);
}
}
}
</script>
<style>
.item .main {
margin-top: 10rpx;
}
.line {
width: 100%;
height: 0rpx;
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
margin: 30rpx 0rpx 20rpx 0rpx;
}
.phone {
border-radius: 8px;
background: rgba(26, 26, 26, 1);
width: calc(100% - 160rpx);
height: 80rpx;
line-height: 80rpx;
text-indent: 20rpx;
}
.btns .btnEdit {
color: rgba(255, 255, 255, 0.87);
margin-right: 20rpx;
}
.btns .btnDrop {
color: rgba(224, 52, 52, 1);
}
.btns {
width: 160rpx;
height: 80rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
align-items: center;
justify-content: flex-end;
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.07px;
text-align: left;
}
.itemTitle {
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
line-height: 40rpx;
height: 40rpx;
letter-spacing: 0.07px;
text-align: left;
}
.w60 {
width: 70%;
margin-left: 15%;
}
.uni-input {
margin: 30rpx 0rpx 0rpx 0rpx;
background-color: #121212;
width: 100%;
height: 60rpx;
color: #ffffffde;
border: 1rpx solid #BBE600de;
border-radius: 8rpx;
font-size: 26rpx;
text-indent: 8rpx;
font-family: "PingFang SC";
line-height: 60rpx;
caret-color: #BBE600;
font-weight: 200;
text-align: left;
text-indent: 10rpx;
}
.btnAdd {
float: right;
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
line-height: 40rpx;
height: 40rpx;
letter-spacing: 0.07px;
text-align: left;
}
.content {
padding: 30rpx;
width: 100%;
min-height: 100vh;
height: auto;
}
.navbarRight .img {
width: 35rpx;
height: 35rpx;
margin-right: 20rpx;
}
.uni-navbar--fixed {
top: 0rpx;
}
/deep/ .uni-navbar--fixed {
top: 0px;
}
/deep/ .uni-navbar__placeholder {
display: none !important;
}
</style>

View File

@ -0,0 +1,251 @@
<template>
<view class="maincontent contentBg">
<view class="text-content">
<view class="uni-textarea">
<textarea class="textarea" v-model="txt" placeholder-class="placehoderClass"
placeholder="SOS求救短信内容二十字以内" :auto-height="true" maxlength="20" cursor-color="#BBE600" />
</view>
</view>
<view class="footBtn">
<view class="fright convert" @click.stop="saveTxt()">保存</view>
<view class="clear"></view>
</view>
<view class="title">常用短信</view>
<view class="staItem" v-for="item,index in list" @click="copyTo(item,index)">{{item}}</view>
<MsgBox ref="msgPop" />
<global-loading ref="loading" />
</view>
</template>
<script>
import request from '@/utils/request.js';
import {
showLoading,
hideLoading,
updateLoading
} from '@/utils/loading.js';
import {
MsgSuccess,
MsgError,
MsgClose,
MsgWarning,
showPop,
MsgInfo
} from '@/utils/MsgPops.js'
import Common from '@/utils/Common.js';
var these = null;
var eventChannel = null;
export default {
data() {
return {
txt: '',
oldTxt:'',
list: ['出现危险,速来救我!', '被困险境,万分危急,求援!', '生死关头,请立刻报警'],
device: {
id: "",
deviceName: "",
deviceImei: "",
deviceMac: "",
communicationMode: 0,
devicePic: "",
typeName: "",
bluetoothName: null,
deviceStatus: null,
bindingTime: "",
onlineStatus: 0,
battery: "0",
latitude: null,
longitude: null,
alarmStatus: null,
detailPageUrl: "",
showConfirm: false
}
}
},
computed: {
},
onUnload() {
},
onShow() {
},
onHide: function() {
},
onLoad() {
these = this;
eventChannel = this.getOpenerEventChannel();
eventChannel.on('device', (data)=> {
console.log("收到父页面的参数:" + JSON.stringify(data));
these.device = data;
if(data.sosSmsMsg){
this.txt=data.sosSmsMsg;
}
});
},
methods: {
copyTo(item, index) {
this.txt = item;
},
saveTxt() {
if (this.txt.replace(/ /g, '') == '') {
MsgError('请输入通知内容', '', these);
return;
}
showLoading(this, {
text: '请稍候...'
});
console.log("this.device=",this.device);
request({
url: '/app/hby018a/device/SetSmsMsg',
method: 'POST',
data: {
sendMsg: this.txt,
deviceIds: [this.device.id]
}
}).then(res => {
if (res && res.code == 200) {
MsgSuccess('操作成功', '', these);
if(eventChannel){
eventChannel.emit('MsgOver', this.txt);
}
return;
}
MsgError(res.msg, '', these);
}).catch(ex => {
MsgError('出现错误,操作失败', '', these);
}).finally(() => {
hideLoading(these)
})
}
}
}
</script>
<style>
.staItem {
width: 100%;
height: 80rpx;
line-height: 80rpx;
border-radius: 8px;
background: rgba(26, 26, 26, 1);
text-indent: 30rpx;
color: rgba(255, 255, 255, 0.6);
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.07px;
margin-bottom: 25rpx;
}
.title {
color: rgba(255, 255, 255, 0.87);
margin: 15rpx 0rpx;
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
line-height: 40rpx;
width: 100%;
height: 40rpx;
letter-spacing: 0.07px;
text-align: left;
}
.footBtn .convert {
/* 组合 99 */
width: 130rpx;
height: 55rpx;
line-height: 55rpx;
border-radius: 180px;
color: #232323;
background-color: #AED600;
text-align: center;
font-family: 'PingFang SC';
font-size: 24rpx;
font-weight: 400;
letter-spacing: 12rpx;
}
.placehoderClass {
color: rgba(255, 255, 255, 0.6);
font-family: PingFang SC;
font-size: 32rpx;
font-weight: 400;
line-height: 44rpx;
letter-spacing: 0.14px;
}
.textarea {
min-height: 200rpx;
width: 100%;
box-sizing: border-box;
}
.text-content {
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
width: 100%;
height: auto;
box-sizing: border-box;
padding: 20rpx;
margin-bottom: 20rpx;
}
.content {
padding: 30rpx;
width: 100%;
min-height: 100vh;
height: auto;
}
.navbarRight .img {
width: 35rpx;
height: 35rpx;
margin-right: 20rpx;
}
.uni-navbar--fixed {
top: 0rpx;
}
/deep/ .uni-navbar--fixed {
top: 0px;
}
/deep/ .uni-navbar__placeholder {
display: none !important;
}
</style>

View File

@ -1,7 +1,7 @@
<template>
<view class="pageContent">
<image src="/static/images/common/login.png" mode="" class="login-bg"></image>
<view class="content_con">
<view class="content_con" @click="account">
<view class="user_logo">
<image src="/static/images/common/logo.png" class="logo"></image>
</view>
@ -37,14 +37,14 @@
<text class="title">关于我们</text>
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
</view>
<view class="menu-item" @click="logOff">
<!-- <view class="menu-item" @click="logOff">
<image src="/static/images/common/zhuxiao.png" class="icon"></image>
<text class="title">注销账号</text>
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
</view>
</view> -->
<view class="menu-item" @click="account">
<image src="/static/images/common/wm.png" class="icon"></image>
<text class="title">账号安全</text>
<text class="title">账号</text>
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
</view>
<view class="btn_footer">