message.page.js
1.62 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
/**
* 我的信息
* @author: yyqing<yanqing.yang@yoho.cn>
* @date: 2016/3/21
*/
var $ = require('yoho-jquery');
var Dialog = require('../common/dialog');
var $container = $('#message-main-container');
var $pickBtn = $('.pick-coupon-btn');
var pickBusy = false;
var Alert = Dialog.Alert,
Confirm = Dialog.Confirm;
require('../common');
function msgOperation(data) {
if (!data) {
return;
}
$.ajax({
type: 'GET',
url: '/home/message/del',
data: data
}).then(function(jsonData) {
if (jsonData.code === 200) {
window.location.reload();
} else {
new Alert(jsonData.message);
}
});
}
$container.on('click', '.del-btn', function() {
var data = $(this).data();
if (data.id) {
new Confirm({
content: '您确定要删除这条短消息?',
cb: function() {
msgOperation(data);
}
}).show();
}
});
$('.show-birth-coupon').click(function() {
var $this = $(this);
$this.siblings('.birth-coupon-wrap').show();
$this.hide().siblings('p').hide();
$(window).scrollTop(0);
});
$pickBtn.click(function() {
var data = $(this).data();
if (pickBusy) {
return;
}
pickBusy = true;
$.ajax({
type: 'GET',
url: '/home/message/pickCoupon',
data: data
}).then(function(jsonData) {
var msg = jsonData.message;
if (jsonData.code === 200) {
msg = '领取成功';
$(this).removeClass('pick-coupon-btn');
}
pickBusy = false;
new Alert(msg);
});
});