const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
let config = require("../../../config/config.js");
let Http = require("../../../utils/HttpBasics");
const util = require("../../../utils/util");
let app = getApp();
const imgurl = require("../../../utils/imgurl");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navigationBarHeight,
    detail: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const detail = JSON.parse(options.item)
    console.log(detail, 'detail');
    // detail.payTime = this.timestampToTime(detail.payTime, 'YYYY-MM-DD hh:mm:ss')
    // detail.createTime = this.timestampToTime(detail.createTime, 'YYYY-MM-DD hh:mm:ss')
    // detail.updateTime = this.timestampToTime(detail.updateTime, 'YYYY-MM-DD hh:mm:ss')
    this.setData({
      detail: detail
    })
  },

  /**
    * @description 根据时间戳获取时间
    * @param {*} timestamp 必传，number类型，时间戳数据（10位及以下，10位至13位）
    * @param {*} format  选传，string类型，提供以下时间格式：YYYY-MM-DD hh:mm:ss、YYYY/MM/DD hh:mm:ss、YYYY.MM.DD hh:mm:ss、YYYY MM DD hh:mm:ss、YYYY年MM月DD日 hh:mm:ss、YYYY-MM-DD、YYYY/MM/DD、YYYY.MM.DD、YYYY MM DD、YYYY年MM月DD日；若不传，则默认为：YYYY-MM-DD
    * @returns 根据要求的时间格式
    * @version V 1.0, Created by YWQ, 2022.10.20
    */
  timestampToTime(timestamp, format) {
    //时间戳为10位需*1000，时间戳为13位不需乘1000
    const length = timestamp.length
    if (length <= 10) {
      var date = new Date(timestamp * 1000)
    } else {
      var date = new Date(timestamp)
    }
    let Y = String(date.getFullYear())
    let M = String(date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
    let D = String(date.getDate() + 1 < 10 ? '0' + (date.getDate()) : date.getDate())
    let h = String(date.getHours() + 1 < 10 ? '0' + (date.getHours()) : date.getHours())
    let m = String(date.getMinutes() + 1 < 10 ? '0' + (date.getMinutes()) : date.getMinutes())
    let s = String(date.getSeconds() + 1 < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
    // return Y + M + D + h + m + s
    if (format == "YYYY-MM-DD hh:mm:ss") {
      return Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s
    } else if (format == "YYYY/MM/DD hh:mm:ss") {
      return Y + "/" + M + "/" + D + " " + h + ":" + m + ":" + s
    } else if (format == "YYYY.MM.DD hh:mm:ss") {
      return Y + "." + M + "." + D + " " + h + ":" + m + ":" + s
    } else if (format == "YYYY MM DD hh:mm:ss") {
      return Y + " " + M + " " + D + " " + h + ":" + m + ":" + s
    } else if (format == "YYYY年MM月DD日 hh:mm:ss") {
      return Y + "年" + M + "月" + D + "日" + " " + h + ":" + m + ":" + s
    } else if (format == "YYYY-MM-DD") {
      return Y + "-" + M + "-" + D
    } else if (format == "YYYY/MM/DD") {
      return Y + "/" + M + "/" + D
    } else if (format == "YYYY.MM.DD") {
      return Y + "." + M + "." + D
    } else if (format == "YYYY MM DD") {
      return Y + " " + M + " " + D
    } else if (format == "YYYY年MM月DD日") {
      return Y + "年" + M + "月" + D + "日"
    } else {
      return Y + "-" + M + "-" + D
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})