Authored by TaoHuang

add resource

... ... @@ -46,9 +46,11 @@ class HaveGain {
const apply = true;
return req.ctx(haveGainModel).checkApply({uid}, apply).then(result => {
return req.ctx(haveGainModel).checkApply({uid}, apply).then(([result, images]) => {
let checkUrl = result.data && result.data.checkUrl || '';
console.log(images);
if (checkUrl.indexOf('activity/have-gain/apply') === -1) {
// 302无法触发app识别、所以前端跳转
... ... @@ -57,6 +59,7 @@ class HaveGain {
page: 'have-gain-apply',
needJump: true,
jumpUrl: checkUrl,
images,
width750: true,
localCss: true,
title: '有货有赚',
... ... @@ -79,7 +82,8 @@ class HaveGain {
navTitle: '有货有赚',
navBtn: false
}),
wechatShare: true
wechatShare: true,
images
});
}).catch(next);
}
... ...
... ... @@ -54,7 +54,8 @@ module.exports = class extends global.yoho.BaseModel {
* @return {[type]} [{}]
*/
checkApply(params, apply) {
return this.get({
return Promise.all([
this.get({
data: Object.assign({
method: 'app.union.shareOrder.checkApply'
}, params)
... ... @@ -78,7 +79,21 @@ module.exports = class extends global.yoho.BaseModel {
_.set(res, 'data.checkUrl', checkUrl);
return res;
});
}),
this.get({
api: global.yoho.ServiceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: 'e5d5bcd09770a49341eaa16282cea7e5',
},
param: {
cache: true,
code: 200
}
}).then(result => {
return _.get(result, 'data', []).map((i) => i.data.src);
})
]);
}
/**
... ...
<div class="have-gain-apply" data-jump="{{needJump}}" data-url="{{jumpUrl}}">
{{#unless needJump}}
<div class="section">
<div class="apply-title">基本信息</div>
<ul class="section-ul">
<li>
<div class="label">姓名</div>
<div class="text">
<input type="text" class="name" placeholder="请输入姓名" />
</div>
</li>
<li>
<div class="label">手机号码</div>
<div class="text">
<input type="number" class="mobile" placeholder="请输入手机号码" />
</div>
</li>
<li>
<div class="label">微信号</div>
<div class="text">
<input type="text" class="wechat" placeholder="请输入微信号(选填)" />
</div>
</li>
</ul>
<p class="other">提供微信号,方便邀您加入达人微信群,赚钱秘籍、特殊福利享不停!<br/>添加关注公众号“有货有赚”,申请状态、高佣活动早知道。<em class="added">点击添加</em></p>
{{#images}}
<img src="{{image2 . w=750 h=500 q=80}}" alt="">
{{/images}}
</div>
<div class="agreement-section">
<div class="agreement">
我已阅读并同意<a href='{{agreementUrl}}'>《有货有赚推广协议》</a>
</div>
<div class="apply-btn disable">申请开通</div>
<div class="apply-btn">申请开通</div>
</div>
{{/unless}}
</div>
... ...
... ... @@ -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>&nbsp;&nbsp;粉丝:<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;
... ...
... ... @@ -9,8 +9,11 @@ body {
.section {
background-color: #fff;
padding: 0 30px;
margin-bottom: 30px;
margin-bottom: 220px;
img {
width: 100%;
}
.apply-title {
font-family: PingFang-SC-Medium, sans-serif;
... ... @@ -136,8 +139,8 @@ body {
bottom: 0;
left: 0;
right: 0;
margin: 30px 30px 0;
padding-bottom: 30px;
padding: 30px;
background-color: white;
.agreement {
margin-bottom: 28px;
... ...