PageSourceSearch

https://zcjun.com/wp-content/themes/b2/Assets/fontend/main.js?ver=5.9.42

js zcjun.com collected 2026-10-06 12:43:47 UTC 160,768 bytes, 6,035 lines download raw bytes

1//挂载axios
2axios.defaults.timeout = 1000000;
3Vue.prototype.$http = axios; //需要鉴权
4Vue.prototype.$https = axios; //不需要鉴权
5Vue.prototype.$b2JsonData = [];
6var b2_rest_url = b2_global.rest_url + "b2/v1/";
7
8// const b2timedom = document.querySelectorAll('.ff');
9
10// if(b2timedom.length > 0){
11//     timeago.render(b2timedom, b2_global.language);
12// }
13
14var b2zoom = new Zooming({
15  enableGrab: true,
16  scrollThreshold: 0,
17  transitionDuration: 0.2,
18  scaleBase: 0.96,
19  scaleExtra: 1,
20  customSize: "100%",
21});
22
23var B2ClientWidth = document.body.clientWidth;
24
25const b2token = b2getCookie("b2_token");
26
27var lazyLoadInstance = new LazyLoad({
28  elements_selector: ".lazy",
29  threshold: 0,
30});
31
32if (b2token) {
33  Vue.prototype.$http.defaults.headers.common["Authorization"] =
34    "Bearer " + b2token;
35}
36
37Vue.prototype.$store = new Vuex.Store({
38  state: {
39    userData: "",
40    userRole: "",
41    announcement: "",
42    oauthLink: "",
43    openOauth: false,
44    authorData: "",
45    carts: {},
46    _carts: {},
47    canImg: false,
48    xieyi: 0,
49  },
50  mutations: {
51    setUserData(state, data) {
52      state.userData = data;
53    },
54    setUserRole(state, data) {
55      state.userRole = data;
56    },
57    setAnnouncement(state, data) {
58      state.announcement = data;
59    },
60    setOauthLink(state, data) {
61      state.oauthLink = data;
62    },
63    setOpenOauth(state, data) {
64      state.openOauth = data;
65    },
66    setauthorData(state, data) {
67      state.authorData = data;
68    },
69    setcartsData(state, data) {
70      state.carts = data;
71    },
72    set_cartsData(state, data) {
73      state._carts = data;
74    },
75    setcanImage(state, data) {
76      state.canImg = data;
77    },
78  },
79});
80
81var passiveSupported = false;
82
83try {
84  var options = Object.defineProperty({}, "passive", {
85    get: function () {
86      passiveSupported = true;
87    },
88  });
89
90  window.addEventListener("test", null, options);
91} catch (err) {}
92
93b2WidgetImageLoaded();
94
95function b2WidgetImageLoaded() {
96  imagesLoaded(document.querySelectorAll(".widget-area"), function (instance) {
97    b2SidebarSticky();
98  });
99}
100
101function b2isWeixin() {
102  //判断是否是微信
103  var ua = navigator.userAgent.toLowerCase();
104  return ua.match(/MicroMessenger/i) == "micromessenger";
105}
106
107document.ready = function (callback) {
108  ///兼容FF,Google
109  if (document.addEventListener) {
110    document.addEventListener(
111      "DOMContentLoaded",
112      function () {
113        document.removeEventListener(
114          "DOMContentLoaded",
115          arguments.callee,
116          false
117        );
118        callback();
119      },
120      passiveSupported ? { passive: true } : false
121    );
122  }
123  //兼容IE
124  else if (document.attachEvent) {
125    document.attachEvent("onreadystatechange", function () {
126      if (document.readyState == "complete") {
127        document.detachEvent("onreadystatechange", arguments.callee);
128        callback();
129      }
130    });
131  } else if (document.lastChild == document.body) {
132    callback();
133  }
134};
135
136var topsearch = new Vue({
137  el: ".top-search",
138  data: {
139    type: "post",
140    data: "",
141    show: false,
142    b2token: false,
143  },
144  mounted() {
145    if (!this.$refs.topsearch) return;
146    this.b2token = b2token;
147    const s = this.$refs.topsearch.getAttribute("data-search");
148    this.data = JSON.parse(s);
149
150    if (b2GetQueryVariable("type") && b2GetQueryVariable("s")) {
151      this.type = b2GetQueryVariable("type");
152    } else {
153      this.type = Object.keys(this.data)[0];
154    }
155  },
156});
157
158const goodsBoxs = document.querySelectorAll(".module-products");
159
160if (goodsBoxs.length > 0) {
161  for (let i = 0; i < goodsBoxs.length; i++) {
162    new Vue({
163      el: goodsBoxs[i].querySelector(".shop-box"),
164      data: {
165        id: 0,
166        opts: [],
167        locked: false,
168        paged: 1,
169      },
170      mounted() {
171        this.opts = JSON.parse(
172          goodsBoxs[i].querySelector(".shop-box").getAttribute("data-opts")
173        );
174      },
175      methods: {
176        getGoods(id) {
177          if (this.loaded) return;
178          this.locked = true;
179
180          var data = {
181            terms: [id],
182            count: this.opts.count,
183            w: this.opts.w,
184            h: this.opts.h,
185            open: this.opts.open,
186            ratio: this.opts.ratio,
187            paged: this.paged,
188          };
189
190          if (id == 0) {
191            delete data.terms;
192          }
193
194          this.id = id;
195          this.$https
196            .post(b2_rest_url + "getShopList", Qs.stringify(data))
197            .then((res) => {
198              if (res.data) {
199                this.$el.querySelector(".b2_gap").innerHTML = res.data;
200                this.$nextTick(() => {
201                  lazyLoadInstance.update();
202                });
203              }
204
205              this.locked = false;
206            })
207            .catch((err) => {
208              Qmsg["warning"](err.response.data.message, { html: true });
209              this.locked = false;
210            });
211        },
212      },
213    });
214  }
215}
216
217var mobileMenu = new Vue({
218  el: "#mobile-menu-button",
219  data: {
220    show: false,
221    b2token: false,
222  },
223  mounted() {
224    if (B2ClientWidth >= 768) return;
225    this.b2token = b2token;
226    this.dorpMenu();
227  },
228  methods: {
229    dorpMenu() {
230      let drop = document.querySelectorAll(
231        ".has_children .b2-arrow-down-s-line"
232      );
233      if (drop.length > 0) {
234        for (let index = 0; index < drop.length; index++) {
235          drop[index].onclick = (event) => {
236            event.stopPropagation();
237            event.preventDefault();
238            if (
239              event.target.parentNode.parentNode.className.indexOf(" show") ==
240              -1
241            ) {
242              this.hideAll();
243              event.target.parentNode.parentNode.className += " show";
244            } else {
245              this.hideAll();
246            }
247          };
248        }
249      }
250    },
251    hideAll() {
252      let sub = document.querySelectorAll(".has_children .sub-menu");
253      for (let i = 0; i < sub.length; i++) {
254        sub[i].parentNode.className = sub[i].parentNode.className.replace(
255          " show",
256          ""
257        );
258      }
259    },
260    showMenu(val) {
261      const menu = document.querySelector("#mobile-menu");
262      body = document.querySelector("html");
263      if (val) {
264        menu.className += " show-menu-box";
265        body.className += " m-open";
266        //bodyScrollLock.lock(this.$refs.MobileMenu)
267        this.show = true;
268      } else {
269        menu.className = menu.className.replace(" show-menu-box", "");
270        setTimeout(() => {
271          body.className = body.className.replace(" m-open", "");
272        }, 300);
273        //bodyScrollLock.unlock(this.$refs.MobileMenu)
274        this.show = false;
275      }
276    },
277    showAc() {
278      this.show = !this.show;
279      this.showMenu(this.show);
280    },
281  },
282});
283
284Vue.component("search-box", {
285  props: ["show", "searchType"],
286  template: b2_global.search_box,
287  data() {
288    return {
289      showSearch: false,
290      type: "post",
291    };
292  },
293  mounted() {
294    const search = document.querySelector(".top-search");
295    if (search) {
296      const data = search.getAttribute("data-search");
297
298      if (data) {
299        let json = JSON.parse(data);
300        this.type = Object.keys(json)[0];
301      }
302    }
303  },
304  methods: {
305    close() {
306      this.$emit("close");
307    },
308  },
309  watch: {
310    searchType(val) {
311      this.type = val;
312    },
313  },
314});
315
316var b2SearchBox = new Vue({
317  el: "#search-box",
318  data: {
319    searchType: "all",
320    show: false,
321  },
322  methods: {
323    close() {
324      this.show = !this.show;
325    },
326  },
327});
328
329function historyWidget() {
330  let history = document.querySelectorAll(".b2-widget-history");
331  if (history.length > 0) {
332    for (let i = 0; i < history.length; i++) {
333      new Vue({
334        el: history[i],
335        data: {
336          data: [],
337          count: 10,
338        },
339        mounted() {
340          this.count = history[i]
341            .querySelector(".history-widget")
342            .getAttribute("data-count");
343
344          let historys =
345            JSON.parse(localStorage.getItem("b2_view_history")) || [];
346
347          //获取前 count 条数据
348          this.data = historys.slice(0, this.count);
349
350          this.$nextTick(() => {
351            b2RestTimeAgo(this.$el.querySelectorAll(".b2timeago"));
352          });
353        },
354        methods: {
355          clear() {
356            //提示是否删除
357            let r = confirm(b2_global.js_text.global.clear_history);
358            console.log(r);
359            if (r) {
360              localStorage.removeItem("b2_view_history");
361              this.data = [];
362            }
363          },
364        },
365      });
366    }
367  }
368}
369
370var userTools = new Vue({
371  el: ".top-user-info",
372  data: {
373    showDrop: false,
374    role: {
375      write: true,
376      newsflashes: false,
377      binding_login: false,
378      create_circle: false,
379      create_topic: false,
380      distribution: false,
381      user_data: "",
382    },
383    b2token: false,
384  },
385  computed: {
386    userData() {
387      return this.$store.state.userData;
388    },
389  },
390  mounted() {
391    this.b2token = b2token;
392
393    document.onclick = (e) => {
394      this.hideAction();
395    };
396
397    if (b2_global.post_id != 0) {
398      this.writeHistory();
399    }
400
401    historyWidget();
402
403    if (b2token) {
404      let footer_text = document.querySelector("#footer-menu-user");
405      if (footer_text) {
406        footer_text.innerText = b2_global.js_text.global.my;
407      }
408
409      this.$http
410        .post(b2_rest_url + "getUserInfo")
411        .then((res) => {
412          this.role = res.data;
413
414          this.$store.commit("setUserRole", res.data);
415          this.$store.commit("setUserData", res.data.user_data);
416          this.$store.commit("setcanImage", res.data.can_img);
417          b2AsideBar.count = res.data.carts;
418
419          topMenuLeft.count = res.data.msg_unread;
420
421          b2bindLogin.type = res.data.binding_login;
422          payCredit.user.credit = res.data.user_data.credit;
423
424          this.$nextTick(() => {
425            b2tooltip(".user-tips");
426            lazyLoadInstance.update();
427          });
428        })
429        .catch((err) => {
430          this.loginOut();
431        });
432    } else {
433      this.$https.get(b2_rest_url + "getOauthLink").then((res) => {
434        this.$store.commit("setOauthLink", res.data);
435        this.$nextTick(() => {
436          lazyLoadInstance.update();
437        });
438      });
439      let ref = b2GetQueryVariable("ref");
440      if (ref) {
441        b2setCookie("ref", ref);
442      }
443    }
444  },
445  methods: {
446    //写入浏览历史
447    writeHistory() {
448      //获取浏览历史
449      let address = JSON.parse(localStorage.getItem("b2_view_history")) || [];
450
451      //获取当前页面URL,不包含锚点和查询参数
452      let url = window.location.origin + window.location.pathname;
453
454      //获取站点的名称和分隔符
455      let siteName = b2_global.site_name;
456      let siteSeparator = b2_global.site_separator;
457
458      let title = document.title;
459
460      //删除标题中的空格
461      title = title.replace(/\s+/g, "");
462
463      //从标题末尾删除站点名称
464      title = title.substring(0, title.length - siteName.length);
465
466      //从标题末尾删除分隔符
467      title = title.substring(0, title.length - siteSeparator.length);
468
469      //获取当前页面缩略图
470      let thumb = document.querySelector('meta[property="og:image"]');
471
472      //如果不存在则获取默认缩略图
473      if (!thumb) {
474        thumb = b2_global.default_thumb;
475      } else {
476        thumb = thumb.getAttribute("content");
477      }
478
479      //判断当前页面是否已经存在于浏览历史中
480      for (let i = 0; i < address.length; i++) {
481        if (address[i].url == url) {
482          address.splice(i, 1);
483        }
484      }
485
486      //如果浏览历史大于10条则删除最后一条
487      if (address.length >= 30) {
488        address.pop();
489      }
490
491      //获取当前访问时间,格式为 2023-01-01 00:00:00
492      let time = new Date()
493        .toLocaleString("zh", { hour12: false })
494        .replace(/\//g, "-");
495
496      //获取当前页面文章形式
497      let type = b2_global.post_type;
498
499      //将当前页面信息写入数组前端
500      address.unshift({
501        url: url,
502        title: title,
503        thumb: thumb,
504        time: time,
505        type: type,
506      });
507
508      localStorage.setItem("b2_view_history", JSON.stringify(address));
509    },
510    hideAction() {
511      this.showDrop = false;
512      if (typeof b2Comment !== "undefined") {
513        b2Comment.show.smile = false;
514        b2Comment.show.image = false;
515      }
516
517      if (typeof b2infomation !== "undefined") {
518        b2infomation.showFliter = false;
519      }
520
521      if (typeof b2TaxTop !== "undefined") {
522        b2TaxTop.showFliter.hot = false;
523        b2TaxTop.showFliter.cat = false;
524      }
525
526      if (typeof topsearch !== "undefined") {
527        topsearch.show = false;
528      }
529
530      if (typeof writeHead !== "undefined") {
531        Qmsg.closeAll();
532      }
533
534      if (typeof b2CirclePostBox !== "undefined") {
535        b2CirclePostBox.ask.focus = false;
536        if (b2CirclePostBox.ask.userInput) {
537          b2CirclePostBox.ask.picked = true;
538        }
539        b2CirclePostBox.role.show = false;
540        b2CirclePostBox.smileShow = false;
541      }
542
543      if (typeof poAsk !== "undefined") {
544        poAsk.ask.focus = false;
545        if (poAsk.userInput) {
546          poAsk.ask.picked = true;
547        }
548      }
549
550      if (typeof b2CircleList !== "undefined") {
551        if (!b2CircleList.$refs.topicForm) return;
552        if (!b2CircleList.commentBox.content) {
553          if (b2CircleList.$refs.topicForm.value == "") {
554            b2CircleList.commentBox.focus = false;
555          }
556          b2CircleList.smileShow = false;
557        }
558
559        //b2CircleList.circle.current = b2CircleList.circle.picked.type
560        b2CircleList.circle.showBox = "";
561        b2CircleList.topicFliter.show = false;
562        b2CircleList.answer.showSmile = false;
563      }
564
565      b2AsideBar.close();
566    },
567    login(type) {
568      login.show = true;
569      login.loginType = type;
570    },
571    showDropMenu() {
572      this.showDrop = !this.showDrop;
573    },
574    loginOut() {
575      axios
576        .get(b2_rest_url + "loginOut")
577        .then((res) => {
578          b2delCookie("b2_token");
579          b2CurrentPageReload();
580        })
581        .catch((err) => {
582          b2delCookie("b2_token");
583          b2CurrentPageReload();
584        });
585    },
586    out() {
587      this.loginOut();
588    },
589    // goLinkRegisterPage(){
590    //     if(!b2token){
591    //         this.login(1)
592    //         return
593    //     }
594    // },
595    goUserPage(type) {
596      if (type === "back") {
597        window.location = b2getCookie("b2_back_url");
598      } else if (type) {
599        if (!b2token) {
600          this.login(1);
601          return;
602        }
603        window.location = this.$store.state.userData.link + "/" + type;
604      } else {
605        if (!b2token) {
606          this.login(1);
607          return;
608        }
609        window.location = this.$store.state.userData.link;
610      }
611    },
612  },
613});
614
615var topMenuLeft = new Vue({
616  el: ".change-theme",
617  data: {
618    theme: "light",
619    count: 0,
620    login: false,
621  },
622  mounted() {
623    if (b2token) {
624      this.login = true;
625    }
626  },
627  methods: {
628    changeTheme(type) {
629      this.theme = type;
630    },
631    showBox() {
632      postPoBox.show = true;
633    },
634    go(type) {
635      if (type === "orders") {
636        if (b2token) {
637          window.location.href = this.$store.state.userData.link + "/orders";
638        } else {
639          login.show = true;
640          login.loginType = 1;
641        }
642      }
643      if (type === "requests") {
644        if (b2token) {
645          window.location.href = b2_global.home_url + "/requests";
646        } else {
647          login.show = true;
648          login.loginType = 1;
649        }
650      }
651    },
652  },
653});
654
655var headerTools = new Vue({
656  el: ".header-tools",
657  computed: {
658    userData() {
659      return this.$store.state.userData;
660    },
661  },
662  methods: {
663    showSearch() {
664      b2SearchBox.close();
665    },
666  },
667});
668
669//登陆与注册
670Vue.component("login-box", {
671  props: [
672    "show",
673    "allowRegister",
674    "checkType",
675    "loginType",
676    "loginText",
677    "invitation",
678    "invitationLink",
679    "invitationText",
680    "imgBoxCode",
681  ],
682  template: b2_global.login,
683  data() {
684    return {
685      data: {
686        nickname: "",
687        username: "",
688        password: "",
689        code: "",
690        img_code: "",
691        invitation_code: "",
692        token: "",
693        smsToken: "",
694        luoToken: "",
695        confirmPassword: "",
696        loginType: "",
697        tencentTicket: "",
698      },
699      loginSocialType:b2_global.login_type,
700      invitationPass: false,
701      eye: false,
702      codeImg: "",
703      locked: false,
704      showLuo: false,
705      issetLuo: false,
706      issetTencent: false,
707      imgLocked: false,
708      SMSLocked: false,
709      count: 60,
710      repass: false,
711      type: "",
712      isWeixin: false,
713    };
714  },
715  computed: {
716    oauth() {
717      return this.$store.state.oauthLink;
718    },
719    openOauth() {
720      return this.$store.state.openOauth;
721    },
722  },
723  mounted() {
724    if (this.checkType == "tencent") {
725      document.getElementById("CaptchaId").onclick = () => {
726        try {
727          // 生成一个验证码对象
728          // CaptchaAppId:登录验证码控制台,从【验证管理】页面进行查看。如果未创建过验证,请先新建验证。注意:不可使用客户端类型为小程序的CaptchaAppId,会导致数据统计错误。
729          //callback:定义的回调函数
730          var captcha = new TencentCaptcha(b2_global.tencent_captcha_appid, this.callback, {});
731          // 调用方法,显示验证码
732          captcha.show();
733        } catch (error) {
734          // 加载异常,调用验证码js加载错误处理函数
735          this.loadErrorCallback();
736        }
737      };
738    }
739  },
740  created() {
741    window.getResponse = (resp) => {
742      if (this.type == "edit") {
743        b2AuthorEdit.sendCode(resp);
744        recaptcha.close();
745      } else {
746        this.data.img_code = resp;
747        this.$nextTick(() => {
748          recaptcha.close();
749          this.sendSMS();
750        });
751      }
752    };
753
754    this.isWeixin = b2isWeixin();
755  },
756  methods: {
757    callback(res) {
758
759      if (res.ret === 0) {
760        // 复制结果至剪切板
761        var str =
762          "【randstr】->【" +
763          res.randstr +
764          "】      【ticket】->【" +
765          res.ticket +
766          "】";
767        var ipt = document.createElement("input");
768        ipt.value = str;
769        document.body.appendChild(ipt);
770        ipt.select();
771        document.execCommand("Copy");
772        document.body.removeChild(ipt);
773        alert(
774          "1. 返回结果(randstr、ticket)已复制到剪切板,ctrl+v 查看。 2. 打开浏览器控制台,查看完整返回结果。"
775        );
776      }
777    },
778    loadErrorCallback() {
779      var appid = "您的CaptchaAppId";
780      // 生成容灾票据或自行做其它处理
781      var ticket =
782        "terror_1001_" + appid + "_" + Math.floor(new Date().getTime() / 1000);
783      callback({
784        ret: 0,
785        randstr: "@" + Math.random().toString(36).substr(2),
786        ticket: ticket,
787        errorCode: 1001,
788        errorMessage: "jsload_error",
789      });
790    },
791    close(val) {
792      this.$emit("close-form", val);
793    },
794    loginAc(val) {
795      this.$emit("login-ac", val);
796    },
797    loginSubmit(e) {
798      e.preventDefault();
799
800      if (this.locked == true) return;
801      this.locked = true;
802
803      //邀请码
804      if (this.invitation != 0 && this.loginType == 2 && !this.invitationPass) {
805        this.invitationCheck();
806      } else if (this.loginType == 1) {
807        //登录
808        this.$https
809          .post(
810            b2_global.rest_url + "jwt-auth/v1/token",
811            Qs.stringify(this.data)
812          )
813          .then((res) => {
814            b2CurrentPageReload();
815            return;
816          })
817          .catch((err) => {
818            Qmsg["warning"](err.response.data.message, {
819              html: true,
820              timeout: 10000,
821            });
822            this.locked = false;
823          });
824      } else if (this.loginType == 2) {
825        if (!this.$store.state.xieyi && this.loginType == 2) {
826          e.preventDefault();
827          Qmsg["warning"](b2_global.js_text.global.xieyi, { html: true });
828          this.locked = false;
829          return;
830        }
831        //注册
832        this.$https
833          .post(b2_rest_url + "regeister", Qs.stringify(this.data))
834          .then((res) => {
835            b2CurrentPageReload();
836
837            return;
838          })
839          .catch((err) => {
840            Qmsg["warning"](err.response.data.message, { html: true });
841            this.locked = false;
842          });
843      } else if (this.loginType == 3) {
844        this.$https
845          .post(b2_rest_url + "forgotPass", Qs.stringify(this.data))
846          .then((res) => {
847            this.loginAc(4);
848            this.locked = false;
849          })
850          .catch((err) => {
851            Qmsg["warning"](err.response.data.message, { html: true });
852            this.locked = false;
853          });
854      } else if (this.loginType == 4) {
855        this.$https
856          .post(b2_rest_url + "resetPass", Qs.stringify(this.data))
857          .then((res) => {
858            this.repass = true;
859            this.data.password = "";
860            this.loginAc(1);
861            this.locked = false;
862          })
863          .catch((err) => {
864            Qmsg["warning"](err.response.data.message, { html: true });
865            this.locked = false;
866          });
867      }
868    },
869    b2IsPhoneAvailable(val) {
870      if (b2IsPhoneAvailable(val)) return true;
871      return false;
872    },
873    invitationCheck() {
874      this.$https
875        .post(
876          b2_rest_url + "invitationCheck",
877          "code=" + this.data.invitation_code
878        )
879        .then((res) => {
880          this.invitationPass = true;
881          this.locked = false;
882          this.showLuo = true;
883        })
884        .catch((err) => {
885          Qmsg["warning"](err.response.data.message, { html: true });
886          this.locked = false;
887        });
888    },
889    sendCode() {
890      recaptcha.show = true;
891      this.close(false);
892    },
893    getCode() {
894      if (this.imgLocked) return;
895      this.codeImg = "";
896      this.imgLocked = true;
897      this.$https
898        .post(b2_rest_url + "getRecaptcha", "number=4&width=186&height=50")
899        .then((res) => {
900          if (res.data) {
901            this.codeImg = res.data.base;
902            this.data.token = res.data.token;
903          }
904          this.imgLocked = false;
905        })
906        .catch((err) => {
907          Qmsg["warning"](err.response.data.message, { html: true });
908          this.imgLocked = false;
909        });
910    },
911    changeCode() {
912      this.getCode();
913    },
914    isEmail(email) {
915      var pattern =
916        /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
917      return pattern.test(email);
918    },
919    checkTips() {
920      let text = "";
921
922      if (this.checkType == "tel") {
923        text = b2_global.js_text.global.check_type.tel;
924      }
925
926      if (this.checkType == "email") {
927        text = b2_global.js_text.global.check_type.mail;
928      }
929
930      if (this.checkType == "telandemail") {
931        if (this.isEmail(this.data.username)) {
932          text = b2_global.js_text.global.check_type.mail;
933        } else {
934          text = b2_global.js_text.global.check_type.tel;
935        }
936      }
937
938      if (text) {
939        Qmsg.info(b2_global.js_text.global.check_message, {
940          showClose: true,
941          autoClose: false,
942        });
943      }
944    },
945    sendSMS() {
946      if (this.SMSLocked) return;
947      this.SMSLocked = true;
948      this.data.loginType = this.loginType;
949      this.$https
950        .post(b2_rest_url + "sendCode", Qs.stringify(this.data))
951        .then((res) => {
952          if (res.data.token) {
953            this.data.smsToken = res.data.token;
954          }
955          this.SMSLocked = false;
956          this.countdown();
957
958          this.checkTips();
959        })
960        .catch((err) => {
961          Qmsg["warning"](err.response.data.message, { html: true });
962          this.SMSLocked = false;
963        });
964    },
965    markHistory(mp, e) {
966      if (!this.$store.state.xieyi && this.loginType == 2 && e) {
967        e.preventDefault();
968        Qmsg["warning"](b2_global.js_text.global.xieyi, { html: true });
969        return;
970      }
971      if (mp) {
972        this.close();
973        mpCode.show = true;
974        mpCode.type = this.loginType;
975      }
976      b2setCookie("b2_back_url", window.location.href);
977    },
978    countdown() {
979      if (this.count <= 1) {
980        this.count = 60;
981        return;
982      }
983      this.count--;
984      setTimeout(() => {
985        this.countdown();
986      }, 1000);
987    },
988    resetPssNext() {
989      this.loginAc(4);
990    },
991  },
992  watch: {
993    oauth(val) {
994      if (val) {
995        Object.keys(val).forEach((key) => {
996          if (val[key].open) {
997            this.$store.commit("setOpenOauth", true);
998          }
999        });
1000
1001        if (b2isWeixin() && b2_global.wx_mp_in_login == 1) {
1002          if (!b2token && document.querySelector("#open-page") === null) {
1003            b2setCookie("b2_back_url", window.location.href);
1004            window.location.href = this.oauth.weixin.url;
1005          }
1006        }
1007      }
1008    },
1009    loginType(val) {
1010      if ((this.invitation == 0 || this.invitationPass) && val == 2) {
1011        this.showLuo = true;
1012      } else {
1013        this.showLuo = false;
1014      }
1015
1016      if (this.issetLuo) {
1017        LUOCAPTCHA && LUOCAPTCHA.reset();
1018      }
1019    },
1020    invitationPass(val) {
1021      if (this.issetLuo && val) {
1022        setTimeout(() => {
1023          LUOCAPTCHA && LUOCAPTCHA.reset();
1024        }, 100);
1025      }
1026    },
1027    show(val) {
1028
1029      if ((val && this.checkType == "text") || b2isWeixin()) {
1030        this.getCode();
1031        this.type = "";
1032      } else if (val && login.qrcode !== "0" && this.loginType == 1) {
1033        this.markHistory(true, null);
1034      }
1035    },
1036    imgBoxCode(val) {
1037      this.data.img_code = val.value;
1038      this.data.token = val.token;
1039    },
1040    showLuo(val) {
1041      if (this.show && this.checkType == "luo" && val && !this.issetLuo) {
1042        let s = document.createElement("script");
1043        s.id = "luosimao";
1044        s.type = "text/javascript";
1045        s.src = "//captcha.luosimao.com/static/dist/api.js";
1046        document.getElementsByTagName("head")[0].appendChild(s);
1047        this.issetLuo = true;
1048      }
1049      if (
1050        this.show &&
1051        this.checkType == "tencent" &&
1052        val &&
1053        !this.issetTencent
1054      ) {
1055        let s = document.createElement("script");
1056        s.id = "tencent";
1057        s.type = "text/javascript";
1058        s.src = "//turing.captcha.qcloud.com/TCaptcha.js";
1059        document.getElementsByTagName("head")[0].appendChild(s);
1060        this.issetTencent = true;
1061      }
1062    },
1063  },
1064});
1065
1066Vue.component("mp-box", {
1067  props: ["show", "invitation", "invitationLink", "invitationText"],
1068  template: b2_global.mp_box,
1069  data() {
1070    return {
1071      code: "",
1072      locked: false,
1073      token: false,
1074      invitationCode: "",
1075      locked: false,
1076      qrcode: "",
1077      t: false,
1078      count: 100,
1079    };
1080  },
1081  computed: {
1082    oauthLink() {
1083      return this.$store.state.oauthLink;
1084    },
1085  },
1086  methods: {
1087    close() {
1088      this.$emit("close");
1089      this.t = null;
1090    },
1091    submit() {
1092      if (this.locked == true) return;
1093      this.locked = true;
1094
1095      if (this.count <= 1 || this.t === null) {
1096        this.t = null;
1097        this.count = 100;
1098        return;
1099      }
1100
1101      this.$http
1102        .post(b2_rest_url + "mpLogin", "code=" + this.code)
1103        .then((res) => {
1104          if (res.data === "waiting") {
1105            this.locked = false;
1106            this.t = setTimeout(() => {
1107              this.submit();
1108            }, 1000);
1109            return;
1110          }
1111
1112          if (res.data.type === "invitation") {
1113            this.token = res.data.token;
1114          } else {
1115            if (res.data === true) {
1116              b2CurrentPageReload();
1117            } else {
1118              this.$store.commit("setUserData", res.data);
1119
1120              Vue.prototype.$http.defaults.headers.common["Authorization"] =
1121                "Bearer " + b2token;
1122              b2CurrentPageReload();
1123            }
1124          }
1125          this.t = null;
1126          this.locked = false;
1127        })
1128        .catch((err) => {
1129          Qmsg["warning"](err.response.data.message, { html: true });
1130          this.locked = false;
1131        });
1132    },
1133    checkInv() {
1134      if (this.locked == true) return;
1135      this.locked = true;
1136
1137      this.$https
1138        .post(
1139          b2_rest_url + "mpLoginInv",
1140          "token=" + this.token + "&inv=" + this.invitationCode
1141        )
1142        .then((res) => {
1143          if (res.data.token) {
1144            b2CurrentPageReload();
1145          }
1146          this.locked = false;
1147        })
1148        .catch((err) => {
1149          Qmsg["warning"](err.response.data.message, { html: true });
1150          this.locked = false;
1151        });
1152    },
1153    getQrcode() {
1154      this.$https
1155        .post(b2_rest_url + "getLoginQrcode")
1156        .then((res) => {
1157          this.code = res.data.sence_id;
1158          this.qrcode = res.data.qrcode;
1159          this.submit();
1160        })
1161        .catch((err) => {
1162          Qmsg["warning"](err.response.data.message, { html: true });
1163        });
1164    },
1165  },
1166  watch: {
1167    show(val) {
1168      if (val) {
1169        if (this.oauthLink.weixin.pc_open) {
1170          b2loadScript(
1171            "https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js",
1172            "",
1173            () => {
1174              new WxLogin({
1175                self_redirect: false,
1176                id: "mp-login-box",
1177                appid: b2_global.wx_appid,
1178                scope: "snsapi_login",
1179                redirect_uri: b2_global.home_url + "/open?type=weixin",
1180                state: "",
1181                style: "black",
1182                href: "data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7DQogICAgd2lkdGg6IDEwMCU7DQogICAgbWFyZ2luLXRvcDogMDsNCiAgICBib3JkZXI6IDA7DQp9DQouaW1wb3dlckJveCAuaW5mbyB7DQogICAgZGlzcGxheTogbm9uZTsNCn0NCi5pbXBvd2VyQm94IC50aXRsZXsNCmRpc3BsYXk6bm9uZQ0KfQ==",
1183              });
1184            }
1185          );
1186        } else {
1187          this.locked = false;
1188          this.t = false;
1189          this.count = 100;
1190          this.getQrcode();
1191        }
1192      }
1193    },
1194  },
1195});
1196
1197var mpCode = new Vue({
1198  el: "#mp-box",
1199  data: {
1200    show: false,
1201    qrcode: "",
1202    type: "1",
1203  },
1204  methods: {
1205    close() {
1206      this.show = !this.show;
1207      if (!b2token && login.qrcode === "0") {
1208        login.show = true;
1209        login.loginType = this.type;
1210      }
1211    },
1212  },
1213});
1214
1215var login = new Vue({
1216  el: "#login-box",
1217  data: {
1218    show: false,
1219    loginType: 1,
1220    checkCodeSendSuccess: false,
1221    isAdmin: false,
1222    imgCode: "",
1223    qrcode: "0",
1224    loginSocialType:b2_global.login_type,
1225  },
1226  mounted() {
1227    this.qrcode = b2_global.mp_qrcode;
1228  },
1229  methods: {
1230    close(val) {
1231      this.show = val;
1232      this.qrcode = b2_global.mp_qrcode;
1233    },
1234    loginAc(val) {
1235      this.loginType = val;
1236    },
1237    imgCodeAc(val) {
1238      this.imgCode = val;
1239    },
1240  },
1241});
1242
1243//验证码组件
1244Vue.component("recaptcha-box", {
1245  props: ["show", "type"],
1246  template: b2_global.check_code,
1247  data() {
1248    return {
1249      recaptcha: "",
1250      token: "",
1251      recaptchaUrl: "",
1252      disabled: true,
1253      issetLuo: false,
1254      locked: false,
1255      loginType: 2,
1256      checkType: b2_global.check_type,
1257    };
1258  },
1259  methods: {
1260    close() {
1261      this.$emit("close-form");
1262    },
1263    change() {
1264      //获取验证码base64及token
1265      if (this.locked) return;
1266      this.recaptchaUrl = "";
1267      this.locked = true;
1268      this.$https
1269        .post(b2_rest_url + "getRecaptcha", "number=4&width=186&height=50")
1270        .then((res) => {
1271          if (res.data) {
1272            this.recaptchaUrl = res.data.base;
1273            this.token = res.data.token;
1274          }
1275          this.locked = false;
1276        })
1277        .catch((err) => {
1278          Qmsg["warning"](err.response.data.message, { html: true });
1279          this.locked = false;
1280        });
1281    },
1282    checkCode() {
1283      if (this.disabled) return;
1284      this.disabled = true;
1285      this.$https
1286        .post(
1287          b2_rest_url + "imgCodeCheck",
1288          "img_code=" +
1289            this.recaptcha +
1290            "&token=" +
1291            this.token +
1292            "&loginType=" +
1293            login.loginType
1294        )
1295        .then((res) => {
1296          if (this.type == "edit") {
1297            b2AuthorEdit.imgCodeAc({
1298              value: this.recaptcha,
1299              token: this.token,
1300            });
1301          } else if (this.type == "bind") {
1302            b2bindLogin.imgCodeAc({
1303              value: this.recaptcha,
1304              token: this.token,
1305            });
1306          } else {
1307            login.imgCodeAc({
1308              value: this.recaptcha,
1309              token: this.token,
1310            });
1311            setTimeout(() => {
1312              login.$refs.loginBox.sendSMS();
1313            }, 50);
1314          }
1315
1316          this.disabled = false;
1317          this.close();
1318        })
1319        .catch((err) => {
1320          Qmsg["warning"](err.response.data.message, { html: true });
1321          this.disabled = false;
1322        });
1323    },
1324  },
1325  watch: {
1326    show(val) {
1327      if (val && b2_global.check_type == "normal") {
1328        this.change();
1329      }
1330      if (val && !this.issetLuo && login.loginType != 3) {
1331        let s = document.createElement("script");
1332        s.id = "luosimao";
1333        s.type = "text/javascript";
1334        s.src =
1335          "//captcha.luosimao.com/static/dist/api.js?time=" +
1336          new Date().getTime();
1337        document.getElementsByTagName("head")[0].appendChild(s);
1338        this.issetLuo = true;
1339      } else if (val && this.issetLuo && login.loginType != 3) {
1340        LUOCAPTCHA && LUOCAPTCHA.reset();
1341      }
1342
1343      if (this.type != "edit") {
1344        this.loginType = login.loginType;
1345      }
1346    },
1347    recaptcha(val) {
1348      if (val.length == 5 || val.length == 6) {
1349        this.disabled = false;
1350      } else {
1351        this.disabled = true;
1352      }
1353    },
1354  },
1355});
1356
1357var recaptcha = new Vue({
1358  el: "#recaptcha-form",
1359  data: {
1360    show: false,
1361    type: "",
1362  },
1363  methods: {
1364    close() {
1365      this.show = false;
1366      if (this.type != "edit" && this.type != "bind") {
1367        login.show = true;
1368      }
1369      if (this.type === "bind") {
1370        b2bindLogin.show = true;
1371      }
1372    },
1373  },
1374});
1375
1376function indexPostModules() {
1377  let m = document.querySelectorAll(".post-list");
1378  if (m.length > 0) {
1379    for (let i = 0; i < m.length; i++) {
1380      let key = m[i].getAttribute("data-key");
1381
1382      if (m[i].id != "undefined") {
1383        new Vue({
1384          el: "#post-item-" + key,
1385          data: {
1386            key: 0,
1387            index: 0,
1388            box: "",
1389            paged: 1,
1390            pages: 0,
1391            type: "cat",
1392            showButton: false,
1393            locked: false,
1394            cat: [],
1395            finish: false,
1396            id: 0,
1397          },
1398          mounted() {
1399            if (this.$el.querySelector(".load-more")) {
1400              this.key = key;
1401              this.index = this.$el.getAttribute("data-i");
1402              this.box = this.$el.querySelectorAll(".b2_gap")[0];
1403              this.showButton = this.$el
1404                .querySelector(".load-more")
1405                .getAttribute("data-showButton");
1406            }
1407          },
1408          methods: {
1409            getList(id, type, postType) {
1410              if (this.finish && type == "more") {
1411                return;
1412              } else {
1413                this.finish = false;
1414              }
1415
1416              if (this.locked) return;
1417              this.locked = true;
1418
1419              this.id = id;
1420
1421              if (type) {
1422                this.type = type;
1423              }
1424
1425              if (this.type == "cat") {
1426                this.paged = 1;
1427                if (id) {
1428                  this.cat = [id];
1429                } else {
1430                  this.cat = [];
1431                }
1432                this.finish = false;
1433              } else {
1434                this.paged = this.paged + 1;
1435              }
1436
1437              let data = {
1438                index: this.index,
1439                id: this.cat,
1440                post_paged: this.paged,
1441              };
1442              axios
1443                .post(b2_rest_url + "getModulePostList", Qs.stringify(data))
1444                .then((res) => {
1445                  if (res.data.count > 0) {
1446                    this.pages = res.data.pages;
1447                    if (this.type == "cat") {
1448                      if (this.pages == 1) {
1449                        this.box.innerHTML = res.data.data;
1450                      } else {
1451                        this.box.innerHTML = res.data.data;
1452                      }
1453
1454                      if (postType == "post-2") {
1455                        b2PackeryLoad();
1456                      }
1457                      this.showButton = true;
1458                    } else if (this.type == "more") {
1459                      this.box.insertAdjacentHTML("beforeend", res.data.data);
1460                      if (postType == "post-2") {
1461                        b2PackeryLoad();
1462                      }
1463                      this.showButton = true;
1464                    }
1465
1466                    if (this.paged >= this.pages) {
1467                      this.finish = true;
1468                    }
1469                  } else {
1470                    if (postType == "post-6") {
1471                      this.box.innerHTML =
1472                        '<tr><td colspan="10" style="border:0">' +
1473                        b2_global.empty_page +
1474                        "</td></tr>";
1475                    } else {
1476                      this.box.innerHTML = b2_global.empty_page;
1477                    }
1478                    this.showButton = false;
1479                  }
1480                  this.locked = false;
1481                  b2SidebarSticky();
1482                  this.$nextTick(() => {
1483                    lazyLoadInstance.update();
1484                  });
1485                });
1486            },
1487          },
1488        });
1489      }
1490    }
1491  }
1492}
1493indexPostModules();
1494
1495//遍历dom树,依次添加 is-visible 类,使其支持渐变显示
1496function listFadein(dom, time) {
1497  return;
1498  var i = 0;
1499  dom.forEach((e) => {
1500    if (e.className.indexOf("is-visible") === -1) {
1501      i++;
1502      if (i == 1) {
1503        e.className += " is-visible";
1504      } else {
1505        setTimeout(function () {
1506          e.className += " is-visible";
1507        }, i * time);
1508      }
1509    }
1510  });
1511}
1512listFadein(document.querySelectorAll(".post-list ul.b2_gap > li"), 10);
1513
1514//加载瀑布流
1515function b2PackeryLoad(e) {
1516  var grid = document.querySelectorAll(".grid");
1517  if (grid.length > 0) {
1518    for (let index = 0; index < grid.length; index++) {
1519      let pack = new Packery(grid[index]);
1520
1521      pack.on("layoutComplete", () => {
1522        b2SidebarSticky();
1523      });
1524    }
1525  }
1526}
1527b2PackeryLoad();
1528
1529//新版分页
1530//type p 分页加载,m 下拉加载
1531Vue.component("pagenav-new", {
1532  props: ["type", "paged", "pages", "opt", "api", "rote"],
1533  template: b2_global.page_nav,
1534  data: function () {
1535    return {
1536      locked: false,
1537      next: false,
1538      per: false,
1539      cpage: 0,
1540      cpaged: 1,
1541      cpages: [],
1542      mobile: false,
1543      showGo: false,
1544    };
1545  },
1546  created() {
1547    window.addEventListener(
1548      "scroll",
1549      _debounce(this.autoLoadMore),
1550      passiveSupported ? { passive: true } : false
1551    );
1552    this.cpaged = parseInt(this.paged);
1553    this.cpages = this.pagesInit();
1554    //监听前进与后退
1555    window.addEventListener(
1556      "popstate",
1557      () => {
1558        let state = history.state;
1559        if (state && state.page && this.type == "p") {
1560          this.go(state.page);
1561        }
1562      },
1563      passiveSupported ? { passive: true } : false
1564    );
1565    this.mobile = B2ClientWidth > 768 ? false : true;
1566  },
1567  methods: {
1568    disabled(page) {
1569      return page == this.cpaged && this.locked == true;
1570    },
1571    pagesInit() {
1572      let pagearr = [];
1573      if (this.pages <= 6) {
1574        for (let i = 1; i <= this.pages; i++) {
1575          pagearr.push(i);
1576        }
1577      } else {
1578        if (!this.cpaged) this.cpaged = this.paged;
1579        if (this.cpaged < 4) {
1580          for (let i = 1; i <= this.pages; i++) {
1581            if (i >= 5) break;
1582            pagearr.push(i);
1583          }
1584          pagearr.push(0, this.pages);
1585        } else if (this.cpaged >= 4 && this.pages - 2 > this.cpaged) {
1586          pagearr.push(1, 0);
1587          for (let i = this.cpaged - 1; i <= this.cpaged + 1; i++) {
1588            pagearr.push(i);
1589          }
1590          pagearr.push(0, this.pages);
1591        } else if (this.pages - 2 <= this.cpaged) {
1592          pagearr.push(1, 0);
1593          for (let i = this.cpaged - 2; i <= this.pages; i++) {
1594            pagearr.push(i);
1595          }
1596        }
1597      }
1598      return pagearr;
1599    },
1600    focus() {
1601      this.showGo = true;
1602    },
1603    blur() {
1604      setTimeout(() => {
1605        this.showGo = false;
1606      }, 100);
1607    },
1608    autoLoadMore() {
1609      if (this.type == "p") return;
1610      if (this.cpaged == this.pages) return;
1611      let scrollTop = document.documentElement.scrollTop;
1612      if (scrollTop + window.innerHeight >= document.body.clientHeight - 550) {
1613        this.go(this.cpaged + 1);
1614      }
1615    },
1616    trimSlashes(str) {
1617      return str.replace(/\/+$/, "");
1618    },
1619    go(page, type, action) {
1620      page = parseInt(page);
1621      if (this.opt.length > 0) return;
1622
1623      if (this.cpaged == page && !action) return;
1624
1625      if (this.locked == true) return;
1626      this.locked = true;
1627
1628      if (this.type === "m" && this.pages <= this.cpaged && page != 1) return;
1629
1630      if (type == "next") {
1631        this.next = true;
1632        this.per = false;
1633      } else if (type == "per") {
1634        this.per = true;
1635        this.next = false;
1636      }
1637
1638      this.cpaged = page;
1639
1640      this.opt["post_paged"] = page;
1641      this.opt["paged"] = page;
1642
1643      this.$http
1644        .post(b2_rest_url + this.api, Qs.stringify(this.opt))
1645        .then((res) => {
1646          this.locked = false;
1647          this.cpages = this.pagesInit();
1648
1649          this.$emit("return", res.data);
1650
1651          if (this.rote) {
1652            let currentURL = window.location.href,
1653              url = this.trimSlashes(currentURL.split("?")[0]),
1654              newURL;
1655            console.log(url);
1656            if (this.cpaged == 1) {
1657              newURL = url.replace(/\/page\/\d/, "");
1658            } else {
1659              if (currentURL.indexOf("/page/") == -1) {
1660                newURL = url + "/page/" + this.cpaged;
1661              } else {
1662                newURL = url.replace(/\/page\/[0-9]*$/, "/page/" + page);
1663              }
1664            }
1665
1666            url = currentURL.replace(url, newURL);
1667
1668            window.history.pushState({ page: page }, null, url);
1669            if (this.type === "p") {
1670              b2AsideBar.goTop();
1671            }
1672          }
1673
1674          b2SidebarSticky();
1675          this.$nextTick(() => {
1676            lazyLoadInstance.update();
1677          });
1678        })
1679        .catch((err) => {
1680          Qmsg["warning"](err.response.data.message, { html: true });
1681        });
1682    },
1683    //获取数据
1684    getData(fn, data) {
1685      this.cpaged = this.cpage;
1686      this.cpages = this.pagesInit();
1687    },
1688    //跳转
1689    jump(event) {
1690      var val =
1691        event.target.value ||
1692        event.target.previousElementSibling.value ||
1693        this.$refs.pagenavnumber.value;
1694
1695      val = parseInt(val);
1696
1697      if (val > this.pages) return;
1698
1699      this.go(val, "p", true);
1700    },
1701  },
1702  watch: {
1703    pages(val) {
1704      this.cpages = this.pagesInit();
1705    },
1706    paged() {
1707      this.cpaged = parseInt(this.paged);
1708      this.cpages = this.pagesInit();
1709    },
1710  },
1711});
1712
1713//分页代码
1714Vue.component("page-nav", {
1715  props: [
1716    "paged",
1717    "navtype",
1718    "pages",
1719    "type",
1720    "box",
1721    "opt",
1722    "api",
1723    "url",
1724    "title",
1725  ],
1726  template: b2_global.page_nav,
1727  data: function () {
1728    return {
1729      locked: false,
1730      next: false,
1731      per: false,
1732      cpage: 0,
1733      cpaged: 1,
1734      cpages: [],
1735      mobile: false,
1736      showGo: false,
1737    };
1738  },
1739  created() {
1740    window.addEventListener(
1741      "scroll",
1742      _debounce(this.autoLoadMore),
1743      passiveSupported ? { passive: true } : false
1744    );
1745    this.cpaged = parseInt(this.paged);
1746    this.cpages = this.pagesInit();
1747    //监听前进与后退
1748    window.addEventListener(
1749      "popstate",
1750      () => {
1751        let state = history.state;
1752        if (state && state.page && this.type == "p") {
1753          this.go(state.page);
1754        }
1755      },
1756      passiveSupported ? { passive: true } : false
1757    );
1758    this.mobile = B2ClientWidth > 768 ? false : true;
1759  },
1760  methods: {
1761    disabled(page) {
1762      return page == this.cpaged && this.locked == true;
1763    },
1764    pagesInit() {
1765      let pagearr = [];
1766      if (this.pages <= 7) {
1767        for (let i = 1; i <= this.pages; i++) {
1768          pagearr.push(i);
1769        }
1770      } else {
1771        if (!this.cpaged) this.cpaged = this.paged;
1772        if (this.cpaged < 5) {
1773          for (let i = 1; i <= this.pages; i++) {
1774            if (i >= 6) break;
1775            pagearr.push(i);
1776          }
1777          pagearr.push(0, this.pages);
1778        } else if (this.cpaged >= 5 && this.pages - 3 > this.cpaged) {
1779          pagearr.push(1, 0);
1780          for (let i = this.cpaged - 2; i <= this.cpaged + 2; i++) {
1781            pagearr.push(i);
1782          }
1783          pagearr.push(0, this.pages);
1784        } else if (this.pages - 3 <= this.cpaged) {
1785          pagearr.push(1, 0);
1786          for (let i = this.cpaged - 3; i <= this.pages; i++) {
1787            pagearr.push(i);
1788          }
1789        }
1790      }
1791      return pagearr;
1792    },
1793    autoLoadMore() {
1794      setTimeout(() => {
1795        if (this.type == "p") return;
1796        let scrollTop = document.documentElement.scrollTop;
1797        if (
1798          scrollTop + window.innerHeight >=
1799          document.body.clientHeight - 550
1800        ) {
1801          this.go(this.cpaged + 1);
1802        }
1803      }, 300);
1804    },
1805    focus() {
1806      this.showGo = true;
1807    },
1808    blur() {
1809      setTimeout(() => {
1810        this.showGo = false;
1811      }, 100);
1812    },
1813    go(page, type, action) {
1814      page = parseInt(page);
1815      if (this.opt.length > 0) return;
1816
1817      if (this.cpaged == page && !action) return;
1818      if (this.locked == true) return;
1819
1820      if (this.type === "m" && this.pages <= this.cpaged && page != 1) return;
1821
1822      this.locked = true;
1823
1824      if (type == "next") {
1825        this.next = true;
1826        this.per = false;
1827      } else if (type == "per") {
1828        this.per = true;
1829        this.next = false;
1830      }
1831
1832      this.cpaged = page;
1833      console.log(this.cpaged);
1834
1835      this.opt["post_paged"] = page;
1836      this.opt["paged"] = page;
1837
1838      this.$http
1839        .post(b2_rest_url + this.api, Qs.stringify(this.opt))
1840        .then((res) => {
1841          this.locked = false;
1842          this.cpages = this.pagesInit();
1843          let dom = document.querySelector(this.box);
1844
1845          //如果返回的是json数据
1846          if (this.navtype === "json") {
1847            this.$emit("return", res.data);
1848          } else {
1849            if (this.type === "p") {
1850              dom.innerHTML = res.data.data;
1851            } else {
1852              dom.insertAdjacentHTML("beforeend", res.data.data);
1853            }
1854          }
1855
1856          if (page != 1) {
1857            this.url = b2removeURLParameter(this.url, "action");
1858          }
1859
1860          //变更地址栏和title
1861          if (
1862            !!(window.history && history.pushState) &&
1863            !(b2_global.is_front_page && this.api == "getNewsflashesList")
1864          ) {
1865            if (page != 1) {
1866              if (this.navtype === "comment") {
1867                if (b2_global.structure) {
1868                  window.history.pushState(
1869                    { page: page },
1870                    null,
1871                    this.url + "/comment-page-" + page + "#comment"
1872                  );
1873                } else {
1874                  window.history.pushState(
1875                    { page: page },
1876                    null,
1877                    this.url + "&cpage=" + page + "#comment"
1878                  );
1879                }
1880              } else {
1881                if (this.navtype != "authorComments" && this.title) {
1882                  document.title =
1883                    this.title +
1884                    " " +
1885                    b2_global.site_separator +
1886                    " " +
1887                    b2_global.page_title.replace("{#}", page) +
1888                    " " +
1889                    b2_global.site_separator +
1890                    " " +
1891                    b2_global.site_name;
1892                }
1893                let currentURL = window.location.href,
1894                  url = currentURL.split("?")[0],
1895                  newURL;
1896
1897                if (this.cpaged == 1) {
1898                  newURL = url.replace(/\/page\/\d/, "");
1899                } else {
1900                  if (currentURL.indexOf("/page/") == -1) {
1901                    newURL = url + "/page/" + this.cpaged;
1902                  } else {
1903                    newURL = url.replace(/\/page\/[0-9]*$/, "/page/" + page);
1904                  }
1905                }
1906
1907                url = currentURL.replace(url, newURL);
1908
1909                window.history.pushState({ page: page }, null, url);
1910                if (this.type === "p") {
1911                  b2AsideBar.goTop();
1912                }
1913              }
1914            } else {
1915              if (this.navtype === "comment") {
1916                window.history.pushState(
1917                  { page: page },
1918                  null,
1919                  this.url + "#comment"
1920                );
1921              } else {
1922                if (this.navtype != "authorComments" && this.title) {
1923                  document.title =
1924                    this.title +
1925                    " " +
1926                    b2_global.site_separator +
1927                    " " +
1928                    b2_global.site_name;
1929                }
1930
1931                window.history.pushState({ page: page }, null, this.url);
1932              }
1933            }
1934          }
1935
1936          if (this.navtype === "comment" || this.navtype === "authorComments") {
1937            let img = document.querySelectorAll(".comment-img-box img");
1938            if (img.length > 0) {
1939              for (let index = 0; index < img.length; index++) {
1940                // var img = new Image();
1941                // img.src = img[index].getAttribute('data-original');
1942                // img.onload = function(){
1943
1944                //     img[index].setAttribute('data-zooming-width',img.width)
1945                //     img[index].setAttribute('data-zooming-height',img.height)
1946
1947                // };
1948                b2zoom.listen(img[index]);
1949              }
1950            }
1951            if (this.navtype === "comment") {
1952              b2CommentList.showSticky();
1953              b2SidebarSticky();
1954            }
1955          } else if (this.navtype === "post") {
1956            b2PackeryLoad();
1957            //渐显
1958            setTimeout(() => {
1959              listFadein(document.querySelectorAll(this.box + " > li"), 20);
1960            }, 500);
1961          }
1962          this.$emit("finish");
1963          b2SidebarSticky();
1964          this.$nextTick(() => {
1965            lazyLoadInstance.update();
1966          });
1967        })
1968        .catch((err) => {
1969          Qmsg["warning"](err.response.data.message, { html: true });
1970        });
1971    },
1972    //获取数据
1973    getData(fn, data) {
1974      this.cpaged = this.cpage;
1975      this.cpages = this.pagesInit();
1976    },
1977    //跳转
1978    jump(event) {
1979      var val =
1980        event.target.value ||
1981        event.target.previousElementSibling.value ||
1982        this.$refs.pagenavnumber.value;
1983
1984      val = parseInt(val);
1985
1986      if (val > this.pages) return;
1987
1988      this.go(val, "p", true);
1989    },
1990  },
1991  watch: {
1992    pages(val) {
1993      this.cpages = this.pagesInit();
1994    },
1995    paged() {
1996      this.cpaged = parseInt(this.paged);
1997      this.cpages = this.pagesInit();
1998    },
1999  },
2000});
2001
2002function b2RestTimeAgo(dom) {
2003  // if(dom && dom.length > 0)
2004  // timeago.render(dom, b2_global.language);
2005}
2006
2007let pageNavBox = new Vue({
2008  el: ".post-nav",
2009  data: {
2010    selecter: "#post-list .b2_gap",
2011    opt: "",
2012    api: "getPostList",
2013    options: [],
2014    value: 1,
2015    showGoN: false,
2016  },
2017  mounted() {
2018    if (typeof b2_cat !== "undefined") {
2019      this.opt = b2_cat.opt;
2020    }
2021  },
2022  methods: {
2023    jumpAc: function (event) {
2024      var val =
2025        event.target.value ||
2026        event.target.previousElementSibling.value ||
2027        this.$refs.pagenavnumber.value;
2028
2029      if (val > this.opt.pages) return;
2030
2031      let currentURL = window.location.href,
2032        url = currentURL.split("?")[0],
2033        newURL;
2034
2035      if (val == 1) {
2036        newURL = url.replace(/\/page\/\d/, "");
2037      } else {
2038        if (currentURL.indexOf("/page/") == -1) {
2039          newURL = url + "/page/" + val;
2040        } else {
2041          newURL = url.replace(/\/page\/[0-9]*$/, "/page/" + val);
2042        }
2043      }
2044
2045      url = currentURL.replace(url, newURL);
2046
2047      window.location.href = url;
2048    },
2049    focus() {
2050      this.showGoN = true;
2051    },
2052    blur() {
2053      setTimeout(() => {
2054        this.showGoN = false;
2055      }, 100);
2056    },
2057  },
2058});
2059
2060//语音播放
2061let b2Audio = new Vue({
2062  el: ".b2-audio-content",
2063  data: {
2064    url: "",
2065    textList: [],
2066    playStatus: false,
2067    api: "https://tts.baidu.com/text2audio?cuid=baike&lan=ZH&ctp=1&pdt=301&tex=",
2068    index: 0,
2069    currentTime: "00:00",
2070    startTime: "00:00",
2071    step: 0,
2072    duration: 0,
2073    ds: "",
2074    width: "0%",
2075  },
2076  methods: {
2077    play() {
2078      //如果未播放,加载播放列表
2079      if (!this.url) {
2080        this.getPlayList();
2081      } else {
2082        this.playList();
2083      }
2084    },
2085    getPlayList() {
2086      this.$https
2087        .post(
2088          b2_rest_url + "getPostAudio",
2089          "post_id=" + this.$refs.audio.getAttribute("data-id")
2090        )
2091        .then((res) => {
2092          if (res.data.length > 0) {
2093            this.textList = res.data;
2094            //res.data
2095            this.playList();
2096            this.watchPlay();
2097          }
2098        });
2099    },
2100    playList() {
2101      this.url = this.api + this.textList[this.index];
2102      setTimeout(() => {
2103        this.button();
2104      });
2105    },
2106    watchPlay() {
2107      this.$refs.audio.addEventListener(
2108        "ended",
2109        () => {
2110          if (this.index >= this.textList.length - 1) {
2111            this.playStatus = false;
2112            this.index = 0;
2113            this.step = 0;
2114            return;
2115          }
2116          this.step = 0;
2117          this.index = this.index + 1;
2118          this.playList();
2119        },
2120        passiveSupported ? { passive: true } : false
2121      );
2122    },
2123    button() {
2124      if (this.$refs.audio !== null) {
2125        if (this.$refs.audio.paused) {
2126          this.$refs.audio.play();
2127          this.playStatus = true;
2128          this.timeSetp();
2129        } else {
2130          this.$refs.audio.pause();
2131          this.playStatus = false;
2132        }
2133
2134        this.$refs.audio.addEventListener(
2135          "loadedmetadata",
2136          () => {
2137            this.duration = Math.round(this.$refs.audio.duration);
2138            this.currentTime = this.secondToDate(this.duration);
2139          },
2140          passiveSupported ? { passive: true } : false
2141        );
2142      }
2143    },
2144    timeSetp() {
2145      if (this.playStatus == true) {
2146        this.startTime = this.secondToDate(this.step++);
2147        if (this.ds) {
2148          clearTimeout(this.ds);
2149        }
2150        this.ds = setTimeout(() => {
2151          this.timeSetp();
2152          this.width = (this.step / this.duration) * 100 + "%";
2153        }, 1000);
2154      }
2155    },
2156    secondToDate(s) {
2157      var t;
2158      if (s > -1) {
2159        var hour = Math.floor(s / 3600);
2160        var min = Math.floor(s / 60) % 60;
2161        var sec = s % 60;
2162        if (hour > 1) {
2163          if (hour < 10) {
2164            t = "0" + hour + ":";
2165          } else {
2166            t = hour + ":";
2167          }
2168        } else {
2169          t = "";
2170        }
2171
2172        if (min < 10) {
2173          t += "0";
2174        }
2175        t += min + ":";
2176        if (sec < 10) {
2177          t += "0";
2178        }
2179        t += sec.toFixed(0);
2180      }
2181      return t;
2182    },
2183  },
2184});
2185
2186var socialLogin = new Vue({
2187  el: "#juhe-social",
2188  data: {
2189    locked: false,
2190    error: "",
2191  },
2192  mounted() {
2193    if (!this.$refs.juhebox) return;
2194    let type = b2GetQueryVariable("type");
2195    this.locked = true;
2196    this.$http
2197      .post(b2_rest_url + "juheSocialLogin", "type=" + type)
2198      .then((res) => {
2199        window.location.href = res.data;
2200      })
2201      .catch((err) => {
2202        this.error = err.response.data.message;
2203        this.locked = false;
2204      });
2205  },
2206  methods: {
2207    back() {
2208      let url = b2getCookie("b2_back_url");
2209
2210      if (url) {
2211        window.location.href = url;
2212      } else {
2213        window.location.href = b2_global.home_url;
2214      }
2215    },
2216  },
2217});
2218
2219var socialBox = new Vue({
2220  el: "#social-box",
2221  data: {
2222    locked: false,
2223    type: "",
2224    data: {
2225      token: "",
2226      invitation: "",
2227      subType: "",
2228    },
2229    error: "",
2230    oauth: "",
2231    name: "",
2232  },
2233  mounted() {
2234    if (this.$refs.socialBox) {
2235      let code = b2GetQueryVariable("code"),
2236        juhe = b2GetQueryVariable("juhe") ? b2GetQueryVariable("juhe") : 0;
2237      this.type = b2GetQueryVariable("type") || "weixin";
2238
2239      if (code) {
2240        this.locked = true;
2241        this.$http
2242          .post(
2243            b2_rest_url + "socialLogin",
2244            "code=" + code + "&type=" + this.type + "&juhe=" + juhe
2245          )
2246          .then((res) => {
2247            this.locked = false;
2248            if (res.data === true) {
2249              this.back();
2250            } else if (res.data.type == "invitation") {
2251              (this.type = "invitation"), (this.data.token = res.data.token);
2252            } else {
2253              this.back();
2254            }
2255          })
2256          .catch((err) => {
2257            if (err.response.data.message.msg) {
2258              this.oauth = err.response.data.message.oauth;
2259              this.error = err.response.data.message.msg;
2260              this.name = err.response.data.message.name;
2261            } else {
2262              this.error = err.response.data.message;
2263            }
2264
2265            this.locked = false;
2266          });
2267      }
2268    }
2269  },
2270  methods: {
2271    back() {
2272      let url = b2getCookie("b2_back_url");
2273
2274      if (url) {
2275        window.location.href = url;
2276      } else {
2277        window.location.href = b2_global.home_url;
2278      }
2279    },
2280    invRegeister(type) {
2281      if (this.locked == "pass" || this.locked == "sub") return;
2282      this.locked = type;
2283      this.data.subType = type;
2284      this.$http
2285        .post(b2_rest_url + "invRegeister", Qs.stringify(this.data))
2286        .then((res) => {
2287          this.back();
2288        })
2289        .catch((err) => {
2290          Qmsg["warning"](err.response.data.message, { html: true });
2291          this.locked = false;
2292        });
2293    },
2294    loginOut(url) {
2295      b2delCookie("b2_token");
2296      b2CurrentPageReload(url);
2297    },
2298    rebuild(ev) {
2299      this.$http
2300        .post(
2301          b2_rest_url + "unBuild",
2302          "type=" + this.type + "&user_id=" + b2_author.author_id
2303        )
2304        .then((res) => {})
2305        .catch((err) => {
2306          ev.preventDefault();
2307
2308          Qmsg["warning"](err.response.data.message, { html: true });
2309        });
2310    },
2311  },
2312});
2313
2314Vue.component("gg-box", {
2315  props: ["show"],
2316  template: b2_global.gg_box,
2317  computed: {
2318    ggdata() {
2319      return this.$store.state.announcement[0];
2320    },
2321  },
2322  methods: {
2323    close() {
2324      this.$emit("close");
2325    },
2326  },
2327});
2328
2329var b2GG = new Vue({
2330  el: "#gong-box",
2331  data: {
2332    show: false,
2333  },
2334  mounted() {
2335    this.$http
2336      .post(b2_rest_url + "getLatestAnnouncement", "count=3")
2337      .then((res) => {
2338        if (res.data.length > 0) {
2339          this.$store.commit("setAnnouncement", res.data);
2340
2341          this.show = res.data[0].show;
2342        } else {
2343          this.$store.commit("setAnnouncement", "none");
2344        }
2345      });
2346  },
2347  methods: {
2348    close() {
2349      this.show = false;
2350      let timestamp = new Date().getTime();
2351      timestamp = parseInt(timestamp / 1000);
2352
2353      b2setCookie("gg_info", timestamp);
2354    },
2355  },
2356});
2357
2358Vue.component("jubao", {
2359  props: ["show", "idType", "id"],
2360  template: b2_global.jubao_box,
2361  data: function () {
2362    return {
2363      type: "",
2364      content: "",
2365      locked: false,
2366      types: b2_global.report_types,
2367      jubaoImg: 0,
2368      jubaoImgUrl: "",
2369      submitLocked: false,
2370    };
2371  },
2372  created() {
2373    this.type = this.types[0];
2374  },
2375  computed: {
2376    email() {
2377      return userTools?.role?.user_data?.email || "";
2378    },
2379  },
2380  methods: {
2381    close() {
2382      this.$emit("close");
2383    },
2384    getFile(event, type) {
2385      if (event.target.files.length <= 0) return;
2386      if (this.locked == true) return;
2387      this.locked = true;
2388      let file = event.target.files[0];
2389
2390      let formData = new FormData();
2391
2392      formData.append("file", file, file.name);
2393      formData.append("post_id", 1);
2394      formData.append("type", "qrcode");
2395
2396      this.$http
2397        .post(b2_rest_url + "fileUpload", formData)
2398        .then((res) => {
2399          this.jubaoImg = res.data.id;
2400          this.jubaoImgUrl = res.data.url;
2401          this.locked = false;
2402          this.$refs.fileInput.value = null;
2403        })
2404        .catch((err) => {
2405          Qmsg["warning"](err.response.data.message, { html: true });
2406          this.jubaoImg = "";
2407          this.$refs.fileInput.value = null;
2408          this.locked = false;
2409        });
2410    },
2411    submit() {
2412      if (this.locked == true || this.submitLocked == true) return;
2413      this.submitLocked = true;
2414
2415      this.$http
2416        .post(
2417          b2_rest_url + "submitReport",
2418          "type=" +
2419            this.type +
2420            "&post_id=" +
2421            this.id +
2422            "&post_type=" +
2423            this.idType +
2424            "&content=" +
2425            this.content +
2426            "&img=" +
2427            this.jubaoImg +
2428            "&email=" +
2429            this.email
2430        )
2431        .then((res) => {
2432          this.submitLocked = false;
2433          this.content = "";
2434          this.jubaoImg = 0;
2435          this.idType = "";
2436          this.id = 0;
2437          this.jubaoImgUrl = "";
2438          this.close();
2439          Qmsg["success"](b2_global.js_text.global.jubao_success, {
2440            html: true,
2441          });
2442        })
2443        .catch((err) => {
2444          Qmsg["warning"](err.response.data.message, { html: true });
2445          this.submitLocked = false;
2446        });
2447    },
2448  },
2449});
2450
2451const jubao = new Vue({
2452  el: "#jubao-box",
2453  data: {
2454    show: false,
2455    idType: "",
2456    id: 0,
2457  },
2458  mounted() {
2459    autosize(this.$el.querySelector("textarea"));
2460  },
2461  methods: {
2462    close(idType, id) {
2463      if (!b2token) {
2464        login.show = true;
2465        login.loginType = 1;
2466        return;
2467      }
2468      console.log(idType, id);
2469      this.idType = idType;
2470      this.id = id;
2471      this.show = !this.show;
2472    },
2473  },
2474});
2475
2476Vue.component("dmsg-box", {
2477  props: ["show", "userid", "type"],
2478  template: b2_global.dmsg_box,
2479  data() {
2480    return {
2481      user: [],
2482      content: "",
2483      locked: false,
2484      nickname: "",
2485      UserList: [],
2486      search: false,
2487    };
2488  },
2489  methods: {
2490    close() {
2491      this.$emit("close");
2492      setTimeout(() => {
2493        this.user = [];
2494        this.content = "";
2495        this.nickname = "";
2496        this.UserList = [];
2497      }, 100);
2498    },
2499    getUserData(id = 0) {
2500      id = !id ? this.userid : id;
2501      this.$http
2502        .post(b2_rest_url + "getUserPublicData", "user_id=" + id)
2503        .then((res) => {
2504          this.user = res.data;
2505          b2Dmsg.userid = id;
2506          b2Dmsg.select = "";
2507          this.UserList = [];
2508        })
2509        .catch((err) => {
2510          Qmsg["warning"](err.response.data.message, { html: true });
2511        });
2512    },
2513    edit() {
2514      b2Dmsg.select = "select";
2515    },
2516    send() {
2517      if (this.locked == true) return;
2518      this.locked = true;
2519      this.$http
2520        .post(
2521          b2_rest_url + "sendDirectmessage",
2522          "user_id=" + this.userid + "&content=" + this.content
2523        )
2524        .then((res) => {
2525          if (res.data == true) {
2526            this.close();
2527          }
2528          if (b2DmsgPage.$refs.dmsgPage) {
2529            b2DmsgPage.getList();
2530          }
2531          this.locked = false;
2532        })
2533        .catch((err) => {
2534          Qmsg["warning"](err.response.data.message, { html: true });
2535          this.locked = false;
2536        });
2537    },
2538    searchUser(val) {
2539      if (this.locked == true) return;
2540      this.locked = true;
2541      this.search = true;
2542      this.$http
2543        .post(b2_rest_url + "searchUsers", "nickname=" + val)
2544        .then((res) => {
2545          if (res.data.length > 0) {
2546            this.UserList = res.data;
2547          } else {
2548            this.UserList = [];
2549          }
2550          this.locked = false;
2551        })
2552        .catch((err) => {
2553          Qmsg["warning"](err.response.data.message, { html: true });
2554          this.locked = false;
2555          this.UserList = [];
2556        });
2557    },
2558  },
2559  watch: {
2560    show(val) {
2561      if (val && this.type !== "select") {
2562        this.getUserData();
2563      }
2564    },
2565    nickname(val) {
2566      if (val) {
2567        this.searchUser(val);
2568      }
2569    },
2570  },
2571});
2572
2573var b2Dmsg = new Vue({
2574  el: "#dmsg-box",
2575  data: {
2576    userid: 0,
2577    show: false,
2578    select: "",
2579  },
2580  methods: {
2581    close() {
2582      this.show = !this.show;
2583    },
2584  },
2585});
2586
2587var b2DmsgPage = new Vue({
2588  el: ".dmsg-page",
2589  data: {
2590    list: false,
2591    locked: false,
2592    count: 0,
2593    pages: 0,
2594    selecter: ".dmsg-header",
2595    opt: {
2596      paged: 1,
2597    },
2598    api: "getUserDirectmessageList",
2599  },
2600  mounted() {
2601    if (this.$refs.dmsgPage) {
2602      this.opt.paged = this.$refs.dmsgPage.getAttribute("data-paged");
2603      this.getList();
2604    }
2605  },
2606  methods: {
2607    getList() {
2608      this.$http
2609        .post(b2_rest_url + "getUserDirectmessageList", Qs.stringify(this.opt))
2610        .then((res) => {
2611          this.list = res.data.data;
2612          this.pages = res.data.count;
2613          this.locked = false;
2614          this.$nextTick(() => {
2615            b2RestTimeAgo(this.$el.querySelectorAll(".b2timeago"));
2616          });
2617        })
2618        .catch((err) => {
2619          Qmsg["warning"](err.response.data.message, { html: true });
2620          this.locked = false;
2621        });
2622    },
2623    showDmsgBox() {
2624      b2Dmsg.select = "select";
2625      b2Dmsg.show = true;
2626    },
2627    get(data) {
2628      this.list = data.data;
2629      this.pages = data.count;
2630      this.$nextTick(() => {
2631        b2RestTimeAgo(this.$el.querySelectorAll(".b2timeago"));
2632      });
2633    },
2634    jump(id) {
2635      window.location.href =
2636        this.$refs.dmsgPage.getAttribute("data-url") + "/to/" + id;
2637    },
2638    deleteDmsg(id) {},
2639  },
2640});
2641
2642var b2dmsgPageTo = new Vue({
2643  el: ".dmsg-page-to",
2644  data: {
2645    list: false,
2646    locked: false,
2647    opt: {
2648      paged: 1,
2649      userid: 0,
2650    },
2651    count: 0,
2652    pages: 0,
2653    selecter: ".dmsg-header",
2654    api: "getMyDirectmessageList",
2655    content: "",
2656    sendLocked: false,
2657  },
2658  mounted() {
2659    if (this.$refs.mydmsg) {
2660      this.opt.userid = this.$refs.mydmsg.getAttribute("data-id");
2661      this.opt.paged = this.$refs.mydmsg.getAttribute("data-paged");
2662      this.getList();
2663    }
2664  },
2665  methods: {
2666    getList() {
2667      this.$http
2668        .post(b2_rest_url + "getMyDirectmessageList", Qs.stringify(this.opt))
2669        .then((res) => {
2670          this.list = res.data.data;
2671          this.locked = false;
2672          this.count = res.data.count;
2673          this.pages = res.data.pages;
2674          this.$nextTick(() => {
2675            b2RestTimeAgo(this.$el.querySelectorAll(".b2timeago"));
2676          });
2677        })
2678        .catch((err) => {
2679          Qmsg["warning"](err.response.data.message, { html: true });
2680          this.locked = false;
2681        });
2682    },
2683    get(val) {
2684      this.list = val.data;
2685      this.count = val.count;
2686      this.pages = val.pages;
2687    },
2688    send() {
2689      if (this.sendLocked == true) return;
2690      this.sendLocked = true;
2691      this.$http
2692        .post(
2693          b2_rest_url + "sendDirectmessage",
2694          "user_id=" + this.opt.userid + "&content=" + this.content
2695        )
2696        .then((res) => {
2697          this.getList();
2698          this.content = "";
2699          this.sendLocked = false;
2700        })
2701        .catch((err) => {
2702          Qmsg["warning"](err.response.data.message, { html: true });
2703          this.sendLocked = false;
2704        });
2705    },
2706  },
2707});
2708
2709var b2DownloadPage = new Vue({
2710  el: "#download-page",
2711  data: {
2712    data: "",
2713    postId: 0,
2714    index: 0,
2715    i: 0,
2716  },
2717  mounted() {
2718    if (this.$refs.downloadPage) {
2719      this.postId = b2GetQueryVariable("post_id");
2720      this.index = b2GetQueryVariable("index");
2721      this.i = b2GetQueryVariable("i");
2722      this.getData();
2723
2724      var clipboard = new ClipboardJS(".fuzhi");
2725      clipboard.on("success", (e) => {
2726        Qmsg["success"](b2_global.js_text.global.copy_success, { html: true });
2727      });
2728      clipboard.on("error", (e) => {
2729        Qmsg["warning"](b2_global.js_text.global.copy_select, { html: true });
2730      });
2731    }
2732  },
2733  methods: {
2734    getData() {
2735      let guest = b2getCookie("b2_guest_buy_" + this.postId + "_x");
2736      if (guest) {
2737        guest = JSON.parse(guest);
2738      }
2739
2740      let data = {
2741        post_id: this.postId,
2742        index: this.index,
2743        i: this.i,
2744        guest: guest,
2745      };
2746
2747      this.$http
2748        .post(b2_rest_url + "getDownloadPageData", Qs.stringify(data))
2749        .then((res) => {
2750          this.data = res.data;
2751        })
2752        .catch((err) => {
2753          Qmsg["warning"](err.response.data.message, { html: true });
2754        });
2755    },
2756    login() {
2757      login.show = true;
2758    },
2759  },
2760});
2761
2762Vue.component("check-box", {
2763  props: ["show", "title", "type", "payt"],
2764  template: b2_global.pay_check,
2765  data() {
2766    return {
2767      success: false,
2768      timeOut: 300,
2769      timesec: "",
2770      sTime: "",
2771      check: false,
2772      checkTime: "",
2773      orderType: "",
2774    };
2775  },
2776  methods: {
2777    close() {
2778      this.$emit("close");
2779      this.sTime = "";
2780      this.checkTime = "";
2781    },
2782    checkAc() {
2783      if (
2784        (this.sTime === null && this.success == "fail") ||
2785        this.checkTime === null ||
2786        this.success === true
2787      ) {
2788        this.checkTime = null;
2789        return;
2790      }
2791
2792      let value = b2getCookie("order_id");
2793      this.$http
2794        .post(b2_rest_url + "payCheck", "order_id=" + value)
2795        .then((res) => {
2796          if (res.data.status === "success") {
2797            this.orderType = res.data.type;
2798            if (!b2token) {
2799              let list = b2getCookie(
2800                "b2_guest_buy_" + res.data.id + "_" + res.data.type
2801              );
2802
2803              if (!list) {
2804                list = new Object();
2805              } else {
2806                list = JSON.parse(list);
2807              }
2808
2809              Reflect.set(list, res.data.index, {
2810                id: res.data.id,
2811                order_id: value,
2812                type: res.data.type,
2813                index: res.data.index,
2814              });
2815
2816              list = JSON.stringify(list);
2817
2818              b2setCookie(
2819                "b2_guest_buy_" + res.data.id + "_" + res.data.type,
2820                list
2821              );
2822            }
2823
2824            //b2delCookie('order_id')
2825
2826            if (typeof B2VerifyPage !== "undefined") {
2827              B2VerifyPage.data.money = true;
2828              this.close();
2829            } else if (typeof carts !== "undefined") {
2830              carts.step = 3;
2831              this.close();
2832            } else if (this.payt === "ask") {
2833              b2CircleList.afterCommentGetData(
2834                b2CircleList.answer.listParent,
2835                b2CircleList.data[b2CircleList.answer.listParent].topic_id,
2836                "ask"
2837              );
2838              this.close();
2839            } else if (this.payt === "hidden") {
2840              b2CircleList.afterCommentGetData(
2841                b2CircleList.hiddenIndex,
2842                b2CircleList.data[b2CircleList.hiddenIndex].topic_id,
2843                "hidden"
2844              );
2845              this.close();
2846            }
2847            this.success = true;
2848            this.checkTime = null;
2849            this.sTime = null;
2850          } else {
2851            this.checkTime = setTimeout(() => {
2852              this.checkAc();
2853            }, 1000);
2854          }
2855        });
2856    },
2857    time() {
2858      this.currTime = parseInt(Date.parse(new Date()) / 1000);
2859      this.endTime = parseInt(this.currTime + this.timeOut);
2860      this.setTime();
2861    },
2862    setTime() {
2863      if (this.show == false || this.success === true) {
2864        this.sTime = null;
2865        this.checkTime = null;
2866        return;
2867      }
2868      let diff_time = parseInt(this.endTime - this.currTime);
2869      let m = Math.floor((diff_time / 60) % 60);
2870      let s = Math.floor(diff_time % 60);
2871      this.timesec =
2872        (m > 0 ? m + "<b>" + b2_global.js_text.global.min + "</b>" : "") +
2873        s +
2874        "<b>" +
2875        b2_global.js_text.global.sec +
2876        "</b>";
2877      if (diff_time > 0) {
2878        this.sTime = setTimeout(() => {
2879          this.endTime = this.endTime - 1;
2880          this.setTime();
2881        }, 1000);
2882      } else {
2883        this.sTime = null;
2884        this.success = "fail";
2885      }
2886    },
2887    refresh() {
2888      if (typeof B2VerifyPage !== "undefined") {
2889        B2VerifyPage.data.money = true;
2890        this.close();
2891      } else if (typeof carts !== "undefined") {
2892        carts.step = 3;
2893        this.close();
2894      } else if (this.payt === "ask") {
2895        b2CircleList.afterCommentGetData(
2896          b2CircleList.answer.listParent,
2897          b2CircleList.data[b2CircleList.answer.listParent].topic_id,
2898          "ask"
2899        );
2900        this.close();
2901      } else if (this.payt === "hidden") {
2902        b2CircleList.afterCommentGetData(
2903          b2CircleList.hiddenIndex,
2904          b2CircleList.data[b2CircleList.hiddenIndex].topic_id,
2905          "hidden"
2906        );
2907        this.close();
2908      } else if (
2909        typeof b2poinfomation !== "undefined" &&
2910        b2poinfomation.$refs.poinfomation
2911      ) {
2912        b2poinfomation.getPoinfomationOpts();
2913        this.close();
2914      } else if (this.orderType === "x") {
2915        b2DownloadBox.getList();
2916        this.close();
2917      } else {
2918        var url = new URL(window.location.href);
2919        url.searchParams.delete("b2paystatus");
2920        window.location.href = url.href;
2921        b2CurrentPageReload();
2922      }
2923    },
2924  },
2925  watch: {
2926    show(val) {
2927      if (this.type == "card") return;
2928      if (val) {
2929        this.sTime = "";
2930        this.checkTime = "";
2931        this.time();
2932
2933        this.checkAc();
2934      } else {
2935        this.sTime = null;
2936        this.success = false;
2937        this.checkTime = null;
2938      }
2939    },
2940  },
2941});
2942
2943//跳转支付检查支付结果
2944var b2PayCheck = new Vue({
2945  el: "#pay-check",
2946  data: {
2947    show: false,
2948    title: "",
2949    type: "",
2950    payType: "",
2951  },
2952  mounted() {
2953    if (b2GetQueryVariable("b2paystatus") == "check") {
2954      this.show = true;
2955    }
2956  },
2957  methods: {
2958    close() {
2959      this.show = !this.show;
2960      if (!this.show) {
2961        this.payType = "";
2962      }
2963    },
2964  },
2965});
2966
2967//支付跳转页面
2968var b2Pay = new Vue({
2969  el: "#pay-page",
2970  data: {
2971    data: [],
2972    token: "",
2973    error: "",
2974    locked: false,
2975    payUrl: "",
2976  },
2977  mounted() {
2978    if (this.$refs.payPage) {
2979      this.token = this.$refs.payPage.getAttribute("data-token");
2980      if (!this.token) {
2981        this.data = JSON.parse(this.$refs.payPage.getAttribute("data-pay"));
2982        this.pay();
2983      }
2984    }
2985  },
2986  methods: {
2987    pay() {
2988      if (this.locked == true) return;
2989      this.locked = true;
2990      this.$http
2991        .post(b2_rest_url + "buildOrder", Qs.stringify(this.data))
2992        .then((res) => {
2993          this.token = res.data;
2994          this.payUrl =
2995            window.location.href.split("?")[0] + "?token=" + this.token;
2996          //b2MakeForm(window.location.href.split('?')[0],this.token)
2997          this.locked = false;
2998        })
2999        .catch((err) => {
3000          this.error = err.response.data.message;
3001          this.locked = false;
3002        });
3003    },
3004  },
3005});
3006
3007function b2MakeForm(url, token) {
3008  // 创建一个 form
3009  var form1 = document.createElement("form");
3010  form1.id = "form1";
3011  form1.name = "form1";
3012
3013  // 添加到 body 中
3014  document.body.appendChild(form1);
3015
3016  // 创建一个输入
3017  var input = document.createElement("input");
3018  // 设置相应参数
3019  input.name = "token";
3020  input.value = token;
3021
3022  // 将该输入框插入到 form 中
3023  form1.appendChild(input);
3024
3025  // form 的提交方式
3026  form1.method = "POST";
3027  // form 提交路径
3028  form1.action = url;
3029
3030  // 对该 form 执行提交
3031  form1.submit();
3032  // 删除该 form
3033  document.body.removeChild(form1);
3034}
3035
3036//扫码支付组件
3037Vue.component("scan-box", {
3038  props: ["show", "data"],
3039  template: b2_global.scan_box,
3040  data() {
3041    return {
3042      locked: false,
3043      qrcode: "",
3044      timeOut: 300,
3045      timesec: "",
3046      sTime: "",
3047      success: "",
3048      checkTime: "",
3049      backData: [],
3050    };
3051  },
3052  methods: {
3053    close() {
3054      this.$emit("close");
3055      this.backData = [];
3056      this.checkTime = null;
3057    },
3058    buildOrder() {
3059      if (this.locked == true) return;
3060      this.locked = true;
3061
3062      this.currTime = parseInt(Date.parse(new Date()) / 1000);
3063      this.endTime = parseInt(this.currTime + this.timeOut);
3064      this.setTime();
3065
3066      this.$http
3067        .post(b2_rest_url + "buildOrder", Qs.stringify(this.data))
3068        .then((res) => {
3069          this.backData = res.data;
3070          if (
3071            res.data.type !== "mapay" &&
3072            res.data.type !== "pay020" &&
3073            res.data.type !== "xunhu"
3074          ) {
3075            var qr = new QRious({
3076              value: this.backData.qrcode,
3077              size: 200,
3078              level: "L",
3079            });
3080            this.backData.qrcode = qr.toDataURL("image/jpeg");
3081          }
3082          this.writeOrder(res.data.order_id);
3083          this.locked = false;
3084          this.checkAc();
3085        })
3086        .catch((err) => {
3087          Qmsg["warning"](err.response.data.message, { html: true });
3088          this.locked = false;
3089        });
3090    },
3091    writeOrder(id) {
3092      b2setCookie("order_id", id);
3093    },
3094    checkAc() {
3095      if (
3096        (this.sTime === null && this.success == "fail") ||
3097        this.checkTime === null ||
3098        this.show == false
3099      ) {
3100        this.checkTime = null;
3101        return;
3102      }
3103
3104      let value = b2getCookie("order_id");
3105      this.$http
3106        .post(b2_rest_url + "payCheck", "order_id=" + value)
3107        .then((res) => {
3108          if (res.data.status === "success") {
3109            if (!b2token) {
3110              let list = b2getCookie(
3111                "b2_guest_buy_" + res.data.id + "_" + res.data.type
3112              );
3113              if (!list) {
3114                list = new Object();
3115              } else {
3116                list = JSON.parse(list);
3117              }
3118
3119              Reflect.set(list, res.data.index, {
3120                id: res.data.id,
3121                order_id: value,
3122                type: res.data.type,
3123                index: res.data.index,
3124              });
3125
3126              list = JSON.stringify(list);
3127
3128              b2setCookie(
3129                "b2_guest_buy_" + res.data.id + "_" + res.data.type,
3130                list
3131              );
3132            }
3133
3134            this.success = true;
3135            this.checkTime = null;
3136            //b2delCookie('order_id')
3137            if (typeof B2VerifyPage !== "undefined") {
3138              B2VerifyPage.data.money = true;
3139              this.close();
3140            }
3141            if (typeof carts !== "undefined") {
3142              carts.step = 3;
3143              this.close();
3144            }
3145            if (this.data.order_type === "circle_read_answer_pay") {
3146              b2CircleList.afterCommentGetData(
3147                b2CircleList.answer.listParent,
3148                b2CircleList.data[b2CircleList.answer.listParent].topic_id,
3149                "ask"
3150              );
3151              this.close();
3152            }
3153            if (this.data.order_type === "circle_hidden_content_pay") {
3154              b2CircleList.afterCommentGetData(
3155                b2CircleList.hiddenIndex,
3156                b2CircleList.data[b2CircleList.hiddenIndex].topic_id,
3157                "hidden"
3158              );
3159              this.close();
3160            }
3161          } else {
3162            this.checkTime = setTimeout(() => {
3163              this.checkAc();
3164            }, 1000);
3165          }
3166        });
3167    },
3168    setTime() {
3169      if (this.show == false) return;
3170      let diff_time = parseInt(this.endTime - this.currTime);
3171      let m = Math.floor((diff_time / 60) % 60);
3172      let s = Math.floor(diff_time % 60);
3173      this.timesec =
3174        (m > 0 ? m + "<b>" + b2_global.js_text.global.min + "</b>" : "") +
3175        s +
3176        "<b>" +
3177        b2_global.js_text.global.sec +
3178        "</b>";
3179      if (diff_time > 0) {
3180        this.sTime = setTimeout(() => {
3181          this.endTime = this.endTime - 1;
3182          this.setTime();
3183        }, 1000);
3184      } else {
3185        this.sTime = null;
3186        this.success = "fail";
3187      }
3188    },
3189    refresh() {
3190      if (this.data.order_type === "circle_read_answer_pay") {
3191        b2CircleList.afterCommentGetData(
3192          b2CircleList.answer.listParent,
3193          b2CircleList.data[b2CircleList.answer.listParent].topic_id,
3194          "ask"
3195        );
3196        this.close();
3197      } else if (this.data.order_type === "circle_hidden_content_pay") {
3198        b2CircleList.afterCommentGetData(
3199          b2CircleList.hiddenIndex,
3200          b2CircleList.data[b2CircleList.hiddenIndex].topic_id,
3201          "hidden"
3202        );
3203        this.close();
3204      } else {
3205        b2CurrentPageReload();
3206      }
3207    },
3208  },
3209  watch: {
3210    show(val) {
3211      if (val) {
3212        this.sTime = "";
3213        this.success = false;
3214        this.checkTime = "";
3215      } else {
3216        this.sTime = null;
3217        this.success = false;
3218        this.checkTime = null;
3219      }
3220    },
3221    data: {
3222      deep: true,
3223      handler(newName, oldName) {
3224        this.buildOrder();
3225      },
3226    },
3227  },
3228});
3229
3230//扫码支付
3231var b2ScanPay = new Vue({
3232  el: "#scan-box",
3233  data: {
3234    data: [],
3235    show: false,
3236  },
3237  methods: {
3238    close() {
3239      this.show = !this.show;
3240    },
3241  },
3242});
3243
3244Vue.component("ds-box", {
3245  props: ["show", "money", "msg", "user", "author", "data", "showtype"],
3246  template: b2_global.ds_box,
3247  data() {
3248    return {
3249      value: 0,
3250      custom: 0,
3251      content: "",
3252      payType: "",
3253      payMoney: "",
3254      locked: false,
3255      jump: "",
3256      href: "",
3257      isWeixin: "",
3258      isMobile: "",
3259      allow: [],
3260      card: [],
3261      cg: [],
3262      newWin: null,
3263      login: false,
3264      redirect: "",
3265      payData: "",
3266      waitOrder: false,
3267    };
3268  },
3269  created() {
3270    this.isWeixin = b2isWeixin();
3271    if (b2token) {
3272      this.login = true;
3273    }
3274    this.redirect = b2getCookie("b2_back_url");
3275  },
3276  methods: {
3277    close() {
3278      this.$emit("close");
3279      this.locked = false;
3280    },
3281    clean() {
3282      this.$emit("clean");
3283    },
3284    picked(m, val) {
3285      this.value = val;
3286      this.payMoney = m;
3287    },
3288    post(url, params) {
3289      var temp = document.createElement("form"); //创建form表单
3290      temp.action = url;
3291      temp.method = "post";
3292      temp.target = "_blank";
3293      temp.style.display = "none"; //表单样式为隐藏
3294
3295      if (Object.keys(params).length > 0) {
3296        Object.keys(params).forEach((key) => {
3297          var opt = document.createElement("input"); //添加input标签
3298          opt.name = key; //设置name属性
3299          opt.value = params[key]; //设置value属性
3300          temp.appendChild(opt);
3301        });
3302      }
3303
3304      document.body.appendChild(temp);
3305      temp.submit();
3306      return temp;
3307    },
3308    restData(data = []) {
3309      if (this.showtype == "ds") {
3310        data = Object.assign(data, {
3311          title: this.$refs.dstitle.innerText,
3312          order_price: this.payMoney,
3313          order_type: "ds",
3314          post_id: b2_global.post_id,
3315          pay_type: this.payType,
3316          order_content: this.content,
3317        });
3318      } else if (this.showtype == "cz") {
3319        data = {
3320          title: b2_global.js_text.global.pay_money,
3321          order_price: this.payMoney,
3322          order_type: "cz",
3323          post_id: 0,
3324          pay_type: this.payType,
3325        };
3326      } else if (this.showtype == "cg") {
3327        data = {
3328          title: b2_global.js_text.global.pay_credit,
3329          order_price: this.payMoney,
3330          order_type: "cg",
3331          post_id: 0,
3332          pay_type: this.payType,
3333        };
3334      } else {
3335        data = Object.assign(this.data, data);
3336      }
3337      data["pay_type"] = this.payType;
3338
3339      var url = new URL(window.location.href);
3340      url.searchParams.set("b2paystatus", "check");
3341
3342      data["redirect_url"] = url.href;
3343
3344      return data;
3345    },
3346    disabled() {
3347      if (this.data.pay_type !== "card") {
3348        if (this.jump == "") return true;
3349        if (
3350          (this.jump == "jump" ||
3351            this.jump == "mweb" ||
3352            this.jump == "jsapi") &&
3353          this.href == "" &&
3354          this.payData == ""
3355        )
3356          return true;
3357        if (this.locked == true) return true;
3358        if (this.payType == "") return true;
3359        if (
3360          this.payMoney === "" &&
3361          (this.showtype == "ds" ||
3362            this.showtype == "cz" ||
3363            this.showtype == "cg")
3364        )
3365          return true;
3366      } else {
3367        if (!this.card.number || !this.card.password) return true;
3368      }
3369
3370      return false;
3371    },
3372    chosePayType(val) {
3373      if (this.locked == true) return;
3374      this.locked = true;
3375      this.payType = val;
3376
3377      this.href = "";
3378      this.payData = "";
3379      this.jump = "";
3380
3381      this.$http
3382        .post(b2_rest_url + "checkPayType", "pay_type=" + val)
3383        .then((res) => {
3384          if (res.data.pay_type == "card") {
3385            this.$emit("change", "card");
3386            this.card.text = res.data.card_text;
3387            this.jump = res.data.pay_type;
3388            this.locked = false;
3389          } else {
3390            if (this.showtype == "card") {
3391              this.$emit("change", "cz");
3392            }
3393            this.jump = res.data.pay_type;
3394
3395            this.isMobile = res.data.is_mobile;
3396            if (
3397              this.jump == "jump" ||
3398              this.jump === "mweb" ||
3399              this.jump === "jsapi"
3400            ) {
3401              let data = Qs.stringify(this.restData());
3402
3403              this.waitOrder = true;
3404              this.$http
3405                .post(b2_rest_url + "buildOrder", data)
3406                .then((res) => {
3407                  this.writeOrder(res.data.id);
3408
3409                  if (typeof res.data.url == "string") {
3410                    this.href = res.data.url;
3411                  } else {
3412                    this.payData = res.data.url;
3413                  }
3414
3415                  this.waitOrder = false;
3416                  this.locked = false;
3417                })
3418                .catch((err) => {
3419                  if (err.response.data.message.msg === "bind_weixin") {
3420                    b2setCookie("b2_back_url", window.location.href);
3421
3422                    if (typeof err.response.data.message.oauth == "string") {
3423                      b2weixinBind.msg = err.response.data.message.oauth;
3424                      b2weixinBind.show = true;
3425                    } else {
3426                      b2weixinBind.show = true;
3427                      b2weixinBind.url =
3428                        err.response.data.message.oauth.weixin.url;
3429                    }
3430                  } else {
3431                    Qmsg["warning"](err.response.data.message, { html: true });
3432                  }
3433                  this.waitOrder = false;
3434                  this.locked = false;
3435                });
3436
3437              // let url = b2_global.pay_url+'?'+Qs.stringify(this.restData())
3438              // this.href = 'javascript:void(0)'
3439              //encodeURI(url)
3440            } else {
3441              this.locked = false;
3442            }
3443          }
3444
3445          b2setCookie("b2_back_url", window.location.href);
3446        })
3447        .catch((err) => {
3448          Qmsg["warning"](err.response.data.message, { html: true });
3449          this.locked = false;
3450        });
3451    },
3452    writeOrder(id) {
3453      b2setCookie("order_id", id);
3454    },
3455    balancePay(order_id) {
3456      let data = this.restData();
3457      this.$http
3458        .post(b2_rest_url + "balancePay", "order_id=" + order_id)
3459        .then((res) => {
3460          this.close();
3461          b2PayCheck.show = true;
3462          b2PayCheck.title = data["title"];
3463          this.locked = false;
3464        })
3465        .catch((err) => {
3466          Qmsg["warning"](err.response.data.message, { html: true });
3467          this.locked = false;
3468        });
3469    },
3470    pay() {
3471      if (this.disabled()) return;
3472
3473      if (this.jump === "card") {
3474        if (this.locked == true) return;
3475        this.locked = true;
3476        this.$http
3477          .post(b2_rest_url + "cardPay", Qs.stringify(this.card))
3478          .then((res) => {
3479            if (res.data === "success") {
3480              b2PayCheck.show = true;
3481              b2PayCheck.title = b2_global.js_text.global.pay_money_success;
3482              b2PayCheck.type = "card";
3483              this.close();
3484            }
3485            this.locked = false;
3486          })
3487          .catch((err) => {
3488            Qmsg["warning"](err.response.data.message, { html: true });
3489            this.locked = false;
3490          });
3491      } else if (this.jump === "jump" || this.jump === "mweb") {
3492        b2PayCheck.show = true;
3493        b2PayCheck.title = this.$refs.dstitle.innerHTML;
3494
3495        this.close();
3496
3497        if (this.payData) {
3498          this.post(this.payData.url, this.payData.data);
3499        }
3500      } else if (this.jump === "balance") {
3501        if (this.locked == true) return;
3502        this.locked = true;
3503
3504        let data = Qs.stringify(this.restData());
3505        this.$http
3506          .post(b2_rest_url + "buildOrder", data)
3507          .then((res) => {
3508            this.writeOrder(res.data);
3509            this.balancePay(res.data);
3510          })
3511          .catch((err) => {
3512            Qmsg["warning"](err.response.data.message, { html: true });
3513            this.locked = false;
3514          });
3515      } else if (this.jump === "scan") {
3516        if (this.isMobile) {
3517          b2ScanPay.data = this.restData({
3518            is_weixin: this.isWeixin,
3519            is_mobile: this.isMobile,
3520          });
3521        } else {
3522          b2ScanPay.data = this.restData();
3523        }
3524        b2ScanPay.show = true;
3525        this.close();
3526      } else if (this.jump === "jsapi") {
3527        let data = this.restData();
3528        jsApiCall(this.payData);
3529        this.close();
3530        b2PayCheck.show = true;
3531        b2PayCheck.title = data["title"];
3532      }
3533
3534      // else if(this.jump === 'mweb' || this.jump === 'jsapi'){
3535      //     if(this.locked == true) return
3536      //     this.locked = true
3537      //     let data = this.restData();
3538      //     let title = data['title']
3539      //     data = Qs.stringify(data);
3540      //     // if(!b2isWeixin()){
3541      //     //     this.newWin = window.open('',"_blank");
3542      //     // }
3543
3544      //     this.$http.post(b2_rest_url+'buildOrder',data).then(res=>{
3545      //         this.writeOrder(res.data.order_id)
3546      //         if(this.jump === 'jsapi'){
3547      //             jsApiCall(res.data.link)
3548      //             this.close()
3549      //             b2PayCheck.show = true
3550      //             b2PayCheck.title = title
3551      //         }else{
3552      //             // window.open(res.data.link)
3553      //             // if(!b2isWeixin()){
3554      //             //     window.location=res.data.link
3555      //             // }else{
3556
3557      //                 // let form = document.querySelector('#wechataction')
3558      //                 // form.action = res.data.link
3559      //                 // form.submit()
3560      //                window.location.href=res.data.link
3561
3562      //                // window.location=res.data.link
3563      //                 // window.open(res.data.link)
3564      //             //}
3565      //             //location.assign();
3566      //             //window.open()
3567      //             this.close()
3568      //             b2PayCheck.show = true
3569      //             b2PayCheck.title = title
3570      //         }
3571      //         this.locked = false
3572      //     }).catch(err=>{
3573      //         if(err.response.data.message.msg === 'bind_weixin'){
3574      //             b2setCookie('b2_back_url',window.location.href)
3575
3576      //             if(typeof err.response.data.message.oauth == 'string'){
3577      //                 b2weixinBind.msg = err.response.data.message.oauth
3578      //                 b2weixinBind.show = true
3579      //             }else{
3580      //                 b2weixinBind.show = true
3581      //                 b2weixinBind.url = err.response.data.message.oauth.weixin.url
3582      //             }
3583
3584      //         }else{
3585
3586      //             Qmsg['warning'](err.response.data.message,{html:true});
3587      //         }
3588
3589      //         this.locked = false
3590      //     })
3591      // }
3592    },
3593    allowPayType() {
3594      this.$http
3595        .post(b2_rest_url + "allowPayType", "show_type=" + this.showtype)
3596        .then((res) => {
3597          this.allow = res.data;
3598          this.user.money = res.data.money;
3599          if (res.data.dh) {
3600            this.cg.min = res.data.min;
3601            this.cg.dh = res.data.dh;
3602            this.payMoney = this.cg.min;
3603          }
3604        });
3605    },
3606    creditAdd() {
3607      return parseInt(this.payMoney * this.cg.dh);
3608    },
3609  },
3610  watch: {
3611    money(val) {
3612      if (this.payMoney == 0) {
3613        this.payMoney = val[0];
3614      }
3615    },
3616    // payMoney(val){
3617    //     if(!/^[0-9]+.?[0-9]*/.test(val)){
3618    //         val = 0
3619    //     }
3620    //     if(this.href && val && this.jump == 'jump'){
3621    //         let url = b2_global.pay_url+'?'+Qs.stringify(this.restData())
3622    //         this.href = encodeURI(url)
3623    //     }
3624    //     this.payMoney = parseFloat(val)
3625    // },
3626    show(val) {
3627      if (val) {
3628        b2setCookie("b2_back_url", window.location.href);
3629        this.allowPayType();
3630      }
3631      if (val && this.money.length > 0) {
3632        this.payMoney = this.money[0];
3633      } else if (val && this.data.length != 0) {
3634        this.payMoney = this.data.order_price;
3635      } else if (val == false) {
3636        setTimeout(() => {
3637          this.value = 0;
3638          this.payMoney = 0;
3639          this.payType = "";
3640          this.clean();
3641        }, 300);
3642      }
3643    },
3644    payType(val) {
3645      this.data.pay_type = val;
3646    },
3647    showtype(val) {},
3648  },
3649});
3650
3651//支付容器
3652var b2DsBox = new Vue({
3653  el: "#ds-box",
3654  data: {
3655    money: [],
3656    show: false,
3657    msg: "",
3658    user: [],
3659    author: [],
3660    data: [],
3661    showtype: "",
3662  },
3663  methods: {
3664    close() {
3665      this.show = !this.show;
3666    },
3667    clean() {
3668      this.data = [];
3669      this.money = [];
3670    },
3671    change(type) {
3672      this.showtype = type;
3673    },
3674  },
3675});
3676
3677var b2Ds = new Vue({
3678  el: "#content-ds",
3679  data: {
3680    data: "",
3681  },
3682  methods: {
3683    show() {
3684      b2DsBox.money = this.data.moneys;
3685      b2DsBox.show = true;
3686      b2DsBox.showtype = "ds";
3687      b2DsBox.msg = this.data.single_post_ds_text;
3688    },
3689  },
3690});
3691
3692function b2pay(event) {
3693  let data = JSON.parse(event.getAttribute("data-pay"));
3694  b2DsBox.data = data;
3695  b2DsBox.show = true;
3696  b2DsBox.showtype = "normal";
3697}
3698
3699function b2creditpay(event) {
3700  if (!b2token) {
3701    login.show = true;
3702  } else {
3703    let data = JSON.parse(event.getAttribute("data-pay"));
3704    payCredit.data = data;
3705    payCredit.show = true;
3706  }
3707}
3708
3709//随机数
3710function uuid(len, radix) {
3711  var chars =
3712    "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
3713  var uuid = [],
3714    i;
3715  radix = radix || chars.length;
3716  if (len) {
3717    for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)];
3718  } else {
3719    var r;
3720    uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-";
3721    uuid[14] = "4";
3722    for (i = 0; i < 36; i++) {
3723      if (!uuid[i]) {
3724        r = 0 | (Math.random() * 16);
3725        uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
3726      }
3727    }
3728  }
3729  return uuid.join("");
3730}
3731
3732function openWin(url, name, iWidth, iHeight) {
3733  var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
3734  var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
3735  window.open(
3736    url,
3737    name,
3738    "height=" +
3739      iHeight +
3740      ",innerHeight=" +
3741      iHeight +
3742      ",width=" +
3743      iWidth +
3744      ",innerWidth=" +
3745      iWidth +
3746      ",top=" +
3747      iTop +
3748      ",left=" +
3749      iLeft +
3750      ",status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no"
3751  );
3752}
3753
3754function deleteHtmlTag(str) {
3755  str = str.replace(/<[^>]+>|&[^>]+;/g, "").trim();
3756  return str;
3757}
3758
3759var b2cache = [];
3760function b2addJs(path, callback) {
3761  var flag = 0; //检查是否加载的状态
3762  for (var i = b2cache.length; i--; ) {
3763    b2cache[i] == path ? (flag = 1) : (flag = 0);
3764  }
3765  if (flag) {
3766    //如果已经加载则不加载
3767    return;
3768  }
3769  var head = document.getElementsByTagName("head")[0];
3770  var script = document.createElement("script");
3771  script.src = path;
3772  script.type = "text/javascript";
3773  head.appendChild(script);
3774  script.onload = script.onreadystatechange = function () {
3775    /*判断是否加载成功*/
3776    if (
3777      !this.readyState ||
3778      this.readyState === "loaded" ||
3779      this.readyState === "complete"
3780    ) {
3781      script.onload = script.onreadystatechange = null;
3782      callback();
3783    }
3784  };
3785  b2cache.push(path); //把加载过的存起来
3786}
3787
3788//微信内支付
3789function jsApiCall(data) {
3790  WeixinJSBridge.invoke("getBrandWCPayRequest", data, function (res) {});
3791}
3792
3793function callpay() {
3794  if (typeof WeixinJSBridge == "undefined") {
3795    if (document.addEventListener) {
3796      document.addEventListener(
3797        "WeixinJSBridgeReady",
3798        jsApiCall,
3799        passiveSupported ? { passive: true } : false
3800      );
3801    } else if (document.attachEvent) {
3802      document.attachEvent("WeixinJSBridgeReady", jsApiCall);
3803      document.attachEvent("onWeixinJSBridgeReady", jsApiCall);
3804    }
3805  } else {
3806    jsApiCall();
3807  }
3808}
3809
3810function b2SidebarSticky() {
3811  if (B2ClientWidth <= 768) return;
3812  if (document.querySelector(".post-style-5")) return;
3813
3814  if (typeof window.b2Stick !== "undefined") {
3815    for (let i = 0; i < window.b2Stick.length; i++) {
3816      if (window.b2Stick[i]) {
3817        window.b2Stick[i].updateSticky();
3818      }
3819    }
3820    return;
3821  }
3822
3823  let b2sidebar = document.querySelectorAll(".sidebar");
3824
3825  if (b2sidebar) {
3826    if (B2ClientWidth > 768) {
3827      var b2Stick = [];
3828      for (let i = 0; i < b2sidebar.length; i++) {
3829        if (!b2sidebar[i].querySelector(".widget-ffixed")) continue;
3830        b2Stick[i] = new StickySidebar(b2sidebar[i], {
3831          containerSelector: ".widget-area",
3832          topSpacing: 20,
3833          resizeSensor: true,
3834          bottomSpacing: 20,
3835        });
3836      }
3837
3838      window.b2Stick = b2Stick;
3839    }
3840  }
3841}
3842
3843Vue.component("credit-box", {
3844  props: ["show", "data", "user"],
3845  template: b2_global.credit_box,
3846  data() {
3847    return {
3848      locked: false,
3849    };
3850  },
3851  methods: {
3852    close() {
3853      this.$emit("close");
3854    },
3855    writeOrder(id) {
3856      b2setCookie("order_id", id);
3857    },
3858    disabled() {
3859      if (this.locked === true) return true;
3860      if (parseInt(this.user.credit) < parseInt(this.data.order_price))
3861        return true;
3862      return false;
3863    },
3864    creditPay(order_id) {
3865      this.writeOrder(order_id);
3866      this.$http
3867        .post(b2_rest_url + "creditPay", "order_id=" + order_id)
3868        .then((res) => {
3869          this.locked = false;
3870          b2PayCheck.show = true;
3871          this.close();
3872        })
3873        .catch((err) => {
3874          Qmsg["warning"](err.response.data.message, { html: true });
3875          this.locked = false;
3876        });
3877    },
3878    pay() {
3879      if (this.locked == true) return;
3880      this.locked = true;
3881
3882      this.data.pay_type = "credit";
3883      let data = Qs.stringify(this.data);
3884      this.$http
3885        .post(b2_rest_url + "buildOrder", data)
3886        .then((res) => {
3887          this.creditPay(res.data);
3888        })
3889        .catch((err) => {
3890          Qmsg["warning"](err.response.data.message, { html: true });
3891          this.locked = false;
3892        });
3893    },
3894  },
3895});
3896
3897var payCredit = new Vue({
3898  el: "#credit-box",
3899  data: {
3900    show: false,
3901    data: [],
3902    user: {
3903      credit: 0,
3904    },
3905    author: [],
3906  },
3907  methods: {
3908    close() {
3909      this.show = !this.show;
3910    },
3911  },
3912});
3913
3914var B2UserWidget = new Vue({
3915  el: ".b2-widget-user",
3916  data: {
3917    show: false,
3918    b2token: false,
3919  },
3920  mounted() {
3921    this.b2token = b2token;
3922  },
3923  computed: {
3924    userData() {
3925      return this.$store.state.userData;
3926    },
3927    oauth() {
3928      return this.$store.state.oauthLink;
3929    },
3930    announcement() {
3931      return this.$store.state.announcement;
3932    },
3933    openOauth() {
3934      return this.$store.state.openOauth;
3935    },
3936  },
3937  watch: {
3938    announcement(val) {
3939      if (val && !this.show) {
3940        this.resize();
3941      }
3942    },
3943  },
3944  methods: {
3945    resize() {
3946      this.$nextTick(() => {
3947        if (!this.$refs.userWidget) return;
3948        if (this.$refs.gujia) {
3949          this.$refs.gujia.style.display = "none";
3950        }
3951        setTimeout(() => {
3952          b2tooltip(".user-w-tips");
3953        }, 300);
3954
3955        this.show = true;
3956      });
3957    },
3958    markHistory(type) {
3959      if (this.oauth.weixin.mp && type === "weixin") {
3960        mpCode.show = true;
3961      }
3962      b2setCookie("b2_back_url", window.location.href);
3963    },
3964  },
3965});
3966
3967var b2Mission = new Vue({
3968  el: ".b2-widget-mission",
3969  data: {
3970    data: "",
3971    locked: false,
3972    type: "today",
3973    paged: 1,
3974    count: 0,
3975    pages: {
3976      today: 1,
3977      always: 1,
3978    },
3979  },
3980  mounted() {
3981    if (this.$refs.missionWidget) {
3982      this.getData();
3983    }
3984  },
3985  methods: {
3986    getData(count, paged) {
3987      if (this.$refs.missionWidget) {
3988        this.count = this.$refs.missionWidget.getAttribute("data-count");
3989      } else {
3990        this.count = 10;
3991      }
3992      if (paged) {
3993        this.paged = paged;
3994      }
3995      this.$http
3996        .post(
3997          b2_rest_url + "getUserMission",
3998          "count=" + this.count + "&paged=" + this.paged
3999        )
4000        .then((res) => {
4001          this.data = res.data;
4002          this.pages.today = res.data.mission_today_list.pages;
4003          this.pages.always = res.data.mission_always_list.pages;
4004          if (this.$refs.missiongujia) {
4005            this.$refs.missiongujia.style.display = "none";
4006          }
4007          this.$nextTick(() => {
4008            b2RestTimeAgo(this.$el.querySelectorAll(".b2timeago"));
4009          });
4010        });
4011    },
4012    mission() {
4013      if (!b2token) {
4014        login.show = true;
4015      } else {
4016        if (this.data.mission.credit) {
4017          Qmsg["warning"](b2_global.js_text.global.has_mission, { html: true });
4018          return;
4019        }
4020        if (this.locked == true) return;
4021        this.locked = true;
4022        this.$http
4023          .post(b2_rest_url + "userMission")
4024          .then((res) => {
4025            this.$nextTick(() => {
4026              this.data.mission = res.data.mission;
4027              this.locked = false;
4028            });
4029            this.getData(this.count, this.paged);
4030          })
4031          .catch((err) => {
4032            Qmsg["warning"](err.response.data.message, { html: true });
4033            this.locked = false;
4034          });
4035      }
4036    },
4037  },
4038});
4039
4040var b2NewComment = new Vue({
4041  el: ".b2-widget-comment",
4042  data: {
4043    data: "",
4044    paged: 1,
4045    pages: 1,
4046    count: 5,
4047    hidden: 1,
4048    next: false,
4049    prev: false,
4050    locked: false,
4051  },
4052  mounted() {
4053    if (this.$refs.commentWidget) {
4054      this.count = this.$refs.commentWidget.getAttribute("data-count");
4055      this.hidden = this.$refs.commentWidget.getAttribute("data-hidden");
4056      this.getList();
4057      if (this.paged == 1) {
4058        this.prev = true;
4059      }
4060    }
4061  },
4062  methods: {
4063    getList() {
4064      if (this.locked == true) return;
4065      this.locked = true;
4066      this.$https
4067        .post(
4068          b2_rest_url + "getNewComments",
4069          "paged=" +
4070            this.paged +
4071            "&count=" +
4072            this.count +
4073            "&hidden=" +
4074            this.hidden
4075        )
4076        .then((res) => {
4077          this.data = res.data.data;
4078          this.pages = res.data.pages;
4079          if (this.$refs.gujia) {
4080            this.$refs.gujia.style.display = "none";
4081          }
4082
4083          this.$nextTick(() => {
4084            b2SidebarSticky();
4085            b2RestTimeAgo(
4086              this.$refs.commentWidget.querySelectorAll(".b2timeago")
4087            );
4088          });
4089          this.locked = false;
4090        });
4091    },
4092    nexAc() {
4093      if (this.next || this.locked) return;
4094      this.paged++;
4095      this.getList();
4096    },
4097    prevAc() {
4098      if (this.prev || this.locked) return;
4099      this.paged--;
4100      this.getList();
4101    },
4102  },
4103  watch: {
4104    paged(val) {
4105      if (val <= 1) {
4106        this.prev = true;
4107      } else {
4108        this.prev = false;
4109      }
4110      if (val >= this.pages) {
4111        this.next = true;
4112      } else {
4113        this.next = false;
4114      }
4115    },
4116  },
4117});
4118
4119//移动端点击展开筛选
4120// function b2ShowFilterBox(event){
4121
4122//     let filterBox = event.parentNode.nextElementSibling
4123
4124//     if(filterBox.className.indexOf('b2-show') !== -1){
4125//         filterBox.className = filterBox.className.replace('b2-show','')
4126//         bodyScrollLock.lock(filterBox)
4127//     }else{
4128//         filterBox.className += ' b2-show'
4129//         bodyScrollLock.unlock(filterBox)
4130//     }
4131// }
4132
4133var b2mobileFooterMenu = new Vue({
4134  el: "#mobile-footer-menu",
4135  data: {
4136    msg: 0,
4137    show: true
4138  },
4139  computed: {
4140    userData() {
4141      return this.$store.state.userData;
4142    }
4143  }
4144});
4145
4146var postPoBox = new Vue({
4147  el: "#post-po-box",
4148  data: {
4149    show: false,
4150    login: false,
4151    allow: "",
4152  },
4153  mounted() {
4154    if (b2token) {
4155      this.login = true;
4156    }
4157  },
4158  methods: {
4159    close() {
4160      this.showPost = !this.showPost;
4161    },
4162    go(val, type) {
4163      if (!this.login) {
4164        login.show = true;
4165        login.type = 0;
4166        return;
4167      }
4168      if (type != "request") {
4169        if (!userTools.role[type]) {
4170          Qmsg["warning"](b2_global.js_text.global.not_allow, { html: true });
4171          return;
4172        }
4173      }
4174      setTimeout(() => {
4175        window.location.href = val;
4176      }, 250);
4177    },
4178  },
4179});
4180
4181var b2AsideBar = new Vue({
4182  el: ".aside-container",
4183  data: {
4184    dmsg: {
4185      count: 0,
4186    },
4187    msg: {
4188      count: 0,
4189    },
4190    showBox: false,
4191    showType: {
4192      user: false,
4193      msg: false,
4194      dmsg: false,
4195      mission: false,
4196      coupon: false,
4197    },
4198    locked: false,
4199    mission: [],
4200    bool: false,
4201    coupon: {
4202      count: 0,
4203      data: "",
4204    },
4205    showCouponInfo: [],
4206    qrcode: "",
4207    ref: "",
4208    dlocked: false,
4209    count: 0,
4210    cartLocked: false,
4211    b2token: false,
4212  },
4213  computed: {
4214    userData() {
4215      return this.$store.state.userData;
4216    },
4217    carts() {
4218      if (this.count && !this.cartLocked) {
4219        return {
4220          count: this.count,
4221          data: "",
4222        };
4223      } else {
4224        let carts = this.$store.state.carts;
4225        return {
4226          count:
4227            carts !== null && carts !== undefined
4228              ? Object.keys(carts).length
4229              : 0,
4230          data: carts,
4231        };
4232      }
4233    },
4234  },
4235  mounted() {
4236    this.b2token = b2token;
4237  },
4238  methods: {
4239    getQrcode(url) {
4240      var url = new URL(url);
4241      url.searchParams.set("ref", this.ref);
4242      var qr = new QRious({
4243        value: url.href,
4244        size: 120,
4245        level: "L",
4246      });
4247      return qr.toDataURL("image/jpeg");
4248    },
4249    goMyPage() {
4250      if (!b2token) {
4251        login.show = true;
4252        login.type = 0;
4253        return;
4254      }
4255
4256      window.location.href = this.userData.link;
4257    },
4258    chat() {
4259      if (b2_global.chat.type == "crisp") {
4260        $crisp.push(["do", "chat:open"]);
4261      }
4262      if (b2_global.chat.type == "qq") {
4263        window.open(
4264          "http://wpa.qq.com/msgrd?v=3&uin=" +
4265            b2_global.chat.qq +
4266            "&site=qq&menu=yes",
4267          "_blank"
4268        );
4269      }
4270      if (b2_global.chat.type == "weixin") {
4271        window.open(b2_global.chat.weixin, "_blank");
4272      }
4273      if (b2_global.chat.type == "dmsg") {
4274        if (!b2token) {
4275          login.show = true;
4276        } else {
4277          b2Dmsg.userid = b2_global.chat.dmsg;
4278          b2Dmsg.show = true;
4279        }
4280      }
4281      if (b2_global.chat.type == "requests") {
4282        if (!b2token) {
4283          login.show = true;
4284        } else {
4285          window.open(b2_global.home_url + "/requests", "_blank");
4286        }
4287      }
4288    },
4289    show(type, value) {
4290      this.closeBox();
4291      if (type === "user") {
4292        if (!b2token) {
4293          login.show = true;
4294          login.type = 0;
4295          return;
4296        }
4297      }
4298      if (type === "dmsg" && this.dmsg.count == 0) {
4299        if (!b2token) {
4300          login.show = true;
4301          login.type = 0;
4302          return;
4303        }
4304        this.jumpTo(value);
4305        return;
4306      }
4307      if (type === "msg") {
4308        if (!b2token) {
4309          login.show = true;
4310          login.type = 0;
4311          return;
4312        }
4313        this.jumpTo(value);
4314        return;
4315      }
4316      if (type == "mission") {
4317        this.mission = b2Mission;
4318        if (this.mission.data.length == 0) {
4319          this.mission.getData(10);
4320        }
4321      }
4322      if (type === "coupon") {
4323        this.getMyCoupons();
4324      }
4325
4326      if (type === "cart") {
4327        if (!b2token) {
4328          login.show = true;
4329          login.type = 0;
4330          return;
4331        }
4332
4333        this.getMycarts();
4334      }
4335      this.showType[type] = true;
4336      this.showBox = true;
4337      // if(B2ClientWidth < 768){
4338      //     bodyScrollLock.lock(this.$refs.asideContainer)
4339      // }
4340      this.$nextTick(() => {
4341        b2RestTimeAgo(this.$el.querySelectorAll(".b2timeago"));
4342      });
4343    },
4344    getMycarts() {
4345      if (this.cartLocked == true) return;
4346      this.cartLocked = true;
4347      this.$http.get(b2_rest_url + "getMyCarts").then((res) => {
4348        if (Object.keys(res.data).length > 0) {
4349          this.$store.commit("setcartsData", res.data);
4350        }
4351      });
4352    },
4353    showAc(val) {
4354      if (!b2token) {
4355        login.show = true;
4356        return;
4357      }
4358
4359      if (val) {
4360        this.show("user");
4361      } else {
4362        this.close();
4363      }
4364    },
4365    closeBox() {
4366      Object.keys(this.showType).forEach((key) => {
4367        this.showType[key] = false;
4368      });
4369      this.showBox = false;
4370      // if(B2ClientWidth < 768){
4371      //     bodyScrollLock.unlock(this.$refs.asideContainer)
4372      // }
4373    },
4374    getNewDmsg() {
4375      if (b2token) {
4376        if (this.locked) return;
4377        this.locked = true;
4378        this.$http.post(b2_rest_url + "getNewDmsg").then((res) => {
4379          this.dmsg = res.data.dmsg;
4380          this.locked = false;
4381        });
4382      }
4383    },
4384    close() {
4385      if (
4386        this.$refs.asideContainer &&
4387        this.$refs.asideContainer.className.indexOf("aside-show") &&
4388        B2ClientWidth < 768
4389      ) {
4390        this.$refs.asideContainer.className =
4391          this.$refs.asideContainer.className.replace(" aside-show", "");
4392        // if(B2ClientWidth < 768){
4393        //     bodyScrollLock.unlock(this.$refs.asideContainer)
4394        // }
4395        this.showBox = false;
4396      } else {
4397        this.closeBox();
4398      }
4399    },
4400    goTop() {
4401      this.$scrollTo(".site", 300, { offset: 0 });
4402    },
4403    login() {
4404      if (!b2token) {
4405        login.show = true;
4406        return;
4407      } else if (!this.$refs.asideContent) {
4408        self.location = this.$store.state.userData.link;
4409      } else {
4410        this.show("user");
4411        this.$refs.asideContainer.className += " aside-show";
4412      }
4413    },
4414    showSearch() {
4415      b2SearchBox.close();
4416    },
4417    jumpTo(url) {
4418      window.location.href = url;
4419    },
4420    updateCarts() {
4421      let data = b2getCookie("carts");
4422      if (data) {
4423        this.carts.data = JSON.parse(data);
4424      } else {
4425        this.carts.data = "";
4426      }
4427
4428      if (this.carts.data) {
4429        if (this.carts.count > Object.keys(this.carts.data).length) {
4430          b2mobileFooterMenu.msg =
4431            b2mobileFooterMenu.msg -
4432            (this.carts.count - Object.keys(this.carts.data).length);
4433        } else {
4434          b2mobileFooterMenu.msg =
4435            b2mobileFooterMenu.msg +
4436            (Object.keys(this.carts.data).length - this.carts.count);
4437        }
4438        this.carts.count = Object.keys(this.carts.data).length;
4439      }
4440    },
4441    deleteCarts(id) {
4442      this.$https
4443        .post(b2_rest_url + "deleteMyCarts", "id=" + id)
4444        .then((res) => {
4445          if (res.data.length == 0) {
4446            this.$store.commit("setcartsData", {});
4447          } else {
4448            this.$store.commit("setcartsData", res.data);
4449          }
4450        });
4451    },
4452    getMyCoupons() {
4453      if (!b2token) {
4454        login.show = true;
4455        return;
4456      }
4457
4458      this.showType.coupon = true;
4459
4460      this.$https.get(b2_rest_url + "getMyCoupons").then((res) => {
4461        this.coupon = res.data;
4462      });
4463    },
4464    couponClass(item) {
4465      if (item.expiration_date.expired) return "stamp04";
4466      if (item.products.length > 0) return "stamp01";
4467      if (item.cats.length > 0) return "stamp02";
4468      return "stamp03";
4469    },
4470    couponMoreInfo(id) {
4471      this.$set(this.showCouponInfo, id, !this.showCouponInfo[id]);
4472    },
4473    deleteCoupon(id) {
4474      var r = confirm(b2_global.js_text.global.delete_coupon);
4475      if (r) {
4476        this.$https
4477          .post(b2_rest_url + "deleteMyCoupon", "id=" + id)
4478          .then((res) => {
4479            this.$delete(this.coupon.data, id);
4480            this.$set(this.coupon, "count", this.coupon.count - 1);
4481          });
4482      }
4483      return;
4484    },
4485  },
4486  watch: {
4487    userData(val) {
4488      if (val && this.$refs.asideContent) {
4489        if (b2token) {
4490          this.ref = val.user_code;
4491          this.getNewDmsg();
4492        }
4493
4494        this.updateCarts();
4495      }
4496    },
4497    dmsg: {
4498      handler(newVal, old) {
4499        if (newVal.count > 0) {
4500          b2mobileFooterMenu.msg += parseInt(newVal.count);
4501        }
4502      },
4503      immediate: true,
4504      deep: true,
4505    },
4506    msg: {
4507      handler(newVal, old) {
4508        if (newVal.count > 0) {
4509          b2mobileFooterMenu.msg += parseInt(newVal.count);
4510        }
4511      },
4512      immediate: true,
4513      deep: true,
4514    },
4515    showBox(val) {
4516      if (val && B2ClientWidth < 768) {
4517        this.$refs.asideContainer.className += " aside-show";
4518      }
4519    },
4520  },
4521});
4522
4523function b2HiddenFilterBox(event) {
4524  event.parentNode.parentNode.className =
4525    event.parentNode.parentNode.className.replace("b2-show", "");
4526  //bodyScrollLock.unlock(event.parentNode.parentNode)
4527}
4528
4529function b2flickity() {
4530  if (B2ClientWidth < 768) return;
4531  var f = document.querySelectorAll(".home-collection-silder");
4532  if (f) {
4533    var collection = [];
4534    for (let i = 0; i < f.length; i++) {
4535      collection[i] = new Flickity(f[i], {
4536        pageDots: false,
4537        groupCells: true,
4538        draggable: true,
4539        prevNextButtons: false,
4540        freeScroll: false,
4541        wrapAround: true,
4542        selectedAttraction: 0.15,
4543        friction: 1,
4544        freeScrollFriction: 0.1,
4545        cellAlign: "left",
4546      });
4547
4548      let previous, next;
4549
4550      if (f[i].querySelector(".coll-3-box")) {
4551        previous = f[i].parentNode.querySelector(".collection-previous");
4552      } else {
4553        previous = f[i].parentNode.parentNode.parentNode.querySelector(
4554          ".collection-previous"
4555        );
4556      }
4557
4558      previous.addEventListener(
4559        "click",
4560        function () {
4561          collection[i].previous();
4562        },
4563        passiveSupported ? { passive: true } : false
4564      );
4565
4566      if (f[i].querySelector(".coll-3-box")) {
4567        next = f[i].parentNode.querySelector(".collection-next");
4568      } else {
4569        next =
4570          f[i].parentNode.parentNode.parentNode.querySelector(
4571            ".collection-next"
4572          );
4573      }
4574
4575      next.addEventListener(
4576        "click",
4577        function () {
4578          collection[i].next();
4579        },
4580        passiveSupported ? { passive: true } : false
4581      );
4582    }
4583  }
4584}
4585
4586b2flickity();
4587
4588function b2HiddenFooter() {
4589  let footer = document.querySelector(".site-footer .site-footer-widget-in");
4590  if (!footer) return;
4591  let footerWidget = footer.querySelectorAll(".mobile-hidden");
4592
4593  if (footerWidget && footerWidget.length >= footer.childNodes.length) {
4594    document.querySelector(".site-footer").className += " mobile-hidden";
4595  }
4596}
4597b2HiddenFooter();
4598
4599var b2SearchUser = new Vue({
4600  el: "#user-list",
4601  data: {
4602    follow: [],
4603    ids: [],
4604  },
4605  mounted() {
4606    if (this.$refs.searchUser) {
4607      this.ids = b2_search_data.users;
4608      this.checkFollowByids();
4609    }
4610  },
4611  methods: {
4612    checkFollowByids() {
4613      let data = {
4614        ids: this.ids,
4615      };
4616      this.$http
4617        .post(b2_rest_url + "checkFollowByids", Qs.stringify(data))
4618        .then((res) => {
4619          this.follow = res.data;
4620        });
4621    },
4622    followAc(id) {
4623      if (!b2token) {
4624        login.show = true;
4625      } else {
4626        this.$http
4627          .post(b2_rest_url + "AuthorFollow", "user_id=" + id)
4628          .then((res) => {
4629            this.follow[id] = res.data;
4630          })
4631          .catch((err) => {
4632            Qmsg["warning"](err.response.data.message, { html: true });
4633          });
4634      }
4635    },
4636    dmsg(id) {
4637      if (!b2token) {
4638        login.show = true;
4639      } else {
4640        b2Dmsg.userid = id;
4641        b2Dmsg.show = true;
4642      }
4643    },
4644  },
4645});
4646
4647//精确计算
4648(function () {
4649  var calc = {
4650    /*
4651        函数,加法函数,用来得到精确的加法结果
4652        说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
4653        参数:arg1:第一个加数;arg2第二个加数;d要保留的小数位数(可以不传此参数,如果不传则不处理小数位数)
4654        调用:Calc.Add(arg1,arg2,d)
4655        返回值:两数相加的结果
4656        */
4657    Add: function (arg1, arg2) {
4658      (arg1 = arg1.toString()), (arg2 = arg2.toString());
4659      var arg1Arr = arg1.split("."),
4660        arg2Arr = arg2.split("."),
4661        d1 = arg1Arr.length == 2 ? arg1Arr[1] : "",
4662        d2 = arg2Arr.length == 2 ? arg2Arr[1] : "";
4663      var maxLen = Math.max(d1.length, d2.length);
4664      var m = Math.pow(10, maxLen);
4665      var result = Number(((arg1 * m + arg2 * m) / m).toFixed(maxLen));
4666      var d = arguments[2];
4667      return typeof d === "number" ? Number(result.toFixed(d)) : result;
4668    },
4669    /*
4670        函数:减法函数,用来得到精确的减法结果
4671        说明:函数返回较为精确的减法结果。
4672        参数:arg1:第一个加数;arg2第二个加数;d要保留的小数位数(可以不传此参数,如果不传则不处理小数位数
4673        调用:Calc.Sub(arg1,arg2)
4674        返回值:两数相减的结果
4675        */
4676    Sub: function (arg1, arg2) {
4677      return Calc.Add(arg1, -Number(arg2), arguments[2]);
4678    },
4679    /*
4680        函数:乘法函数,用来得到精确的乘法结果
4681        说明:函数返回较为精确的乘法结果。
4682        参数:arg1:第一个乘数;arg2第二个乘数;d要保留的小数位数(可以不传此参数,如果不传则不处理小数位数)
4683        调用:Calc.Mul(arg1,arg2)
4684        返回值:两数相乘的结果
4685        */
4686    Mul: function (arg1, arg2) {
4687      var r1 = arg1.toString(),
4688        r2 = arg2.toString(),
4689        m,
4690        resultVal,
4691        d = arguments[2];
4692      m =
4693        (r1.split(".")[1] ? r1.split(".")[1].length : 0) +
4694        (r2.split(".")[1] ? r2.split(".")[1].length : 0);
4695      resultVal =
4696        (Number(r1.replace(".", "")) * Number(r2.replace(".", ""))) /
4697        Math.pow(10, m);
4698      return typeof d !== "number"
4699        ? Number(resultVal)
4700        : Number(resultVal.toFixed(parseInt(d)));
4701    },
4702    /*
4703        函数:除法函数,用来得到精确的除法结果
4704        说明:函数返回较为精确的除法结果。
4705        参数:arg1:除数;arg2被除数;d要保留的小数位数(可以不传此参数,如果不传则不处理小数位数)
4706        调用:Calc.Div(arg1,arg2)
4707        返回值:arg1除于arg2的结果
4708        */
4709    Div: function (arg1, arg2) {
4710      var r1 = arg1.toString(),
4711        r2 = arg2.toString(),
4712        m,
4713        resultVal,
4714        d = arguments[2];
4715      m =
4716        (r2.split(".")[1] ? r2.split(".")[1].length : 0) -
4717        (r1.split(".")[1] ? r1.split(".")[1].length : 0);
4718      resultVal =
4719        (Number(r1.replace(".", "")) / Number(r2.replace(".", ""))) *
4720        Math.pow(10, m);
4721      return typeof d !== "number"
4722        ? Number(resultVal)
4723        : Number(resultVal.toFixed(parseInt(d)));
4724    },
4725  };
4726  window.Calc = calc;
4727})();
4728
4729function b2stmap() {
4730  let stmaps = document.querySelectorAll(".stamp");
4731  if (stmaps.length > 0) {
4732    let h_axios = axios;
4733
4734    if (b2token) {
4735      h_axios.defaults.headers.common["Authorization"] = "Bearer " + b2token;
4736    }
4737
4738    for (let i = 0; i < stmaps.length; i++) {
4739      if (stmaps[i].querySelector(".coupon-receive")) {
4740        stmaps[i].querySelector(".coupon-receive").onclick = (event) => {
4741          if (!b2token) {
4742            login.show = true;
4743            return;
4744          }
4745
4746          h_axios
4747            .post(
4748              b2_rest_url + "ShopCouponReceive",
4749              "&id=" + event.target.getAttribute("data-id")
4750            )
4751            .then((res) => {
4752              if (res.data) {
4753                Qmsg["success"](b2_global.js_text.global.get_success, {
4754                  html: true,
4755                });
4756              }
4757            })
4758            .catch((err) => {
4759              Qmsg["success"](err.response.data.message, { html: true });
4760            });
4761        };
4762        stmaps[i].querySelector(".more-coupon-info").onclick = (event) => {
4763          event.target.nextElementSibling.style.display = "block";
4764        };
4765        stmaps[i].querySelector(".close-coupon-info").onclick = (event) => {
4766          event.target.parentNode.parentNode.style.display = "none";
4767        };
4768      }
4769    }
4770  }
4771}
4772b2stmap();
4773
4774// document.ready(function () {
4775//     let link = document.createElement("link");
4776//     link.rel = "stylesheet";
4777//     link.href = "//at.alicdn.com/t/font_1105559_00rtseygv6tsc.css";
4778
4779//     document.head.appendChild(link);
4780// })
4781
4782function b2IsPhoneAvailable(phonevalue) {
4783  var phoneReg = /^1[0-9]{10}/;
4784  var emailReg = /[a-zA-Z0-9]{1,10}@[a-zA-Z0-9]{1,5}\.[a-zA-Z0-9]{1,5}/;
4785  if (phoneReg.test(phonevalue) || emailReg.test(phonevalue)) {
4786    return true;
4787  } else {
4788    return false;
4789  }
4790}
4791
4792var b2TaxTop = new Vue({
4793  el: ".tax-header",
4794  data: {
4795    showFliter: {
4796      hot: false,
4797      cat: false,
4798    },
4799  },
4800  methods: {
4801    show(type) {
4802      if (type === "hot") {
4803        this.showFliter.hot = !this.showFliter.hot;
4804        this.showFliter.cat = false;
4805      }
4806      if (type === "cat") {
4807        this.showFliter.cat = !this.showFliter.cat;
4808        this.showFliter.hot = false;
4809      }
4810    },
4811  },
4812});
4813
4814function b2scroll(fn) {
4815  var beforeScrollTop = document.documentElement.scrollTop,
4816    fn = fn || function () {};
4817
4818  window.bodyScrool = function () {
4819    var afterScrollTop =
4820        document.documentElement.scrollTop || document.body.scrollTop,
4821      delta = afterScrollTop - beforeScrollTop;
4822
4823    if (delta === 0) return false;
4824
4825    fn(delta > 0 ? "down" : "up", afterScrollTop);
4826
4827    beforeScrollTop = afterScrollTop;
4828  };
4829
4830  window.addEventListener(
4831    "scroll",
4832    window.bodyScrool,
4833    passiveSupported ? { passive: true } : false
4834  );
4835}
4836
4837function b2HeaderTop() {
4838  const banner = document.querySelector(".header-banner-left");
4839  const header = document.querySelector(".site");
4840  const aside = document.querySelector(".bar-user-info");
4841  const socialTop = document.querySelector(".social-top");
4842  const nosub = document.querySelector(".social-no-sub");
4843  const footer = document.querySelector(".mobile-footer-menu");
4844  if (!banner) return;
4845
4846  let h = 96;
4847  if (B2ClientWidth < 768) {
4848    h = 77;
4849  }
4850
4851  if (socialTop) {
4852    h = 113;
4853  }
4854
4855  if (nosub) {
4856    h = 58;
4857  }
4858
4859  b2scroll(function (direction, top) {
4860    if (top > h) {
4861      if (direction === "down") {
4862        if (banner.className.indexOf(" hidden") === -1) {
4863          banner.className += " hidden";
4864        }
4865        if (header.className.indexOf(" up") === -1) {
4866          header.className += " up";
4867        }
4868
4869        if (
4870          footer &&
4871          B2ClientWidth < 768 &&
4872          footer.className.indexOf(" footer-down") === -1
4873        ) {
4874          footer.className += " footer-down";
4875        }
4876      } else {
4877        banner.className = banner.className.replace(" hidden", "");
4878        header.className = header.className.replace(" up", "");
4879
4880        if (footer && B2ClientWidth < 768) {
4881          footer.className = footer.className.replace(" footer-down", "");
4882        }
4883      }
4884      if (header.className.indexOf(" action") === -1) {
4885        header.className += " action";
4886      }
4887    } else {
4888      header.className = header.className.replace(" action", "");
4889      banner.className = banner.className.replace(" hidden", "");
4890      header.className = header.className.replace(" up", "");
4891    }
4892  });
4893}
4894
4895b2HeaderTop();
4896
4897var b2NewsfalshesWidget = new Vue({
4898  el: ".widget-newsflashes-box",
4899  data: {
4900    options: [],
4901    list: "",
4902  },
4903  mounted() {
4904    if (this.$refs.newsWidget) {
4905      this.options = JSON.parse(
4906        this.$refs.newsWidget.getAttribute("data-json")
4907      );
4908      this.getList();
4909    }
4910  },
4911  methods: {
4912    getList() {
4913      this.$https
4914        .post(b2_rest_url + "getWidgetNewsflashes", Qs.stringify(this.options))
4915        .then((res) => {
4916          this.list = res.data;
4917          this.$refs.gujia.style.display = "none";
4918        });
4919    },
4920  },
4921});
4922
4923Vue.component("weixin-bind", {
4924  props: ["show", "url", "msg"],
4925  template: b2_global.weixin_bind,
4926  methods: {
4927    close() {
4928      this.$emit("close");
4929    },
4930  },
4931});
4932
4933//微信绑定
4934var b2weixinBind = new Vue({
4935  el: "#weixin-bind",
4936  data: {
4937    show: false,
4938    url: "",
4939    msg: "",
4940  },
4941  methods: {
4942    close() {
4943      this.show = !this.show;
4944    },
4945  },
4946});
4947
4948function b2CurrentPageReload(url) {
4949  if (!url) {
4950    url = location.href;
4951  }
4952  setTimeout(() => {
4953    location.replace(url);
4954  }, 200);
4955}
4956
4957function b2GetQueryVariable(variable) {
4958  var query = window.location.search.substring(1);
4959  var vars = query.split("&");
4960  for (var i = 0; i < vars.length; i++) {
4961    var pair = vars[i].split("=");
4962    if (pair[0] == variable) {
4963      return pair[1];
4964    }
4965  }
4966  return false;
4967}
4968
4969function b2removeURLParameter(url, parameter) {
4970  //prefer to use l.search if you have a location/link object
4971  var urlparts = url.split("?");
4972  if (urlparts.length >= 2) {
4973    var prefix = encodeURIComponent(parameter) + "=";
4974    var pars = urlparts[1].split(/[&;]/g);
4975
4976    //reverse iteration as may be destructive
4977    for (var i = pars.length; i-- > 0; ) {
4978      //idiom for string.startsWith
4979      if (pars[i].lastIndexOf(prefix, 0) !== -1) {
4980        pars.splice(i, 1);
4981      }
4982    }
4983
4984    return urlparts[0] + (pars.length > 0 ? "?" + pars.join("&") : "");
4985  }
4986  return url;
4987}
4988
4989function updateURLParameter(uri, key, value) {
4990  if (!value) {
4991    return uri;
4992  }
4993  var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
4994  var separator = uri.indexOf("?") !== -1 ? "&" : "?";
4995  if (uri.match(re)) {
4996    return uri.replace(re, "$1" + key + "=" + value + "$2");
4997  } else {
4998    return uri + separator + key + "=" + value;
4999  }
5000}
5001
5002function validate(evt) {
5003  var theEvent = evt || window.event;
5004
5005  // Handle paste
5006  if (theEvent.type === "paste") {
5007    key = event.clipboardData.getData("text/plain");
5008  } else {
5009    // Handle key press
5010    var key = theEvent.keyCode || theEvent.which;
5011    key = String.fromCharCode(key);
5012  }
5013  var regex = /[0-9]|\./;
5014  if (!regex.test(key)) {
5015    theEvent.returnValue = false;
5016    if (theEvent.preventDefault) theEvent.preventDefault();
5017  }
5018}
5019
5020Vue.component("bind-login", {
5021  props: ["show", "type"],
5022  template: b2_global.bind_login,
5023  data() {
5024    return {
5025      locked: false,
5026      count: 60,
5027      SMSLocked: false,
5028      data: {
5029        img_code: "",
5030        token: "",
5031        username: "",
5032        password: "",
5033        confirmPassword: "",
5034        code: "",
5035      },
5036      eye: false,
5037      success: "",
5038    };
5039  },
5040  computed: {
5041    userData() {
5042      return this.$store.state.userData;
5043    },
5044  },
5045  methods: {
5046    close() {
5047      this.$emit("close");
5048    },
5049    showCheck() {
5050      if (
5051        this.type !== "text" &&
5052        this.type !== "luo" &&
5053        this.data.username &&
5054        this.show
5055      ) {
5056        return true;
5057      }
5058      return false;
5059    },
5060    sendCode() {
5061      recaptcha.show = true;
5062      recaptcha.type = "bind";
5063      this.close();
5064    },
5065    sendSMS() {
5066      if (this.SMSLocked == true) return;
5067      this.SMSLocked = true;
5068      this.$http
5069        .post(b2_rest_url + "sendCode", Qs.stringify(this.data))
5070        .then((res) => {
5071          if (res.data.token) {
5072            this.countdown();
5073            this.data.smsToken = res.data.token;
5074          }
5075          this.SMSLocked = false;
5076        })
5077        .catch((err) => {
5078          Qmsg["warning"](err.response.data.message, { html: true });
5079          this.SMSLocked = false;
5080        });
5081    },
5082    countdown() {
5083      if (this.count <= 1) {
5084        this.count = 60;
5085        return;
5086      }
5087      this.count--;
5088      setTimeout(() => {
5089        this.countdown();
5090      }, 1000);
5091    },
5092    setToken(val) {
5093      this.data.img_code = val.value;
5094      this.data.token = val.token;
5095      this.sendSMS();
5096    },
5097    submit() {
5098      if (this.locked) return;
5099      this.locked = true;
5100      this.$http
5101        .post(b2_rest_url + "bindUserLogin", Qs.stringify(this.data))
5102        .then((res) => {
5103          this.success = res.data;
5104          this.locked = false;
5105        })
5106        .catch((err) => {
5107          Qmsg["warning"](err.response.data.message, { html: true });
5108          this.locked = false;
5109        });
5110    },
5111  },
5112});
5113
5114//强制绑定登录名
5115var b2bindLogin = new Vue({
5116  el: "#binding-login",
5117  data: {
5118    show: false,
5119    type: false,
5120  },
5121  methods: {
5122    close() {
5123      this.show = !this.show;
5124    },
5125    imgCodeAc(val) {
5126      this.$refs.bindBox.setToken(val);
5127    },
5128  },
5129  watch: {
5130    type(val) {
5131      if (val) {
5132        this.show = true;
5133      }
5134    },
5135  },
5136});
5137
5138var b2CreditTop = new Vue({
5139  el: ".credit-top",
5140  data: {
5141    settings: [],
5142    data: "",
5143  },
5144  mounted() {
5145    if (this.$refs.creditTop) {
5146      this.settings = JSON.parse(
5147        this.$refs.creditTop.getAttribute("data-settings")
5148      );
5149      this.getList();
5150    }
5151  },
5152  methods: {
5153    getList() {
5154      this.$http
5155        .post(b2_rest_url + "getGoldTop", Qs.stringify(this.settings))
5156        .then((res) => {
5157          this.data = res.data;
5158          this.$nextTick(() => {
5159            this.$refs.creditTopGujia.style.display = "none";
5160          });
5161        });
5162    },
5163  },
5164});
5165
5166function grin(tag, myField) {
5167  if (document.selection) {
5168    myField.focus();
5169    sel = document.selection.createRange();
5170    sel.text = tag;
5171    myField.focus();
5172  } else if (myField.selectionStart || myField.selectionStart == "0") {
5173    var startPos = myField.selectionStart;
5174    var endPos = myField.selectionEnd;
5175    var cursorPos = startPos;
5176    myField.value =
5177      myField.value.substring(0, startPos) +
5178      tag +
5179      myField.value.substring(endPos, myField.value.length);
5180    cursorPos += tag.length;
5181    myField.focus();
5182    myField.selectionStart = cursorPos;
5183    myField.selectionEnd = cursorPos;
5184  } else {
5185    myField.value += tag;
5186    myField.focus();
5187  }
5188}
5189
5190//圈子小工具
5191var b2HotCircle = new Vue({
5192  el: ".b2-widget-hot-circle",
5193  data: {
5194    data: "",
5195    count: 6,
5196    type: "hot",
5197    paged: {
5198      hot: 1,
5199      join: 1,
5200      create: 1,
5201    },
5202    locked: false,
5203  },
5204  mounted() {
5205    if (!this.$refs.hotCircle) return;
5206    this.count = this.$refs.hotCircle.getAttribute("data-count");
5207    this.getCirclesList("hot");
5208  },
5209  methods: {
5210    go(link) {
5211      window.location.href = link;
5212    },
5213    getCirclesList(type) {
5214      if (!b2token && type !== "hot") {
5215        login.show = true;
5216        login.type = 1;
5217        return;
5218      }
5219      if (this.locked === true) return;
5220      this.locked = true;
5221      let data = {
5222        count: this.count,
5223        type: type,
5224        paged: this.paged[type],
5225      };
5226      this.$refs.gujia.style.display = "block";
5227      this.data = "";
5228      this.$http
5229        .post(b2_rest_url + "getCirclesList", Qs.stringify(data))
5230        .then((res) => {
5231          this.data = res.data;
5232          this.$nextTick(() => {
5233            this.$refs.gujia.style.display = "none";
5234            b2SidebarSticky();
5235            lazyLoadInstance.update();
5236          });
5237          this.type = type;
5238          this.locked = false;
5239        })
5240        .catch((err) => {
5241          Qmsg["warning"](err.response.data.message, { html: true });
5242          this.locked = false;
5243        });
5244    },
5245  },
5246});
5247
5248if (!window.scrollTo) {
5249  window.scrollTo = function (x, y) {
5250    window.pageXOffset = x;
5251    window.pageYOffset = y;
5252  };
5253}
5254if (!window.scrollBy) {
5255  window.scrollBy = function (x, y) {
5256    window.pageXOffset += x;
5257    window.pageYOffset += y;
5258  };
5259}
5260if (!document.body.scrollTo) {
5261  Element.prototype.scrollTo = function (x, y) {
5262    this.scrollLeft = x;
5263    this.scrollTop = y;
5264  };
5265}
5266if (!document.body.scrollBy) {
5267  Element.prototype.scrollBy = function (x, y) {
5268    this.scrollLeft += x;
5269    this.scrollTop += y;
5270  };
5271}
5272
5273var payReturn = new Vue({
5274  el: "#pay-return",
5275  data: {
5276    login: false,
5277  },
5278  mounted() {
5279    if (b2token) {
5280      this.login = true;
5281    }
5282  },
5283});
5284
5285const searchBox = document.querySelectorAll(".search-module");
5286
5287if (searchBox) {
5288  for (let index = 0; index < searchBox.length; index++) {
5289    let id = searchBox[index].getAttribute("data-i");
5290    new Vue({
5291      el: "#search-module-" + id,
5292      data: {
5293        link: b2_global.home_url,
5294        keyword: "",
5295        category: b2_global.js_text.global.all,
5296        show: false,
5297      },
5298      mounted() {
5299        document.onclick = (e) => {
5300          this.show = false;
5301          userTools.hideAction();
5302        };
5303      },
5304      methods: {
5305        picked(id, category, link) {
5306          this.link = link;
5307          this.category = category;
5308          this.show = false;
5309        },
5310        pickedKey(key) {},
5311      },
5312    });
5313  }
5314}
5315
5316var b2recommendedCircle = new Vue({
5317  el: ".b2-widget-recommended-circle",
5318  data: {
5319    data: "",
5320    current: 0,
5321  },
5322  mounted() {
5323    if (!this.$refs.recommendedGujia) return;
5324    this.getCircles();
5325  },
5326  methods: {
5327    create() {
5328      if (!b2token) {
5329        login.show = true;
5330        login.loginType = 1;
5331      } else {
5332        window.open(b2_global.home_url + "/create-circle", "_blank");
5333      }
5334    },
5335    getCircles() {
5336      let ids = JSON.parse(
5337        this.$refs.recommendedGujia.getAttribute("data-ids")
5338      );
5339      if (ids.length == 0) return;
5340      let data = {
5341        ids: ids,
5342      };
5343
5344      this.$http
5345        .post(b2_rest_url + "getCircleDataByCircleIds", Qs.stringify(data))
5346        .then((res) => {
5347          this.data = res.data;
5348          this.$nextTick(() => {
5349            this.$refs.recommendedGujia.style.display = "none";
5350            if (typeof b2CirclePostBox != "undefined") {
5351              if (b2CirclePostBox.$refs.textareaTopic) {
5352                this.current = parseInt(
5353                  b2CirclePostBox.$refs.textareaTopic.getAttribute(
5354                    "data-circle"
5355                  )
5356                );
5357              }
5358            }
5359            this.$nextTick(() => {
5360              lazyLoadInstance.update();
5361            });
5362            b2SidebarSticky();
5363          });
5364        });
5365    },
5366    go(even, index) {
5367      if (typeof b2CirclePostBox != "undefined") {
5368        even.stopPropagation();
5369        even.preventDefault();
5370        let id = this.data[index].id;
5371        b2CirclePostBox.circle.picked = id;
5372        this.current = id;
5373        b2CircleList.pickedCircle("widget", id);
5374        b2CirclePostBox.getCurrentUserCircleData();
5375        window.history.pushState(
5376          id,
5377          this.data[index].name,
5378          this.data[index].link
5379        );
5380        document.title =
5381          this.data[index].name +
5382          " " +
5383          b2_global.site_separator +
5384          " " +
5385          b2_global.site_name;
5386        // b2AsideBar.goTop()
5387        return false;
5388      }
5389    },
5390  },
5391});
5392
5393document.b2ready = function (callback) {
5394  ///兼容FF,Google
5395  if (document.addEventListener) {
5396    document.addEventListener(
5397      "DOMContentLoaded",
5398      function () {
5399        document.removeEventListener(
5400          "DOMContentLoaded",
5401          arguments.callee,
5402          false
5403        );
5404        callback();
5405      },
5406      false
5407    );
5408  }
5409  //兼容IE
5410  else if (document.attachEvent) {
5411    document.attachEvent("onreadystatechange", function () {
5412      if (document.readyState == "complete") {
5413        document.detachEvent("onreadystatechange", arguments.callee);
5414        callback();
5415      }
5416    });
5417  } else if (document.lastChild == document.body) {
5418    callback();
5419  }
5420};
5421
5422function b2tooltip(cla) {
5423  const d = document.querySelectorAll(cla);
5424  if (!d) return;
5425  if (B2ClientWidth < 768) return;
5426
5427  var x = 15;
5428  var y = 10;
5429
5430  window.b2thistip = [];
5431
5432  for (let i = 0; i < d.length; i++) {
5433    d[i].addEventListener(
5434      "mouseover",
5435      function (e) {
5436        var tooltip =
5437          "<div class='b2tooltip' id='b2tooltip" +
5438          i +
5439          "'>" +
5440          this.getAttribute("data-title") +
5441          "</div>";
5442
5443        document.body.insertAdjacentHTML("beforeend", tooltip);
5444
5445        window.b2thistip[i] = document.querySelector("#b2tooltip" + i);
5446
5447        window.b2thistip[i].style.top = e.pageY + y + "px";
5448        window.b2thistip[i].style.left = e.pageX + x + "px";
5449
5450        window.b2thistip[i].style.display = "block";
5451      },
5452      passiveSupported ? { passive: true } : false
5453    );
5454
5455    d[i].addEventListener(
5456      "mouseout",
5457      function (e) {
5458        if (typeof window.b2thistip[i] != "undefined")
5459          window.b2thistip[i].remove();
5460      },
5461      passiveSupported ? { passive: true } : false
5462    );
5463
5464    d[i].addEventListener(
5465      "mousemove",
5466      function (e) {
5467        window.b2thistip[i].style.top = e.pageY + y + "px";
5468        window.b2thistip[i].style.left = e.pageX + x + "px";
5469      },
5470      passiveSupported ? { passive: true } : false
5471    );
5472  }
5473}
5474
5475b2tooltip(".b2tooltipbox");
5476
5477function b2cpay() {
5478  const paybox = document.querySelectorAll(".custom-pay-box");
5479
5480  if (paybox.length > 0) {
5481    for (let i = 0; i < paybox.length; i++) {
5482      new Vue({
5483        el: paybox[i],
5484        data: {
5485          locked: {},
5486          count: {},
5487          files: {},
5488          progress: {},
5489          // edited by fuzqing
5490          related: false,
5491          related_field: "",
5492          related_prices: [],
5493          active_time: {
5494            active: false,
5495            tips: "",
5496          },
5497
5498          price: "",
5499          api: "getCpayResout",
5500          selecter: "cpay-resout-list-in",
5501          list: {
5502            pages: 0,
5503            paged: 1,
5504            count: 20,
5505            id: 0,
5506            data: "",
5507          },
5508          allow: 0,
5509          tab: "form",
5510        },
5511        mounted() {
5512          if (this.$refs.pickprice) {
5513            this.price = this.$refs.pickprice.getAttribute("data-price");
5514          }
5515          if (this.$refs.cpayresout) {
5516            this.list.id = this.$refs.cpayresout.getAttribute("data-id");
5517            // this.getList()
5518            this.$refs.reslist.go(this.list.paged, "comment", true, true);
5519          }
5520          // edited by fuzqing
5521          this.getCpayInfo();
5522        },
5523        // edited by fuzqing
5524        watch: {
5525          related_field: function (val) {
5526            this.price = this.related_prices[val];
5527          },
5528        },
5529        methods: {
5530          // edited by fuzqing
5531          getCpayInfo() {
5532            this.$http
5533              .post(b2_rest_url + "getCpayInfo", "post_id=" + this.list.id)
5534              .then((res) => {
5535                if (res.data.related === true) {
5536                  this.related = true;
5537                  this.related_field = res.data.related_field_value;
5538                  this.related_prices = res.data.related_prices;
5539                }
5540                this.active_time = res.data.active_time;
5541              })
5542              .catch((err) => {
5543                Qmsg["warning"](err.response.data.message, { html: true });
5544              });
5545          },
5546          getList(res) {
5547            this.list.data = res.data;
5548            this.allow = res.allow;
5549            this.list.pages = res.pages;
5550          },
5551          submit(title, id, postid) {
5552            let obj = {};
5553            let data = new FormData(this.$refs.form);
5554            for (let [key, value] of data) {
5555              if (obj[key] !== undefined) {
5556                if (!Array.isArray(obj[key])) {
5557                  obj[key] = [obj[key]];
5558                }
5559                obj[key].push(value);
5560              } else {
5561                obj[key] = value;
5562              }
5563
5564              if (typeof obj[key] == "object") {
5565                if (obj[key].lastModified) {
5566                  delete obj[key];
5567                }
5568              }
5569
5570              if (this.files.hasOwnProperty(key)) {
5571                obj[key] = this.files[key];
5572              }
5573
5574              if (this.$refs[key + "required"]) {
5575                let required =
5576                  this.$refs[key + "required"].getAttribute("data-required");
5577
5578                required = parseInt(required);
5579                if (
5580                  required &&
5581                  (!obj[key] ||
5582                    (Array.isArray(obj[key]) && obj[key].length == 0))
5583                ) {
5584                  Qmsg["warning"](
5585                    b2_global.js_text.global.cpay_required_fields,
5586                    { html: true }
5587                  );
5588                  return;
5589                }
5590              }
5591            }
5592
5593            if (!obj.price) {
5594              Qmsg["warning"](b2_global.js_text.global.cpay_required_fields, {
5595                html: true,
5596              });
5597              return;
5598            }
5599
5600            b2DsBox.data = {
5601              title: title,
5602              order_type: "custom",
5603              order_price: obj.price,
5604              post_id: id,
5605              order_key: postid,
5606              order_value: JSON.stringify(obj),
5607            };
5608            b2DsBox.show = true;
5609
5610            console.log(b2DsBox.data);
5611
5612            return obj;
5613          },
5614          deleteAc(key, index) {
5615            if (confirm(b2_global.js_text.circle.remove_file)) {
5616              this.$delete(this.files[key], index);
5617              this.$delete(this.progress[key], index);
5618              this.locked[key] = false;
5619              this.$set(this.count, key, this.count[key] - 1);
5620            }
5621          },
5622          fileExists(mime) {
5623            let index = mime.lastIndexOf(".");
5624            let ext = mime.substr(index + 1);
5625            return ext.toLowerCase();
5626          },
5627          readablizeBytes(bytes) {
5628            let s = ["B", "KB", "MB", "GB", "TB", "PB"];
5629            let e = Math.floor(Math.log(bytes) / Math.log(1024));
5630            return (
5631              (bytes / Math.pow(1024, Math.floor(e))).toFixed(2) + " " + s[e]
5632            );
5633          },
5634          fileType(ext) {
5635            ext = ext.toLowerCase();
5636            switch (ext) {
5637              case "jpg":
5638              case "png":
5639              case "gif":
5640              case "jpeg":
5641              case "ico":
5642              case "webp":
5643                return "image";
5644              case "mp3":
5645              case "m4a":
5646              case "ogg":
5647              case "wav":
5648                return "video";
5649              case "mp4":
5650              case "mov":
5651              case "avi":
5652              case "mpg":
5653              case "ogv":
5654              case "3gp":
5655              case "3g2":
5656                return "audio";
5657              default:
5658                return "file";
5659            }
5660          },
5661          fileChange(event, count, key, id) {
5662            if (event.target.files.length > count) {
5663              let msg = b2_global.js_text.global.cpay_file_count;
5664              msg = msg.replace("${count}", count);
5665              Qmsg["warning"](msg, { html: true });
5666
5667              // event.target.
5668              return;
5669            }
5670
5671            if (event.target.files.length <= 0) return;
5672
5673            if (!this.files.hasOwnProperty(key)) {
5674              this.$set(this.files, key, []);
5675              this.$set(this.progress, key, []);
5676              this.$set(this.locked, key, []);
5677              this.$set(this.count, key, 0);
5678            }
5679
5680            if (event.target.files.length > count - this.count[key]) {
5681              let msg = b2_global.js_text.global.cpay_file_count_less;
5682              msg = msg.replace("${count}", count - this.count[key]);
5683              Qmsg["warning"](msg, { html: true });
5684
5685              return;
5686            }
5687
5688            if (this.locked[key] == true) return;
5689
5690            let index = parseInt(this.files[key].length);
5691
5692            Object.keys(event.target.files).forEach((k) => {
5693              console.log(k);
5694              this.$set(this.count, key, this.count[key] + 1);
5695
5696              this.locked[key] = true;
5697
5698              k = parseInt(k);
5699
5700              const ext = this.fileExists(event.target.files[k].name);
5701
5702              this.$set(this.files[key], k + index, {
5703                size: this.readablizeBytes(event.target.files[k].size),
5704                name: event.target.files[k].name,
5705                ext: ext,
5706                type: this.fileType(ext),
5707              });
5708
5709              this.$set(this.progress[key], k + index, {
5710                status: "doing",
5711                number: 0,
5712                msg: "",
5713              });
5714
5715              let formData = new FormData();
5716
5717              formData.append(
5718                "file",
5719                event.target.files[k],
5720                event.target.files[k].name
5721              );
5722              formData.append("post_id", id);
5723              formData.append("type", "cpay");
5724
5725              let config = {
5726                onUploadProgress: (progressEvent) => {
5727                  this.$set(
5728                    this.progress[key][k + index],
5729                    "number",
5730                    ((progressEvent.loaded / progressEvent.total) * 100) | 0
5731                  );
5732                },
5733              };
5734
5735              this.$http
5736                .post(b2_rest_url + "fileUpload", formData, config)
5737                .then((res) => {
5738                  console.log(res);
5739                  if (res.data.status == 401) {
5740                    Qmsg["warning"](res.data.message, { html: true });
5741
5742                    this.$set(this.progress[key][k + index], "status", "fail");
5743                    this.$set(
5744                      this.progress[key][k + index],
5745                      "msg",
5746                      res.data.message
5747                    );
5748                  } else {
5749                    this.$set(this.files[key][k + index], "url", res.data.url);
5750
5751                    this.$set(this.files[key][k + index], "id", res.data.id);
5752
5753                    this.$set(
5754                      this.progress[key][k + index],
5755                      "status",
5756                      "success"
5757                    );
5758                  }
5759
5760                  console.log(this.files);
5761
5762                  if (this.count[key] >= count) {
5763                    this.locked[key] = true;
5764                  } else {
5765                    this.locked[key] = false;
5766                  }
5767                  event.target.value = "";
5768                })
5769                .catch((err) => {
5770                  Qmsg["warning"](err.response.data.message, { html: true });
5771                  this.locked[key] = false;
5772                  this.$set(this.progress[key][k + index], "status", "fail");
5773                  this.$set(
5774                    this.progress[key][k + index],
5775                    "msg",
5776                    err.response.data.message
5777                  );
5778                  event.target.value = "";
5779                });
5780            });
5781          },
5782        },
5783      });
5784    }
5785  }
5786}
5787b2cpay();
5788
5789function b2fingerprint() {
5790  var canvas = document.createElement("canvas");
5791  var ctx = canvas.getContext("2d");
5792  var txt = "i9asdm..$#po((^@KbXrww!~cz";
5793  ctx.textBaseline = "top";
5794  ctx.font = "16px 'Arial'";
5795  ctx.textBaseline = "alphabetic";
5796  ctx.rotate(0.05);
5797  ctx.fillStyle = "#f60";
5798  ctx.fillRect(125, 1, 62, 20);
5799  ctx.fillStyle = "#069";
5800  ctx.fillText(txt, 2, 15);
5801  ctx.fillStyle = "rgba(102, 200, 0, 0.7)";
5802  ctx.fillText(txt, 4, 17);
5803  ctx.shadowBlur = 10;
5804  ctx.shadowColor = "blue";
5805  ctx.fillRect(-20, 10, 234, 5);
5806  var strng = canvas.toDataURL();
5807
5808  var hash = 0;
5809  if (strng.length == 0) return;
5810  for (i = 0; i < strng.length; i++) {
5811    char = strng.charCodeAt(i);
5812    hash = (hash << 5) - hash + char;
5813    hash = hash & hash;
5814  }
5815  return hash;
5816}
5817
5818var b2stream = new Vue({
5819  el: "#b2-stream",
5820  data: {
5821    paged: 1,
5822    pages: 0,
5823    author: 1,
5824    data: "",
5825    empty: false,
5826    locked: false,
5827  },
5828  mounted() {
5829    if (!this.$refs.b2stream) return;
5830    this.paged = this.$refs.b2stream.getAttribute("data-paged");
5831    this.author = this.$refs.b2stream.getAttribute("data-author");
5832    this.getList();
5833  },
5834  methods: {
5835    getList() {
5836      this.$http
5837        .post(
5838          b2_rest_url + "getStreamList",
5839          "paged=" + this.paged + "&author=" + this.author
5840        )
5841        .then((res) => {
5842          this.data = res.data;
5843
5844          if (this.data.length == 0) {
5845            this.empty = true;
5846          }
5847          this.$refs.gujia.style.display = "none";
5848
5849          this.$nextTick(() => {
5850            b2SidebarSticky();
5851            lazyLoadInstance.update();
5852          });
5853        });
5854    },
5855    vote(type, id, index) {
5856      if (!b2token) {
5857        login.show = true;
5858      } else {
5859        if (this.locked == true) return;
5860        this.locked = true;
5861
5862        this.$http
5863          .post(b2_rest_url + "postVote", "type=" + type + "&post_id=" + id)
5864          .then((res) => {
5865            this.$set(
5866              this.data[index].data.data,
5867              "up",
5868              parseInt(this.data[index].data.data.up) + parseInt(res.data.up)
5869            );
5870            this.$set(
5871              this.data[index].data.data,
5872              "down",
5873              parseInt(this.data[index].data.data.down) +
5874                parseInt(res.data.down)
5875            );
5876
5877            if (res.data.up > 0) {
5878              this.$set(this.data[index].data.data, "up_isset", 1);
5879            } else {
5880              this.$set(this.data[index].data.data, "up_isset", 0);
5881            }
5882
5883            if (res.data.down > 0) {
5884              this.$set(this.data[index].data.data, "down_isset", 1);
5885            } else {
5886              this.$set(this.data[index].data.data, "down_isset", 0);
5887            }
5888
5889            this.locked = false;
5890          })
5891          .catch((err) => {
5892            Qmsg["warning"](err.response.data.message, { html: true });
5893            this.locked = false;
5894          });
5895      }
5896    },
5897  },
5898});
5899
5900//防抖
5901function _debounce(fn, delay) {
5902  var delay = delay || 200;
5903  var timer;
5904  return function () {
5905    var th = this;
5906    var args = arguments;
5907    if (timer) {
5908      clearTimeout(timer);
5909    }
5910    timer = setTimeout(function () {
5911      timer = null;
5912      fn.apply(th, args);
5913    }, delay);
5914  };
5915}
5916// 节流
5917function _throttle(fn, interval) {
5918  var last;
5919  var timer;
5920  var interval = interval || 200;
5921  return function () {
5922    var th = this;
5923    var args = arguments;
5924    var now = +new Date();
5925    if (last && now - last < interval) {
5926      clearTimeout(timer);
5927      timer = setTimeout(function () {
5928        last = now;
5929        fn.apply(th, args);
5930      }, interval);
5931    } else {
5932      last = now;
5933      fn.apply(th, args);
5934    }
5935  };
5936}
5937
5938var askWidget = new Vue({
5939  el: ".b2-widget-ask",
5940  data: {
5941    data: "",
5942    fliter: "last",
5943    paged: 1,
5944    pages: 0,
5945    count: 0,
5946    cat: 0,
5947    empty: false,
5948    locked: false,
5949    prev: true,
5950    next: false,
5951  },
5952  mounted() {
5953    if (!this.$refs.askwidget) return;
5954    this.count = this.$refs.askwidget.getAttribute("data-count");
5955    this.time = this.$refs.askwidget.getAttribute("data-time");
5956    const archive = document.querySelector(".ask-archive");
5957
5958    if (archive) {
5959      this.cat = archive.getAttribute("data-term");
5960    }
5961
5962    const single = document.querySelector(".ask-single-top");
5963
5964    if (single) {
5965      this.cat = single.getAttribute("data-term");
5966    }
5967
5968    this.getData();
5969  },
5970  watch: {
5971    fliter(val) {
5972      this.prev = true;
5973      this.next = false;
5974      this.data = "";
5975      this.paged = 1;
5976      this.empty = false;
5977      this.$refs.askwidget.querySelector(".gujia").style.display = "block";
5978      this.getData();
5979    },
5980  },
5981  methods: {
5982    nexAc() {
5983      if (this.paged >= this.data.pages) return;
5984      if (this.locked) return;
5985      this.next = true;
5986      this.paged++;
5987      this.getData();
5988    },
5989    prevAc() {
5990      if (this.paged < 1) return;
5991      if (this.locked) return;
5992      this.prev = true;
5993      this.paged--;
5994      this.getData();
5995    },
5996    getData() {
5997      if (this.locked) return;
5998      this.locked = true;
5999      this.$http
6000        .post(
6001          b2_rest_url + "getAskData",
6002          "paged=" +
6003            this.paged +
6004            "&type=" +
6005            this.fliter +
6006            "&count=" +
6007            this.count +
6008            "&cat=" +
6009            this.cat
6010        )
6011        .then((res) => {
6012          this.locked = false;
6013          if (this.paged == 1) {
6014            if (res.data.data.length == 0) {
6015              this.empty = true;
6016              this.data.data = [];
6017            } else {
6018              this.data = res.data;
6019            }
6020          } else {
6021            this.data.data = res.data.data;
6022          }
6023          if (this.data.pages > 1 && this.paged < this.data.pages) {
6024            this.next = false;
6025          }
6026          if (this.paged > 1) {
6027            this.prev = false;
6028          }
6029          this.$nextTick(() => {
6030            this.$refs.askwidget.querySelector(".gujia").style.display = "none";
6031          });
6032        });
6033    },
6034  },
6035});

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.