register.js 6.47 KB
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_login = require("../../common/login.js");
const config = require("../../config.js");
require("../../common/request.js");
require("../../common/aes.js");
if (!Array) {
  const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  const _easycom_uni_countdown2 = common_vendor.resolveComponent("uni-countdown");
  (_easycom_uni_easyinput2 + _easycom_uni_countdown2)();
}
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_uni_countdown = () => "../../uni_modules/uni-countdown/components/uni-countdown/uni-countdown.js";
if (!Math) {
  (_easycom_uni_easyinput + _easycom_uni_countdown)();
}
const _sfc_main = {
  __name: "register",
  setup(__props) {
    common_vendor.ref(false);
    const codeUrl = common_vendor.ref(null);
    const registerForm = common_vendor.ref({
      telNo: null,
      password: null,
      password2: null,
      code: null,
      uuid: null,
      captcha: null
    });
    const countDown = common_vendor.ref({
      start: false,
      second: 60
    });
    const inputstyle = common_vendor.ref({
      borderColor: "transparent",
      fontSize: "30rpx"
    });
    common_vendor.onMounted(() => {
      getCode();
    });
    function register() {
      if (!registerForm.value.telNo) {
        common_vendor.index.showToast({
          title: "手机号不能为空",
          icon: "none"
        });
        return;
      }
      if (!registerForm.value.password || !registerForm.value.password2) {
        common_vendor.index.showToast({
          title: "密码不能为空",
          icon: "none"
        });
        return;
      }
      if (registerForm.value.password != registerForm.value.password2) {
        common_vendor.index.showToast({
          title: "两次密码不一致,请重新输入",
          icon: "none"
        });
        return;
      }
      if (!registerForm.value.code) {
        common_vendor.index.showToast({
          title: "验证码不能为空",
          icon: "none"
        });
        return;
      }
      common_login.groupMemberRegister(registerForm.value).then((res) => {
        common_vendor.index.showToast({
          title: `恭喜你,您的账号 ${registerForm.value.telNo} 注册成功!`
        });
        registerForm.value = {};
        setTimeout(goLogin, 2e3);
      });
    }
    function goLogin() {
      let path = "/pages/index/login";
      common_vendor.index.navigateTo({
        url: path
      });
    }
    function getCode() {
      common_login.getCodeImg().then((res) => {
        codeUrl.value = "data:image/gif;base64," + res.data.img;
        registerForm.value.uuid = res.data.uuid;
      });
    }
    function getCaptchaSms() {
      if (!registerForm.value.telNo) {
        common_vendor.index.showToast({
          title: "手机号不能为空",
          icon: "none"
        });
        return;
      }
      if (!registerForm.value.captcha) {
        common_vendor.index.showToast({
          title: "图形验证码不能为空",
          icon: "none"
        });
        return;
      }
      common_login.getSmsCode({
        uuid: registerForm.value.uuid,
        telNo: registerForm.value.telNo,
        code: registerForm.value.captcha
      }).then((res) => {
        common_vendor.index.showToast({
          title: "短信验证码下发成功",
          icon: "none"
        });
        countDown.value.start = true;
      }).catch(getCode);
    }
    function timeup() {
      countDown.value.start = false;
      countDown.value.second = 60;
      getCode();
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/ren1.png",
        b: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/logo@2x.png",
        c: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag01@2x.png",
        d: common_vendor.o(($event) => registerForm.value.telNo = $event),
        e: common_vendor.p({
          styles: inputstyle.value,
          placeholder: "请输入手机号",
          modelValue: registerForm.value.telNo
        }),
        f: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag02@2x.png",
        g: common_vendor.o(($event) => registerForm.value.password = $event),
        h: common_vendor.p({
          styles: inputstyle.value,
          placeholder: "密码",
          type: "password",
          modelValue: registerForm.value.password
        }),
        i: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag03@2x.png",
        j: common_vendor.o(($event) => registerForm.value.password2 = $event),
        k: common_vendor.p({
          styles: inputstyle.value,
          placeholder: "确认密码",
          type: "password",
          modelValue: registerForm.value.password2
        }),
        l: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag03@2x.png",
        m: common_vendor.o(($event) => registerForm.value.captcha = $event),
        n: common_vendor.p({
          styles: inputstyle.value,
          placeholder: "图形验证码",
          modelValue: registerForm.value.captcha
        }),
        o: codeUrl.value,
        p: common_vendor.o(getCode),
        q: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag04@2x.png",
        r: common_vendor.o(($event) => registerForm.value.code = $event),
        s: common_vendor.p({
          styles: inputstyle.value,
          placeholder: "短信验证码",
          modelValue: registerForm.value.code
        }),
        t: !countDown.value.start
      }, !countDown.value.start ? {
        v: common_vendor.o(getCaptchaSms)
      } : {}, {
        w: countDown.value.start
      }, countDown.value.start ? {
        x: common_vendor.o(timeup),
        y: common_vendor.p({
          color: "#014A9F",
          ["show-day"]: false,
          ["show-hour"]: false,
          ["show-min"]: false,
          start: countDown.value.start,
          second: countDown.value.second
        })
      } : {}, {
        z: common_vendor.o(register),
        A: common_vendor.o(goLogin),
        B: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/ren2.png"
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-224dede7"], ["__file", "/Users/yangyang/ztx_wx_minapp/pages/index/register.vue"]]);
wx.createPage(MiniProgramPage);