设备控制页上传logo图联调
This commit is contained in:
@ -187,8 +187,12 @@
|
|||||||
<view class="example-body">
|
<view class="example-body">
|
||||||
<!-- <uni-file-picker limit="1" class="custom-file-picker"></uni-file-picker> -->
|
<!-- <uni-file-picker limit="1" class="custom-file-picker"></uni-file-picker> -->
|
||||||
<view class="icoContent" @click="checkImgUpload">
|
<view class="icoContent" @click="checkImgUpload">
|
||||||
<image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png">
|
<!-- <image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png">
|
||||||
</image>
|
</image> -->
|
||||||
|
<image v-if="selectedImage" :src="selectedImage" mode="aspectFit" class="img"
|
||||||
|
style="width: 100%; height: 100%;"></image>
|
||||||
|
<image v-else mode="aspectFit" class="img"
|
||||||
|
src="/static/images/6155/DeviceDetail/add.png"></image>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="example_title">点击上传图片</view> -->
|
<!-- <view class="example_title">点击上传图片</view> -->
|
||||||
</view>
|
</view>
|
||||||
@ -238,7 +242,11 @@
|
|||||||
import {
|
import {
|
||||||
getDeviceId
|
getDeviceId
|
||||||
} from '../../../store/BLETools';
|
} from '../../../store/BLETools';
|
||||||
|
import {
|
||||||
|
baseURL,
|
||||||
|
getToken,
|
||||||
|
clientid
|
||||||
|
} from '@/utils/request'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -278,7 +286,9 @@
|
|||||||
showPopupFlag: false, //是否显示弹框
|
showPopupFlag: false, //是否显示弹框
|
||||||
popupMessage: '!',
|
popupMessage: '!',
|
||||||
popupConfirmText: '确认',
|
popupConfirmText: '确认',
|
||||||
showUploadPopup: false
|
showUploadPopup: false,
|
||||||
|
selectedImage: null, // 添加这个变量来存储选择的图片
|
||||||
|
file: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -288,9 +298,9 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// *******定位******
|
// *******定位******
|
||||||
gpsPosition(){
|
gpsPosition() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/pages/common/map/index'
|
url: '/pages/common/map/index'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// ***********进度条***********
|
// ***********进度条***********
|
||||||
@ -370,38 +380,75 @@
|
|||||||
checkImgUpload() {
|
checkImgUpload() {
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1,
|
count: 1,
|
||||||
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
sizeType: ['original', 'compressed'],
|
||||||
sourceType: ['album', 'camera'], //从相册,相机选择,,
|
sourceType: ['album', 'camera'],
|
||||||
success: function(res) {
|
success: (res) => {
|
||||||
uni.navigateTo({
|
// 将选择的图片赋值给selectedImage
|
||||||
url: "/pages/6155/ImgCrop",
|
const file = res.tempFiles[0];
|
||||||
events: {
|
const fileSize = file.size || 0;
|
||||||
ImgCutOver: function(data) {
|
if (fileSize > 2 * 1024 * 1024) {
|
||||||
console.log("我收到裁剪后的图片了,感谢老铁," + data)
|
console.log(`文件过大: ${fileSize} 字节`); // 调试日志
|
||||||
uni.showLoading({
|
uni.showToast({
|
||||||
title: "正在发送..."
|
title: '图片大小不能超过2MB',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 3000
|
||||||
});
|
});
|
||||||
setTimeout(function() {
|
return;
|
||||||
processAndSendImageData(data).catch(() => {});
|
|
||||||
}, 0)
|
|
||||||
}
|
}
|
||||||
|
this.selectedImage = res.tempFilePaths[0];
|
||||||
|
console.log('选择的图片:', res);
|
||||||
|
this.file = res.tempFiles[0].file
|
||||||
},
|
},
|
||||||
success(ev) {
|
fail: (err) => {
|
||||||
ev.eventChannel.emit('checkImg', {
|
console.error('选择图片失败:', err);
|
||||||
data: res.tempFiles[0].path
|
uni.showToast({
|
||||||
})
|
title: '选择图片失败',
|
||||||
},
|
icon: 'none'
|
||||||
fail(ex) {
|
|
||||||
console.log("跳转页面失败" + JSON.stringify(ex));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 上传开机画面确认按键
|
// 上传开机画面确认按键
|
||||||
handleupload() {
|
handleupload() {
|
||||||
|
uni.uploadFile({
|
||||||
|
url: baseURL + '/app/device/uploadLogo',
|
||||||
|
filePath: this.selectedImage,
|
||||||
|
name:this.file,
|
||||||
|
formData: {
|
||||||
|
deviceId: this.deviceID,
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
'Authorization': 'Bearer ' + getToken(),
|
||||||
|
'clientid': clientid(),
|
||||||
|
},
|
||||||
|
complete: (res) => {
|
||||||
|
console.log(res, 'resss');
|
||||||
|
try {
|
||||||
|
const responseData = JSON.parse(res.data);
|
||||||
|
if (responseData.code === 200) {
|
||||||
|
uni.showToast({
|
||||||
|
title: responseData.msg,
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
this.selectedImage=''
|
||||||
this.lightModeB = false
|
this.lightModeB = false
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: responseData.msg,
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '上传失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
// 分享
|
// 分享
|
||||||
shareUp() {
|
shareUp() {
|
||||||
@ -634,11 +681,11 @@
|
|||||||
const statusTopic = `A/${this.itemInfo.deviceImei}`;
|
const statusTopic = `A/${this.itemInfo.deviceImei}`;
|
||||||
this.mqttClient.subscribe(statusTopic, (payload) => {
|
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||||
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
|
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
|
||||||
uni.showModal({
|
// uni.showModal({
|
||||||
title: '收到设备消息',
|
// title: '收到设备消息',
|
||||||
content: payload,
|
// content: payload,
|
||||||
showCancel: false
|
// showCancel: false
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (this.apiType === 'listA') {
|
if (this.apiType === 'listA') {
|
||||||
@ -894,7 +941,7 @@
|
|||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
background: rgba(58, 58, 58, 1);
|
background: rgba(58, 58, 58, 1);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height:200rpx;
|
line-height: 200rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.img {
|
.img {
|
||||||
|
@ -189,7 +189,6 @@
|
|||||||
.device-content {
|
.device-content {
|
||||||
background-color: rgb(26, 26, 26);
|
background-color: rgb(26, 26, 26);
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
margin-bottom: 20rpx;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
/* display: flex; */
|
/* display: flex; */
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
Reference in New Issue
Block a user