|
|
|
|
|
import App from './App'
|
|
|
|
|
|
import Vue from 'vue'
|
|
|
|
|
|
import './uni.promisify.adaptor'
|
|
|
|
|
|
import uView from "uview-ui";
|
|
|
|
|
|
import G from './utils/common.js';
|
|
|
|
|
|
import Ajax from './utils/ajax.js';
|
|
|
|
|
|
import apiInfo from './api/index.js';
|
|
|
|
|
|
|
|
|
|
|
|
import gEmpty from './components/empty.vue';
|
|
|
|
|
|
import gLoading from './components/loading.vue';
|
|
|
|
|
|
import gButton from './components/button.vue';
|
|
|
|
|
|
import gListJob from './components/list/job.vue';
|
|
|
|
|
|
import gListBill from './components/list/bill.vue';
|
|
|
|
|
|
import gListYiJob from './components/list/yiJob.vue';
|
|
|
|
|
|
import gListApply from './components/list/apply.vue';
|
|
|
|
|
|
import gPanelServer from './components/panel/server.vue';
|
|
|
|
|
|
import gPanelImage from './components/panel/image.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';
|
|
|
|
|
|
import gChatJob from './components/chatEvent/job.vue';
|
|
|
|
|
|
import gChatMessage from './components/chatEvent/message.vue';
|
|
|
|
|
|
import gChatRich from './components/chatEvent/rich.vue';
|
|
|
|
|
|
|
|
|
|
|
|
Vue.config.productionTip = false;
|
|
|
|
|
|
|
|
|
|
|
|
Vue.component('g-empty', gEmpty);
|
|
|
|
|
|
Vue.component('g-loading', gLoading);
|
|
|
|
|
|
Vue.component('g-button', gButton);
|
|
|
|
|
|
Vue.component('g-list-job', gListJob);
|
|
|
|
|
|
Vue.component('g-list-bill', gListBill);
|
|
|
|
|
|
Vue.component('g-yi-list-job', gListYiJob);
|
|
|
|
|
|
Vue.component('g-list-apply', gListApply);
|
|
|
|
|
|
Vue.component('g-panel-server', gPanelServer);
|
|
|
|
|
|
Vue.component('g-panel-image', gPanelImage);
|
|
|
|
|
|
Vue.component('g-panel-form-item', gPanelFormItem);
|
|
|
|
|
|
Vue.component('g-panel-form-slot', gPanelFormSlot);
|
|
|
|
|
|
Vue.component('g-panel-card-num', gPanelCardNum);
|
|
|
|
|
|
Vue.component('g-panel-card-info', gPanelCardInfo);
|
|
|
|
|
|
Vue.component('g-panel-hr', gPanelHr);
|
|
|
|
|
|
Vue.component('g-panel-fond', gPanelFond);
|
|
|
|
|
|
Vue.component('g-panel-about', gPanelAbout);
|
|
|
|
|
|
Vue.component('g-panel-detail-item', gPanelDetailItem);
|
|
|
|
|
|
Vue.component('g-panel-record', gPanelRecord);
|
|
|
|
|
|
Vue.component('g-panel-time', gPanelTime);
|
|
|
|
|
|
Vue.component('g-panel-tabbar', gPanelTabbar);
|
|
|
|
|
|
Vue.component('g-panel-fixed', gPanelFixed);
|
|
|
|
|
|
Vue.component('g-chat-job', gChatJob);
|
|
|
|
|
|
Vue.component('g-chat-message', gChatMessage);
|
|
|
|
|
|
Vue.component('g-chat-rich', gChatRich);
|
|
|
|
|
|
|
|
|
|
|
|
Vue.prototype.api = apiInfo;
|
|
|
|
|
|
Vue.prototype.G = Object.assign(G, Ajax, {
|
|
|
|
|
|
/*
|
|
|
|
|
|
* 检查token,获取最新登录者信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
checkToken () {
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
G.Get('/checkToken', '', (res) => {
|
|
|
|
|
|
console.log('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.是发单号
|
|
|
|
|
|
|
|
|
|
|
|
resolve(res)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getAgencyInfo () {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
// if (uni.getStorageSync("apply-token")) {
|
|
|
|
|
|
G.Get("/yishoudan/agency/getInfo", {}, (res) => {
|
|
|
|
|
|
console.log('getAgencyInfo res', res);
|
|
|
|
|
|
uni.setStorageSync("miniApp-info", res.agency);
|
|
|
|
|
|
console.log('app', app.$forceUpdate);
|
|
|
|
|
|
app.$forceUpdate();
|
|
|
|
|
|
});
|
|
|
|
|
|
// }
|
|
|
|
|
|
},
|
|
|
|
|
|
getServiceQRCode () {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
G.Get("/yishoudan/agency/teamsman/customService", {}, (res) => {
|
|
|
|
|
|
// if (res) {
|
|
|
|
|
|
uni.setStorageSync("CUSTOMSERVICE_INFO", res);
|
|
|
|
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// let miniApp = uni.getStorageSync("miniApp-info")
|
|
|
|
|
|
// uni.setStorageSync("CUSTOMSERVICE_INFO", { tel: miniApp.contactTel, userName: miniApp.contactUserName, wechatQrcode: miniApp.contactWechatQrcode });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// console.log('getServiceQRCode res', res);
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/*
|
|
|
|
|
|
* 新的检查token,获取最新登录者信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
checkTokenNew () {
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
G.Get('/appLoginByToken', '', (res) => {
|
|
|
|
|
|
console.log('res', 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.是发单号
|
|
|
|
|
|
|
|
|
|
|
|
resolve(res)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/* 上传图片
|
|
|
|
|
|
*/
|
|
|
|
|
|
uploadImg (callback = () => { }, type = 'default', $num = 1, $sourceType = ['album', 'camera']) {
|
|
|
|
|
|
G.uploadImage($num, (imgRes) => {
|
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
|
title: '上传中...',
|
|
|
|
|
|
})
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
callback({
|
|
|
|
|
|
status: '上传成功',
|
|
|
|
|
|
image: imageStr
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: function (res) { },
|
|
|
|
|
|
});
|
|
|
|
|
|
}, $sourceType);
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 上传临时文件(不需要选择图库)
|
|
|
|
|
|
*/
|
|
|
|
|
|
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) { },
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 上传图片前需要裁剪的
|
|
|
|
|
|
*/
|
|
|
|
|
|
cropBeforeUpload (options) {
|
|
|
|
|
|
G.uploadImage(1, (res) => {
|
|
|
|
|
|
uni.cropImage({
|
|
|
|
|
|
src: JSON.parse(res)[0],
|
|
|
|
|
|
cropScale: options.cropScale,
|
|
|
|
|
|
success: (res) => {
|
|
|
|
|
|
G.uploadTmpImg(res.tempFilePath, (res) => {
|
|
|
|
|
|
options.success(res);
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
|
options.fail(err);
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/* 上传媒体文件
|
|
|
|
|
|
*/
|
|
|
|
|
|
uploadMedia (callback = () => { }, type = 'default', $num = 9) {
|
|
|
|
|
|
G.uploadM($num, (imgRes) => {
|
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
|
title: '上传中...',
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
console.log('imgRes', imgRes)
|
|
|
|
|
|
|
|
|
|
|
|
let args = Array.from(JSON.parse(imgRes));
|
|
|
|
|
|
console.log('args', args)
|
|
|
|
|
|
// return
|
|
|
|
|
|
let imgList = []
|
|
|
|
|
|
args.forEach((item, index) => {
|
|
|
|
|
|
console.log('item,', item)
|
|
|
|
|
|
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) {
|
|
|
|
|
|
console.log('uploadFileRes', res)
|
|
|
|
|
|
imgList.push(JSON.parse(res.data).data)
|
|
|
|
|
|
if (imgList.length == args.length) {
|
|
|
|
|
|
callback({
|
|
|
|
|
|
status: '上传成功',
|
|
|
|
|
|
imgList: imgList
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: function (res) {
|
|
|
|
|
|
console.log('res', res)
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
Vue.prototype.G.getAgencyInfo()
|
|
|
|
|
|
console.log('main.js 公共方法:', Object.assign(G, Ajax), ' 当前设备信息:', uni.getSystemInfoSync(), ' API:', apiInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
App.mpType = 'app'
|
|
|
|
|
|
|
|
|
|
|
|
Vue.use(uView)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const app = new Vue({
|
|
|
|
|
|
...App
|
|
|
|
|
|
})
|
|
|
|
|
|
app.$mount()
|