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, getUser } 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 = () => { // uni.showLoading({ // mask: true, // title: '登录中...' // }) return new Promise((reslove, reject) => { uni.getAuthCode({ success: (user) => { getToken(user.authCode).then((res) => { if (res.errcode == 0) { uni.setStorageSync('token', res.result.token) getUser().then(data => { console.log(data) uni.setStorageSync('user', data) uni.hideLoading() // uni.showToast({ // title: '登录成功', // icon: 'success' // }) }) reslove(res) } }).catch(err => { uni.showToast({ title: '登录失败,服务器出错了', icon: 'error' }) }) }, }) }) } // 提示框 点击确定进入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