转让市场
This commit is contained in:
@@ -174,22 +174,24 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { managesGoodsCreate, managesCreate, managesGoodsEdit } from '@/apis/interfaces/goods'
|
||||
import { managesGoodsCreate, managesCreate, managesGoodsEdit, managesGoodsPut } from '@/apis/interfaces/goods'
|
||||
import { uploads } from '@/apis/interfaces/uploading'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
categoryId : '', // 一级分类
|
||||
categoryCid : '', // 二级分类
|
||||
name : '', // 标题
|
||||
pictures : [], // 轮播图
|
||||
content : [], // 详情图
|
||||
description : '', // 商品描述
|
||||
isPostSale : false, // 是否允许售后
|
||||
services : [], // 商品服务
|
||||
skus_cost : '0.00',// 市场价格
|
||||
skus_price : '0.00',// 销售价格
|
||||
skus_cost : '', // 市场价格
|
||||
skus_price : '', // 销售价格
|
||||
skus_number : 1, // 易货起购数量
|
||||
skus_unit : '件', // 规格文字
|
||||
skus_charge : '0.00',// 分销佣金
|
||||
skus_charge : '', // 分销佣金
|
||||
skus_stock : '', // 库存
|
||||
isChange : false, // 是否支持易货
|
||||
stores : [], // 关联店铺
|
||||
@@ -208,10 +210,49 @@
|
||||
};
|
||||
},
|
||||
created() {
|
||||
if(this.$Route.query.type === 'edit'){
|
||||
console.log('编辑')
|
||||
// 编辑状态信息
|
||||
if(this.$Route.query.type && this.$Route.query.type === 'edit'){
|
||||
managesGoodsEdit(this.$Route.query.id).then(res => {
|
||||
console.log(res)
|
||||
let services = [], stores = []
|
||||
let servicesArr = res.services.map(val => {
|
||||
let check = (res.data.services.findIndex(obj => obj.service_id === val.service_id)) >= 0
|
||||
if(check){
|
||||
services.push(val.service_id)
|
||||
}
|
||||
return{
|
||||
check,
|
||||
...val
|
||||
}
|
||||
})
|
||||
let storesArr = res.stores.map(val => {
|
||||
let check = (res.data.stores.findIndex(obj => obj.store_id === val.store_id)) >= 0
|
||||
if(check){
|
||||
stores.push(val.store_id)
|
||||
}
|
||||
return {
|
||||
check,
|
||||
...val
|
||||
}
|
||||
})
|
||||
this.categoryId = res.data.category.category_id
|
||||
this.categoryCid = res.data.category_sub.category_id
|
||||
this.name = res.data.name
|
||||
this.content = res.data.content
|
||||
this.description = res.data.description
|
||||
this.pictures = res.data.pictures
|
||||
this.skus_cost = res.data.skus[0].cost
|
||||
this.skus_price = res.data.skus[0].price
|
||||
this.skus_number = res.data.skus[0].number
|
||||
this.skus_unit = res.data.skus[0].unit
|
||||
this.skus_charge = res.data.skus[0].charge
|
||||
this.skus_stock = res.data.skus[0].stock
|
||||
this.isPostSale = res.data.is_post_sale == 0
|
||||
this.isChange = res.data.is_change == 0
|
||||
this.logisticType= this.logisticArr.findIndex(val => val.type === res.data.logistic_type)
|
||||
this.servicesArr = servicesArr
|
||||
this.storesArr = storesArr
|
||||
this.services = services
|
||||
this.stores = stores
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
@@ -220,6 +261,7 @@
|
||||
})
|
||||
return
|
||||
}
|
||||
// 添加配置信息
|
||||
managesCreate({
|
||||
category_cid: this.$Route.query.cid
|
||||
}).then(res => {
|
||||
@@ -239,6 +281,8 @@
|
||||
this.tags = res.tags
|
||||
this.servicesArr= res.services
|
||||
this.type = res.type
|
||||
this.categoryId = this.$Route.query.id
|
||||
this.categoryCid= this.$Route.query.cid
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
@@ -315,8 +359,8 @@
|
||||
let submitData = {
|
||||
name : this.name,
|
||||
cover : this.pictures[0].path,
|
||||
category_id : this.$Route.query.id,
|
||||
category_cid : this.$Route.query.cid,
|
||||
category_id : this.categoryId,
|
||||
category_cid : this.categoryCid,
|
||||
pictures : pictures,
|
||||
content : content,
|
||||
description : this.description,
|
||||
@@ -333,7 +377,8 @@
|
||||
stores : this.stores,
|
||||
expiried_at : this.expiriedAt
|
||||
}
|
||||
let submitFund = managesGoodsCreate(submitData)
|
||||
|
||||
let submitFund = this.$Route.query.type === 'edit' ? managesGoodsPut(this.$Route.query.id, submitData) : managesGoodsCreate(submitData)
|
||||
submitFund.then(res => {
|
||||
if(this.type === 2){
|
||||
uni.showModal({
|
||||
@@ -342,13 +387,27 @@
|
||||
showCancel : false,
|
||||
success : res => {
|
||||
if(res.confirm){
|
||||
this.$Router.back()
|
||||
this.$Router.back(this.$Route.query.type === 'edit' ? 1 : 2)
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
this.$Router.push({name: 'goodsAuth', params: { id: res , type: 'goodsAdd'}})
|
||||
uni.showModal({
|
||||
title : '提示',
|
||||
content : this.$Route.query.type === 'edit' ? '商品权证已更新,是否立即补充产品附加信息认证?' : '商品权证已发布,是否立即补充产品附加信息认证?',
|
||||
cancelText : '稍后认证',
|
||||
confirmText : '立即认证',
|
||||
success : res => {
|
||||
if(res.cancel){
|
||||
this.$Router.back(this.$Route.query.type === 'edit' ? 1 : 2)
|
||||
}
|
||||
if(res.confirm){
|
||||
let goodsId = this.$Route.query.type === 'edit' ? this.$Route.query.id : res
|
||||
this.$Router.push({name: 'goodsAuth', params: { id: goodsId , type: 'goodsAdd', edit: this.$Route.query.type === 'edit'}})
|
||||
}
|
||||
}
|
||||
})
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
|
||||
Reference in New Issue
Block a user