new_file.html
5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>新增邮寄地址</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<meta name="format-detection" content="email=no" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="">
<meta name="google" value="notranslate"><!-- 禁止Chrome 浏览器中自动提示翻译 -->
<link rel="stylesheet" type="text/css" href="../../../../iconfont/iconfont.css"/>
<link href="../../../../css/reset.css" rel="stylesheet"/>
</head>
<style>
.maildizhis{
}
.maildizhis li{
padding: 10px;
border: 1px solid #000;
}
</style>
<body>
<ul class="maildizhis">
<li data-id="2" class="aa" onclick="tj(this);">222</li>
<li data-id="1" class="a1" onclick="tj(this);">222</li>
</ul>
<br />
<br />
<button class="addressbtn">新增地址</button>
</body>
</html>
<script src="../../../../js/jquery-3.2.1.min.js"></script>
<script src="../../../../js/zepto.js"></script>
<script src="../../../../js/soft/layer.js"></script>
<!--md5 start-->
<script src="http://cdn.bootcss.com/blueimp-md5/1.1.0/js/md5.js?v=1.1"></script>
<script src="http://cdn.bootcss.com/blueimp-md5/1.1.0/js/md5.min.js?v=1.1"></script>
<!--md5 end-->
<script src="../../../../js/url.js"></script>
<script src="../../../../js/ajax.js"></script>
<script>
//点击长按 start
var t,t1=0;
var pointer = document.querySelector('.maildizhis li');
var cancelTimeout = function() {
if(t) {
clearTimeout(t);
t = null;
}
};
$('body').on('touchstart','.maildizhis li',function(e){
var obj = $(this).attr('class');
var id = $(this).attr('data-id');
t = setTimeout(function() {
console.log(obj);
inputc(obj,id);
cancelTimeout();
t1 = t1+1;
console.log("hhhd "+t1);
}, 900);
e.preventDefault();
return false;
})
$('body').on('touchend','.maildizhis li',function(){
var id = $(this).attr('data-id');
console.log(" tt "+t+"t1 "+t1);
if(t1!=1){
window.location.href = 'addressInfo.html?id='+id;
}
t1 = 0;
cancelTimeout();
})
$('body').on('touchcancel','.maildizhis li',function(){
cancelTimeout();
});
//点击niput
function inputc(obj,id){
//页面层
func.index = layer.open({
type: 1,
skin: 'layui-layer-rim', //加上边框
area: ['420px', '240px'], //宽高
content: '<div class="layselect" data-id="'+id+'" data-d="'+obj+'"> <div class="def">设置为默认</div> <div class="delete">删除</div> </div>'
});
}
//end
//点击调转到详情页面
function tj(obj){
alert('sbs');
}
var func = {
index:''
}
$(function(){
//获取上一页地址 start
/*var urll = document.referrer;
var arrurl = urll.split('/');
console.log(arrurl.length);
console.log(arrurl[arrurl.length-1]);*/
//end
$('body').on('click','.addressbtn',function(){
window.location.href = 'addAddress.html';
});
//选择点击进入详情
$('body').on('click','.maildizhis li',function(){
console.log('sb');
/*var id = $(this).attr('data-id');
console.log('跳转详情 '+id);
window.location.href = 'addressInfo.html?id='+id;*/
});
//点击设置为默认
$('body').on('click','.layselect .def',function(){
var d = $(this).parent().attr('data-d');
var id = $(this).parent().attr('data-id');
$('.'+d).children('.ultype').children().children().children().children('.uldicon').addClass('actived');
$('.'+d).siblings().children('.ultype').children().children().children().children('.uldicon').removeClass('actived')
layer.close(func.index);
console.log(d);
});
//点击删除
$('body').on('click','.layselect .delete',function(){
var d = $(this).parent().attr('data-d');
var id = $(this).parent().attr('data-id');
console.log(d);
deleteAddr(id,function(data){
console.log(JSON.stringify(data));
if(data.code==0){
$('.'+d).fadeOut(300);
setTimeout(function(){
$('.'+d).remove();
},300);
layer.close(func.index);
}
})
});
});
//删除一条地址
function deleteAddr(id,fn){
var salt = jsajax.salt(32);
var token = mUrl.GetToken();
var sortd = [
{keyname:'app_id',value:'0eca8f5373ca4866aec2f8e9d9367104'},
{keyname:'deviceInfo',value:'BC0703A4-AFB0-4B51-9089-9B7487C0CC6E'},
{keyname:'salt',value:salt},
{keyname:'sign_type',value:'md5'},
{keyname:'token',value:token},
{keyname:'id',value:id}
];
var mdsign = jsajax.getsign(sortd);
var jsond = {
app_id : "0eca8f5373ca4866aec2f8e9d9367104",
deviceInfo : "BC0703A4-AFB0-4B51-9089-9B7487C0CC6E",
salt : salt,
sign : mdsign,
sign_type : "md5",
token : token,
id:id
}
console.log("数据 "+JSON.stringify(jsond));
jsajax.defaultReq(
mUrl.deleteaddress,
JSON.stringify(jsond),
function(data){
fn(data);
}
);
}
</script>