|
@@ -197,14 +197,33 @@ export default {
|
|
|
dictList: [],
|
|
|
fileList: [],
|
|
|
fileurl: [],
|
|
|
- content: ''
|
|
|
+ content: '',
|
|
|
+ type: '',
|
|
|
+ goodsId: ''
|
|
|
}
|
|
|
},
|
|
|
onReady() {
|
|
|
//如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
|
|
|
// this.$refs.form.setRules(this.rules)
|
|
|
},
|
|
|
+ onLoad({ type, goodsId }) {
|
|
|
+ // console.log(type, goodsId)
|
|
|
+ // this.type = type
|
|
|
+ // this.goodsId = goodsId
|
|
|
+ // if (goodsId) {
|
|
|
+ // this.show = false
|
|
|
+ // this.getDetail()
|
|
|
+ // }
|
|
|
+ },
|
|
|
onShow() {
|
|
|
+ const value = uni.getStorageSync('issuePageParam')
|
|
|
+ if (value) {
|
|
|
+ this.type = value.type
|
|
|
+ this.goodsId = value.goodsId
|
|
|
+ this.show = false
|
|
|
+ this.getDetail()
|
|
|
+ uni.removeStorageSync('issuePageParam');
|
|
|
+ }
|
|
|
this.getConfig()
|
|
|
this.getList()
|
|
|
this.getDictList()
|
|
@@ -217,6 +236,43 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ //
|
|
|
+ getDetail() {
|
|
|
+ this.$api
|
|
|
+ .postJson('/goods/detail', {
|
|
|
+ id: this.goodsId
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ console.log(res)
|
|
|
+ this.form = {
|
|
|
+ title: res.data.title,
|
|
|
+ content: res.data.content,
|
|
|
+ categoryName: res.data.categoryName,
|
|
|
+ categoryId: res.data.categoryId,
|
|
|
+ lng: res.data.lng,
|
|
|
+ lat: res.data.lat,
|
|
|
+ address: res.data.address,
|
|
|
+ amount: String(res.data.amount),
|
|
|
+ num: String(res.data.num),
|
|
|
+ brand: res.data.brand,
|
|
|
+ power: res.data.power,
|
|
|
+ energy: res.data.energy,
|
|
|
+ province: res.data.province,
|
|
|
+ city: res.data.city,
|
|
|
+ area: res.data.area,
|
|
|
+ street: res.data.street,
|
|
|
+ goodsCreateTime: res.data.goodsCreateTime
|
|
|
+ }
|
|
|
+ this.fileList = res.data.goodsFiles.map(v => v.imgUrl)
|
|
|
+ this.fileurl = []
|
|
|
+ res.data.goodsFiles.forEach(v => {
|
|
|
+ this.fileurl.push({
|
|
|
+ imgUrl: v.imgUrl
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+ },
|
|
|
getConfig() {
|
|
|
this.$api
|
|
|
.get('/app/config/detail-by-type', {
|
|
@@ -249,8 +305,17 @@ export default {
|
|
|
}
|
|
|
this.$toast('发布成功')
|
|
|
setTimeout(() => {
|
|
|
+ let path = '/goods/add'
|
|
|
+ if (this.goodsId && this.type == 1) {
|
|
|
+ path = '/goods/updateUp'
|
|
|
+ params.id = this.goodsId
|
|
|
+ }
|
|
|
+ if (this.goodsId && this.type == 2) {
|
|
|
+ path = '/goods/update'
|
|
|
+ params.id = this.goodsId
|
|
|
+ }
|
|
|
this.$api
|
|
|
- .post('/goods/add', params)
|
|
|
+ .post(path, params)
|
|
|
.then(res => {
|
|
|
this.form = {
|
|
|
title: '',
|
|
@@ -281,7 +346,9 @@ export default {
|
|
|
'switchTab'
|
|
|
)
|
|
|
})
|
|
|
- .catch((err) => {this.$toast(err)})
|
|
|
+ .catch(err => {
|
|
|
+ this.$toast(err)
|
|
|
+ })
|
|
|
}, 1000)
|
|
|
}
|
|
|
})
|