Files
hiddendangerDingtalk/main.js
T
2025-03-28 09:16:48 +08:00

107 lines
2.2 KiB
JavaScript

import App from './App'
import Inputli from './components/form/input-li.vue';
import Selectli from './components/form/select-li.vue';
import Dateli from './components/form/date-li.vue';
import { getToken } from './api/create.js'
import { formatDate, calculator } from './com/index.js'
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
Vue.prototype.a = '1234456'
const msg = (title,icon = 'none', duration = 1500, mask = false, ) => {
//统一提示方便全局修改
if (Boolean(title) === false) {
return;
}
uni.showToast({
title,
duration,
mask,
icon
});
}
const setNavigationBar = ( title = '教育平台', backgroundColor = '#ffffff') =>{
my.setNavigationBar({
title,
backgroundColor
});
}
const navTo = (url, skip = 'navigateTo') =>{
uni[skip]({
url
});
}
const login = () =>{
return new Promise((reslove,reject)=>{
uni.getAuthCode({
success:(user)=>{
console.log(user)
getToken(user.authCode).then((res)=>{
if(res){
reslove(res.data)
console.log(res.data)
}
}).catch(err =>{
reject(err)
})
},
})
})
}
// 提示框 点击确定进入resolve 取消进入reject
const showModel = (content) =>{
return new Promise((resolve, reject)=>{
uni.showModal({
title: '提示',
content: content,
cancelText: '取消',
confirmText: '确定',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
resolve('affirm')
} else if (res.cancel) {
console.log('用户点击取消');
reject('cancal')
}
}
});
})
}
Vue.prototype.$navTo = navTo // 页面跳转
Vue.prototype.$msg = msg
Vue.prototype.$setNavigationBar = setNavigationBar
Vue.prototype.$login = login
Vue.prototype.$calculator = calculator // 计算数
Vue.prototype.$formatDate = formatDate // 日期格式修改
Vue.prototype.$showModel = showModel // 提示框
Vue.component("Inputli",Inputli)
Vue.component("Selectli",Selectli)
Vue.component("Dateli",Dateli)
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif