diff --git a/pages/ideasAndNeeds/ideasAndNeeds.vue b/pages/ideasAndNeeds/ideasAndNeeds.vue index ada208f..b61fd06 100644 --- a/pages/ideasAndNeeds/ideasAndNeeds.vue +++ b/pages/ideasAndNeeds/ideasAndNeeds.vue @@ -30,7 +30,7 @@ - {{needsPublishForm.cate_id}} + {{cateName}} 请选择分类 @@ -40,24 +40,24 @@ - {{needsPublishForm.pname}} + {{cateName}} 请选择产品类型 - - - {{needsPublishForm.position}} + + {{tagName}} 请选择产品定位 - - @@ -121,10 +121,7 @@ name: '创意发布' }], tabCurrent: 0, - needsPublishForm: { - city: null, - position: null - }, + needsPublishForm: {}, formLabelStyle: { 'font-size': '32rpx !important' }, @@ -135,20 +132,24 @@ seconds: 10, disabled: false, tips: '获取验证码', - productPickerList: [ - ['烘焙', '零食', '饮料'] + productPickerList: [], + productPickerColumn: [ + [] // {name: '烘焙', val: 'hongbei'} // {name: '零食', val: 'ls'} // {name: '饮料', val: 'yl'} ], - positionPickerList: [ - ['无添加剂', '无添加剂', '无添加剂'] + positionPickerList: [], + positionPickerColumn: [ + [] ], categoryPickerList: [ ['类别1', '类别', '类别'] ], fileList1: [], - isLoad: true + isLoad: true, + cateName: null, + tagName: null } }, onLoad(options) { @@ -167,12 +168,48 @@ return } this.isLoad = true + 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] + }).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 @@ -181,11 +218,29 @@ }, getProductValue(data) { this.showProductPicker = false - this.needsPublishForm.tagids = data.value[0] + 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() }, getPositionValue(data) { this.showPositionPicker = false - this.needsPublishForm.position = 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 @@ -287,6 +342,14 @@ this.$toast.warn('请输入正确的手机号') return false } + this.needsPublishForm.type = Number(this.tabCurrent + 1) + this.needsPublishForm.pub_time = new Date().getTime() + const data = { + ...this.needsPublishForm + } + apiService.submitIdeasAndNeeds(data).then(res => { + this.$toast.success(res.msg) + }) }, reOnLoad() { console.log('----------------true') diff --git a/service/request.js b/service/request.js index 34d0bad..4f5a7b9 100644 --- a/service/request.js +++ b/service/request.js @@ -116,6 +116,32 @@ const service = { }) }) }, + putWithFormData(url, data, isLogin) { + const header = {} + header['token'] = uni.getStorageSync('token') + header['content-type'] = 'application/x-www-form-urlencoded' + return new Promise((resolve, reject) => { + uni.request({ + method: 'put', + url: serverHost + url, + header: header, + success: res => { + if (!res.data.flag) { + isOutTime(res) + reject(res) + } + resolve(res) + }, + data: data, + fail: err => { + // 调用接口失败 + // toast.error(res.data.message) + uni.hideLoading() + reject(err) + } + }) + }) + }, delete(url, data, isLogin) { const header = {} header['token'] = uni.getStorageSync('token') @@ -349,6 +375,12 @@ const apiService = { resolve(service.post(url, data)) }) }, + submitIdeasAndNeeds(data) { + const url = `/require/release/` + return new Promise((resolve, reject) => { + resolve(service.putWithFormData(url, data)) + }) + }, postMobileByMnp(data) { const url = `/user/getMobileByMnp` return new Promise((resolve, reject) => {