blk 块
bar 栏
str 字符串
act 行为
mark 标记
label 标签
tag 标签
console.log();
//js跳转页面
window.location.reload();
window.location.replace('order.php')
window.location.href="users_edit.php?action=out";
// 延时执行
setTimeout(() => {
callback('你的真实H5地址');
}, 100);
//截取地址里的网址
var shareUrl = options.webViewUrl.replace(app.data.siteurl, '');
//js赋值
document.getElementById('loading').style.display="none";
document.getElementById("cartnum").innerHTML = '<img src="images/wmyoff.png">';
//退出登录
if($_GET['action']=="out"){
setcookie("usersid","",time()-3600,"/");
die("<script>location.replace('index.php');</script>");
}
//提交form
document.getElementById('myform').submit();
document.getElementById("cartwmy").innerHTML = '<img src="images/wmyoff.png">';
//js手指触摸屏幕事件
touchstart 当用户开始触摸屏幕时触发。
touchmove 当用户在不离开触摸屏幕的情况下移动手指时触发。
touchend 当用户停止触摸屏幕时触发。
//监听事件
document.addEventListener('touchend', function(event) {
alert("离开")
});
//js 把页面滚动到指定位置
window.scrollTo(0, 500);
//获取页面滚动位置
let scrollY = window.scrollY || window.pageYOffset || document.documentElement.scrollTop;
//小程序h5里关闭页面
wx.miniProgram.navigateBack();
//小程序关闭并跳转
wx.navigateBack({
delta: 1,
success() {
wx.redirectTo({
url: '/pages/show/index?pageurl=' + encodeURIComponent('/my/address_edit.php?fulladdress=' + res.address)
})
}
})
//小程序跳转h5共用页,链接调用方法如下
// wx.navigateTo({
// url: '/pages/h5/index?pageurl=newsshow.php' + encodeURIComponent("?id=") + id
// });
onShow() {
//给isMapOpened赋值+1
this.setData({ isMapOpened: this.data.isMapOpened + 1 });
console.log(this.data.roadurl);
//判断只要不是第一次,就刷新页面
if (this.data.isMapOpened==2) {
// this.setData({
// bindurl: app.data.siteurl + this.data.roadurl+"&tim=1"
// });
wx.navigateBack()
setTimeout(() => {
wx.navigateTo({
url: '/pages/show/index?pageurl='+encodeURIComponent(this.data.roadurl)
});
}, 100);
}
}
//css页面动画
body{background:linear-gradient(#ffde1b 10%, #f2f1f6 25%, #f2f1f6);background-attachment:fixed;padding-top:1px;}
/*划出动画*/
body{position:relative;-webkit-animation:slide-in 0.3s 1;}
@-webkit-keyframes slide-in{from{right:-300px}to{right:0px}}
//================================================================
// B页面
// 离开前存储当前地址
//localStorage.setItem('previousPage', window.location.href);
// A页面
// 防止页面刷新后滚动到头部
//document.addEventListener('touchend', function(event) {
// const scrollY = window.scrollY || window.pageYOffset || document.documentElement.scrollTop;
// localStorage.setItem('mallscrollY', scrollY);
//});
//
//// 读取上一个页面
//const previousPage = localStorage.getItem('previousPage');
//
//// 如果是mallShow页,就滚动到页面离开时的位置
//if(previousPage.includes("mallShow.php")){
// window.scrollTo(0, localStorage.getItem('mallscrollY'));
//}else{
// localStorage.setItem('mallscrollY', '');
//}
// 用完可以清除
//localStorage.removeItem('previousPage');
//================================================================
//已选择的商品
//for (let i = 0; i < mallCartArr.length; i++) {
// //alert( mallCartArr[i].mallid );
// let cartbtn = document.getElementById("cartbtn"+mallCartArr[i].mallid);
// if (cartbtn) {cartbtn.style.display = 'none';}
//
//let numbtn = document.getElementById("numbtn"+mallCartArr[i].mallid);
// if (numbtn) {numbtn.style.display = 'block';}
//
// let num = document.getElementById("num"+mallCartArr[i].mallid);
// if (num) {num.value = mallCartArr[i].number;}
//}
//加载购物车数据
function loadCartData3(userid) {
//统计有多少件商品
const mallCartData = localStorage.getItem('mallCart');
const mallCartArr = JSON.parse(mallCartData || '[]');
// 当前用户购物车数据
const userCartArr = mallCartArr.filter(item => item.userid === userid);
if(userCartArr.length === 0){
//console.log('当前用户购物车为空');
document.getElementById("totalnumber").style.display = 'none';
return;
}
//购买总数
const number = mallCartArr.reduce((sum, item) => sum + Number(item.number), 0);
if(number != 0){
document.getElementById("totalnumber").style.display = 'inline-block';
document.getElementById("totalnumber").innerHTML = number;
}
}
