需求发布接口对接
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
</u-form-item>
|
||||
<u-form-item label="分类" borderBottom>
|
||||
<view class="select-view" @tap="showCategoryPicker = true">
|
||||
<text v-if="needsPublishForm.cate_id">{{cateName}}</text>
|
||||
<text v-if="needsPublishForm.class">{{needsPublishForm.class}}</text>
|
||||
<text v-else style="color:#CCCCCC;">请选择分类</text>
|
||||
<u-icon name="arrow-right" color="#969696" size="14"></u-icon>
|
||||
</view>
|
||||
@@ -40,16 +40,16 @@
|
||||
</view>
|
||||
<u-form-item label="产品" borderBottom>
|
||||
<view class="select-view" @tap="showProductPicker = true">
|
||||
<text v-if="needsPublishForm.cate_id">{{cateName}}</text>
|
||||
<text v-if="needsPublishForm.product">{{needsPublishForm.product}}</text>
|
||||
<text v-else style="color:#CCCCCC;">请选择产品类型</text>
|
||||
<u-icon name="arrow-right" color="#969696" size="14"></u-icon>
|
||||
</view>
|
||||
<u-picker :show="showProductPicker" :columns="productPickerColumn" @cancel="showProductPicker = false"
|
||||
@confirm="getProductValue"></u-picker>
|
||||
<u-picker :show="showProductPicker" :columns="productPickerColumn"
|
||||
@cancel="showProductPicker = false" @confirm="getProductValue"></u-picker>
|
||||
</u-form-item>
|
||||
<u-form-item label="定位" borderBottom>
|
||||
<view class="select-view" @tap="selectProductPosition">
|
||||
<text v-if="needsPublishForm.tagids">{{tagName}}</text>
|
||||
<view class="select-view" @tap="showPositionPicker = true">
|
||||
<text v-if="needsPublishForm.loc">{{needsPublishForm.loc}}</text>
|
||||
<text v-else style="color:#CCCCCC;">请选择产品定位</text>
|
||||
<u-icon name="arrow-right" color="#969696" size="14"></u-icon>
|
||||
</view>
|
||||
@@ -65,8 +65,8 @@
|
||||
<view v-if="tabCurrent === 1" style="margin-bottom: 20rpx;">
|
||||
<u-form-item label="上传图片" labelPosition="top">
|
||||
<view style="padding-left: 20rpx;margin-top: 20rpx;">
|
||||
<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
|
||||
:maxCount="10"></u-upload>
|
||||
<u-upload :fileList="fileList1" :auto-upload="false" @afterRead="afterRead" @delete="deletePic"
|
||||
name="1" multiple :maxCount="10"></u-upload>
|
||||
</view>
|
||||
</u-form-item>
|
||||
</view>
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user