1111
This commit is contained in:
-98
@@ -1,98 +0,0 @@
|
||||
"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
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
<view class="u-code data-v-ac37a9df"></view>
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* 这里是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;
|
||||
}
|
||||
Reference in New Issue
Block a user