This commit is contained in:
zoujiandong
2025-07-30 13:58:39 +08:00
parent afc79a0f26
commit 43abd1f3d6
360 changed files with 27253 additions and 0 deletions
@@ -0,0 +1,98 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "u-code",
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$15],
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-ac37a9df"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/node-modules/uview-plus/components/u-code/u-code.js.map
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1 @@
<view class="u-code data-v-ac37a9df"></view>
@@ -0,0 +1,49 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.u-empty.data-v-ac37a9df,
.u-empty__wrap.data-v-ac37a9df,
.u-tabs.data-v-ac37a9df,
.u-tabs__wrapper.data-v-ac37a9df,
.u-tabs__wrapper__scroll-view-wrapper.data-v-ac37a9df,
.u-tabs__wrapper__scroll-view.data-v-ac37a9df,
.u-tabs__wrapper__nav.data-v-ac37a9df,
.u-tabs__wrapper__nav__line.data-v-ac37a9df,
.up-empty.data-v-ac37a9df,
.up-empty__wrap.data-v-ac37a9df,
.up-tabs.data-v-ac37a9df,
.up-tabs__wrapper.data-v-ac37a9df,
.up-tabs__wrapper__scroll-view-wrapper.data-v-ac37a9df,
.up-tabs__wrapper__scroll-view.data-v-ac37a9df,
.up-tabs__wrapper__nav.data-v-ac37a9df,
.up-tabs__wrapper__nav__line.data-v-ac37a9df {
display: flex;
flex-direction: column;
flex-shrink: 0;
flex-grow: 0;
flex-basis: auto;
align-items: stretch;
align-content: flex-start;
}