import Vue from 'vue'
import App from './App'
import './uni.promisify.adaptor'

import {
    http
} from "./components/js_sdk/index";

import alarModel from "./components/component/alarModel.vue";
import tenMinutes from './components/component/tenMinutes.vue';

Vue.component('alarModel', alarModel);
Vue.component('tenMinutes', tenMinutes);

Vue.prototype.$http = http;

// 挂载处理时间的方法
function timestampToTime(value, type = 0) {
    var time = new Date(value);
    var year = time.getFullYear();
    var month = time.getMonth() + 1;
    var date = time.getDate();
    var hour = time.getHours();
    var minute = time.getMinutes();
    var second = time.getSeconds();

    // 补零
    month = month < 10 ? "0" + month : month;
    date = date < 10 ? "0" + date : date;
    hour = hour < 10 ? "0" + hour : hour;
    minute = minute < 10 ? "0" + minute : minute;
    second = second < 10 ? "0" + second : second;

    var arr = [
        year + "-" + month + "-" + date,
        year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second,
        year + "年" + month + "月" + date + "日",
        year + "年" + month + "月" + date + " " + hour + ":" + minute + ":" + second,
        hour + ":" + minute + ":" + second,
        year + "-" + month + "-" + date + " " + hour + ":" + minute,
        month + "月" + date + "日" + hour + ":" + minute,
    ]
    return arr[type];
}

Vue.prototype.$time = timestampToTime;


Vue.config.productionTip = false;
if (__wxConfig.envVersion == 'develop') {
    Vue.prototype.uploadimg = 'https://api.radar-power.asia:4443';

}
if (__wxConfig.envVersion == 'trial') {
    Vue.prototype.upload = 'https://api.radar-power.asia:4443';
}
if (__wxConfig.envVersion == 'release') {
    Vue.prototype.uploadimg = 'https://api.radar-power.asia:4443';
}
App.mpType = "app";

const app = new Vue({
    ...App,
});
app.$mount();
