PageSourceSearch

https://www.heweiseating.com/assets/js/unit/affiliate2.js

js heweiseating.com collected 2026-10-04 16:19:30 UTC 9,428 bytes, 251 lines download raw bytes

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.