305 lines
9.0 KiB
JavaScript
305 lines
9.0 KiB
JavaScript
// pages/shop/publishCopyright/publishCopyright.js
|
|
import Shop from '../../../net/api/shop'
|
|
import {
|
|
sImgPrefix
|
|
} from '../../../net/mainUrl'
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
msgHint: '',
|
|
msgType: 'info',
|
|
msgShow: false,
|
|
showType: false,
|
|
goodsId: '',
|
|
goods: null,
|
|
typeNameList: [],
|
|
cardTypeName: '',
|
|
cityName: '',
|
|
leaderType: '',
|
|
needRefresh: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
wx.setNavigationBarTitle({
|
|
title: '详情',
|
|
})
|
|
wx.setNavigationBarColor({
|
|
frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000
|
|
backgroundColor: '#FFFFFF', // 传递的颜色值,仅支持十六进制颜色
|
|
animation: { // 可选项
|
|
duration: 500,
|
|
timingFunc: 'easeIn'
|
|
}
|
|
})
|
|
const id = options.id
|
|
if (id && id != '') {
|
|
this.setData({
|
|
goodsId: id
|
|
})
|
|
this.doGetGoodsDetail()
|
|
} else {
|
|
this.setData({
|
|
msgHint: '数据有误,请稍后重试',
|
|
msgType: 'error',
|
|
msgShow: true
|
|
})
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 1500);
|
|
}
|
|
},
|
|
onShow() {
|
|
if (this.data.needRefresh) {
|
|
this.setData({
|
|
needRefresh: false
|
|
})
|
|
this.doGetGoodsDetail()
|
|
}
|
|
},
|
|
//获取商品详情
|
|
doGetGoodsDetail() {
|
|
wx.showLoading({
|
|
title: '加载中...',
|
|
})
|
|
const _self = this
|
|
Shop.doGetGoodsDetail(this.data.goodsId)
|
|
.then(res => {
|
|
wx.hideLoading()
|
|
if (res && res != null) {
|
|
res.goodsLocalPhoto = sImgPrefix + res.goodsLocalPhoto
|
|
switch (res.goodsLeaderType) {
|
|
case '1':
|
|
res.goodsLeaderTypeName = '自然人'
|
|
break
|
|
case '2':
|
|
res.goodsLeaderTypeName = '法人'
|
|
break
|
|
case '3':
|
|
res.goodsLeaderTypeName = '非法人组织或其他'
|
|
break
|
|
}
|
|
|
|
_self.setData({
|
|
goods: res
|
|
})
|
|
console.log(_self.data.goods)
|
|
_self.getDic()
|
|
} else {
|
|
_self.setData({
|
|
msgHint: '网络错误,请稍后重试',
|
|
msgType: 'error',
|
|
msgShow: true
|
|
})
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 1800);
|
|
}
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading()
|
|
_self.setData({
|
|
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
|
msgType: 'error',
|
|
msgShow: true
|
|
})
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 1800);
|
|
})
|
|
},
|
|
//获取字典详情
|
|
getDic() {
|
|
wx.showLoading({
|
|
title: '加载中...',
|
|
})
|
|
const _self = this
|
|
//软著分类 goodsType
|
|
const sort = Shop.doGetGoodsDic('0b00884a-f7a2-425f-93e5-599fbaad4bde')
|
|
//证件类别 goodsLeaderIdcardType
|
|
const type = Shop.doGetDicDetail(_self.data.goods.goodsLeaderIdcardType)
|
|
//省市 goodsLeaderCity1 goodsLeaderCity2
|
|
const city1 = Shop.doGetAreaDetail(_self.data.goods.goodsLeaderCity1)
|
|
const city2 = Shop.doGetAreaDetail(_self.data.goods.goodsLeaderCity2)
|
|
const list = [sort, type, city1, city2]
|
|
Promise.all(list)
|
|
.then(res => {
|
|
wx.hideLoading()
|
|
if (res && res.length > 0) {
|
|
const tempList = []
|
|
res[0].forEach(item => {
|
|
if (_self.data.goods.goodsType.indexOf(item.dataId) != -1) {
|
|
tempList.push(item)
|
|
}
|
|
})
|
|
_self.setData({
|
|
typeNameList: tempList,
|
|
cardTypeName: res[1].dataName,
|
|
cityName: res[2].areaName + '/' + res[3].areaName
|
|
})
|
|
}
|
|
})
|
|
.catch(err => {
|
|
console.log(err)
|
|
wx.hideLoading()
|
|
})
|
|
},
|
|
doPreImg(e) {
|
|
wx.previewImage({
|
|
urls: [e.currentTarget.dataset.value],
|
|
})
|
|
},
|
|
backPageRefresh() {
|
|
let pages = getCurrentPages();
|
|
let beforePage = pages[pages.length - 2];
|
|
beforePage.setData({
|
|
needRefresh: true
|
|
})
|
|
wx.navigateBack()
|
|
},
|
|
//提交审核
|
|
doCheck() {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '确定要将该软著商品提交审核吗?',
|
|
complete: (res) => {
|
|
if (res.confirm) {
|
|
this.goCheck()
|
|
}
|
|
}
|
|
})
|
|
},
|
|
//去审核
|
|
goCheck() {
|
|
wx.showLoading({
|
|
title: '提交中...',
|
|
})
|
|
const _self = this
|
|
Shop.doSubCheck(_self.data.goodsId)
|
|
.then(res => {
|
|
wx.hideLoading()
|
|
_self.setData({
|
|
msgHint: '提交成功',
|
|
msgType: 'success',
|
|
msgShow: true
|
|
})
|
|
_self.upPageNeedRefresh()
|
|
_self.doGetGoodsDetail()
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading()
|
|
_self.setData({
|
|
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
|
msgType: 'error',
|
|
msgShow: true
|
|
})
|
|
})
|
|
},
|
|
//去编辑
|
|
doEdit() {
|
|
const _self = this
|
|
wx.navigateTo({
|
|
url: '/pages/shop/publishCopyright/publishCopyright?id=' + _self.data.goodsId,
|
|
})
|
|
},
|
|
//删除
|
|
doDel() {
|
|
wx.showModal({
|
|
title: '警告',
|
|
content: '您确定要删除该软著商品吗?',
|
|
complete: (res) => {
|
|
if (res.confirm) {
|
|
this.goDel()
|
|
}
|
|
}
|
|
})
|
|
},
|
|
//删除
|
|
goDel() {
|
|
wx.showLoading({
|
|
title: '删除中...',
|
|
})
|
|
const _self = this
|
|
Shop.doDelGoods(_self.data.goodsId)
|
|
.then(res => {
|
|
wx.hideLoading()
|
|
_self.setData({
|
|
msgHint: '删除成功',
|
|
msgType: 'success',
|
|
msgShow: true
|
|
})
|
|
setTimeout(() => {
|
|
_self.backPageRefresh()
|
|
}, 1200);
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading()
|
|
_self.setData({
|
|
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
|
msgType: 'error',
|
|
msgShow: true
|
|
})
|
|
})
|
|
},
|
|
//上架或下架
|
|
doSale() {
|
|
var content
|
|
var status = 'publish'
|
|
if (this.data.goods.goodsStatus == '1') {
|
|
//下架
|
|
content = '您确定要下架该软著商品吗?'
|
|
status = 'no-publish'
|
|
} else if (this.data.goods.goodsStatus == '0') {
|
|
//上架
|
|
content = '您确定要上架该软著商品吗?'
|
|
status = 'publish'
|
|
}
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: content,
|
|
complete: (res) => {
|
|
if (res.confirm) {
|
|
this.goSale(status)
|
|
}
|
|
}
|
|
})
|
|
},
|
|
//上下架
|
|
goSale(status) {
|
|
wx.showLoading({
|
|
title: '操作中...',
|
|
})
|
|
const _self = this
|
|
Shop.doSaleGoods(status, _self.data.goodsId)
|
|
.then(res => {
|
|
wx.hideLoading()
|
|
_self.setData({
|
|
msgHint: '操作成功',
|
|
msgType: 'success',
|
|
msgShow: true
|
|
})
|
|
_self.upPageNeedRefresh()
|
|
_self.doGetGoodsDetail()
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading()
|
|
_self.setData({
|
|
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
|
msgType: 'error',
|
|
msgShow: true
|
|
})
|
|
})
|
|
},
|
|
upPageNeedRefresh() {
|
|
let pages = getCurrentPages();
|
|
let beforePage = pages[pages.length - 2];
|
|
beforePage.setData({
|
|
needRefresh: true
|
|
})
|
|
}
|
|
}) |