Files
PropertyDeployment/resources/Web/MicroCommunityWeb/html/components/room/roomMeterQrcode/roomMeterQrcode.js
2025-12-09 20:22:03 +08:00

153 lines
6.2 KiB
JavaScript

(function (vc) {
vc.extends({
data: {
roomMeterQrcodeInfo: {
meterType: '',
roomId: '',
objId: '',
objName: '',
feeTypeCd: '',
feeConfigs: [],
configId: '',
objType: '3333',
hasRoom: false,
ownerName: '',
typeName:'',
meterTypes: [],
showQrcode:false,
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('roomMeterQrcode', 'openRoomMeterQrcodeModal', function (_param) {
$that.clearRoomMeterQrcodeInfo();
$that.roomMeterQrcodeInfo.hasRoom = true;
$that.roomMeterQrcodeInfo.roomId = _param.roomId;
$that.roomMeterQrcodeInfo.objId = _param.roomId;
// $that.roomMeterQrcodeInfo.objName = _param.roomName.replace('0单元', ''); //处理商铺
$that.roomMeterQrcodeInfo.objName = $that.transRoomName(_param.roomName);
let _ownerName = _param.roomName;
if (_param.ownerName) {
_ownerName += ('(' + _param.ownerName + ')');
}
$that.roomMeterQrcodeInfo.ownerName = _ownerName;
$('#roomMeterQrcodeModel').modal('show');
$that._listRoomMeterTypes();
});
vc.on("roomMeterQrcode", "notify", function (_param) {
if (_param.hasOwnProperty("roomId") && _param.roomId != "") {
$that.roomMeterQrcodeInfo.roomId = _param.roomId;
$that.roomMeterQrcodeInfo.objId = _param.roomId;
// $that.roomMeterQrcodeInfo.objName = _param.name.replace('0单元', ''); //处理商铺;
$that.roomMeterQrcodeInfo.objName = $that.transRoomName(_param.name);
$that._queryPreMeterWater(_param.roomId);
}
});
},
methods: {
// 将1-1-1 转化为 1栋1单元1室
transRoomName: function (roomName) {
// 没有-则返回
if (roomName.indexOf('-') < 0) {
return roomName;
}
roomName = roomName.split('-');
return roomName[0] + '栋' + roomName[1] + '单元' + roomName[2] + '室';
},
_generaotrMeterQrcode: function () {
let _configId = $that.roomMeterQrcodeInfo.configId;
let _meterType = $that.roomMeterQrcodeInfo.meterType;
let _roomId = $that.roomMeterQrcodeInfo.roomId;
if(!_configId || !_meterType || !_roomId){
return;
}
$that.roomMeterQrcodeInfo.meterTypes.forEach(_m => {
if(_m.typeId == _meterType){
$that.roomMeterQrcodeInfo.typeName = _m.typeName;
}
});
$that.roomMeterQrcodeInfo.showQrcode = true;
let _communityId = vc.getCurrentCommunity().communityId;
let _url = vc.getData('java110SystemInfo').propertyUrl;
_url += ("pages/meter/qrcodeMeter?configId="+_configId+"&meterType="+_meterType+"&roomId="+_roomId+"&communityId="+_communityId);
document.getElementById("roomMeterQrcodeDiv").innerHTML = "";
let qrcode = new QRCode(document.getElementById("roomMeterQrcodeDiv"), {
text: _url, //你想要填写的文本
width: 200, //生成的二维码的宽度
height: 200, //生成的二维码的高度
colorDark: "#000000", // 生成的二维码的深色部分
colorLight: "#ffffff", //生成二维码的浅色部分
correctLevel: QRCode.CorrectLevel.L
});
qrcode.makeCode(_url);
},
_changeMeterMeterWaterFeeTypeCd: function (_feeTypeCd) {
var param = {
params: {
page: 1,
row: 20,
communityId: vc.getCurrentCommunity().communityId,
feeTypeCd: _feeTypeCd,
isDefault: 'F',
valid: '1'
}
};
//发送get请求
vc.http.apiGet('/feeConfig.listFeeConfigs', param,
function (json, res) {
var _feeConfigManageInfo = JSON.parse(json);
$that.roomMeterQrcodeInfo.feeConfigs = _feeConfigManageInfo.feeConfigs;
},
function (errInfo, error) {
console.log('请求失败处理');
});
},
_listRoomMeterTypes: function (_page, _rows) {
let param = {
params: {
page: 1,
row: 50,
communityId: vc.getCurrentCommunity().communityId
}
};
//发送get请求
vc.http.apiGet('/meterType.listMeterType',
param,
function (json, res) {
let _json = JSON.parse(json);
$that.roomMeterQrcodeInfo.meterTypes = _json.data;
},
function (errInfo, error) {
console.log('请求失败处理');
}
);
},
clearRoomMeterQrcodeInfo: function () {
$that.roomMeterQrcodeInfo = {
meterType: '',
roomId: '',
objId: '',
objName: '',
feeTypeCd: '',
feeConfigs: [],
configId: '',
objType: '3333',
hasRoom: false,
ownerName: '',
meterTypes: [],
showQrcode:false,
typeName:'',
};
},
}
});
})(window.vc);