reverse()数组逆转
1、json字符串转json对象,调用parse方法
var ob = JSON.parse(data);
1
2、json对象转为json字符串,调用JSON.stringify()方法
var str = JSON.stringify(data);
//遮罩层样式
.mask-ll{
display: none;
background-color: black;
/position: absolute;/
position:fixed;
width: 100%;
height: 100%;
top:50%;
left:50%;
transform:translateX(-50%) translateY(-50%);
z-index: 8888;
opacity: 0.6;
/filter: alpha(opacity=50)-moz-opacity: 0.5;/
/display: none;/
}
弹窗样式
.popup-ll {
display: none;
width: 40%;
height: 250px;
background-color: #fff;
position:fixed;
top:50%;
left:50%;
transform:translateX(-50%) translateY(-50%);
z-index: 9999;
border-radius: 10px;
text-align: center;
padding-top: 30px;
}
ios 兼容问题 IOS 前端 时间乱码(ios时间显示NaN) new Date(“2019-04-12 17:30:00”.replace(/-/g,’/’)).getTime()
上传的图片 安卓机和苹果机显示问题
getPicture() {
let data = {
url:window.location.href.split(’#’)[0]
}
this.$http.post('wechat/wxUtil/WXscan.json',data,{emulateJSON: true}).then(result =>{
// console.log(result.body);
wx.config({
debug: false, // 开启调试模式,
appId: 'wx138b48eadbbb7ea4', // 必填,企业号的唯一标识,此处填写企业号corpid
timestamp: result.body.Object.timestamp, // 必填,生成签名的时间戳
nonceStr: result.body.Object.nonceStr, // 必填,生成签名的随机串
signature: result.body.Object.signature,// 必填,签名,见附录1
jsApiList: ['checkJsApi','chooseImage', 'uploadImage','translateVoice','getLocalImgData','downloadImage'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
});
wx.ready(function () {
// 在这里调用 API
wx.checkJsApi({
jsApiList: [ 'checkJsApi','chooseImage', 'uploadImage', 'translateVoice','getLocalImgData', 'downloadImage' ],
success: function (res) {
// console.log(JSON.stringify(res));
}
});
});
// 错误时
wx.error(function (res) {
alert("出错了:" + res.errMsg);//这个地方的好处就是wx.config配置错误,会弹出窗口哪里错误,然后根据微信文档查询即可。
});
})
},
uploadPhone () {
let that = this
// this.show =true
wx.chooseImage({
count: 1, // 默认9
// needResult: 1,
sizeType: ['original'], // 指定是原图还是压缩图,默认都有
sourceType: ['album', 'camera'], // 指定来源是相册还是相机,默认都有
success: function (res) {
// console.log(res);
// alert('扫描结果:'+res)
var localId = res.localIds[0].toString(); // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
wx.getLocalImgData({
localId: localId, // 图片的localID
success: function(res) {
var localData = res.localData;
if(window.__wxjs_is_wkwebview){
that.Phoneimg =localData.replace('jgp', 'jpeg') //如果是ios显示这张图
if (localData.indexOf('data:image') != 0) {
//判断是否有这样的头部
localData = 'data:image/jpeg;base64,' + localData
}
localData = localData.replace(/\r|\n/g, '').replace('data:image/jgp', 'data:image/jpeg')
let data = {
file:localData,
userId:localStorage.getItem('userid')
}
that.$http.post('rest/face/faceDevice/registerFace',data,{emulateJSON: true}).then(result=> {
// alert('上传成功')
if(result.body.CODE==='0') {
that.$toast(result.body.MESSAGE);
}else {
that.$toast(result.body.MESSAGE);
that.Phoneimg =require('../img/人脸录入@3x.png')
}
})
} else{
if (localData.indexOf('data:image') != 0) {
//判断是否有这样的头部
localData = 'data:image/jpeg;base64,' + localData.replace(/\n/g,""); //在拼接前需要对localData进行换行符的全局替换
}
that.Phoneimg =localId;//如果是安卓直接显示这张图
let data = {
file:localData,
userId:localStorage.getItem('userid')
}
that.$http.post('rest/face/faceDevice/registerFace',data,{emulateJSON: true}).then(result=> {
// alert('上传成功')
if(result.body.CODE==='0') {
that.$toast(result.body.MESSAGE);
}else {
that.$toast(result.body.MESSAGE);
that.Phoneimg =require('../img/人脸录入@3x.png')
}
})
}
}
});
}
});
},
ios点击失效事件 加native
数组去重
let arr = [1, 2, 3, 3, 3, ‘0’, ‘1’, ‘2’, ‘测试’, ‘重复’, ‘重复’, NaN, NaN, false, false];
let temp =[];
for(let i = 0; i < arr.length; i++) {
if( !temp.includes( arr[i]) ) {//includes 检测数组是否有某个值 内部调用Object.is() 利用判断NaN
temp.push(arr[i]);
}
}
console.log(temp);//去重后: [ 1, 2, 3, ‘0’, ‘1’, ‘2’, ‘测试’, ‘重复’, NaN, false ]
var arr=[2,8,5,0,5,2,6,7,2];
function unique1(arr){
var hash=[];
for (var i = 0; i < arr.length; i++) {
if(hash.indexOf(arr[i])==-1){
hash.push(arr[i]);
}
}
return hash;
}
筛选过后的分页问题
//获取接收列表
getRevTableForm() {
let that = this;
this.loading = true;
let params = {
pageNo: this.revPageNo,
pageSize: this.revPageSize
};
if(this.siteState){
params.siteState = this.siteState
}
this.$api
.getRevSiteManage(params)
.then(res => {
that.loading = false
this.revTableDataForm = []
this.revTableDataForm = res.RESULT.list;
this.revTableCount = res.RESULT.count;
})
.catch(err => {
that.loading = false;
console.log(err + “服务器错误”);
});
},
if (command.label == ‘验收通过’) {
this.$confirm(‘确认根据 验收通过 筛选吗?’, ‘筛选提示’, {
confirmButtonText: ‘确定’,
cancelBut