From c7983aadb3da915f4f8e0dc2c6b55cc04ac5122a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Dchenxuelian=E2=80=9C?= <“chenxuelian@cjiedata.com”> Date: Tue, 17 Jan 2023 23:35:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E5=8F=91=E5=B8=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/ideasAndNeeds/ideasAndNeeds.vue | 184 ++++++++++++++------------ service/request.js | 8 +- 2 files changed, 105 insertions(+), 87 deletions(-) diff --git a/pages/ideasAndNeeds/ideasAndNeeds.vue b/pages/ideasAndNeeds/ideasAndNeeds.vue index b61fd06..8f28b3a 100644 --- a/pages/ideasAndNeeds/ideasAndNeeds.vue +++ b/pages/ideasAndNeeds/ideasAndNeeds.vue @@ -30,7 +30,7 @@ - {{cateName}} + {{needsPublishForm.class}} 请选择分类 @@ -40,16 +40,16 @@ - {{cateName}} + {{needsPublishForm.product}} 请选择产品类型 - + - - {{tagName}} + + {{needsPublishForm.loc}} 请选择产品定位 @@ -65,8 +65,8 @@ - + @@ -146,10 +146,13 @@ categoryPickerList: [ ['类别1', '类别', '类别'] ], - fileList1: [], + fileList1: [ + // uploads/images/20230117/202301172309397deda1543.jpg + ], isLoad: true, cateName: null, - tagName: null + tagName: null, + token: null } }, onLoad(options) { @@ -168,48 +171,57 @@ return } this.isLoad = true - this.getProductPickerList() + this.token = uni.getStorageSync('token') + this.getFormData() + // this.getProductPickerList() }, methods: { tabChange(data) { this.tabCurrent = data.index this.needsPublishForm = {} }, - selectProductPosition() { - if (this.needsPublishForm.cate_id) { - this.showPositionPicker = true - } else { - this.$toast.warn('请先选择产品类型') - } - }, - getProductPickerList() { - const data = {} - const temp = [] - this.$apiServe.getCategories(data).then(res => { - this.productPickerList = res.data.data.map((item, index) => { - temp.push(item.name) - return item - }) - this.productPickerColumn[0] = [...temp] + getFormData() { + this.$apiServe.getIdeasAndNeedsFormdata().then(res => { + console.log(res.data.data) + const formData = res.data.data + this.productPickerColumn[0] = formData.product + this.positionPickerColumn[0] = formData.loc + this.categoryPickerList[0] = formData.class + // this.productPickerList = res.data.data.map((item, index) => { + // temp.push(item.name) + // return item + // }) + // this.productPickerColumn[0] = [...temp] }).finally(_ => {}) }, - getPositionPickerList() { - if(this.needsPublishForm.cate_id) { - const data = { - pid: this.needsPublishForm.cate_id - } - this.$apiServe.getTags(data).then(res => { - const temp = [] - this.positionPickerList = res.data.data.map((item, index) => { - temp.push(item.name) - return item - }) - this.positionPickerColumn[0] = temp - }).finally(_ => {}) - } else { - that.$toast.warn('请先选择产品类型') - } - }, + // getProductPickerList() { + // const data = {} + // const temp = [] + // this.$apiServe.getCategories(data).then(res => { + // this.productPickerList = res.data.data.map((item, index) => { + // temp.push(item.name) + // return item + // }) + // // this.productPickerColumn[0] = [...temp] + // }).finally(_ => {}) + // }, + // getPositionPickerList() { + // if (this.needsPublishForm.cate_id) { + // const data = { + // pid: this.needsPublishForm.cate_id + // } + // this.$apiServe.getTags(data).then(res => { + // const temp = [] + // this.positionPickerList = res.data.data.map((item, index) => { + // temp.push(item.name) + // return item + // }) + // this.positionPickerColumn[0] = temp + // }).finally(_ => {}) + // } else { + // that.$toast.warn('请先选择产品类型') + // } + // }, getCityValue(data) { console.log(data) this.showCityPicker = false @@ -219,32 +231,32 @@ getProductValue(data) { this.showProductPicker = false this.showCategoryPicker = false - console.log(data) - const obj = this.productPickerList.find(item => { - return item.name === data.value[0] - }) - this.cateName = data.value[0] - if (obj) { - this.needsPublishForm.cate_id = obj.id - } - this.needsPublishForm.tagids = null - this.getPositionPickerList() + this.needsPublishForm.product= data.value[0] + // console.log(data) + // const obj = this.productPickerList.find(item => { + // return item.name === data.value[0] + // }) + // this.cateName = data.value[0] + // if (obj) { + // this.needsPublishForm.cate_id = obj.id + // } + // this.needsPublishForm.tagids = null + // this.getPositionPickerList() }, getPositionValue(data) { this.showPositionPicker = false - - const obj = this.positionPickerList.find(item => { - return item.name === data.value[0] - }) - this.tagName = data.value[0] - if (obj) { - this.needsPublishForm.tagids = obj.id - } - + this.needsPublishForm.loc = data.value[0] + // const obj = this.positionPickerList.find(item => { + // return item.name === data.value[0] + // }) + // this.tagName = data.value[0] + // if (obj) { + // this.needsPublishForm.tagids = obj.id + // } }, getCategoryValue(data) { this.showCategoryPicker = false - this.needsPublishForm.cate_id = data.value[0] + this.needsPublishForm.class = data.value[0] }, getCode() { if (this.$refs.uCode.canGetCode) { @@ -274,6 +286,9 @@ async afterRead(event) { // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式 let lists = [].concat(event.file) + console.log(this.fileList1) + console.log(lists) + console.log(this[`fileList${event.name}`]) let fileListLen = this[`fileList${event.name}`].length lists.map((item) => { this[`fileList${event.name}`].push({ @@ -296,25 +311,27 @@ }, uploadFilePromise(url) { return new Promise((resolve, reject) => { - const data = { - file: new File - } - let a = apiService.postImage(data).then(res => { - console.log(res) - }) - // let a = uni.uploadFile({ - // url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址 - // filePath: url, - // name: 'file', - // formData: { - // user: 'test' - // }, - // success: (res) => { - // setTimeout(() => { - // resolve(res.data.data) - // }, 1000) - // } - // }); + // const data = { + // file: new File + // } + // let a = apiService.postImage(data).then(res => { + // console.log(res) + // }) + let a = uni.uploadFile({ + url: apiService.uploadImgUrl, // 仅为示例,非真实的接口地址 + filePath: url, + name: 'file', + header: { + "Content-Type": "multipart/form-data", + "token": this.token + }, + success: (res) => { + setTimeout(() => { + console.log(JSON.parse(res.data).data.url) + resolve(JSON.parse(res.data).data.url) + }, 1000) + } + }); }) }, //BlobUrl转blob数据 @@ -361,6 +378,7 @@ // }) return } + this.token = uni.getStorageSync('token') this.isLoad = true }, failToLoad() { diff --git a/service/request.js b/service/request.js index 4f5a7b9..b3450fc 100644 --- a/service/request.js +++ b/service/request.js @@ -205,7 +205,7 @@ const toast = { } } const apiService = { - uploadImgUrl: serverHost, + uploadImgUrl: serverHost + `/upload/image/`, imgUrl: serverHost, // login: data => { // data = Object.assign(data || {}, {}) @@ -375,10 +375,10 @@ const apiService = { resolve(service.post(url, data)) }) }, - submitIdeasAndNeeds(data) { - const url = `/require/release/` + getIdeasAndNeedsFormdata(data) { + const url = `/require/formdata/` return new Promise((resolve, reject) => { - resolve(service.putWithFormData(url, data)) + resolve(service.post(url, data)) }) }, postMobileByMnp(data) {