Authored by TaoHuang

add resource

@@ -46,9 +46,11 @@ class HaveGain { @@ -46,9 +46,11 @@ class HaveGain {
46 46
47 const apply = true; 47 const apply = true;
48 48
49 - return req.ctx(haveGainModel).checkApply({uid}, apply).then(result => { 49 + return req.ctx(haveGainModel).checkApply({uid}, apply).then(([result, images]) => {
50 let checkUrl = result.data && result.data.checkUrl || ''; 50 let checkUrl = result.data && result.data.checkUrl || '';
51 51
  52 + console.log(images);
  53 +
52 if (checkUrl.indexOf('activity/have-gain/apply') === -1) { 54 if (checkUrl.indexOf('activity/have-gain/apply') === -1) {
53 55
54 // 302无法触发app识别、所以前端跳转 56 // 302无法触发app识别、所以前端跳转
@@ -57,6 +59,7 @@ class HaveGain { @@ -57,6 +59,7 @@ class HaveGain {
57 page: 'have-gain-apply', 59 page: 'have-gain-apply',
58 needJump: true, 60 needJump: true,
59 jumpUrl: checkUrl, 61 jumpUrl: checkUrl,
  62 + images,
60 width750: true, 63 width750: true,
61 localCss: true, 64 localCss: true,
62 title: '有货有赚', 65 title: '有货有赚',
@@ -79,7 +82,8 @@ class HaveGain { @@ -79,7 +82,8 @@ class HaveGain {
79 navTitle: '有货有赚', 82 navTitle: '有货有赚',
80 navBtn: false 83 navBtn: false
81 }), 84 }),
82 - wechatShare: true 85 + wechatShare: true,
  86 + images
83 }); 87 });
84 }).catch(next); 88 }).catch(next);
85 } 89 }
@@ -54,31 +54,46 @@ module.exports = class extends global.yoho.BaseModel { @@ -54,31 +54,46 @@ module.exports = class extends global.yoho.BaseModel {
54 * @return {[type]} [{}] 54 * @return {[type]} [{}]
55 */ 55 */
56 checkApply(params, apply) { 56 checkApply(params, apply) {
57 - return this.get({  
58 - data: Object.assign({  
59 - method: 'app.union.shareOrder.checkApply'  
60 - }, params)  
61 - }).then(res => {  
62 - let checkStatus = _.get(res, 'data.status', 0); 57 + return Promise.all([
  58 + this.get({
  59 + data: Object.assign({
  60 + method: 'app.union.shareOrder.checkApply'
  61 + }, params)
  62 + }).then(res => {
  63 + let checkStatus = _.get(res, 'data.status', 0);
63 64
64 - let checkUrl = 'https://activity.yoho.cn/feature/2601.html?&title=有货有赚&openby:yohobuy={"action":"go.h5","params":{"title":"有货有赚","url":"https://activity.yoho.cn/feature/2601.html"}}'; // 中间页 65 + let checkUrl = 'https://activity.yoho.cn/feature/2601.html?&title=有货有赚&openby:yohobuy={"action":"go.h5","params":{"title":"有货有赚","url":"https://activity.yoho.cn/feature/2601.html"}}'; // 中间页
65 66
66 - if (apply) {  
67 - checkUrl = helpers.urlFormat('/activity/have-gain/apply', {}); // 未申请  
68 - } 67 + if (apply) {
  68 + checkUrl = helpers.urlFormat('/activity/have-gain/apply', {}); // 未申请
  69 + }
69 70
70 - if (checkStatus === 1) { // 审核中  
71 - checkUrl = helpers.urlFormat('/activity/have-gain/verify', {});  
72 - } else if (checkStatus === 2) { // 审核成功  
73 - checkUrl = helpers.urlFormat('') + '?title=有货有赚&openby:yohobuy={"action":"go.minealliance","params":{"type": "myAlliance", "title":"有货有赚"}}' // eslint-disable-line  
74 - } else if (checkStatus === 3) { // 申请拒绝  
75 - checkUrl = helpers.urlFormat('/activity/have-gain/fail', {});  
76 - } 71 + if (checkStatus === 1) { // 审核中
  72 + checkUrl = helpers.urlFormat('/activity/have-gain/verify', {});
  73 + } else if (checkStatus === 2) { // 审核成功
  74 + checkUrl = helpers.urlFormat('') + '?title=有货有赚&openby:yohobuy={"action":"go.minealliance","params":{"type": "myAlliance", "title":"有货有赚"}}' // eslint-disable-line
  75 + } else if (checkStatus === 3) { // 申请拒绝
  76 + checkUrl = helpers.urlFormat('/activity/have-gain/fail', {});
  77 + }
77 78
78 - _.set(res, 'data.checkUrl', checkUrl); 79 + _.set(res, 'data.checkUrl', checkUrl);
79 80
80 - return res;  
81 - }); 81 + return res;
  82 + }),
  83 + this.get({
  84 + api: global.yoho.ServiceAPI,
  85 + url: 'operations/api/v5/resource/get',
  86 + data: {
  87 + content_code: 'e5d5bcd09770a49341eaa16282cea7e5',
  88 + },
  89 + param: {
  90 + cache: true,
  91 + code: 200
  92 + }
  93 + }).then(result => {
  94 + return _.get(result, 'data', []).map((i) => i.data.src);
  95 + })
  96 + ]);
82 } 97 }
83 98
84 /** 99 /**
1 <div class="have-gain-apply" data-jump="{{needJump}}" data-url="{{jumpUrl}}"> 1 <div class="have-gain-apply" data-jump="{{needJump}}" data-url="{{jumpUrl}}">
2 {{#unless needJump}} 2 {{#unless needJump}}
3 <div class="section"> 3 <div class="section">
4 - <div class="apply-title">基本信息</div>  
5 - <ul class="section-ul">  
6 - <li>  
7 - <div class="label">姓名</div>  
8 - <div class="text">  
9 - <input type="text" class="name" placeholder="请输入姓名" />  
10 - </div>  
11 - </li>  
12 - <li>  
13 - <div class="label">手机号码</div>  
14 - <div class="text">  
15 - <input type="number" class="mobile" placeholder="请输入手机号码" />  
16 - </div>  
17 - </li>  
18 - <li>  
19 - <div class="label">微信号</div>  
20 - <div class="text">  
21 - <input type="text" class="wechat" placeholder="请输入微信号(选填)" />  
22 - </div>  
23 - </li>  
24 - </ul>  
25 - <p class="other">提供微信号,方便邀您加入达人微信群,赚钱秘籍、特殊福利享不停!<br/>添加关注公众号“有货有赚”,申请状态、高佣活动早知道。<em class="added">点击添加</em></p> 4 + {{#images}}
  5 + <img src="{{image2 . w=750 h=500 q=80}}" alt="">
  6 + {{/images}}
26 </div> 7 </div>
27 <div class="agreement-section"> 8 <div class="agreement-section">
28 <div class="agreement"> 9 <div class="agreement">
29 我已阅读并同意<a href='{{agreementUrl}}'>《有货有赚推广协议》</a> 10 我已阅读并同意<a href='{{agreementUrl}}'>《有货有赚推广协议》</a>
30 </div> 11 </div>
31 - <div class="apply-btn disable">申请开通</div> 12 + <div class="apply-btn">申请开通</div>
32 </div> 13 </div>
33 {{/unless}} 14 {{/unless}}
34 </div> 15 </div>
@@ -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>&nbsp;&nbsp;粉丝:<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
@@ -9,8 +9,11 @@ body { @@ -9,8 +9,11 @@ body {
9 9
10 .section { 10 .section {
11 background-color: #fff; 11 background-color: #fff;
12 - padding: 0 30px;  
13 - margin-bottom: 30px; 12 + margin-bottom: 220px;
  13 +
  14 + img {
  15 + width: 100%;
  16 + }
14 17
15 .apply-title { 18 .apply-title {
16 font-family: PingFang-SC-Medium, sans-serif; 19 font-family: PingFang-SC-Medium, sans-serif;
@@ -136,8 +139,8 @@ body { @@ -136,8 +139,8 @@ body {
136 bottom: 0; 139 bottom: 0;
137 left: 0; 140 left: 0;
138 right: 0; 141 right: 0;
139 - margin: 30px 30px 0;  
140 - padding-bottom: 30px; 142 + padding: 30px;
  143 + background-color: white;
141 144
142 .agreement { 145 .agreement {
143 margin-bottom: 28px; 146 margin-bottom: 28px;