You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
apply-assistant-v3/main.js

354 lines
12 KiB
JavaScript

6 months ago
import App from './App'
import Vue from 'vue'
import './uni.promisify.adaptor'
import uView from './uni_modules/vk-uview-ui';
import G from './utils/common.js';
import Ajax from './utils/ajax.js';
5 months ago
import wyyx from './utils/wyyx.js';
6 months ago
import apiInfo from './api/index.js';
import gEmpty from './components/empty.vue';
3 months ago
import gTabbar from './components/customTabbar.vue';
6 months ago
import gLoading from './components/loading.vue';
import gButton from './components/button.vue';
import gListJob from './components/list/job.vue';
import gListApply from './components/list/apply.vue';
import gPanelServer from './components/panel/server.vue';
import gPanelImage from './components/panel/defaultImage.vue';
import gPanelFormItem from './components/panel/formItem.vue';
import gPanelFormSlot from './components/panel/formSlot.vue';
import gPanelCardNum from './components/panel/numCard.vue';
import gPanelCardInfo from './components/panel/infoCard.vue';
import gPanelHr from './components/panel/hr.vue';
import gPanelFond from './components/panel/fond.vue';
import gPanelAbout from './components/panel/about.vue';
import gPanelDetailItem from './components/panel/detailItem.vue';
import gPanelRecord from './components/panel/record.vue';
import gPanelTime from './components/panel/time.vue';
import gPanelTabbar from './components/panel/tabbar.vue';
import gPanelFixed from './components/panel/fixed.vue';
5 months ago
import gFilter from './pages/home/child/filter.vue';
6 months ago
import { createSSRApp } from 'vue'
export function createApp () {
const app = createSSRApp(App)
app.config.productionTip = false;
6 months ago
6 months ago
app.component('g-empty', gEmpty);
2 months ago
app.component('g-tabbar', gTabbar);
6 months ago
app.component('g-loading', gLoading);
app.component('g-button', gButton);
app.component('g-list-job', gListJob);
app.component('g-list-apply', gListApply);
app.component('g-panel-server', gPanelServer);
app.component('g-panel-image', gPanelImage);
app.component('g-panel-form-item', gPanelFormItem);
app.component('g-panel-form-slot', gPanelFormSlot);
app.component('g-panel-card-num', gPanelCardNum);
app.component('g-panel-card-info', gPanelCardInfo);
app.component('g-panel-hr', gPanelHr);
app.component('g-panel-fond', gPanelFond);
app.component('g-panel-about', gPanelAbout);
app.component('g-panel-detail-item', gPanelDetailItem);
app.component('g-panel-record', gPanelRecord);
app.component('g-panel-time', gPanelTime);
app.component('g-panel-tabbar', gPanelTabbar);
app.component('g-panel-fixed', gPanelFixed);
5 months ago
app.component('g-filter', gFilter);
6 months ago
6 months ago
app.config.globalProperties.api = apiInfo;
app.config.globalProperties.G = Object.assign(G, Ajax, {
/*
* 检查token,获取最新登录者信息
*/
checkToken () {
return new Promise((resolve, reject) => {
G.Get('/checkToken', '', (res) => {
uni.setStorageSync("apply-userinfo", res)
uni.setStorageSync('apply-userinfo-copy', JSON.stringify(res));
uni.setStorageSync("apply-agencyId", res.user.agencyId); // 单独存储 -- 代理id方便获取
uni.setStorageSync("apply-supplierAccount", res.supplierAccount); // 单独存储 -- 是否是发单号,方便获取 0.不是发单号 1.是发单号
3 months ago
if (res.agencyId) {
4 months ago
G.Get(apiInfo.login_agencyInfo, {}, (aRes) => {
uni.setStorageSync("agencyInfo", aRes.agency); // 1是创建者 2是普通成员
uni.setStorageSync("IS_CREATOR", aRes.agency.userId == res.user.id || res.admin == true ? 1 : 2); // 1是创建者 2是普通成员
// 登录跳转到首页的判断
uni.setStorageSync("SHOW_INVITE", 1);
resolve(res)
});
} else {
resolve(res)
4 months ago
}
6 months ago
6 months ago
},
function fail (err) {
console.log(err);
resolve(err)
2 months ago
}
)
6 months ago
})
6 months ago
},
/*
* 新的检查token,获取最新登录者信息
*/
checkTokenNew () {
return new Promise((resolve, reject) => {
G.Get('/appLoginByToken', '', (res) => {
uni.setStorageSync("apply-userinfo", res)
uni.setStorageSync('apply-userinfo-copy', JSON.stringify(res));
uni.setStorageSync("apply-agencyId", res.user.agencyId); // 单独存储 -- 代理id方便获取
uni.setStorageSync("apply-supplierAccount", res.supplierAccount); // 单独存储 -- 是否是发单号,方便获取 0.不是发单号 1.是发单号
3 months ago
if (res.agencyId) {
2 months ago
// if (res.agencyStatus == 1) {
4 months ago
G.Get(apiInfo.login_agencyInfo, {}, (aRes) => {
uni.setStorageSync("agencyInfo", aRes.agency); // 1是创建者 2是普通成员
uni.setStorageSync("IS_CREATOR", aRes.agency.userId == res.user.id || res.admin == true ? 1 : 2); // 1是创建者 2是普通成员
// 登录跳转到首页的判断
uni.setStorageSync("SHOW_INVITE", 1);
resolve(res)
});
} else {
resolve(res)
4 months ago
}
6 months ago
})
})
},
6 months ago
6 months ago
/*
*/
uploadImg (callback = () => { }, type = 'default', $num = 1, $sourceType = ['album', 'camera']) {
G.uploadImage($num, (imgRes) => {
uni.showLoading({
title: '上传中...',
})
6 months ago
uni.uploadFile({
url: G.ajaxUrl + apiInfo.uploadImage,
method: "post",
6 months ago
filePath: JSON.parse(imgRes)[0],
6 months ago
name: "uploadFile",
header: Object.assign({
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
}, Ajax.setPublicParams()),
formData: Ajax.setPublicParams(),
success: function (res) {
6 months ago
let imageStr = ''
imageStr = JSON.parse(res.data).data;
if (type == 'idcard') {
// 调用身份证识别
uni.uploadFile({
url: G.ajaxUrl + apiInfo.getIDcard,
filePath: JSON.parse(imgRes)[0],
name: 'uploadFile',
header: Object.assign({
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
}, Ajax.setPublicParams()),
formData: Ajax.setPublicParams(),
success: (uploadFileRes) => {
let cardData = {
status: '上传成功',
image: imageStr,
info: JSON.parse(uploadFileRes.data).data
}
uni.hideLoading()
callback(cardData);
}
});
} else {
uni.hideLoading()
6 months ago
callback({
status: '上传成功',
6 months ago
image: imageStr
6 months ago
});
}
},
6 months ago
fail: function (res) { },
6 months ago
});
6 months ago
}, $sourceType);
},
3 months ago
5 months ago
/*
*/
uploadImgByCamera (callback = () => { }, type = 'default', $num = 1, $sourceType = ['camera']) {
5 months ago
var that = this;
5 months ago
G.uploadImage($num, (imgRes) => {
uni.showLoading({
title: '上传中...',
})
if (type == 'idcard') {
that.recognizeTmpIDcard(imgRes, (cardData) => {
callback(cardData);
})
} else {
uni.uploadFile({
url: G.ajaxUrl + apiInfo.uploadImage,
method: "post",
filePath: JSON.parse(imgRes)[0],
name: "uploadFile",
header: Object.assign({
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
}, Ajax.setPublicParams()),
formData: Ajax.setPublicParams(),
success: function (res) {
let imageStr = ''
imageStr = JSON.parse(res.data).data;
uni.hideLoading()
callback({
status: '上传成功',
image: imageStr
});
},
fail: function (res) { },
});
4 months ago
}
5 months ago
}, $sourceType);
},
/*
*/
uploadImgByAlbum (callback = () => { }, type = 'default', $num = 1, $sourceType = ['album']) {
var that = this;
G.uploadImage($num, (imgRes) => {
uni.showLoading({
title: '上传中...',
})
if (type == 'idcard') {
that.recognizeTmpIDcard(imgRes, (cardData) => {
callback(cardData);
})
} else {
uni.uploadFile({
url: G.ajaxUrl + apiInfo.uploadImage,
method: "post",
filePath: JSON.parse(imgRes)[0],
name: "uploadFile",
header: Object.assign({
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
}, Ajax.setPublicParams()),
formData: Ajax.setPublicParams(),
success: function (res) {
let imageStr = ''
imageStr = JSON.parse(res.data).data;
uni.hideLoading()
callback({
status: '上传成功',
image: imageStr
});
},
fail: function (res) { },
});
}
}, $sourceType);
},
6 months ago
/**
* 上传临时文件(不需要选择图库)
*/
uploadTmpImg ($fileName, callback = () => { }) {
uni.uploadFile({
url: G.ajaxUrl + apiInfo.uploadImage,
method: "post",
filePath: $fileName,
name: "uploadFile",
header: Object.assign({
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
}, Ajax.setPublicParams()),
formData: Ajax.setPublicParams(),
success: function (res) {
let imageStr = ''
imageStr = JSON.parse(res.data).data;
callback({
status: '上传成功',
image: imageStr
});
},
fail: function (res) { },
});
},
5 months ago
/**
* 识别临时身份证文件
*/
recognizeTmpIDcard ($fileName, callback = () => { }) {
uni.uploadFile({
url: G.ajaxUrl + apiInfo.uploadImage,
method: "post",
filePath: Array.isArray($fileName) ? $fileName[0] : JSON.parse($fileName)[0],
name: "uploadFile",
header: Object.assign({
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
}, Ajax.setPublicParams()),
formData: Ajax.setPublicParams(),
success: function (res) {
let imageStr = ''
imageStr = JSON.parse(res.data).data;
uni.uploadFile({
url: G.ajaxUrl + apiInfo.getIDcard,
filePath: Array.isArray($fileName) ? $fileName[0] : JSON.parse($fileName)[0],
name: 'uploadFile',
header: Object.assign({
5 months ago
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
5 months ago
}, Ajax.setPublicParams()),
formData: Ajax.setPublicParams(),
success: (uploadFileRes) => {
let cardData = {
status: '上传成功',
image: imageStr,
5 months ago
info: JSON.parse(uploadFileRes.data).data
5 months ago
}
uni.hideLoading()
callback(cardData);
}
});
},
fail: function (res) { },
});
},
6 months ago
/*
*/
uploadMedia (callback = () => { }, type = 'default', $num = 9) {
G.uploadM($num, (imgRes) => {
uni.showLoading({
title: '上传中...',
})
let args = Array.from(JSON.parse(imgRes));
let imgList = []
args.forEach((item, index) => {
uni.uploadFile({
url: G.ajaxUrl + apiInfo.uploadImage,
method: "post",
filePath: item.tempFilePath,
name: "uploadFile",
header: Object.assign({
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
}, Ajax.setPublicParams()),
formData: Ajax.setPublicParams(),
success: function (res) {
imgList.push(JSON.parse(res.data).data)
if (imgList.length == args.length) {
callback({
status: '上传成功',
imgList: imgList
});
}
},
fail: function (res) {
console.log('res', res)
},
});
})
});
}
});
4 months ago
app.config.globalProperties.F = wyyx;
6 months ago
app.use(uView)
return {
app
6 months ago
}
6 months ago
}
6 months ago