|
|
@@ -1,430 +0,0 @@
|
|
|
-"use strict";
|
|
|
-const common_vendor = require("../../common/vendor.js");
|
|
|
-const common_assets = require("../../common/assets.js");
|
|
|
-const utils_api = require("../../utils/api.js");
|
|
|
-const utils_formatTime = require("../../utils/formatTime.js");
|
|
|
-const utils_plate = require("../../utils/plate.js");
|
|
|
-const utils_des = require("../../utils/des.js");
|
|
|
-const utils_imageCompress = require("../../utils/imageCompress.js");
|
|
|
-const utils_cos = require("../../utils/cos.js");
|
|
|
-if (!Array) {
|
|
|
- const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
|
|
|
- const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
|
|
|
- (_easycom_uni_datetime_picker2 + _easycom_uni_easyinput2)();
|
|
|
-}
|
|
|
-const _easycom_uni_datetime_picker = () => "../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
|
|
|
-const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
|
|
|
-if (!Math) {
|
|
|
- (_easycom_uni_datetime_picker + _easycom_uni_easyinput)();
|
|
|
-}
|
|
|
-const _sfc_main = {
|
|
|
- __name: "register",
|
|
|
- setup(__props) {
|
|
|
- const type = common_vendor.ref("");
|
|
|
- const visName = common_vendor.ref("");
|
|
|
- const visPhone = common_vendor.ref("");
|
|
|
- const visStartTime = common_vendor.ref("");
|
|
|
- const visEndTime = common_vendor.ref("");
|
|
|
- const visIdNumber = common_vendor.ref("");
|
|
|
- const visReason = common_vendor.ref("");
|
|
|
- const imgList = common_vendor.ref([]);
|
|
|
- const visCarNumber = common_vendor.ref("");
|
|
|
- const visPeopleNum = common_vendor.ref("");
|
|
|
- const list = common_vendor.ref([]);
|
|
|
- const passiveName = common_vendor.ref("");
|
|
|
- const passivePhone = common_vendor.ref("");
|
|
|
- const authValue = common_vendor.ref(false);
|
|
|
- const maxImgCount = common_vendor.ref(3);
|
|
|
- const cw = common_vendor.index.getSystemInfoSync().windowWidth;
|
|
|
- const btnFlag = common_vendor.computed(() => {
|
|
|
- const tem = list.value.some((item) => item.isChecked);
|
|
|
- if (visName.value && visPhone.value && visStartTime.value && visEndTime.value && [type.value === "1" && !visIdNumber.value] && visReason.value && [type.value === "1" && !list.value.length] && [type.value === "1" && !tem] && [type.value === "2" && !passiveName.value] && [
|
|
|
- type.value === "2" && !passivePhone.value
|
|
|
- ] && authValue.value) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- common_vendor.onLoad((options) => {
|
|
|
- type.value = options.type;
|
|
|
- if (type.value === "1") {
|
|
|
- visName.value = common_vendor.index.getStorageSync("userInfo").name;
|
|
|
- visPhone.value = common_vendor.index.getStorageSync("userInfo").phone;
|
|
|
- visIdNumber.value = common_vendor.index.getStorageSync("userInfo").idCard;
|
|
|
- getList();
|
|
|
- } else {
|
|
|
- passiveName.value = common_vendor.index.getStorageSync("userInfo").name;
|
|
|
- passivePhone.value = common_vendor.index.getStorageSync("userInfo").phone;
|
|
|
- }
|
|
|
- });
|
|
|
- const getList = async () => {
|
|
|
- const res = await utils_api.myRequest({
|
|
|
- url: "/wanzai/api/smartUser/queryAffiliateUserById",
|
|
|
- data: {
|
|
|
- id: common_vendor.index.getStorageSync("userInfo").id
|
|
|
- }
|
|
|
- });
|
|
|
- const result = JSON.parse(utils_des.decryptDes(res.data));
|
|
|
- list.value = result;
|
|
|
- };
|
|
|
- const handleSubmit = () => {
|
|
|
- const flag = verifyValue();
|
|
|
- if (flag) {
|
|
|
- if (type.value === "1") {
|
|
|
- parentAppointment();
|
|
|
- } else {
|
|
|
- otherAppointment();
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- const parentAppointment = async () => {
|
|
|
- let temList = [];
|
|
|
- list.value.forEach((ele) => {
|
|
|
- if (ele.isChecked) {
|
|
|
- temList.push(ele);
|
|
|
- }
|
|
|
- });
|
|
|
- const res = await utils_api.myRequest({
|
|
|
- url: "/wanzai/api/smartVisitor/parentsAppointment",
|
|
|
- method: "post",
|
|
|
- data: {
|
|
|
- userId: common_vendor.index.getStorageSync("userInfo").id,
|
|
|
- visitorTime: visStartTime.value,
|
|
|
- visitReason: visReason.value,
|
|
|
- carNum: visCarNumber.value,
|
|
|
- peerNum: visPeopleNum.value ? visPeopleNum.value : 0,
|
|
|
- image: imgList.value.join(","),
|
|
|
- students: temList
|
|
|
- }
|
|
|
- });
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: res.message,
|
|
|
- icon: "none",
|
|
|
- duration: 2e3
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- common_vendor.index.setStorageSync("Tab-activeIndex", 1);
|
|
|
- common_vendor.index.reLaunch({
|
|
|
- url: "/pagesReservation/record/record"
|
|
|
- });
|
|
|
- }, 2e3);
|
|
|
- };
|
|
|
- const otherAppointment = async () => {
|
|
|
- const res = await utils_api.myRequest({
|
|
|
- url: "/wanzai/api/smartVisitor/otherAppointment",
|
|
|
- method: "post",
|
|
|
- data: {
|
|
|
- userId: common_vendor.index.getStorageSync("userInfo").id,
|
|
|
- userName: visName.value,
|
|
|
- userPhone: visPhone.value,
|
|
|
- userCard: visIdNumber.value,
|
|
|
- visitorTime: visStartTime.value,
|
|
|
- visitReason: visReason.value,
|
|
|
- carNum: visCarNumber.value,
|
|
|
- peerNum: visPeopleNum.value ? visPeopleNum.value : 0,
|
|
|
- respondentName: passiveName.value,
|
|
|
- respondentPhone: passivePhone.value
|
|
|
- }
|
|
|
- });
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: res.message,
|
|
|
- icon: "none",
|
|
|
- duration: 2e3
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- common_vendor.index.setStorageSync("Tab-activeIndex", 2);
|
|
|
- common_vendor.index.reLaunch({
|
|
|
- url: "/pagesReservation/record/record"
|
|
|
- });
|
|
|
- }, 2e3);
|
|
|
- };
|
|
|
- const changeStart = (e) => {
|
|
|
- const temTime = e.replace(/-/g, "/");
|
|
|
- const timestamp = Date.parse(new Date(temTime));
|
|
|
- const addTime = 1e3 * 60 * 60 * 4;
|
|
|
- visEndTime.value = utils_formatTime.time_format(timestamp + addTime);
|
|
|
- };
|
|
|
- const verifyValue = () => {
|
|
|
- const regName = /^[\u4e00-\u9fa5]{2,4}$/;
|
|
|
- const regPhone = /^1[3-9]\d{9}$/;
|
|
|
- const regIdentity = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
|
|
|
- if (!visName.value) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请输入访客姓名",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!regName.test(visName.value)) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "姓名格式错误",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!visPhone.value) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请输入访客手机号",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!regPhone.test(visPhone.value)) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "手机号码格式错误",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!visStartTime.value) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请选择来访时间",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!visEndTime.value) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请选择来访结束时间",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (type.value != 1 && !visIdNumber.value) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请输入访客证件号",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (type.value != 1 && !regIdentity.test(visIdNumber.value)) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "证件号格式错误",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!visReason.value) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请输入访问事由",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (visCarNumber.value && !utils_plate.isVehicleNumber(visCarNumber.value)) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请输入正确的车牌号",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (type.value === "1" && !list.value.length) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请绑定学生后再开始预约",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- const tem = list.value.some((item) => item.isChecked);
|
|
|
- if (type.value === "1" && !tem) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请选择受访学生",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (type.value === "2" && !passiveName.value) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请输入受访者姓名",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (type.value === "2" && !regName.test(passiveName.value)) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "受访者姓名格式错误",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (type.value === "2" && !passivePhone.value) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请输入受访者电话",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (type.value === "2" && !regPhone.test(passivePhone.value)) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "受访者手机号格式错误",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!authValue.value) {
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "请同意授权证件号",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- };
|
|
|
- const handleClick = (item) => {
|
|
|
- item.isChecked = !item.isChecked;
|
|
|
- };
|
|
|
- const handleAuth = () => {
|
|
|
- authValue.value = !authValue.value;
|
|
|
- };
|
|
|
- const uploadingImg = () => {
|
|
|
- common_vendor.index.chooseMedia({
|
|
|
- count: maxImgCount.value - imgList.value.length,
|
|
|
- mediaType: ["image"],
|
|
|
- sizeType: ["compressed"],
|
|
|
- success: (res) => {
|
|
|
- res.tempFiles.forEach((ele) => {
|
|
|
- let canvasId = "zipCanvas";
|
|
|
- let imagePath = ele.tempFilePath;
|
|
|
- let limitSize = 1024 * 3;
|
|
|
- let drawWidth = common_vendor.index.getSystemInfoSync().windowWidth;
|
|
|
- utils_imageCompress.getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, (resPath) => {
|
|
|
- handleUploadMini(resPath);
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
- const handleUploadMini = (ele) => {
|
|
|
- common_vendor.index.showLoading({
|
|
|
- title: "上传中",
|
|
|
- mask: true
|
|
|
- });
|
|
|
- let filePath = ele;
|
|
|
- let Key = filePath.substr(filePath.lastIndexOf("/") + 1);
|
|
|
- utils_cos.cos.postObject(
|
|
|
- {
|
|
|
- Bucket: "wanzai-1306339220",
|
|
|
- Region: "ap-shanghai",
|
|
|
- Key,
|
|
|
- FilePath: filePath,
|
|
|
- onProgress: (info) => {
|
|
|
- }
|
|
|
- },
|
|
|
- (err, data) => {
|
|
|
- if (err) {
|
|
|
- console.log("上传失败", err);
|
|
|
- } else {
|
|
|
- console.log("上传成功", data);
|
|
|
- common_vendor.index.hideLoading();
|
|
|
- let imgUrl = "https://" + data.Location;
|
|
|
- imgList.value.push(imgUrl);
|
|
|
- console.log(imgList.value);
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- };
|
|
|
- const handleDelete = (index) => {
|
|
|
- imgList.value.splice(index, 1);
|
|
|
- };
|
|
|
- const handleLookImg = (urls, current) => {
|
|
|
- common_vendor.index.previewImage({
|
|
|
- urls,
|
|
|
- current
|
|
|
- });
|
|
|
- };
|
|
|
- return (_ctx, _cache) => {
|
|
|
- return common_vendor.e({
|
|
|
- a: type.value == 1,
|
|
|
- b: visName.value,
|
|
|
- c: common_vendor.o(($event) => visName.value = $event.detail.value),
|
|
|
- d: type.value == 1,
|
|
|
- e: visPhone.value,
|
|
|
- f: common_vendor.o(($event) => visPhone.value = $event.detail.value),
|
|
|
- g: common_vendor.t(visStartTime.value || "请选择来访时间 >"),
|
|
|
- h: visStartTime.value ? 1 : "",
|
|
|
- i: common_vendor.o(changeStart),
|
|
|
- j: common_vendor.o(($event) => visStartTime.value = $event),
|
|
|
- k: common_vendor.p({
|
|
|
- modelValue: visStartTime.value
|
|
|
- }),
|
|
|
- l: common_vendor.t(visEndTime.value || "来访时间为4小时"),
|
|
|
- m: visEndTime.value ? 1 : "",
|
|
|
- n: type.value != 1
|
|
|
- }, type.value != 1 ? {
|
|
|
- o: type.value == 1,
|
|
|
- p: visIdNumber.value,
|
|
|
- q: common_vendor.o(($event) => visIdNumber.value = $event.detail.value)
|
|
|
- } : {}, {
|
|
|
- r: common_vendor.o(($event) => visReason.value = $event),
|
|
|
- s: common_vendor.p({
|
|
|
- type: "textarea",
|
|
|
- maxlength: 50,
|
|
|
- placeholder: "请输入访问事由(不超过50个字符)",
|
|
|
- modelValue: visReason.value
|
|
|
- }),
|
|
|
- t: type.value == 1
|
|
|
- }, type.value == 1 ? {
|
|
|
- v: common_vendor.t(maxImgCount.value)
|
|
|
- } : {}, {
|
|
|
- w: type.value == 1
|
|
|
- }, type.value == 1 ? common_vendor.e({
|
|
|
- x: common_vendor.f(imgList.value, (item, index, i0) => {
|
|
|
- return {
|
|
|
- a: item,
|
|
|
- b: common_vendor.o(($event) => handleLookImg(imgList.value, index), item),
|
|
|
- c: common_vendor.o(($event) => handleDelete(index), item),
|
|
|
- d: item
|
|
|
- };
|
|
|
- }),
|
|
|
- y: common_assets._imports_0$7,
|
|
|
- z: imgList.value.length < maxImgCount.value
|
|
|
- }, imgList.value.length < maxImgCount.value ? {
|
|
|
- A: common_assets._imports_1$5,
|
|
|
- B: common_vendor.o(uploadingImg)
|
|
|
- } : {}) : {}, {
|
|
|
- C: visCarNumber.value,
|
|
|
- D: common_vendor.o(($event) => visCarNumber.value = $event.detail.value),
|
|
|
- E: visPeopleNum.value,
|
|
|
- F: common_vendor.o(common_vendor.m(($event) => visPeopleNum.value = $event.detail.value, {
|
|
|
- number: true
|
|
|
- })),
|
|
|
- G: type.value == 2
|
|
|
- }, type.value == 2 ? {
|
|
|
- H: type.value == 2,
|
|
|
- I: passiveName.value,
|
|
|
- J: common_vendor.o(($event) => passiveName.value = $event.detail.value)
|
|
|
- } : {}, {
|
|
|
- K: type.value == 2
|
|
|
- }, type.value == 2 ? {
|
|
|
- L: type.value == 2,
|
|
|
- M: passivePhone.value,
|
|
|
- N: common_vendor.o(($event) => passivePhone.value = $event.detail.value)
|
|
|
- } : {}, {
|
|
|
- O: type.value == 1
|
|
|
- }, type.value == 1 ? {} : {}, {
|
|
|
- P: type.value == 1
|
|
|
- }, type.value == 1 ? {
|
|
|
- Q: common_vendor.f(list.value, (item, k0, i0) => {
|
|
|
- return {
|
|
|
- a: item.isChecked,
|
|
|
- b: common_vendor.t(item.name),
|
|
|
- c: common_vendor.t(item.cardNo),
|
|
|
- d: item.id,
|
|
|
- e: common_vendor.o(($event) => handleClick(item), item.id)
|
|
|
- };
|
|
|
- })
|
|
|
- } : {}, {
|
|
|
- R: authValue.value,
|
|
|
- S: common_vendor.o(handleAuth),
|
|
|
- T: btnFlag.value ? 1 : "",
|
|
|
- U: common_vendor.o(handleSubmit),
|
|
|
- V: common_vendor.unref(cw) + "px",
|
|
|
- W: common_vendor.unref(cw) + "px",
|
|
|
- X: -1
|
|
|
- });
|
|
|
- };
|
|
|
- }
|
|
|
-};
|
|
|
-const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-0b2c2ae2"]]);
|
|
|
-wx.createPage(MiniProgramPage);
|