1class ScriptAffiliate2 extends Script { 2 constructor(params) { 3 super(params) 4 this.site_id = window.app.info.site.site_id 5 this.$t = window.app.utilts.$t 6 } 7 /** åå§åï¼æ¯æå¼æ¥ */ 8 async init() { 9 const _that = this 10 11 await new Load('/assets/plugins/vue.min.js') 12 new Vue({ 13 el: `#${_that.attrId} .unit-affiliate-before`, 14 data: { 15 site_id:_that.site_id, 16 attrId:_that.attrId, 17 api: ScriptAffiliateApi.ins(), 18 isLogin: false, 19 isShow: false, 20 pageInfo:{ 21 sign: 'guide_page_design', 22 visitor_visit: 0, 23 banner_img: '/assets/images/affiliate/fenxiao_before.jpg', 24 banner_url: '', 25 content: ` 26 <div class="af-entrance-title text-center w-100">${window.app.utilts.$t('Invite to earn money')}</div> 27 <div class="af-entrance-desc w-100">${window.app.utilts.$t('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar sic tempor. Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus pronin sapien nunc accuan eget.')}</div> 28 `, 29 form_field: 0, 30 form_field_list: [], 31 form_protocol: 0, 32 agree_text: '', 33 agree_url: '', 34 agree_url_define: '', 35 button_text: window.app.utilts.$t('Make Money Now') 36 }, 37 isAgree:false, 38 formData: {}, 39 patternArr: ['email','phone'], 40 formPattern: { 41 email: '^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$', 42 password: '(?=.*([a-zA-Z].*))(?=.*[0-9].*)[a-zA-Z0-9-*/+.~!@#$%^&*()]{6,20}$', 43 phone: '[0-9\\-]{1,30}' 44 }, 45 formPatternTips: { 46 email:_that.$t('email format does not match'), 47 password: _that.$t('Password contains at least numbers and letters length should be 6-20'), 48 phone:_that.$t('phone can only be numbers or line') 49 }, 50 showPassword: false, 51 password:'', 52 isLoading: false 53 }, 54 created() { 55 this.getInfo() 56 }, 57 methods: { 58 // é®ç®±è¾å ¥ 59 emailChange(e) { 60 const val = e.target.value 61 if ((new RegExp(this.formPattern.email)).test(val)) this.checkEmailExist(val) 62 else this.showPassword = false 63 }, 64 // ç»å½é»è¾è·³è½¬ 65 jumpToPage(url,tag = '') { 66 url = this.isLogin ? url : 'login.html' + tag 67 window.location.href = globalThis.Server.getRinseHref(url, window.app.info.site) 68 }, 69 // 夿æ¯å¦ä¸ºä¼å 70 async checkEmailExist(account) { 71 const res = await this.api.doublePromise('getMemberExistsByAccount',{site_id:this.site_id, account}) 72 if (res.code === 0) { 73 this.showPassword = !res.data.exists 74 } 75 }, 76 // çå¾ æ§è¡ 77 waitFun(time = 100) { 78 return new Promise(resolve => { 79 setTimeout(() => resolve(), time) 80 }) 81 }, 82 // æ ¡éªå®¡æ ¸è¡¨å 83 async commitCheckForm() { 84 if (this.isLoading) return 85 this.isLoading = true 86 await this.waitFun(200) 87 const ev = document.getElementById('checkForm') 88 ev.classList.add("was-validated") 89 if (ev.checkValidity() === false) { 90 this.isLoading = false 91 return 92 } 93 if (!this.pageInfo.form_field) { 94 this.jumpToPage('/affiliate.html?from=Application','?affiliate=1') 95 return 96 } 97 // 妿éè¦è®¾ç½®å¯ç 98 if (this.showPassword) this.formData['password'] = this.password 99 // æäº¤è¡¨å 100 const res = await this.api.doublePromise('getDistributeMemberSubmitAudit',{site_id:this.site_id, ...this.formData,visitor_code: window.app.info.user.visitor_code,}) 101 if (res.code === 0) { 102 // æ¯å¦å¼å¯å®¡æ ¸ 103 if (res.data.audit_status) { 104 // æ¯å¦æ¯åéå 105 if (res.data.new) {
106 new Modal().confirm(_that.$t('Thank you for your application to join our affiliate program, we will review and verify your information as soon as possible and notify you.'), _that.$t('Tips'), { isHideCancel:true, isCloseNoCancel: true }) 107 .then(() => { 108 this.jumpToPage('/user.html?from=Application') 109 }).catch(err=> {}) 110 } else { 111 new Modal().confirm(_that.$t('You have applied to join the Affiliate Program.'), _that.$t('Tips'), { isHideCancel:true, isCloseNoCancel: true }) 112 .then(() => { 113 if (res.data.status === 1) this.jumpToPage('/affiliate.html?from=Application','?affiliate=1') 114 else this.jumpToPage('/user.html?from=Application') 115 }).catch(err=> {}) 116 } 117 } else { 118 this.jumpToPage('/affiliate.html?from=Application','?affiliate=1') 119 } 120 } 121 this.isLoading = false 122 }, 123 // 页é¢ä¿¡æ¯ 124 async getInfo() { 125 const res = await this.api.doublePromise('getDistributeConfigDesignDetail',{site_id:this.site_id,sign:'guide_page_design'}) 126 if (res.code === 0) { 127 const obj = res.data 128 for(let key in obj) { 129 if (obj[key]) this.pageInfo[key] = obj[key] 130 } 131 this.pageInfo.agree_url_define = globalThis.Server.getRinseHref(this.pageInfo.agree_url, window.app.info.site) 132 if (!window.LFSDK.isLogin() && !this.pageInfo.visitor_visit){ 133 window.location.href = globalThis.Server.getRinseHref(`/login.html`, window.app.info.site) 134 return 135 } 136 if (obj.form_field && obj.form_field_list?.length) { 137 obj.form_field_list.forEach(item => { 138 if (item.field_status) this.formData[item.field_column] = '' 139 }) 140 // ç»å½æ åµç´æ¥èµå¼é®ç®± 141 this.isLogin = window.app.info.user.is_login 142 if (this.isLogin) { 143 this.formData['email'] = window.app.info.user.username 144 this.checkMemberStatus() 145 } 146 } 147 } 148 this.isShow = true 149 }, 150 // æ£æ¥å®¡æ ¸ç¶æ 151 async checkMemberStatus() { 152 const res = await this.api.doublePromise('getDistributeConfigEntrance',{site_id:this.site_id}) 153 if (res.code === 0) { 154 if (res.data.member_status === -1) { 155 new Modal().confirm(_that.$t('You will be notified of the review result via email.'), _that.$t('Tips'), { isHideCancel:true, isCloseNoCancel: true }) 156 .then(() => { 157 this.jumpToPage('/user.html?from=Application') 158 }).catch(err=> {}) 159 } 160 } 161 } 162 } 163 }) 164 this.moveDom() 165 } 166 167 moveDom() { 168 const $app = document.querySelector('#app') 169 if ($app) { 170 const $affiliate_entrance = $app.querySelector('.unit-affiliate-entrance') 171 $app.appendChild($affiliate_entrance) 172 $affiliate_entrance.style.opacity = 1 173 $app.style.opacity = 1 174 } 175 } 176 177} 178// apiæ¥å£ 179class ScriptAffiliateApi { 180 constructor() { 181 this.utilts = Utilts.ins() 182 } 183 /** å便¨¡å¼ */ 184 static ins() { 185 if (!this.instance) { 186 return this.instance = new ScriptAffiliateApi() 187 } 188 return this.instance 189 } 190 // äºæ¬¡å°è£ çpromise(è§£å³awaitæè·é®é¢) 191 async doublePromise(funName,params = {},showTip = true) { 192 return new Promise(resolve => { 193 this[funName](params).then(res => { 194 if (res.code !== 0 && showTip) { 195 console.error('error=>',res.msg) 196 new Message()['error'](window.app.utilts.$t(res.msg)) 197 } 198 resolve(res) 199 }).catch(err => { 200 const msg = err.msg || err 201 console.error('error=>', msg) 202 if (showTip) new Message()['error'](window.app.utilts.$t(msg)) 203 resolve({code:-1,msg}) 204 }) 205 }) 206 } 207 /** åé页é¢è®¾è®¡ */ 208 getDistributeConfigDesignDetail(params) { 209 return new Promise((resolve, reject) => { 210 this.utilts.request({ 211 url: '/distribute-config/design-detail', 212 method: 'GET', 213 params 214 }).then(res => resolve(res)) 215 .catch(err => reject(err)) 216 }) 217 } 218 /** åé页é¢è®¾è®¡ */ 219 getDistributeMemberSubmitAudit(params) { 220 return new Promise((resolve, reject) => { 221 this.utilts.request({ 222 url: '/distribute-member/submit-audit', 223 method: 'POST', 224 params 225 }).then(res => resolve(res)) 226 .catch(err => reject(err)) 227 }) 228 } 229 /** 夿é®ç®±æ¯å¦ä¸ºä¼å */
230 getMemberExistsByAccount(params) { 231 return new Promise((resolve, reject) => { 232 this.utilts.request({ 233 url: '/member/exists-by-account', 234 method: 'GET', 235 params 236 }).then(res => resolve(res)) 237 .catch(err => reject(err)) 238 }) 239 } 240 /** è·åå®¡æ ¸ç¶æ */ 241 getDistributeConfigEntrance(params) { 242 return new Promise((resolve, reject) => { 243 this.utilts.request({ 244 url: '/distribute-config/entrance', 245 method: 'GET', 246 params 247 }).then(res => resolve(res)) 248 .catch(err => reject(err)) 249 }) 250 } 251}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.