软著商品编辑,重构前备份
This commit is contained in:
parent
0f2dce9354
commit
d96d649d56
@ -1,7 +1,8 @@
|
|||||||
// pages/shop/publishCopyright/publishCopyright.js
|
// pages/shop/publishCopyright/publishCopyright.js
|
||||||
import Shop from '../../../net/api/shop'
|
import Shop from '../../../net/api/shop'
|
||||||
import {
|
import {
|
||||||
upShopImgUrl
|
upShopImgUrl,
|
||||||
|
sImgPrefix
|
||||||
} from '../../../net/mainUrl'
|
} from '../../../net/mainUrl'
|
||||||
const {
|
const {
|
||||||
isValidPhone
|
isValidPhone
|
||||||
@ -48,7 +49,9 @@ Page({
|
|||||||
msgType: 'info',
|
msgType: 'info',
|
||||||
msgShow: false,
|
msgShow: false,
|
||||||
files: [],
|
files: [],
|
||||||
showType: false
|
showType: false,
|
||||||
|
goodsId: '',
|
||||||
|
goods: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +74,55 @@ Page({
|
|||||||
selectFile: this.selectFile.bind(this),
|
selectFile: this.selectFile.bind(this),
|
||||||
uploadFile: this.uploadFile.bind(this)
|
uploadFile: this.uploadFile.bind(this)
|
||||||
})
|
})
|
||||||
this.getDic()
|
const id = options.id
|
||||||
|
if (id && id != '') {
|
||||||
|
this.setData({
|
||||||
|
goodsId: id
|
||||||
|
})
|
||||||
|
this.doGetGoodsDetail()
|
||||||
|
} else {
|
||||||
|
this.getDic()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//获取商品详情
|
||||||
|
doGetGoodsDetail() {
|
||||||
|
wx.showLoading({
|
||||||
|
title: '加载中...',
|
||||||
|
})
|
||||||
|
const _self = this
|
||||||
|
Shop.doGetGoodsDetail(_self.data.goodsId)
|
||||||
|
.then(res => {
|
||||||
|
wx.hideLoading()
|
||||||
|
var tempFile = [{
|
||||||
|
fileId: res.goodsLocalPhoto,
|
||||||
|
fileName: 'ceshi',
|
||||||
|
fileSize: 223,
|
||||||
|
fileUrl: sImgPrefix + res.goodsLocalPhoto,
|
||||||
|
url: sImgPrefix + res.goodsLocalPhoto
|
||||||
|
}]
|
||||||
|
_self.setData({
|
||||||
|
rightName: res.goodsName,
|
||||||
|
rightPrice: res.goodsPrice,
|
||||||
|
rightStopDate: res.goodsLastTime,
|
||||||
|
orgName: res.goodsLeader,
|
||||||
|
orgPhone: res.goodsLeaderPhone,
|
||||||
|
cardNumber: res.goodsLeaderIdcard,
|
||||||
|
files: tempFile,
|
||||||
|
goods: res
|
||||||
|
})
|
||||||
|
_self.getDic()
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
wx.hideLoading()
|
||||||
|
_self.setData({
|
||||||
|
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
||||||
|
msgType: 'error',
|
||||||
|
msgShow: true
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
wx.navigateBack()
|
||||||
|
}, 1500);
|
||||||
|
})
|
||||||
},
|
},
|
||||||
inputRightName(e) {
|
inputRightName(e) {
|
||||||
this.setData({
|
this.setData({
|
||||||
@ -239,6 +290,7 @@ Page({
|
|||||||
orgPhone: ''
|
orgPhone: ''
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
//获取字典
|
||||||
getDic() {
|
getDic() {
|
||||||
const _self = this
|
const _self = this
|
||||||
const cre = Shop.doGetGoodsDic('0b00884a-f7a2-425f-93e5-599fbaad4bde') //软著分类
|
const cre = Shop.doGetGoodsDic('0b00884a-f7a2-425f-93e5-599fbaad4bde') //软著分类
|
||||||
@ -256,13 +308,43 @@ Page({
|
|||||||
_self.data.rightType.forEach(item => {
|
_self.data.rightType.forEach(item => {
|
||||||
item.checked = false
|
item.checked = false
|
||||||
})
|
})
|
||||||
//默认加载第一个area
|
//判断是否是编辑
|
||||||
_self.setData({
|
if (_self.data.goodsId != '') {
|
||||||
selCreType: _self.data.creType[0],
|
_self.data.rightType.forEach(item => {
|
||||||
selArea: _self.data.areaList[0],
|
// selRightType
|
||||||
rightType: _self.data.rightType
|
if (_self.data.goods.goodsType.indexOf(item.dataId) != -1) {
|
||||||
})
|
item.checked = true
|
||||||
_self.doGetArea(_self.data.selArea.areaId)
|
_self.data.selRightType.push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var tempPersonType
|
||||||
|
_self.data.personType.forEach(item => {
|
||||||
|
if (_self.data.goods.goodsLeaderType == item.dataId) {
|
||||||
|
tempPersonType = item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var tempCreType
|
||||||
|
_self.data.creType.forEach(item => {
|
||||||
|
if (_self.data.goods.goodsLeaderIdcardType == item.dataId) {
|
||||||
|
tempCreType = item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
_self.setData({
|
||||||
|
rightType: _self.data.rightType,
|
||||||
|
selRightType: _self.data.selRightType,
|
||||||
|
selPersonType: tempPersonType,
|
||||||
|
selCreType: tempCreType
|
||||||
|
})
|
||||||
|
_self.doGetProvince(_self.data.goods.goodsLeaderCity1)
|
||||||
|
} else {
|
||||||
|
//默认加载第一个area
|
||||||
|
_self.setData({
|
||||||
|
selCreType: _self.data.creType[0],
|
||||||
|
selArea: _self.data.areaList[0],
|
||||||
|
rightType: _self.data.rightType
|
||||||
|
})
|
||||||
|
_self.doGetArea(_self.data.selArea.areaId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@ -277,6 +359,29 @@ Page({
|
|||||||
})
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
//获取省
|
||||||
|
doGetProvince(id) {
|
||||||
|
wx.showLoading({
|
||||||
|
title: '加载中...',
|
||||||
|
})
|
||||||
|
const _self = this
|
||||||
|
Shop.doGetAreaDetail(id)
|
||||||
|
.then(res => {
|
||||||
|
wx.hideLoading()
|
||||||
|
_self.setData({
|
||||||
|
selArea: res
|
||||||
|
})
|
||||||
|
_self.doGetArea(_self.data.selArea.areaId)
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
wx.hideLoading()
|
||||||
|
//重置selArea selCity
|
||||||
|
_self.setData({
|
||||||
|
selArea: null,
|
||||||
|
selCity: null
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
//获取区域
|
//获取区域
|
||||||
doGetArea(pId) {
|
doGetArea(pId) {
|
||||||
wx.showLoading({
|
wx.showLoading({
|
||||||
@ -286,14 +391,26 @@ Page({
|
|||||||
Shop.doGetAreaList(pId)
|
Shop.doGetAreaList(pId)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
console.log(res)
|
|
||||||
if (res) {
|
if (res) {
|
||||||
_self.setData({
|
_self.setData({
|
||||||
cityList: res,
|
cityList: res
|
||||||
selCity: res[0]
|
|
||||||
})
|
})
|
||||||
|
if (_self.data.goodsId != '') {
|
||||||
|
var tempCity
|
||||||
|
_self.data.cityList.forEach(item => {
|
||||||
|
if (_self.data.goods.goodsLeaderCity2 == item.areaId) {
|
||||||
|
tempCity = item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
_self.setData({
|
||||||
|
selCity: tempCity
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
_self.setData({
|
||||||
|
selCity: res[0]
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
@ -330,8 +447,8 @@ Page({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//保存商品
|
//发布新商品
|
||||||
doSave() {
|
doConfirmPublish() {
|
||||||
const isLegal = this.checkParams()
|
const isLegal = this.checkParams()
|
||||||
if (isLegal) {
|
if (isLegal) {
|
||||||
const _self = this
|
const _self = this
|
||||||
@ -361,6 +478,48 @@ Page({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//修改新商品
|
||||||
|
doConfirmUpdate() {
|
||||||
|
const isLegal = this.checkParams()
|
||||||
|
if (isLegal) {
|
||||||
|
const _self = this
|
||||||
|
const data = _self.buildParams()
|
||||||
|
wx.showLoading({
|
||||||
|
title: '保存中...',
|
||||||
|
})
|
||||||
|
Shop.doUpdateGoods(_self.data.goodsId, data)
|
||||||
|
.then(res => {
|
||||||
|
wx.hideLoading()
|
||||||
|
//修改成功
|
||||||
|
_self.setData({
|
||||||
|
msgType: 'success',
|
||||||
|
msgHint: '修改成功',
|
||||||
|
msgShow: true
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
_self.backPageRefresh()
|
||||||
|
}, 1500);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
wx.hideLoading()
|
||||||
|
_self.setData({
|
||||||
|
msgType: 'error',
|
||||||
|
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
||||||
|
msgShow: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//保存商品
|
||||||
|
doSave() {
|
||||||
|
if (this.data.goodsId != '') {
|
||||||
|
//编辑
|
||||||
|
this.doConfirmUpdate()
|
||||||
|
} else {
|
||||||
|
//新增
|
||||||
|
this.doConfirmPublish()
|
||||||
|
}
|
||||||
|
},
|
||||||
//校验参数
|
//校验参数
|
||||||
checkParams() {
|
checkParams() {
|
||||||
const rules = [{
|
const rules = [{
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
.section {
|
.section {
|
||||||
margin-bottom: 15rpx;
|
margin-bottom: 15rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
@ -73,7 +74,7 @@
|
|||||||
min-height: 70rpx;
|
min-height: 70rpx;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
border-radius: 5rpx;
|
border-radius: 5rpx;
|
||||||
padding: 0rpx 15rpx 10rpx 10rpx;
|
padding: 0rpx 15rpx 10rpx 0rpx;
|
||||||
border-bottom: 1rpx solid var(--divider-color);
|
border-bottom: 1rpx solid var(--divider-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +86,7 @@
|
|||||||
height: 70rpx;
|
height: 70rpx;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
border-radius: 5rpx;
|
border-radius: 5rpx;
|
||||||
padding: 0rpx 15rpx 10rpx 15rpx;
|
padding: 0rpx 15rpx 10rpx 0rpx;
|
||||||
border-bottom: 1rpx solid var(--divider-color);
|
border-bottom: 1rpx solid var(--divider-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,13 +106,10 @@
|
|||||||
padding: 5rpx 15rpx;
|
padding: 5rpx 15rpx;
|
||||||
border-radius: 5rpx;
|
border-radius: 5rpx;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
|
margin-right: 20rpx;
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.select-item-item:nth-of-type(n+1) {
|
|
||||||
margin: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.desc {
|
.desc {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
color: #999;
|
color: #999;
|
||||||
|
@ -18,7 +18,8 @@ Page({
|
|||||||
typeNameList: [],
|
typeNameList: [],
|
||||||
cardTypeName: '',
|
cardTypeName: '',
|
||||||
cityName: '',
|
cityName: '',
|
||||||
leaderType: ''
|
leaderType: '',
|
||||||
|
needRefresh: false
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,6 +54,14 @@ Page({
|
|||||||
}, 1500);
|
}, 1500);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onShow() {
|
||||||
|
if (this.data.needRefresh) {
|
||||||
|
this.setData({
|
||||||
|
needRefresh: false
|
||||||
|
})
|
||||||
|
this.doGetGoodsDetail()
|
||||||
|
}
|
||||||
|
},
|
||||||
//获取商品详情
|
//获取商品详情
|
||||||
doGetGoodsDetail() {
|
doGetGoodsDetail() {
|
||||||
wx.showLoading({
|
wx.showLoading({
|
||||||
@ -193,7 +202,10 @@ Page({
|
|||||||
},
|
},
|
||||||
//去编辑
|
//去编辑
|
||||||
doEdit() {
|
doEdit() {
|
||||||
|
const _self = this
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '/pages/shop/publishCopyright/publishCopyright?id=' + _self.data.goodsId,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
//删除
|
//删除
|
||||||
doDel() {
|
doDel() {
|
||||||
|
Loading…
Reference in New Issue
Block a user