123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // 处理多次点击
- function noMultipleClicks(methods) {
- //复制this对象指向当时的this,防止找不到原来的对象
- let that = this;
- if (that.noClick) {
- that.noClick = false;
- //点击方法
- methods();
- setTimeout(function() {
- that.noClick = true;
- }, 2000)
- } else {
- uni.$showMsg('正在加载中', 500)
- }
- }
- //获取胶囊位置信息
- function getCapsuleSite() {
- let res = uni.getMenuButtonBoundingClientRect()
- this.capsuleBottom = res.bottom + 5
- this.capsuleMiddle = res.left
- this.capsuleWidth = res.width
- }
- //处理更新时间
- function getTimeStamp() {
- this.timeStamp = (new Date()).format("hh:mm")
- }
- //获取近几天时间数组
- function getRecentDateArray(day) {
- let recentDate = new Array();
- for (let i = day; i > 0; i--) {
- let dayTime = new Date();
- dayTime.setDate(dayTime.getDate() - i + 1);
- recentDate.push(dayTime.format("MM-dd"));
- }
- return recentDate
- }
- //导出并在Main.js中全局注册
- export default {
- noMultipleClicks, //禁止多次点击
- getCapsuleSite, //获取胶囊位置信息
- getTimeStamp, //处理更新时间
- getRecentDateArray //获取近几天时间数组
- }
|