微信小程序跳6

//金额格式化

    rmoney: function(money) {

        return parseFloat(money).toFixed(2).toString().split('').reverse().join('').replace(/(\d{3})/g, '$1,')

            .replace(

                /\,$/, '').split('').reverse().join('');

    },

    daysUntil: function(milliseconds) {

        const endDate = new Date(milliseconds);

        let currentDate = new Date();

        currentDate.setHours(0, 0, 0, 0);

        const difference = endDate - currentDate;

        const days = difference / (1000 * 60 * 60 * 24);

        return Math.floor(days);

    },

    yearsUntil: function(milliseconds) {

        const endDate = new Date(milliseconds);

        let currentDate = new Date();

        currentDate.setHours(0, 0, 0, 0);

        const difference = endDate - currentDate;

        const years = difference / (1000 * 60 * 60 * 24 * 365);

        return years.toFixed(2);

    },

    monthsUntil: function(milliseconds) {

        const endDate = new Date(milliseconds);

        let currentDate = new Date();

        currentDate.setHours(0, 0, 0, 0);

        const difference = endDate - currentDate;

        const months = difference / (1000 * 60 * 60 * 24 * 30);

        return months.toFixed(1);

    },


工具类,金额格式化

你可能感兴趣的:(微信小程序,微信小程序)