...
|
...
|
@@ -3,10 +3,8 @@ import Page from 'js/yoho-page'; |
|
|
import $ from 'yoho-jquery';
|
|
|
import tip from 'js/plugin/tip';
|
|
|
import dialog from 'js/plugin/dialog';
|
|
|
import fillInHbs from 'hbs/activity/have-gain/fill-in.hbs';
|
|
|
import yoho from 'js/yoho-app';
|
|
|
import parse from 'yoho-qs/parse';
|
|
|
import Clipboard from 'clipboard';
|
|
|
import cookie from 'yoho-cookie';
|
|
|
import linkTo from '../../../utils/linkTo';
|
|
|
|
...
|
...
|
@@ -17,11 +15,6 @@ class HaveGainApplyPage extends Page { |
|
|
this.selector = {
|
|
|
isFlag: false,
|
|
|
$apply: $('.have-gain-apply'),
|
|
|
$nameInput: $('.section .name'),
|
|
|
$mobileInput: $('.section .mobile'),
|
|
|
$wxInput: $('.section .wechat'),
|
|
|
$fillIn: $('.party-icon-item .fill-in'),
|
|
|
$added: $('.other .added'),
|
|
|
$agreement: $('.agreement-section .agreement'),
|
|
|
$applyBtn: $('.apply-btn'),
|
|
|
};
|
...
|
...
|
@@ -30,61 +23,13 @@ class HaveGainApplyPage extends Page { |
|
|
}
|
|
|
|
|
|
init() {
|
|
|
let that = this;
|
|
|
let clipboard = new Clipboard('.added', {
|
|
|
text: function() {
|
|
|
return '有货有赚';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
new Clipboard('.apply-btn', {
|
|
|
text: function() {
|
|
|
return '有货有赚';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
clipboard.on('success', function(e) {
|
|
|
that.copyDialog();
|
|
|
e.clearSelection();
|
|
|
});
|
|
|
|
|
|
clipboard.on('error', function() {
|
|
|
that.copyDialog();
|
|
|
});
|
|
|
|
|
|
this.bindEvents();
|
|
|
}
|
|
|
|
|
|
copyDialog() {
|
|
|
let ua = navigator.userAgent.toLowerCase();
|
|
|
let isWeixin = ua.indexOf('micromessenger') !== -1;
|
|
|
let hasFooter = {
|
|
|
leftBtnText: '取消',
|
|
|
rightBtnText: '去添加'
|
|
|
};
|
|
|
|
|
|
if (isWeixin) {
|
|
|
hasFooter = {
|
|
|
centerBtnText: '确认'
|
|
|
};
|
|
|
}
|
|
|
|
|
|
dialog.showDialog({
|
|
|
dialogText: '“有货有赚”服务号已经复制,请去微信搜索添加',
|
|
|
hasClass: 'dialog-text-apply',
|
|
|
hasFooter: hasFooter
|
|
|
}, function() {
|
|
|
window.location.href = 'weixin://';
|
|
|
});
|
|
|
}
|
|
|
|
|
|
bindEvents() {
|
|
|
let that = this;
|
|
|
|
|
|
this.jumpVerify();
|
|
|
this.selector.$nameInput.on('input', this.changeBtnStatus.bind(this));
|
|
|
this.selector.$mobileInput.on('input', this.changeBtnStatus.bind(this));
|
|
|
this.selector.$fillIn.on('click', that.tapFillIn.bind(this));
|
|
|
this.selector.$agreement.on('click', that.tapAgreement);
|
|
|
this.selector.$applyBtn.on('click', this.apply.bind(this));
|
|
|
}
|
...
|
...
|
@@ -126,72 +71,6 @@ class HaveGainApplyPage extends Page { |
|
|
}
|
|
|
}
|
|
|
|
|
|
changeBtnStatus() {
|
|
|
let errStatus = 0;
|
|
|
let name = $.trim(this.selector.$nameInput.val());
|
|
|
let mobile = $.trim(this.selector.$mobileInput.val());
|
|
|
|
|
|
if (name === '') {
|
|
|
errStatus = 1;
|
|
|
} else if (mobile === '') {
|
|
|
errStatus = 2;
|
|
|
} else if (!/^1[0-9]{10}$/.test(mobile)) {
|
|
|
errStatus = 21;
|
|
|
}
|
|
|
|
|
|
if (errStatus) {
|
|
|
this.selector.$applyBtn.addClass('disable');
|
|
|
return errStatus;
|
|
|
}
|
|
|
|
|
|
this.selector.$applyBtn.removeClass('disable');
|
|
|
|
|
|
return errStatus;
|
|
|
}
|
|
|
|
|
|
tapFillIn(event) {
|
|
|
let _this = this;
|
|
|
let $event = $(event.target);
|
|
|
|
|
|
if ($event.hasClass('disable')) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
let $accountName = $event.closest('.party-icon-item').find('.account-name');
|
|
|
|
|
|
dialog.showDialog({
|
|
|
hasHeader: '填写信息',
|
|
|
hasClass: 'dialog-fill-apply',
|
|
|
dialogText: fillInHbs({
|
|
|
account: $accountName.find('em').eq(0).text() || '',
|
|
|
fans: $accountName.find('em').eq(1).data('fans') || ''
|
|
|
}),
|
|
|
hasFooter: {
|
|
|
leftBtnText: '取消',
|
|
|
rightBtnText: '确定'
|
|
|
}
|
|
|
}, function() {
|
|
|
let account = $.trim($('.dialog-fill-apply .account').val() || '');
|
|
|
let fans = $.trim($('.dialog-fill-apply .fans').val() || '');
|
|
|
let fansFix = Math.round((fans / 10000) * 100) / 100; // 保留二个小数
|
|
|
|
|
|
if (!account) {
|
|
|
return tip.show('请输入账号昵称');
|
|
|
}
|
|
|
|
|
|
if (fans === '') {
|
|
|
return tip.show('请输入粉丝数量');
|
|
|
}
|
|
|
|
|
|
fansFix = fansFix >= 10 ? fansFix + '万' : fans;
|
|
|
|
|
|
$accountName.html(`账号:<em>${account}</em> 粉丝:<em data-fans="${fans}">${fansFix}</em>`); // eslint-disable-line
|
|
|
dialog.hideDialog();
|
|
|
_this.changeBtnStatus();
|
|
|
$event.text('已填写').addClass('disable');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
tapAgreement(event) {
|
|
|
let $event = $(event.target);
|
|
|
|
...
|
...
|
@@ -199,7 +78,11 @@ class HaveGainApplyPage extends Page { |
|
|
return true;
|
|
|
}
|
|
|
|
|
|
$event.hasClass('activate') ? $event.removeClass('activate') : $event.addClass('activate');
|
|
|
if ($event.hasClass('activate')) {
|
|
|
$event.removeClass('activate');
|
|
|
} else {
|
|
|
$event.addClass('activate');
|
|
|
}
|
|
|
}
|
|
|
clickFun() {
|
|
|
let env = linkTo.getEnv();
|
...
|
...
|
@@ -216,37 +99,14 @@ class HaveGainApplyPage extends Page { |
|
|
}
|
|
|
}
|
|
|
apply() {
|
|
|
let errStatus = this.changeBtnStatus();
|
|
|
let socialMediaList = [];
|
|
|
|
|
|
let union = linkTo.getQueryObj();
|
|
|
|
|
|
if (errStatus === 1) {
|
|
|
tip.show('请输入姓名');
|
|
|
} else if (errStatus === 2) {
|
|
|
tip.show('请输入手机号');
|
|
|
} else if (errStatus === 21) {
|
|
|
tip.show('请输入正确的手机号');
|
|
|
}
|
|
|
|
|
|
if (errStatus) {
|
|
|
$('html,body').animate({scrollTop: 0}, 'slow');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!this.selector.$agreement.hasClass('activate')) {
|
|
|
return tip.show('请勾选《我已阅读并同意》');
|
|
|
}
|
|
|
|
|
|
let wxAccount = $.trim(this.selector.$wxInput.val());
|
|
|
|
|
|
if (wxAccount) {
|
|
|
socialMediaList.push({
|
|
|
type: 1,
|
|
|
account: wxAccount
|
|
|
});
|
|
|
}
|
|
|
|
|
|
let unionTypeYas = cookie.get('unionTypeYas');
|
|
|
|
|
|
if (unionTypeYas) {
|
...
|
...
|
@@ -266,10 +126,7 @@ class HaveGainApplyPage extends Page { |
|
|
return this.ajax({
|
|
|
type: 'post',
|
|
|
url: `/activity/have-gain/submitApply${window.location.search}`,
|
|
|
data: Object.assign({
|
|
|
name: $.trim(this.selector.$nameInput.val()),
|
|
|
mobile: $.trim(this.selector.$mobileInput.val())
|
|
|
}, union)
|
|
|
data: union
|
|
|
}).then(res => {
|
|
|
this.selector.isFlag = false;
|
|
|
|
...
|
...
|
|