|
@@ -3,10 +3,8 @@ import Page from 'js/yoho-page'; |
|
@@ -3,10 +3,8 @@ import Page from 'js/yoho-page'; |
3
|
import $ from 'yoho-jquery';
|
3
|
import $ from 'yoho-jquery';
|
4
|
import tip from 'js/plugin/tip';
|
4
|
import tip from 'js/plugin/tip';
|
5
|
import dialog from 'js/plugin/dialog';
|
5
|
import dialog from 'js/plugin/dialog';
|
6
|
-import fillInHbs from 'hbs/activity/have-gain/fill-in.hbs';
|
|
|
7
|
import yoho from 'js/yoho-app';
|
6
|
import yoho from 'js/yoho-app';
|
8
|
import parse from 'yoho-qs/parse';
|
7
|
import parse from 'yoho-qs/parse';
|
9
|
-import Clipboard from 'clipboard';
|
|
|
10
|
import cookie from 'yoho-cookie';
|
8
|
import cookie from 'yoho-cookie';
|
11
|
import linkTo from '../../../utils/linkTo';
|
9
|
import linkTo from '../../../utils/linkTo';
|
12
|
|
10
|
|
|
@@ -17,11 +15,6 @@ class HaveGainApplyPage extends Page { |
|
@@ -17,11 +15,6 @@ class HaveGainApplyPage extends Page { |
17
|
this.selector = {
|
15
|
this.selector = {
|
18
|
isFlag: false,
|
16
|
isFlag: false,
|
19
|
$apply: $('.have-gain-apply'),
|
17
|
$apply: $('.have-gain-apply'),
|
20
|
- $nameInput: $('.section .name'),
|
|
|
21
|
- $mobileInput: $('.section .mobile'),
|
|
|
22
|
- $wxInput: $('.section .wechat'),
|
|
|
23
|
- $fillIn: $('.party-icon-item .fill-in'),
|
|
|
24
|
- $added: $('.other .added'),
|
|
|
25
|
$agreement: $('.agreement-section .agreement'),
|
18
|
$agreement: $('.agreement-section .agreement'),
|
26
|
$applyBtn: $('.apply-btn'),
|
19
|
$applyBtn: $('.apply-btn'),
|
27
|
};
|
20
|
};
|
|
@@ -30,61 +23,13 @@ class HaveGainApplyPage extends Page { |
|
@@ -30,61 +23,13 @@ class HaveGainApplyPage extends Page { |
30
|
}
|
23
|
}
|
31
|
|
24
|
|
32
|
init() {
|
25
|
init() {
|
33
|
- let that = this;
|
|
|
34
|
- let clipboard = new Clipboard('.added', {
|
|
|
35
|
- text: function() {
|
|
|
36
|
- return '有货有赚';
|
|
|
37
|
- }
|
|
|
38
|
- });
|
|
|
39
|
-
|
|
|
40
|
- new Clipboard('.apply-btn', {
|
|
|
41
|
- text: function() {
|
|
|
42
|
- return '有货有赚';
|
|
|
43
|
- }
|
|
|
44
|
- });
|
|
|
45
|
-
|
|
|
46
|
- clipboard.on('success', function(e) {
|
|
|
47
|
- that.copyDialog();
|
|
|
48
|
- e.clearSelection();
|
|
|
49
|
- });
|
|
|
50
|
-
|
|
|
51
|
- clipboard.on('error', function() {
|
|
|
52
|
- that.copyDialog();
|
|
|
53
|
- });
|
|
|
54
|
-
|
|
|
55
|
this.bindEvents();
|
26
|
this.bindEvents();
|
56
|
}
|
27
|
}
|
57
|
|
28
|
|
58
|
- copyDialog() {
|
|
|
59
|
- let ua = navigator.userAgent.toLowerCase();
|
|
|
60
|
- let isWeixin = ua.indexOf('micromessenger') !== -1;
|
|
|
61
|
- let hasFooter = {
|
|
|
62
|
- leftBtnText: '取消',
|
|
|
63
|
- rightBtnText: '去添加'
|
|
|
64
|
- };
|
|
|
65
|
-
|
|
|
66
|
- if (isWeixin) {
|
|
|
67
|
- hasFooter = {
|
|
|
68
|
- centerBtnText: '确认'
|
|
|
69
|
- };
|
|
|
70
|
- }
|
|
|
71
|
-
|
|
|
72
|
- dialog.showDialog({
|
|
|
73
|
- dialogText: '“有货有赚”服务号已经复制,请去微信搜索添加',
|
|
|
74
|
- hasClass: 'dialog-text-apply',
|
|
|
75
|
- hasFooter: hasFooter
|
|
|
76
|
- }, function() {
|
|
|
77
|
- window.location.href = 'weixin://';
|
|
|
78
|
- });
|
|
|
79
|
- }
|
|
|
80
|
-
|
|
|
81
|
bindEvents() {
|
29
|
bindEvents() {
|
82
|
let that = this;
|
30
|
let that = this;
|
83
|
|
31
|
|
84
|
this.jumpVerify();
|
32
|
this.jumpVerify();
|
85
|
- this.selector.$nameInput.on('input', this.changeBtnStatus.bind(this));
|
|
|
86
|
- this.selector.$mobileInput.on('input', this.changeBtnStatus.bind(this));
|
|
|
87
|
- this.selector.$fillIn.on('click', that.tapFillIn.bind(this));
|
|
|
88
|
this.selector.$agreement.on('click', that.tapAgreement);
|
33
|
this.selector.$agreement.on('click', that.tapAgreement);
|
89
|
this.selector.$applyBtn.on('click', this.apply.bind(this));
|
34
|
this.selector.$applyBtn.on('click', this.apply.bind(this));
|
90
|
}
|
35
|
}
|
|
@@ -126,72 +71,6 @@ class HaveGainApplyPage extends Page { |
|
@@ -126,72 +71,6 @@ class HaveGainApplyPage extends Page { |
126
|
}
|
71
|
}
|
127
|
}
|
72
|
}
|
128
|
|
73
|
|
129
|
- changeBtnStatus() {
|
|
|
130
|
- let errStatus = 0;
|
|
|
131
|
- let name = $.trim(this.selector.$nameInput.val());
|
|
|
132
|
- let mobile = $.trim(this.selector.$mobileInput.val());
|
|
|
133
|
-
|
|
|
134
|
- if (name === '') {
|
|
|
135
|
- errStatus = 1;
|
|
|
136
|
- } else if (mobile === '') {
|
|
|
137
|
- errStatus = 2;
|
|
|
138
|
- } else if (!/^1[0-9]{10}$/.test(mobile)) {
|
|
|
139
|
- errStatus = 21;
|
|
|
140
|
- }
|
|
|
141
|
-
|
|
|
142
|
- if (errStatus) {
|
|
|
143
|
- this.selector.$applyBtn.addClass('disable');
|
|
|
144
|
- return errStatus;
|
|
|
145
|
- }
|
|
|
146
|
-
|
|
|
147
|
- this.selector.$applyBtn.removeClass('disable');
|
|
|
148
|
-
|
|
|
149
|
- return errStatus;
|
|
|
150
|
- }
|
|
|
151
|
-
|
|
|
152
|
- tapFillIn(event) {
|
|
|
153
|
- let _this = this;
|
|
|
154
|
- let $event = $(event.target);
|
|
|
155
|
-
|
|
|
156
|
- if ($event.hasClass('disable')) {
|
|
|
157
|
- return false;
|
|
|
158
|
- }
|
|
|
159
|
-
|
|
|
160
|
- let $accountName = $event.closest('.party-icon-item').find('.account-name');
|
|
|
161
|
-
|
|
|
162
|
- dialog.showDialog({
|
|
|
163
|
- hasHeader: '填写信息',
|
|
|
164
|
- hasClass: 'dialog-fill-apply',
|
|
|
165
|
- dialogText: fillInHbs({
|
|
|
166
|
- account: $accountName.find('em').eq(0).text() || '',
|
|
|
167
|
- fans: $accountName.find('em').eq(1).data('fans') || ''
|
|
|
168
|
- }),
|
|
|
169
|
- hasFooter: {
|
|
|
170
|
- leftBtnText: '取消',
|
|
|
171
|
- rightBtnText: '确定'
|
|
|
172
|
- }
|
|
|
173
|
- }, function() {
|
|
|
174
|
- let account = $.trim($('.dialog-fill-apply .account').val() || '');
|
|
|
175
|
- let fans = $.trim($('.dialog-fill-apply .fans').val() || '');
|
|
|
176
|
- let fansFix = Math.round((fans / 10000) * 100) / 100; // 保留二个小数
|
|
|
177
|
-
|
|
|
178
|
- if (!account) {
|
|
|
179
|
- return tip.show('请输入账号昵称');
|
|
|
180
|
- }
|
|
|
181
|
-
|
|
|
182
|
- if (fans === '') {
|
|
|
183
|
- return tip.show('请输入粉丝数量');
|
|
|
184
|
- }
|
|
|
185
|
-
|
|
|
186
|
- fansFix = fansFix >= 10 ? fansFix + '万' : fans;
|
|
|
187
|
-
|
|
|
188
|
- $accountName.html(`账号:<em>${account}</em> 粉丝:<em data-fans="${fans}">${fansFix}</em>`); // eslint-disable-line
|
|
|
189
|
- dialog.hideDialog();
|
|
|
190
|
- _this.changeBtnStatus();
|
|
|
191
|
- $event.text('已填写').addClass('disable');
|
|
|
192
|
- });
|
|
|
193
|
- }
|
|
|
194
|
-
|
|
|
195
|
tapAgreement(event) {
|
74
|
tapAgreement(event) {
|
196
|
let $event = $(event.target);
|
75
|
let $event = $(event.target);
|
197
|
|
76
|
|
|
@@ -199,7 +78,11 @@ class HaveGainApplyPage extends Page { |
|
@@ -199,7 +78,11 @@ class HaveGainApplyPage extends Page { |
199
|
return true;
|
78
|
return true;
|
200
|
}
|
79
|
}
|
201
|
|
80
|
|
202
|
- $event.hasClass('activate') ? $event.removeClass('activate') : $event.addClass('activate');
|
81
|
+ if ($event.hasClass('activate')) {
|
|
|
82
|
+ $event.removeClass('activate');
|
|
|
83
|
+ } else {
|
|
|
84
|
+ $event.addClass('activate');
|
|
|
85
|
+ }
|
203
|
}
|
86
|
}
|
204
|
clickFun() {
|
87
|
clickFun() {
|
205
|
let env = linkTo.getEnv();
|
88
|
let env = linkTo.getEnv();
|
|
@@ -216,37 +99,14 @@ class HaveGainApplyPage extends Page { |
|
@@ -216,37 +99,14 @@ class HaveGainApplyPage extends Page { |
216
|
}
|
99
|
}
|
217
|
}
|
100
|
}
|
218
|
apply() {
|
101
|
apply() {
|
219
|
- let errStatus = this.changeBtnStatus();
|
|
|
220
|
let socialMediaList = [];
|
102
|
let socialMediaList = [];
|
221
|
|
103
|
|
222
|
let union = linkTo.getQueryObj();
|
104
|
let union = linkTo.getQueryObj();
|
223
|
|
105
|
|
224
|
- if (errStatus === 1) {
|
|
|
225
|
- tip.show('请输入姓名');
|
|
|
226
|
- } else if (errStatus === 2) {
|
|
|
227
|
- tip.show('请输入手机号');
|
|
|
228
|
- } else if (errStatus === 21) {
|
|
|
229
|
- tip.show('请输入正确的手机号');
|
|
|
230
|
- }
|
|
|
231
|
-
|
|
|
232
|
- if (errStatus) {
|
|
|
233
|
- $('html,body').animate({scrollTop: 0}, 'slow');
|
|
|
234
|
- return false;
|
|
|
235
|
- }
|
|
|
236
|
-
|
|
|
237
|
if (!this.selector.$agreement.hasClass('activate')) {
|
106
|
if (!this.selector.$agreement.hasClass('activate')) {
|
238
|
return tip.show('请勾选《我已阅读并同意》');
|
107
|
return tip.show('请勾选《我已阅读并同意》');
|
239
|
}
|
108
|
}
|
240
|
|
109
|
|
241
|
- let wxAccount = $.trim(this.selector.$wxInput.val());
|
|
|
242
|
-
|
|
|
243
|
- if (wxAccount) {
|
|
|
244
|
- socialMediaList.push({
|
|
|
245
|
- type: 1,
|
|
|
246
|
- account: wxAccount
|
|
|
247
|
- });
|
|
|
248
|
- }
|
|
|
249
|
-
|
|
|
250
|
let unionTypeYas = cookie.get('unionTypeYas');
|
110
|
let unionTypeYas = cookie.get('unionTypeYas');
|
251
|
|
111
|
|
252
|
if (unionTypeYas) {
|
112
|
if (unionTypeYas) {
|
|
@@ -266,10 +126,7 @@ class HaveGainApplyPage extends Page { |
|
@@ -266,10 +126,7 @@ class HaveGainApplyPage extends Page { |
266
|
return this.ajax({
|
126
|
return this.ajax({
|
267
|
type: 'post',
|
127
|
type: 'post',
|
268
|
url: `/activity/have-gain/submitApply${window.location.search}`,
|
128
|
url: `/activity/have-gain/submitApply${window.location.search}`,
|
269
|
- data: Object.assign({
|
|
|
270
|
- name: $.trim(this.selector.$nameInput.val()),
|
|
|
271
|
- mobile: $.trim(this.selector.$mobileInput.val())
|
|
|
272
|
- }, union)
|
129
|
+ data: union
|
273
|
}).then(res => {
|
130
|
}).then(res => {
|
274
|
this.selector.isFlag = false;
|
131
|
this.selector.isFlag = false;
|
275
|
|
132
|
|