获取元素距离顶部的距离
const query = uni.createSelectorQuery()
query.select('XXX').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec(function(res){
res[0].top;
})
js数组中改变元素的位置——互换,置顶,上移,下移
function swapArr(arr, index1, index2) {
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
return arr;
}
function toFirst(fieldData,index) {
if(index!=0){
fieldData.unshift(fieldData.splice(index , 1)[0]);
}
}
function upGo(fieldData,index){
if(index!=0){
fieldData[index] = fieldData.splice(index-1, 1, fieldData[index])[0];
}else{
fieldData.push(fieldData.shift());
}
}
function downGo(fieldData,index) {
if(index!=fieldData.length-1){
fieldData[index] = fieldData.splice(index+1, 1, fieldData[index])[0];
}else{
fieldData.unshift( fieldData.splice(index,1)[0]);
}
}
oss图片裁剪
?x-oss-process=image/crop,x_100,y_50,w_100,h_100
APP隐私弹窗
{
"version" : "1",
"prompt" : "template",
"title" : "用户协议和隐私政策",
"message" : " 请你务必审慎阅读、充分理解“用户协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/> 你可阅读<a href=\"https://XXX\">《用户协议》</a>和<a href=\"https://XXX\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。",
"buttonAccept" : "同意并接受",
"buttonRefuse" : "暂不同意",
"hrefLoader" : "system|default",
"second" : {
"title" : "确认提示",
"message" : " 进入应用前,你需先同意<a href=\"https://XXX\">《用户协议》</a>和<a href=\"https://XXX\">《隐私政策》</a>,否则将退出应用。",
"buttonAccept" : "同意并继续",
"buttonRefuse" : "退出应用"
},
"styles" : {
"backgroundColor" : "#FFFFFF",
"borderRadius" : "10px",
"title" : {
"color" : "#333333"
},
"buttonAccept" : {
"color" : "#333333"
},
"buttonRefuse" : {
"color" : "#9B9AB9"
}
}
}
APP微信登录
let isWx = plus.runtime.isApplicationExist({
pname:'com.tencent.mm',action:'weixin://'});
if(!isWx){
return false;
}
uni.getProvider({
service: 'oauth',
success: