diff --git a/main.js b/main.js index e1247ca..150c6a3 100644 --- a/main.js +++ b/main.js @@ -26,192 +26,377 @@ 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 { createSSRApp } from 'vue' +export function createApp () { + const app = createSSRApp(App) + app.config.productionTip = false; -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-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.prototype.api = apiInfo; -Vue.prototype.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.是发单号 - - resolve(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) - }) - }) - }, + app.component('g-empty', gEmpty); + 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); - /* 上传图片 - */ - 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; + 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.是发单号 - 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) { }, - }); - }, - /* 上传媒体文件 - */ - uploadMedia (callback = () => { }, type = 'default', $num = 9) { - G.uploadM($num, (imgRes) => { - uni.showLoading({ - title: '上传中...', + resolve(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.是发单号 - console.log('imgRes', imgRes) + resolve(res) + }) + }) + }, - let args = Array.from(JSON.parse(imgRes)); - console.log('args', args) - // return - let imgList = [] - args.forEach((item, index) => { - console.log('item,', item) + /* 上传图片 + */ + 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: item.tempFilePath, + filePath: JSON.parse(imgRes)[0], 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) { + 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: '上传成功', - imgList: imgList + image: imageStr }); } - - }, - fail: function (res) { - console.log('res', res) }, + 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) { }, + }); + }, + /* 上传媒体文件 + */ + 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) + }, + }); + }) + }); + } + }); + app.use(uView) + return { + app } -}); -console.log('main.js 公共方法:', Object.assign(G, Ajax), ' 当前设备信息:', uni.getSystemInfoSync(), ' API:', apiInfo); + +} + + + +/** +* Vue2 +*/ +// 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-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.prototype.api = apiInfo; +// Vue.prototype.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.是发单号 + +// resolve(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) { }, +// }); +// }, +// /* 上传媒体文件 +// */ +// 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.use(uView) +// const app = new Vue({ +// ...App +// }) +// app.$mount() -App.mpType = 'app' -Vue.use(uView) -const app = new Vue({ - ...App -}) -app.$mount() diff --git a/manifest.json b/manifest.json index cb6dea2..e61638a 100644 --- a/manifest.json +++ b/manifest.json @@ -127,5 +127,5 @@ "uniStatistics" : { "enable" : false }, - "vueVersion" : "2" + "vueVersion" : "3" } diff --git a/pages/person/index.vue b/pages/person/index.vue index 0979bf2..2bc1888 100644 --- a/pages/person/index.vue +++ b/pages/person/index.vue @@ -13,7 +13,7 @@ /> - + 我的发单账号 diff --git a/root/detail/job.vue b/root/detail/job.vue index ca4e4fa..152ba41 100644 --- a/root/detail/job.vue +++ b/root/detail/job.vue @@ -1,282 +1,295 @@