From 26490dec59bbd06d61468b5e87cd1a9c1e8ba440 Mon Sep 17 00:00:00 2001 From: yunkexin <760754045@qq.com> Date: Wed, 31 Jul 2024 09:59:56 +0800 Subject: [PATCH] 1 --- pages.json | 2 +- pages/apply/index.vue | 8 +- pages/apply/subPages/riskReport.vue | 533 ++++++++++++++++++++++++++++ pages/index/index.vue | 55 ++- services/apply.js | 4 +- utils/request.js | 254 +++++++------ 6 files changed, 736 insertions(+), 120 deletions(-) create mode 100644 pages/apply/subPages/riskReport.vue diff --git a/pages.json b/pages.json index f910334..70db082 100644 --- a/pages.json +++ b/pages.json @@ -56,7 +56,7 @@ "globalStyle": { "navigationBarTextStyle": "black", "navigationBarTitleText": "uni-app", - "navigationBarBackgroundColor": "#f6faff", + "navigationBarBackgroundColor": "#fff", //f6faff "backgroundColor": "#F8F8F8" }, "uniIdRouter": {} diff --git a/pages/apply/index.vue b/pages/apply/index.vue index 92f8622..4d03300 100644 --- a/pages/apply/index.vue +++ b/pages/apply/index.vue @@ -37,7 +37,8 @@ 重置 - 提交 + 提交 + 提交 @@ -66,6 +67,7 @@ showSex: false, formatter: null, pickerShow: false, + loading:false, pickerColumns: [Array(60).fill(null).map((_, i) => i)], model1: { userInfo: { @@ -212,6 +214,7 @@ }) return } + this.loading = true this.model2.userInfo = this.model1.userInfo if (this.model1.userInfo.Sex == '男') { this.model2.userInfo.Sex = '1' @@ -230,16 +233,19 @@ RegisterUser(json).then((res) => { if (res.code == 200) { console.log('成功', res); + this.loading = false uni.navigateTo({ url: '/pages/apply/complete?type=success' }) } else { + this.loading = false uni.navigateTo({ url: `/pages/apply/complete?type=failed&title=${res.msg}` }) } }).catch((err) => { + this.loading = false uni.navigateTo({ url: `/pages/apply/complete?type=failed&title=${err.msg}` }) diff --git a/pages/apply/subPages/riskReport.vue b/pages/apply/subPages/riskReport.vue new file mode 100644 index 0000000..766b460 --- /dev/null +++ b/pages/apply/subPages/riskReport.vue @@ -0,0 +1,533 @@ + + + + + \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index 821f5b8..3d76b65 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -20,6 +20,8 @@ import { getMenu } from '../../services/apply' + import config from '../../config/common' + import request from '../../utils/request.js' export default { data() { return { @@ -31,15 +33,15 @@ }, // { // name: "风险区域明细", - // iconName: "man-add" + // iconName: "order" // }, // { // name: "区域风险四色图", - // iconName: "man-add" + // iconName: "list-dot" // }, // { // name: "区域隐患数量", - // iconName: "man-add" + // iconName: "info-circle" // }, @@ -88,9 +90,43 @@ }) }, goCamera() { - uni.navigateTo({ - url: '/pages/camera/index' - }) + // uni.chooseImage({ + // count: 6, //默认9 + // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 + // sourceType: ['camera'], + // success: (res) => { + // const url = config.serviceHost('/PF/File/UploadFile') + // request.upload(url, res.tempFilePaths).then((result) => { + // if (result.IsSuccessful) { + // // TODO: 目前只支持一张照片 + // store.commit('updateImageLists', [{ + // IMG_FILE_ID: result.Data.imgFileID, + // IMG_FILE_PATH: result.Data.imgFilePath + // }]); + // uni.showActionSheet({ + // title: '选择上报类型', + // itemList: ['随手拍', '隐患上报'], + // success: (e) => { + // if (e.tapIndex === 0) { + // uni.navigateTo({ + // url: '/pages/camera/index' + // }) + // } else { + // uni.navigateTo({ + // url: '/pages/apply/subPages/riskReport' + // }) + // } + // } + // }) + // } + // }).catch((error) => { + // console.log(error) + // }); + // }, + // complete: function(com) { + // console.log('choose image complete', com) + // } + // }) }, getCaidan() { @@ -125,7 +161,7 @@ } .list { - padding: 20px; + padding: 20px 40px; } .list .u-grid { @@ -135,9 +171,10 @@ .list .u-grid-item { padding: 20px 0px; /* margin: 0px 0px 20px 0px; */ - margin: 20px 10px; - width: 40% !important; + margin: 10px 0px; + width: 47% !important; border-radius: 10px; + box-shadow: 5px 5px 5px #ceccca; } .home-button { diff --git a/services/apply.js b/services/apply.js index 546fa37..ee89167 100644 --- a/services/apply.js +++ b/services/apply.js @@ -1,7 +1,7 @@ import request from '../utils/request.js' export const getMenu = (params) => { - return request({ + return request.send({ url: '/BI/H5Controller/GetMenu', method: 'get', data: params, @@ -9,7 +9,7 @@ export const getMenu = (params) => { } export const RegisterUser = (params) => { - return request({ + return request.send({ url: '/BI/H5Controller/RegisterUser', method: 'post', data: params, diff --git a/utils/request.js b/utils/request.js index d398131..4ab340c 100644 --- a/utils/request.js +++ b/utils/request.js @@ -3,119 +3,159 @@ import handle401 from './handle401' // import MD5 from 'md5' -export default (params) => { - let pages = getCurrentPages() - let currentPage = pages[pages.length - 1] - let options = currentPage.options - let tenantId = '' - console.log(options, 'options') - if (options.Company == 'DCJD') { - tenantId = 'A0000025' - } else if (options.Company == 'GXBB') { - tenantId = 'A0000028' - } else if (options.Company == 'LYYL') { - tenantId = 'A0000024' - } else if (options.Company == 'LYXT') { - tenantId = '0002' - } else { - tenantId = '0001' - } - console.log(tenantId, 'tenantId') - let url = params.url; - let method = params.method || "get"; - let data = params.data || {}; - let header = { - // 'Blade-Auth': uni.getStorageSync('token') || '', - 'Content-Type': 'application/json;charset=UTF-8', - // 'Authorization': 'Basic c2FiZXI6c2FiZXJfc2VjcmV0', - 'Tenant': tenantId, // avue配置相关 - ...params.header - } - if (method == "post") { - header = { - 'Content-Type': 'application/x-www-form-urlencoded', - 'Tenant': tenantId, +export default { + send(params) { + let pages = getCurrentPages() + let currentPage = pages[pages.length - 1] + let options = currentPage.options + let tenantId = '' + console.log(options, 'options') + if (options.Company == 'DCJD') { + tenantId = 'A0000025' + } else if (options.Company == 'GXBB') { + tenantId = 'A0000028' + } else if (options.Company == 'LYYL') { + tenantId = 'A0000024' + } else if (options.Company == 'LYXT') { + tenantId = '0002' + } else { + tenantId = '0001' + } + console.log(tenantId, 'tenantId') + let url = params.url; + let method = params.method || "get"; + let data = params.data || {}; + let header = { + // 'Blade-Auth': uni.getStorageSync('token') || '', + 'Content-Type': 'application/json;charset=UTF-8', + // 'Authorization': 'Basic c2FiZXI6c2FiZXJfc2VjcmV0', + 'Tenant': tenantId, // avue配置相关 ...params.header - }; - } - return new Promise((resolve, reject) => { - uni.request({ - url: config.serviceHost(url), - method: method, - header: header, - data: data, - // timeout, - success(response) { - const res = response - // 根据返回的状态码做出对应的操作 - //获取成功 - // console.log(res.statusCode); - if (res.statusCode == 200) { - resolve(res.data); - } else { - uni.clearStorageSync() - switch (res.statusCode) { - case 401: - setTimeout(() => { - uni.showToast({ - icon: 'error', - title: '请稍后重试...', - duration: 3000, - }) - }, 10) + } + if (method == "post") { + header = { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Tenant': tenantId, + ...params.header + }; + } + return new Promise((resolve, reject) => { + uni.request({ + url: config.serviceHost(url), + method: method, + header: header, + data: data, + // timeout, + success(response) { + const res = response + // 根据返回的状态码做出对应的操作 + //获取成功 + // console.log(res.statusCode); + if (res.statusCode == 200) { + resolve(res.data); + } else { + uni.clearStorageSync() + switch (res.statusCode) { + case 401: + setTimeout(() => { + uni.showToast({ + icon: 'error', + title: '请稍后重试...', + duration: 3000, + }) + }, 10) - break; - case 404: - setTimeout(() => { - uni.showToast({ - icon: 'error', - title: '请求地址不存在...', - duration: 3000, - }) - }, 10) + break; + case 404: + setTimeout(() => { + uni.showToast({ + icon: 'error', + title: '请求地址不存在...', + duration: 3000, + }) + }, 10) - break; - default: - setTimeout(() => { - uni.showToast({ - icon: 'error', - title: '服务器内部错误...', - duration: 3000, - }) - }, 10) + break; + default: + setTimeout(() => { + uni.showToast({ + icon: 'error', + title: '服务器内部错误...', + duration: 3000, + }) + }, 10) - break; + break; + } } + }, + fail(err) { + console.log(err) + if (err.errMsg.indexOf('request:fail') !== -1) { + setTimeout(() => { + uni.showToast({ + title: '网络异常', + icon: "error", + duration: 2000 + }) + }, 10) + + } else { + setTimeout(() => { + uni.showToast({ + title: '未知异常', + duration: 2000 + }) + }, 10) + + } + reject(err); + + }, + complete() { + // 不管成功还是失败都会执行 + // uni.hideLoading(); + uni.hideToast(); } - }, - fail(err) { - console.log(err) - if (err.errMsg.indexOf('request:fail') !== -1) { - setTimeout(() => { - uni.showToast({ - title: '网络异常', - icon: "error", - duration: 2000 - }) - }, 10) - - } else { - setTimeout(() => { - uni.showToast({ - title: '未知异常', - duration: 2000 - }) - }, 10) - + }); + }).catch(() => {}); + }, + upload(url = '', filePath) { + const appInfoData = uni.getStorageSync('appInfo') + const tenant = uni.getStorageSync('Tenant') || '' + const userId = appInfoData?.User?.ID || '' + const orgId = appInfoData?.User?.ORG_ID || '' + return new Promise((resolve, reject) => { + uni.showLoading() + uni.uploadFile({ + url: url, + filePath: filePath[0], + name: 'file', + formData: { + OrgId: orgId, + userID: userId + }, + header: { + Tenant: tenant, + userid: userId + }, + success: (res) => { + if (res.statusCode === 200) { + uni.hideLoading() + resolve(JSON.parse(res.data)) + const uploadResult = JSON.parse(res.data) + if (uploadResult.IsSuccessful) { + resolve(uploadResult.Data) + } else { + reject(uploadResult.ErrorMessage) + } + } + }, + fail: (err) => { + console.log(err) } - reject(err); + }) + }) + }, - }, - complete() { - // 不管成功还是失败都会执行 - // uni.hideLoading(); - uni.hideToast(); - } - }); - }).catch(() => {}); } \ No newline at end of file