common.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // 获取当前时间 yyyy-mm-dd
  2. const getNowDate = function () {
  3. // 获取当前日期
  4. const date = new Date(); // 获取当前月份
  5. let nowMonth = date.getMonth() + 1; // 获取当前是几号
  6. let strDate = date.getDate(); // 添加分隔符“-”
  7. const seperator = '-'; // 对月份进行处理,1-9月在前面添加一个“0”
  8. if (nowMonth >= 1 && nowMonth <= 9) {
  9. nowMonth = `0${nowMonth}`;
  10. } // 对月份进行处理,1-9号在前面添加一个“0”
  11. if (strDate >= 0 && strDate <= 9) {
  12. strDate = `0${strDate}`;
  13. } // 最后拼接字符串,得到一个格式为(yyyy-MM-dd)的日期
  14. return date.getFullYear() + seperator + nowMonth + seperator + strDate;
  15. };
  16. const CREATE_CARD_TYPE = {
  17. CREATE: 0,
  18. BIND: 1,
  19. EDIT: 2,
  20. CARD_TYPE_TITLE: {
  21. 0: '创建就诊卡',
  22. 1: '绑定就诊卡',
  23. 2: '修改就诊卡'
  24. }
  25. };
  26. const getCurrentPage = () => {
  27. const pages = getCurrentPages(); // eslint-disable-next-line no-proto
  28. return `/${pages[pages.length - 1].__proto__.route}`;
  29. };
  30. export { getNowDate, CREATE_CARD_TYPE, getCurrentPage };