Skip to content

Commit

Permalink
Merge pull request #991 from pxgo/master
Browse files Browse the repository at this point in the history
修复
  • Loading branch information
pxgo authored Nov 7, 2024
2 parents 62a0eb7 + 65ef0c6 commit cb31928
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dataModels/ThreadModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ threadSchema.methods.updateThreadMessage = async function (toSearch = true) {
const PostModel = mongoose.model('posts');
const updateObj = {};
const oc = await PostModel.findOneAndUpdate(
{ tid: thread.tid },
{ tid: thread.tid, type: 'thread' },
{
$set: {
reviewed: thread.reviewed,
Expand Down
10 changes: 8 additions & 2 deletions pages/shop/manage/goods/goods.pug
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ block shopContent
.order-cover
img(src=`/r/${product.imgMaster}`)
.order-name
a(href=`/shop/product/${product.productId}` title=product.name target="_blank")=product.name
if product.productStatus === 'notonshelf'
a(href=`/shop/manage/shelf?productId=${product.productId}` target="_blank")=product.name
else
a(href=`/shop/product/${product.productId}` title=product.name target="_blank")=product.name
.order-param=`上架时间:${format("YYYY/MM/DD HH:mm:ss", product.toc)}`
th
div.stocks-surplus=total
Expand All @@ -55,7 +58,10 @@ block shopContent
else
div 待上架
th.order-links
a(href=`/editor?type=modifyThread&id=${product.oc}` target="_blank") 修改商品信息
if product.productStatus === 'notonshelf'
a(href=`/shop/manage/shelf?productId=${product.productId}` target="_blank") 修改商品信息
else
a(href=`/editor?type=modifyThread&id=${product.oc}` target="_blank") 修改商品信息
a(href=`/shop/manage/shelf?productId=${product.productId}` target="_blank") 修改出售信息
if product.productStatus === "insale"
a.pointer(onclick=`stopSale('${product.productId}')`) 停售
Expand Down
28 changes: 19 additions & 9 deletions pages/shop/manage/shelf/shelf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const data = NKC.methods.getDataById("data");

const {grades, dealInfo, product} = data;
const {grades, dealInfo, product,selectForumsInfo=[]} = data;

const vipDisGroupObj = {};

Expand Down Expand Up @@ -49,21 +49,22 @@ window.app = new Vue({
data: {

type: product? "modify": "create", // 新上架:create, 编辑:modify
productStatus: product ? product.productStatus : '',

submitting: false,

showCloseInfo: true,

// 提供选择的交易板块
shopForums: data.shopForumTypes,
selectedShopForumId: "",
selectedShopForumId: product ? product.mainForumsId[0] : '',
// 辅助板块
mainForums: [],
mainForums: product ? selectForumsInfo.filter(item=>product.mainForumsId.slice(1).includes(item.fid)) : [],
// 商品标题、描述、关键词
title: "",
abstract: "",
content: "",
keywords: [],
title: product ? product.threadInfo.title :"",
abstract: product ? product.threadInfo.abstractCn :"",
content: product ? product.threadInfo.content : "",
keywords: product ? product.threadInfo.keyWordsCn : [],
// 商品介绍图
imgIntroductions: product? product.imgIntroductions: ["", "", "", "", ""],

Expand Down Expand Up @@ -132,6 +133,10 @@ window.app = new Vue({
// 编辑商品 预制内容
if(product) {

if(this.productStatus === 'notonshelf'){
window.CommonModal = new NKC.modules.CommonModal();
window.SelectForums = new NKC.modules.ForumSelector();
}
} else {
window.CommonModal = new NKC.modules.CommonModal();
window.SelectForums = new NKC.modules.ForumSelector();
Expand Down Expand Up @@ -187,7 +192,7 @@ window.app = new Vue({
Promise.resolve()
.then(() => {
self.submitting = true;
if(self.type === "create") {
if(self.type === "create" || self.productStatus === 'notonshelf') {
self.content = self.$refs.shopEditor.getContent();
if(!self.selectedShopForumId) throw "请选择商品分类";
// if(!self.mainForums.length) throw "请选择商品辅助分类";
Expand Down Expand Up @@ -523,7 +528,12 @@ window.app = new Vue({
self.addParam(self.newParam(name));
})
this.paramForum = false;
}
},
readyEditorCall() {
if (product && product.productStatus === 'notonshelf') {
this.$refs.shopEditor.setContent(product.threadInfo.content);
}
},
}
});

Expand Down
6 changes: 3 additions & 3 deletions pages/shop/manage/shelf/shelf.pug
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ block shopTitle
link(href='/bootstrap/css/bootstrap-datetimepicker.min.css' media="screen" rel='stylesheet')
block shopContent
#app(v-cloak).shop-shelf
div(v-if="type === 'create'")
div(v-if="type === 'create' || productStatus === 'notonshelf'")
.shop-header 基本信息
.form.form-horizontal.m-t-1
.form-group
Expand Down Expand Up @@ -44,7 +44,7 @@ block shopContent
.form-group
label.col-sm-2.control-label 图文描述
.col-sm-10
editor(:configs="editorConfigs" ref="shopEditor" :plugs="editorPlugs")
editor(:configs="editorConfigs" ref="shopEditor" :plugs="editorPlugs" @ready="readyEditorCall")
//script#container(name='content', type='text/plain')
.shop-header 其他信息
Expand Down Expand Up @@ -266,7 +266,7 @@ block shopContent
button.shop-btn.primary(v-if="!submitting" @click="save") 提交
button.shop-btn.disabled(v-else) 提交中..
.fa.fa-spinner.fa-spin.fa-fw
#data.hidden=objToStr({order: data.order, shopForumTypes: data.shopForumTypes, grades: data.grades, dealInfo: data.dealInfo, product: data.product})
#data.hidden=objToStr({order: data.order, shopForumTypes: data.shopForumTypes, grades: data.grades, dealInfo: data.dealInfo, product: data.product,selectForumsInfo:data.selectForumsInfo})
block shopScripts
include ../../../publicModules/commonModal/commonModal
include ../../../publicModules/forumSelector/forumSelector
Expand Down
31 changes: 30 additions & 1 deletion routes/shop/manage/shelf.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ shelfRouter
if (!product) {
ctx.throw(400, `商品不存在,productId: ${productId}`);
}
data.selectForumsInfo = await db.ForumModel.find(
{ fid: { $in: product.mainForumsId } },
{ fid: 1, color: 1, displayName: 1 },
);
data.product = (await db.ShopGoodsModel.extendProductsInfo([product]))[0];
data.navType = 'goods';
} else {
Expand Down Expand Up @@ -80,7 +84,7 @@ shelfRouter
}
}

if (!product) {
if (!product || (product && product.productStatus === 'notonshelf')) {
// 验证商品文字信息
checkString(productName, {
name: '商品标题',
Expand Down Expand Up @@ -416,6 +420,31 @@ shelfRouter
await db.ShopProductsParamModel(param).save();
}
}
if (product.productStatus === 'notonshelf') {
const options = {
title: productName,
abstractCn: productDescription,
keyWordsCn: attention,
content: productDetails,
uid: user.uid,
fids: mainForumsId,
cids: [],
ip: ctx.address,
type: 'product',
};
await db.ForumModel.checkGlobalPostAndForumWritePermission(
options.uid,
options.fids,
);
await db.ForumModel.checkForumCategoryBeforePost(options.fids);
await product.updateOne({
threadInfo: options,
mainForumsId,
});
if (productStatus === 'insale') {
await product.onshelf();
}
}
}
return await next();
/*
Expand Down

0 comments on commit cb31928

Please sign in to comment.