'use strict';

(function(e) {
  Object.defineProperty(l, '__esModule', { value: !0 }),
  l.default = void 0;
  var a = function(l) {
    e.navigateTo({ url: l })
  },
  t = function(l) {
    e.switchTab({ url: l })
  },
  u = function(l) {
    var a = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1500,
    t = arguments.length > 2 && void 0 !== arguments[2] && arguments[2],
    u = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 'none';
    !1 !== Boolean(l) && e.showToast({ title: l, duration: a, mask: t, icon: u })
  },
  n = function(l) {
    var a = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1500,
    t = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1;
    l && (u(l), setTimeout((function() {
      e.navigateBack({ delta: t })
    }), a))
  },
  v = function() {
    for (var e = new Date, l = e.getFullYear().toString() + (e.getMonth() + 1).toString() + e.getDate().toString() + e.getHours().toString() + e.getMinutes().toString() + e.getSeconds().toString() + e.getMilliseconds().toString(), a = 0; a < 5; a++)
      l += Math.floor(10 * Math.random());
    return l
  },
  r = function() {
    var e = new Date,
    l = e.getFullYear(),
    a = e.getMonth() + 1 < 10 ? '0' + (e.getMonth() + 1) : e.getMonth() + 1,
    t = e.getDate() < 10 ? '0' + e.getDate() : e.getDate(),
    u = e.getHours(),
    n = e.getMinutes(),
    v = e.getSeconds();
    return l + '-' + a + '-' + t + ' ' + u + ':' + n + ':' + v
  },
  o = function() {
    var e = new Date,
    l = e.getFullYear(),
    a = e.getMonth() + 1 < 10 ? '0' + (e.getMonth() + 1) : e.getMonth() + 1,
    t = e.getDate() < 10 ? '0' + e.getDate() : e.getDate();
    return l + '-' + a + '-' + t
  },
  b = {
    jump: a,
    msg: u,
    msgBack: n,
    tab: t,
    genTradeNo: v,
    getCurDateTime: r,
    getCurDate: o
  };
  l.default = b
}).call(this, a('543d')['default']);

该代码库包含了一系列方便的小程序开发工具函数,用于实现页面跳转、消息提示、时间获取、生成订单号等功能,提高小程序开发效率。

主要功能:

  • jump(url): 跳转到指定页面
  • msg(title, duration, mask, icon): 显示提示框,参数分别为标题、持续时间、是否显示遮罩、图标
  • msgBack(title, duration, delta): 显示提示框并返回上一页,参数分别为标题、持续时间、返回层级
  • tab(url): 跳转到指定 tabBar 页面
  • genTradeNo(): 生成一个随机订单号
  • getCurDateTime(): 获取当前时间,格式为 YYYY-MM-DD HH:mm:ss
  • getCurDate(): 获取当前日期,格式为 YYYY-MM-DD

使用示例:

import tools from './utils/tools.js';

tools.jump('/pages/index/index');
tools.msg('操作成功');
tools.msgBack('操作失败', 2000, 2);
tools.tab('/pages/home/home');
let tradeNo = tools.genTradeNo();
let curDateTime = tools.getCurDateTime();
let curDate = tools.getCurDate();
小程序工具库:便捷的页面跳转、消息提示、时间获取等功能