set-trend-world.js
2.74 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
let tip = require('plugin/tip');
let dialog = require('plugin/dialog');
$('.show-explain').on('click', function() {
$('.show-explain').hide();
$('.explain-main').css({height: 'auto'});
});
$('.hide-explain').on('click', function() {
$('.show-explain').show();
$('.explain-main').css({height: 0});
});
// 埋点
function point(type, trend) {
let pointJosn = {
TYPE: type
};
if (trend) {
pointJosn.TREND = trend;
}
if ($('.yoho-page').hasClass('my-page')) {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_HOMEPOP_TREND_SET_C',
param: JSON.stringify(pointJosn)
}, true);
}
} else if ($('.yoho-page').hasClass('my-promotion-page') && trend) {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_MYPROMOTION_TREND_SET_C',
appop: 'YB_H5_MYPROMOTION_TREND_SET_C',
param: JSON.stringify({
TREND: trend
})
}, true);
}
}
}
$('.set-world').click(function() {
let trendWord = $('.trend-world-area').val();
$.ajax({
type: 'GET',
url: '/activity/set-trend-world',
data: {
trendWord: trendWord
},
success: function(result) {
tip.show(result.message);
if (result.code === 200) {
let copyUrl = `//m.yohobuy.com/?openby:yohobuy={"action":"go.copy","params":{"text":"${trendWord}","message":"复制成功"}}`; // eslint-disable-line
point(1, $('.trend-world-area').val());
if ($('.yoho-page').hasClass('my-page')) {
$('.trend-code').html('# ' + $('.trend-world-area').val() + ' #');
} else {
$('.trend-code').html($('.trend-world-area').val());
}
$('.copy.button').eq(0).attr('href', copyUrl);
setTimeout(function() {
$('.set-trend-world').hide();
}, 2500);
}
}
});
});
$('.withhold').click(function() {
if ((!window.cookie('trend-path') || parseInt(window.cookie('trend-path'), 10) !== 1) &&
/^\/home/.test(location.pathname)) {
dialog.showDialog({
dialogText: '您还可以在“个人中心-基本资料-我的潮流口令”中进行设置',
hasFooter: {
centerBtnText: '我知道了'
}
});
window.setCookie('trend-path', 1);
}
point(2);
$('.set-trend-world').hide();
});
$('.set-trend-world').on('mousewheel touchmove', function(e) {
e.preventDefault();
return false;
});