first commit

This commit is contained in:
PC-202306242200\Administrator
2026-03-28 23:09:02 +08:00
commit dac42e3b0c
3512 changed files with 181637 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
"use strict";
const uni_modules_uviewPlus_libs_config_props = require("../../libs/config/props.js");
const props = {
props: {
// 倒计时总秒数
seconds: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.code.seconds
},
// 尚未开始时提示
startText: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.code.startText
},
// 正在倒计时中的提示
changeText: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.code.changeText
},
// 倒计时结束时的提示
endText: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.code.endText
},
// 是否在H5刷新或各端返回再进入时继续倒计时
keepRunning: {
type: Boolean,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.code.keepRunning
},
// 为了区分多个页面,或者一个页面多个倒计时组件本地存储的继续倒计时变了
uniqueKey: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.code.uniqueKey
}
}
};
exports.props = props;

View File

@@ -0,0 +1,16 @@
.u-empty.data-v-8783e3d0,
.u-empty__wrap.data-v-8783e3d0,
.u-tabs.data-v-8783e3d0,
.u-tabs__wrapper.data-v-8783e3d0,
.u-tabs__wrapper__scroll-view-wrapper.data-v-8783e3d0,
.u-tabs__wrapper__scroll-view.data-v-8783e3d0,
.u-tabs__wrapper__nav.data-v-8783e3d0,
.u-tabs__wrapper__nav__line.data-v-8783e3d0 {
display: flex;
flex-direction: column;
flex-shrink: 0;
flex-grow: 0;
flex-basis: auto;
align-items: stretch;
align-content: flex-start;
}

View File

@@ -0,0 +1 @@
<view class="u-code data-v-8783e3d0"></view>

View File

@@ -0,0 +1,100 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_uviewPlus_components_uCode_props = require("./props.js");
const uni_modules_uviewPlus_libs_mixin_mpMixin = require("../../libs/mixin/mpMixin.js");
const uni_modules_uviewPlus_libs_mixin_mixin = require("../../libs/mixin/mixin.js");
const _sfc_main = {
name: "u-code",
mixins: [uni_modules_uviewPlus_libs_mixin_mpMixin.mpMixin, uni_modules_uviewPlus_libs_mixin_mixin.mixin, uni_modules_uviewPlus_components_uCode_props.props],
data() {
return {
secNum: this.seconds,
timer: null,
canGetCode: true
// 是否可以执行验证码操作
};
},
mounted() {
this.checkKeepRunning();
},
watch: {
seconds: {
immediate: true,
handler(n) {
this.secNum = n;
}
}
},
emits: ["start", "end", "change"],
methods: {
checkKeepRunning() {
let lastTimestamp = Number(common_vendor.index.getStorageSync(this.uniqueKey + "_$uCountDownTimestamp"));
if (!lastTimestamp)
return this.changeEvent(this.startText);
let nowTimestamp = Math.floor(+/* @__PURE__ */ new Date() / 1e3);
if (this.keepRunning && lastTimestamp && lastTimestamp > nowTimestamp) {
this.secNum = lastTimestamp - nowTimestamp;
common_vendor.index.removeStorageSync(this.uniqueKey + "_$uCountDownTimestamp");
this.start();
} else {
this.changeEvent(this.startText);
}
},
// 开始倒计时
start() {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
this.$emit("start");
this.canGetCode = false;
this.changeEvent(this.changeText.replace(/x|X/, this.secNum));
this.timer = setInterval(() => {
if (--this.secNum) {
this.changeEvent(this.changeText.replace(/x|X/, this.secNum));
} else {
clearInterval(this.timer);
this.timer = null;
this.changeEvent(this.endText);
this.secNum = this.seconds;
this.$emit("end");
this.canGetCode = true;
}
}, 1e3);
this.setTimeToStorage();
},
// 重置,可以让用户再次获取验证码
reset() {
this.canGetCode = true;
clearInterval(this.timer);
this.secNum = this.seconds;
this.changeEvent(this.endText);
},
changeEvent(text) {
this.$emit("change", text);
},
// 保存时间戳为了防止倒计时尚未结束H5刷新或者各端的右上角返回上一页再进来
setTimeToStorage() {
if (!this.keepRunning || !this.timer)
return;
if (this.secNum > 0 && this.secNum < this.seconds) {
let nowTimestamp = Math.floor(+/* @__PURE__ */ new Date() / 1e3);
common_vendor.index.setStorage({
key: this.uniqueKey + "_$uCountDownTimestamp",
data: nowTimestamp + Number(this.secNum)
});
}
}
},
// 组件销毁的时候,清除定时器,否则定时器会继续存在,系统不会自动清除
beforeUnmount() {
this.setTimeToStorage();
clearTimeout(this.timer);
this.timer = null;
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-8783e3d0"]]);
my.createComponent(Component);

View File

@@ -0,0 +1,5 @@
{
"component": true,
"styleIsolation": "apply-shared",
"usingComponents": {}
}