"use strict"; const common_vendor = require("../common/vendor.js"); if (!Array) { const _easycom_up_upload2 = common_vendor.resolveComponent("up-upload"); const _easycom_up_radio2 = common_vendor.resolveComponent("up-radio"); const _easycom_up_radio_group2 = common_vendor.resolveComponent("up-radio-group"); const _easycom_up_input2 = common_vendor.resolveComponent("up-input"); (_easycom_up_upload2 + _easycom_up_radio2 + _easycom_up_radio_group2 + _easycom_up_input2)(); } const _easycom_up_upload = () => "../node-modules/uview-plus/components/u-upload/u-upload.js"; const _easycom_up_radio = () => "../node-modules/uview-plus/components/u-radio/u-radio.js"; const _easycom_up_radio_group = () => "../node-modules/uview-plus/components/u-radio-group/u-radio-group.js"; const _easycom_up_input = () => "../node-modules/uview-plus/components/u-input/u-input.js"; if (!Math) { (_easycom_up_upload + _easycom_up_radio + _easycom_up_radio_group + _easycom_up_input)(); } const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "login", emits: ["showChange"], setup(__props, { emit }) { const $api = common_vendor.inject("$api"); const $apifile = common_vendor.inject("$apifile"); const showType = common_vendor.ref(false); const form = common_vendor.ref({}); const roleList = common_vendor.ref([]); const agree = common_vendor.ref(false); const openid = common_vendor.computed(() => { return common_vendor.index.getStorageSync("openid"); }); common_vendor.computed(() => { return common_vendor.index.getStorageSync("user"); }); const config = common_vendor.computed(() => { return common_vendor.index.getStorageSync("config"); }); common_vendor.onShow(async () => { await searchOther(); }); const searchOther = async () => { let res; res = await $api(`dictData`, "GET", { code: "role", is_use: "0" }); if (res.errcode === 0) roleList.value = res.data; }; const deletePic = (event) => { form.value.icon = []; }; const afterRead = async (event) => { const url = event.file[0].url; const result = await $apifile(`/web/learn_user/upload`, "file", url, "file"); if (result.errcode === 0) form.value.icon = [result]; }; const toCancel = async () => { form.value = { icon: [] }; showType.value = false; agree.value = false; emit("showChange", false); }; const isValidPhoneNumber = (phoneNumber) => { const regex = /^1[3456789]\d{9}$/; return regex.test(phoneNumber); }; const toLogin = async () => { if (agree.value) { if (openid.value) { if (form.value.type) { if (form.value.phone) { if (isValidPhoneNumber(form.value.phone)) { common_vendor.index.getUserProfile({ desc: "用于展示", success: async function(res) { const type = form.value.type; delete form.value.type; let parmas = { openid: openid.value, status: "1" }; if (!form.value.nick_name) parmas.nick_name = res.userInfo.nickName + common_vendor.hooks().valueOf(); if (!form.value.icon || form.value.icon.length === 0) parmas.icon = config.value.icon; let arr; if (type == "0") arr = await $api(`teacher`, "POST", { ...form.value, ...parmas, is_show: "1" }); else arr = await $api(`student`, "POST", { ...form.value, ...parmas }); if (arr.errcode == "0") { let role_type; if (type == "0") role_type = "Teacher"; else role_type = "Student"; common_vendor.index.setStorageSync("user", { ...arr.data, role_type }); common_vendor.index.showToast({ title: "登录成功", icon: "success" }); await toCancel(); } else { common_vendor.index.showToast({ title: arr.errmsg, icon: "error" }); } }, fail: function(err) { console.log(err); } }); } else { common_vendor.index.showToast({ title: "请输入正确的手机号!", icon: "none" }); } } else { common_vendor.index.showToast({ title: "请输入手机号!", icon: "none" }); } } else { common_vendor.index.showToast({ title: "请选择用户身份!", icon: "none" }); } } else { common_vendor.index.showToast({ title: "系统更新中,请稍后再试!", icon: "none" }); } } else { common_vendor.index.showToast({ title: "请阅读并同意软件使用许可协议和隐私协议", icon: "none" }); } }; const toAgree = () => { common_vendor.index.navigateTo({ url: `/pagesHome/agree/index` }); }; const changeAgree = () => { agree.value = !agree.value; }; return (_ctx, _cache) => { return { a: common_vendor.t(common_vendor.unref(config).title || "学吧"), b: common_vendor.o(afterRead), c: common_vendor.o(deletePic), d: common_vendor.p({ fileList: form.value.icon, name: "icon", multiple: true, maxCount: 1 }), e: common_vendor.f(roleList.value, (item, index, i0) => { return { a: index, b: "b3197993-2-" + i0 + ",b3197993-1", c: common_vendor.p({ customStyle: { marginRight: "16px" }, label: item.label, name: item.value }) }; }), f: common_vendor.o(($event) => form.value.type = $event), g: common_vendor.p({ placement: "row", modelValue: form.value.type }), h: common_vendor.o(($event) => form.value.nick_name = $event), i: common_vendor.p({ placeholder: "请输入昵称", border: "surround", shape: "circle", modelValue: form.value.nick_name }), j: common_vendor.o(($event) => form.value.phone = $event), k: common_vendor.p({ placeholder: "请输入手机号", border: "surround", shape: "circle", modelValue: form.value.phone }), l: agree.value, m: common_vendor.t(common_vendor.unref(config).title || "学吧"), n: common_vendor.o(($event) => toAgree()), o: common_vendor.o(changeAgree), p: common_vendor.o(toCancel), q: common_vendor.o(toLogin), r: common_vendor.o(() => { }) }; }; } }); const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b3197993"], ["__file", "D:/project/学吧/learn_applet/components/login.vue"]]); wx.createComponent(Component);