diff --git a/dataModels/ThreadModel.js b/dataModels/ThreadModel.js index 6e40003f7..547aba9ed 100644 --- a/dataModels/ThreadModel.js +++ b/dataModels/ThreadModel.js @@ -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, diff --git a/pages/shop/manage/goods/goods.pug b/pages/shop/manage/goods/goods.pug index ef4bf5375..dca5d94d5 100644 --- a/pages/shop/manage/goods/goods.pug +++ b/pages/shop/manage/goods/goods.pug @@ -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 @@ -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}')`) 停售 diff --git a/pages/shop/manage/shelf/shelf.js b/pages/shop/manage/shelf/shelf.js index 399ef4de1..6861169b7 100644 --- a/pages/shop/manage/shelf/shelf.js +++ b/pages/shop/manage/shelf/shelf.js @@ -1,6 +1,6 @@ const data = NKC.methods.getDataById("data"); -const {grades, dealInfo, product} = data; +const {grades, dealInfo, product,selectForumsInfo=[]} = data; const vipDisGroupObj = {}; @@ -49,6 +49,7 @@ window.app = new Vue({ data: { type: product? "modify": "create", // 新上架:create, 编辑:modify + productStatus: product ? product.productStatus : '', submitting: false, @@ -56,14 +57,14 @@ window.app = new Vue({ // 提供选择的交易板块 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: ["", "", "", "", ""], @@ -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(); @@ -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 "请选择商品辅助分类"; @@ -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); + } + }, } }); diff --git a/pages/shop/manage/shelf/shelf.pug b/pages/shop/manage/shelf/shelf.pug index 45ae266d5..349557bb4 100644 --- a/pages/shop/manage/shelf/shelf.pug +++ b/pages/shop/manage/shelf/shelf.pug @@ -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 @@ -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 其他信息 @@ -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 diff --git a/routes/shop/manage/shelf.js b/routes/shop/manage/shelf.js index 2938d4873..e25f0be39 100644 --- a/routes/shop/manage/shelf.js +++ b/routes/shop/manage/shelf.js @@ -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 { @@ -80,7 +84,7 @@ shelfRouter } } - if (!product) { + if (!product || (product && product.productStatus === 'notonshelf')) { // 验证商品文字信息 checkString(productName, { name: '商品标题', @@ -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(); /*