diff --git a/config.js b/config.js index 9861bec..b2655d2 100644 --- a/config.js +++ b/config.js @@ -1,7 +1,7 @@ // 应用全局配置 module.exports = { // http://192.168.0.165:1208 - baseUrl: process.env.NODE_ENV === 'development' ? 'http://192.168.0.165:12080' : 'http://dev.ccwin-in.com:25200/api', + baseUrl: process.env.NODE_ENV === 'development' ? 'http://192.168.1.18:12080' : 'http://dev.ccwin-in.com:25200/api', baseApi:process.env.NODE_ENV === 'development' ? '/admin-api' : '/api/admin-api', // 应用信息 appInfo: { diff --git a/pages/deviceReport/addForm.vue b/pages/deviceReport/addForm.vue index 28f23ea..3c9b4c5 100644 --- a/pages/deviceReport/addForm.vue +++ b/pages/deviceReport/addForm.vue @@ -29,6 +29,18 @@ + + + + + + + + + + + + @@ -46,23 +58,26 @@ import * as deviceApi from "@/api/device.js" import * as moldApi from "@/api/mold.js" import * as dictApi from "@/api/dict.js" + import * as uploadApi from "@/api/upload.js" + export default { data() { return { loading: false, type: "", - appDeviceMoldType:[], + appDeviceMoldType: [], form: { describes: "", deviceNumber: '', deviceName: '', factoryAreaName: '', factoryAreaNumber: '', - receiverType:'' + receiverType: '' }, singleColumnShow: false, singleColumnDefaultValue: [], singleColumnList: [], + imgList: [] } }, methods: { @@ -181,12 +196,39 @@ this.$emit('singleColumn', this.field, this.form[this.field]) this.$forceUpdate() }, - + chooseImage() { + uni.chooseImage({ + count: 1, // 默认9 + sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 + success: (res) => { + let filePath = res.tempFilePaths[0] + this.$modal.loading() + uploadApi.uploadFile({ + filePath: filePath, + name: 'file', + formData: { + 'user': 'test' + }, + }).then(ret => { + this.$modal.closeLoading() + this.imgList.push(ret.data) + console.log(ret) + }).catch((err) => { + this.$modal.closeLoading() + }); + }, + }); + }, + // 删除图片 + delImage(index) { + this.imgList.splice(index, 1) + } }, async onLoad(option) { if (option.type) this.type = option.type; this.appDeviceMoldType = await dictApi.getDict('app_device_mold_type') - } + } } @@ -239,7 +281,8 @@ } } } -.select { + + .select { display: flex; align-items: center; height: 72rpx; @@ -258,6 +301,7 @@ } } + .footer { position: fixed; bottom: 0px; @@ -302,4 +346,51 @@ text-align: center; font-size: 28rpx; } + + .image { + padding: 0px 30rpx; + padding-bottom: 30rpx; + display: flex; + align-items: center; + + flex-wrap: wrap; + + .image-list { + display: flex; + align-items: center; + flex-wrap: wrap; + } + } + + .image-item { + width: 210rpx; + height: 210rpx; + margin-right: 20rpx; + position: relative; + border: 1px solid rgba(230, 230, 230, 0.5); + margin-bottom: 20rpx; + border-radius: 20rpx; + overflow: hidden; + + image { + width: 100%; + height: 100%; + } + + .close { + position: absolute; + right: 0px; + top: 0px; + } + } + + .image-item1 { + border: none; + margin-right: 0px; + + image { + width: 100%; + height: 100%; + } + } \ No newline at end of file diff --git a/utils/upload.js b/utils/upload.js index fb6b379..eb0b018 100644 --- a/utils/upload.js +++ b/utils/upload.js @@ -3,11 +3,12 @@ import config from '@/config' import { getAccessToken } from '@/utils/auth' import errorCode from '@/utils/errorCode' import { toast, showConfirm, tansParams } from '@/utils/common' - let timeout = 10000 const baseUrl = config.baseUrl +const baseApi = config.baseApi const upload = config => { +console.log(config) // 是否需要设置 token const isToken = (config.headers || {}).isToken === false config.header = config.header || {} @@ -25,7 +26,7 @@ const upload = config => { return new Promise((resolve, reject) => { uni.uploadFile({ timeout: config.timeout || timeout, - url: baseUrl + config.url, + url: baseUrl +baseApi+ config.url, filePath: config.filePath, name: config.name || 'file', header: config.header,