const uploadFileType = ['jpg', 'png', 'doc', 'docx', 'xls', 'xlsx', 'pdf'] const docType = ['doc', 'docx', 'xls', 'xlsx', 'pdf'] const FILE_UPLOAD_ADDRESS = '/file_server/uploadFile' const FILE_DELETE_ADDRESS = '/file_server/deleteFile' const FILE_STREAM_PREVIEW_ADDRESS = '/file_server/fileStreamPreview' Vue.component('m-page-loading', httpVueLoader('/components/mobile/common/MLoading.vue')) Vue.component('m-table-loading', httpVueLoader('/components/mobile/common/MTableLoading.vue')) Vue.component('m-card', httpVueLoader('/components/mobile/common/MCard.vue')) Vue.component('vant-file-upload', httpVueLoader('/components/plugins/VantFileUpload.vue')) const GetQueryString = (name) => { const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); const r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return ""; } const removeHTMLTag = (str) => { str = str.replace(/<\/?[^>]*>/g, ''); //去除HTML tag str = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白 str = str.replace(/\n[\s| | ]*\r/g, '\n'); //去除多余空行 str = str.replace(/ /ig, '');//去掉  return str; } const CREATE_PREVIEW_URL = (val) => { return FILE_STREAM_PREVIEW_ADDRESS + "?id=" + val } const clone = (val) => { return JSON.parse(JSON.stringify(val)) } const toChinesNum = (num) => { let changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; let unit = ["", "十", "百", "千", "万"]; num = parseInt(num); let getWan = (temp) => { let strArr = temp.toString().split("").reverse(); let newNum = ""; for (let i = 0; i < strArr.length; i++) { newNum = (i == 0 && strArr[i] == 0 ? "" : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? "" : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum; } return newNum; } let overWan = Math.floor(num / 10000); let noWan = num % 10000; if (noWan.toString().length < 4) { noWan = "0" + noWan; } return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num); } const loc = () => { return location.href.replace(location.search, "").replace(location.hash, "") } const modal = { // 消息提示 msg(content) { vant.Toast(content) }, // 错误消息 msgError(content) { vant.Toast.fail(content) }, // 成功消息 msgSuccess(content) { vant.Toast.success(content) }, // 弹出提示 alert(content) { vant.Dialog.alert({ title: '提示', message: content }).then(() => { // on close }); }, // 确认窗体 confirm(content) { return new Promise((resolve, reject) => { vant.Dialog.confirm({ title: '提示', message: content, }).then(() => { resolve() }).catch(() => { // reject() }) }) }, // 提示信息 showToast(option) { if (typeof option === "object") { vant.Toast(option) } else { vant.Toast.loading({ message: option, forbidClick: true, loadingType: 'spinner', duration: 2500 }); } }, // 打开遮罩层 loading(content) { vant.Toast.loading({ message: content, forbidClick: true, overlay: true, duration: 0 }); }, // 关闭遮罩层 closeLoading() { vant.Toast.clear(); } } Vue.prototype.$modal = modal