收藏
回答

IOS日期展示为什么在预览情况下显示不正常?真机调试正常却正常


回答关注问题邀请回答
收藏

3 个回答

  • 是小白啊
    是小白啊
    2019-10-24

    检查下格式,真机调试时候使用的电脑端的时间格式

    2019-10-24
    有用
    回复
  • 原点
    原点
    2019-10-24

    怎么个不正常

    2019-10-24
    有用
    回复 1
    • 清欢
      清欢
      2019-10-24
      wxml渲染异常
      2019-10-24
      回复
  • 清欢
    清欢
    2019-10-24

    var util = require('../../utils/util.js');

    Component ({

    options: {

    addGlobalClass: true

    },

    properties: {

    obj:{

    type:Object,

    value:{}

    }

    },

    data: {

    hasEmptyGrid: false

    },

    ready(options) {

    let year = this.data.obj.project_signs[0].year

    let month = this.data.obj.project_signs[0].month

    let day = this.data.obj.project_signs[0].day


    const cur_year = new Date( year + '/' + month ).getFullYear();

    const cur_month = new Date( year + '/' + month ).getMonth() + 1;

    const weeks_ch = ['日', '一', '二', '三', '四', '五', '六'];

    this.calculateEmptyGrids(cur_year, cur_month);

    this.calculateDays(cur_year, cur_month);


    this.setData({

    cur_year,

    cur_month,

    sign_in_count: new Date(this.data.obj.sign_in_count).getDate(),

    sign_out_count: new Date(this.data.obj.sign_out_count).getDate(),

    no_work_count: new Date(this.data.obj.no_work_count).getDate()

    })

    },

    methods: {

    getThisMonthDays(year, month) {

    return new Date(year, month, 0).getDate();

    },

    getFirstDayOfWeek(year, month) {

    return new Date(Date.UTC(year, month - 1, 1)).getDay();

    },

    calculateEmptyGrids(year, month) {

    const firstDayOfWeek = this.getFirstDayOfWeek(year, month);

    let empytGrids = [];

    if (firstDayOfWeek > 0) {

    for (let i = 0; i < firstDayOfWeek; i++) {

    empytGrids.push(i);

    }

    this.setData({

    hasEmptyGrid: true,

    empytGrids

    });

    } else {

    this.setData({

    hasEmptyGrid: false,

    empytGrids: []

    });

    }

    },

    calculateDays(year, month) {

    let days = [];


    const thisMonthDays = this.getThisMonthDays(year, month);


    for (let i = 1; i <= thisMonthDays; i++) {

    days.push(i);

    }


    this.setData({

    days

    });

    },

    handleCalendar(e) {

    const handle = e.currentTarget.dataset.handle;

    const cur_year = this.data.cur_year;

    const cur_month = this.data.cur_month;

    if (handle === 'prev') {

    let newMonth = cur_month - 1;

    let newYear = cur_year;

    if (newMonth < 1) {

    newYear = cur_year - 1;

    newMonth = 12;

    }


    this.calculateDays(newYear, newMonth);

    this.calculateEmptyGrids(newYear, newMonth);


    this.setData({

    cur_year: newYear,

    cur_month: newMonth

    })


    } else {

    let newMonth = cur_month + 1;

    let newYear = cur_year;

    if (newMonth > 12) {

    newYear = cur_year + 1;

    newMonth = 1;

    }


    this.calculateDays(newYear, newMonth);

    this.calculateEmptyGrids(newYear, newMonth);


    this.setData({

    cur_year: newYear,

    cur_month: newMonth

    })

    }

    },

    onShareAppMessage() {

    return {

    title: '工程日志',

    desc: '分享查看',

    path: 'pages/home/projectlog/main'

    }

    }

    }

    })




    2019-10-24
    有用
    回复
登录 后发表内容
问题标签