Преглед изворни кода

库存状态判断的优化

shish пре 6 година
родитељ
комит
dd7a4e2c02

+ 4 - 2
mall/src/pages/goods/components/buy-foot.vue

@@ -14,14 +14,16 @@
             </div>
         </div>
         <div class="btn-right">
-            <button class="button-com red" @click="buy">立即购买</button>
+            <button v-if="stock == 0" class="button-com default" @click="buy">已售完</button>
+            <button v-else class="button-com red" @click="buy">立即购买</button>
         </div>
     </div>
 </template>
 
 <script>
 export default {
-	name: 'buy-foot',
+    name: 'buy-foot',
+    props:['stock'],
 	methods: {
 		buy() {
 			this.$emit('buy')

+ 255 - 239
mall/src/pages/goods/detail.vue

@@ -1,248 +1,264 @@
 <template>
-	<div class="app-content">
-		<app-swiper :height="{type: 'number',val: 750}" :tagShow="true" :list="imgList" />
-		<!-- 商品简介 -->
-		<div class="shop-intro">
-			<div class="app-price app-bold">
-				<text>¥</text>
-				<text class="app-size-34">{{ data.price }}</text>
-				<!-- <text>.00</text> -->
-			</div>
-			<div class="tui-pro-titbox">
-				<div class="tui-pro-title app-size-32">{{ data.goodsName }}</div>
-				<button open-type="share" class="tui-share-btn tui-share-position" @click="shareFn">
-					<app-tag type="gray" tui-tag-class="tui-tag-share tui-size" shape="circleLeft" size="small">
-						<div class="flex-center">
-							<i class="iconfont iconfenxiang"></i>
-							<text class="tui-share-text tui-gray">分享</text>
-						</div>
-					</app-tag>
-				</button>
-			</div>
-			<div class="shop-express app-color-3">
-				<div>{{ data.freeSendDist }}公里内免运费</div>
-				<div>
-					<span class="prompt-text">已售</span>
-					<span>{{ data.sold }}</span>
-				</div>
-				<div>
-					<span class="prompt-text">剩余</span>
-					<span>{{ data.stock }}</span>
-				</div>
-			</div>
-		</div>
-		<!-- 商品简介 -->
-		<!-- 商品详情 -->
-		<div class="module-wrap shop-detail">
-			<div class="module-tit app-size-30">商品详情</div>
-			<div class="module-det">
-				<!-- <app-img :src="imgNormal" alt mode="widthFix" /> -->
-				<div class="module-det-text" v-html="data.content"></div>
-			</div>
-		</div>
-		<!-- 商品详情 -->
-		<!-- 简要说明 -->
-		<div class="module-wrap shop-desc">
-			<div class="module-tit app-size-30">简要说明</div>
-			<div class="module-det">
-				<div class="module-det-text">{{ data.commonIntro }}</div>
-			</div>
-		</div>
-		<!-- 简要说明 -->
-		<app-trademark />
-		<sel-popup :show="popupShow" :info="data" :buyNum="buyNum" @change="changeNum" @close="hidePopup" />
-		<buy-foot @buy="showPopup" />
-		<!-- login -->
-		<go-login :show.sync="loginShow" />
-		<!-- 分享 -->
-		<app-share-mask :show="showShare" text="即可分享商品" @click="hideShare" />
-	</div>
+  <div class="app-content">
+    <app-swiper :height="{type: 'number',val: 750}" :tagShow="true" :list="imgList" />
+    <!-- 商品简介 -->
+    <div class="shop-intro">
+      <div class="app-price app-bold">
+        <text>¥</text>
+        <text class="app-size-34">{{ data.price }}</text>
+        <!-- <text>.00</text> -->
+      </div>
+      <div class="tui-pro-titbox">
+        <div class="tui-pro-title app-size-32">{{ data.goodsName }}</div>
+        <button open-type="share" class="tui-share-btn tui-share-position" @click="shareFn">
+          <app-tag
+            type="gray"
+            tui-tag-class="tui-tag-share tui-size"
+            shape="circleLeft"
+            size="small"
+          >
+            <div class="flex-center">
+              <i class="iconfont iconfenxiang"></i>
+              <text class="tui-share-text tui-gray">分享</text>
+            </div>
+          </app-tag>
+        </button>
+      </div>
+      <div class="shop-express app-color-3">
+        <div>{{ data.freeSendDist }}公里内免运费</div>
+        <div>
+          <span class="prompt-text">已售</span>
+          <span>{{ data.sold }}</span>
+        </div>
+        <div>
+          <template v-if="data.stock != -1">
+            <span class="prompt-text">剩余</span>
+            <span>{{ data.stock }}</span>
+          </template>
+          <template v-else></template>
+        </div>
+      </div>
+    </div>
+    <!-- 商品简介 -->
+    <!-- 商品详情 -->
+    <div class="module-wrap shop-detail">
+      <div class="module-tit app-size-30">商品详情</div>
+      <div class="module-det">
+        <!-- <app-img :src="imgNormal" alt mode="widthFix" /> -->
+        <div class="module-det-text" v-html="data.content"></div>
+      </div>
+    </div>
+    <!-- 商品详情 -->
+    <!-- 简要说明 -->
+    <div class="module-wrap shop-desc">
+      <div class="module-tit app-size-30">简要说明</div>
+      <div class="module-det">
+        <div class="module-det-text">{{ data.commonIntro }}</div>
+      </div>
+    </div>
+    <!-- 简要说明 -->
+    <app-trademark />
+    <sel-popup
+      :show="popupShow"
+      :info="data"
+      :buyNum="buyNum"
+      @change="changeNum"
+      @close="hidePopup"
+    />
+    <buy-foot @buy="showPopup" :stock="data.stock" />
+    <!-- login -->
+    <go-login :show.sync="loginShow" />
+    <!-- 分享 -->
+    <app-share-mask :show="showShare" text="即可分享商品" @click="hideShare" />
+  </div>
 </template>
 
 <script>
-	import AppImg from '@/components/app-img'
-	import AppSwiper from '@/components/app-swiper'
-	import AppTag from '@/components/module/app-tag.vue'
-	import AppTrademark from '@/components/module/app-trademark'
-	import BuyFoot from './components/buy-foot.vue'
-	import SelPopup from './components/sel-popup.vue'
-	import GoLogin from '@/pages/home/components/go-login.vue'
-	import AppShareMask from '@/components/module/app-share-mask'
-	import { share } from '@/mixins'
-	// api
-	import { getDetail } from '@/api/goods'
-	export default {
-		name: 'goods-detail',
-		mixins: [share],
-		components: {
-			AppSwiper,
-			AppTag,
-			AppTrademark,
-			BuyFoot,
-			SelPopup,
-			AppImg,
-			GoLogin,
-			AppShareMask
-		},
-		data() {
-			return {
-				data: {},
-				imgList: [],
-				buyNum: 1,
-				popupShow: false,
-				loginShow: false,
-				// share
-				showShare: false
-			}
-		},
-		onLoad(option) {},
-		mounted() {
-			// this.$util.getCheckLogin().then(res => {
-			// 	if (!res) return false
-			// this.init()
-			// })
-		},
-		computed: {
-			// imgNormal() {
-			// 	if (!this.$util.isEmpty(this.data)) {
-			// 		return this.data.imgList[0]
-			// 	} else {
-			// 		return ''
-			// 	}
-			// }
-		},
-		methods: {
-			init() {
-				// #ifdef H5
-				// 微信二次分享
-				let href = window.location.href
-				if (href.indexOf('from=singlemessage') > 0) {
-					location.href = `${this.$constant.formal}/#/pages/interest/invite${this.$util.parse(this.option)}`
-					return false
-				}
-				// #endif
+import AppImg from "@/components/app-img";
+import AppSwiper from "@/components/app-swiper";
+import AppTag from "@/components/module/app-tag.vue";
+import AppTrademark from "@/components/module/app-trademark";
+import BuyFoot from "./components/buy-foot.vue";
+import SelPopup from "./components/sel-popup.vue";
+import GoLogin from "@/pages/home/components/go-login.vue";
+import AppShareMask from "@/components/module/app-share-mask";
+import { share } from "@/mixins";
+// api
+import { getDetail } from "@/api/goods";
+export default {
+  name: "goods-detail",
+  mixins: [share],
+  components: {
+    AppSwiper,
+    AppTag,
+    AppTrademark,
+    BuyFoot,
+    SelPopup,
+    AppImg,
+    GoLogin,
+    AppShareMask
+  },
+  data() {
+    return {
+      data: {},
+      imgList: [],
+      buyNum: 1,
+      popupShow: false,
+      loginShow: false,
+      // share
+      showShare: false
+    };
+  },
+  onLoad(option) {},
+  mounted() {
+    // this.$util.getCheckLogin().then(res => {
+    // 	if (!res) return false
+    // this.init()
+    // })
+  },
+  computed: {
+    // imgNormal() {
+    // 	if (!this.$util.isEmpty(this.data)) {
+    // 		return this.data.imgList[0]
+    // 	} else {
+    // 		return ''
+    // 	}
+    // }
+  },
+  methods: {
+    init() {
+      // #ifdef H5
+      // 微信二次分享
+      let href = window.location.href;
+      if (href.indexOf("from=singlemessage") > 0) {
+        location.href = `${
+          this.$constant.formal
+        }/#/pages/interest/invite${this.$util.parse(this.option)}`;
+        return false;
+      }
+      // #endif
 
-				this._getDetail().then(() => {
-					// 设置分享
-					let shareParams = {
-						title: `${this.data.goodsName}`, // 分享标题
-						desc: '这束花不错推荐给你', // 分享内容
-						imgUrl: this.data.smallImgList[0],
-						// #ifdef H5
-						pagePath: `${window.location.protocol}//mall.${this.$constant.firstHost}.com/#/pages/goods/detail?id=${this.data.id}`,
-						// #endif
-						// #ifndef H5
-						pagePath: `/pages/goods/detail?id=${this.data.id}`
-						// #endif
-					}
-					this.jweixinFn(shareParams)
-				})
-			},
-			async _getDetail() {
-				await getDetail({ id: this.option.id }).then(res => {
-					if (this.$util.isEmpty(res.data)) return false
-					let newArr = []
-					for (let i in res.data.imgList) {
-						newArr.push({
-							img: res.data.imgList[i]
-						})
-					}
-					this.imgList = newArr
-					// 格式化数据
-					let goodsStyleList = []
-					for (let i in res.data.goodsStyleList) {
-						goodsStyleList.push(res.data.goodsStyleList[i])
-					}
-					res.data.stock = res.data.stock ? parseInt(res.data.stock) : 0
-					res.data.goodsStyleList = goodsStyleList
-					
-					this.data = res.data
-				})
-			},
-			// 更换数量
-			changeNum(e) {
-				this.buyNum = e.value
-			},
-			showPopup() {
-				if (this.$util.isLogin()) {
-					this.popupShow = true
-				} else {
-					this.loginShow = true
-				}
-			},
-			hidePopup() {
-				this.popupShow = false
-			},
-			// 分享
-			shareFn() {
-				console.log('asdfasdf')
-				this.showShare = true
-			},
-			hideShare() {
-				this.showShare = false
-			}
-		}
-	}
+      this._getDetail().then(() => {
+        // 设置分享
+        let shareParams = {
+          title: `${this.data.goodsName}`, // 分享标题
+          desc: "这束花不错推荐给你", // 分享内容
+          imgUrl: this.data.smallImgList[0],
+          // #ifdef H5
+          pagePath: `${window.location.protocol}//mall.${this.$constant.firstHost}.com/#/pages/goods/detail?id=${this.data.id}`,
+          // #endif
+          // #ifndef H5
+          pagePath: `/pages/goods/detail?id=${this.data.id}`
+          // #endif
+        };
+        this.jweixinFn(shareParams);
+      });
+    },
+    async _getDetail() {
+      await getDetail({ id: this.option.id }).then(res => {
+        if (this.$util.isEmpty(res.data)) return false;
+        let newArr = [];
+        for (let i in res.data.imgList) {
+          newArr.push({
+            img: res.data.imgList[i]
+          });
+        }
+        this.imgList = newArr;
+        // 格式化数据
+        let goodsStyleList = [];
+        for (let i in res.data.goodsStyleList) {
+          goodsStyleList.push(res.data.goodsStyleList[i]);
+        }
+        res.data.stock = res.data.stock ? parseInt(res.data.stock) : 0;
+        res.data.goodsStyleList = goodsStyleList;
+
+        this.data = res.data;
+      });
+    },
+    // 更换数量
+    changeNum(e) {
+      this.buyNum = e.value;
+    },
+    showPopup() {
+      if (this.$util.isLogin()) {
+        this.popupShow = true;
+      } else {
+        this.loginShow = true;
+      }
+    },
+    hidePopup() {
+      this.popupShow = false;
+    },
+    // 分享
+    shareFn() {
+      console.log("asdfasdf");
+      this.showShare = true;
+    },
+    hideShare() {
+      this.showShare = false;
+    }
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-	.app-content {
-		padding-bottom: 120px;
-		// 公共模块
-		.module-wrap {
-			margin-top: 20px;
-			background-color: #fff;
-			.module-tit {
-				padding: 14px 24px;
-				border-bottom: 1px solid $borderColor;
-			}
-			.module-det {
-				color: $fontColor2;
-				.module-det-text {
-					padding: 24px;
-				}
-			}
-		}
-		// 公共模块
-		.shop-intro {
-			background: #fff;
-			padding: 30px 0 30px 30px;
-			.tui-pro-titbox {
-				margin: 30px 0 20px;
-				@include disFlex(center, space-between);
-				.tui-pro-title {
-					width: 80%;
-				}
-				.tui-share-btn {
-					display: block;
-					background: none;
-					margin: 0;
-					padding: 0;
-					border-radius: 0;
-					.tui-share-text {
-						padding-left: 4px;
-						color: $fontColor3;
-					}
-				}
-				.iconfenxiang {
-					font-size: 26px;
-					color: $fontColor3;
-					margin-right: 6px;
-				}
-			}
-			.shop-express {
-				padding-right: 30px;
-				@include disFlex(center, space-between);
-				.prompt-text {
-					margin-right: 4px;
-				}
-			}
-		}
-		.shop-desc {
-			.module-det {
-				// padding: 24px;
-				line-height: 48px;
-			}
-		}
-	}
+.app-content {
+  padding-bottom: 120px;
+  // 公共模块
+  .module-wrap {
+    margin-top: 20px;
+    background-color: #fff;
+    .module-tit {
+      padding: 14px 24px;
+      border-bottom: 1px solid $borderColor;
+    }
+    .module-det {
+      color: $fontColor2;
+      .module-det-text {
+        padding: 24px;
+      }
+    }
+  }
+  // 公共模块
+  .shop-intro {
+    background: #fff;
+    padding: 30px 0 30px 30px;
+    .tui-pro-titbox {
+      margin: 30px 0 20px;
+      @include disFlex(center, space-between);
+      .tui-pro-title {
+        width: 80%;
+      }
+      .tui-share-btn {
+        display: block;
+        background: none;
+        margin: 0;
+        padding: 0;
+        border-radius: 0;
+        .tui-share-text {
+          padding-left: 4px;
+          color: $fontColor3;
+        }
+      }
+      .iconfenxiang {
+        font-size: 26px;
+        color: $fontColor3;
+        margin-right: 6px;
+      }
+    }
+    .shop-express {
+      padding-right: 30px;
+      @include disFlex(center, space-between);
+      .prompt-text {
+        margin-right: 4px;
+      }
+    }
+  }
+  .shop-desc {
+    .module-det {
+      // padding: 24px;
+      line-height: 48px;
+    }
+  }
+}
 </style>

+ 14 - 13
shop/src/views/goods/goods-add.vue

@@ -3,13 +3,13 @@
 		<div class="form-wrap">
 			<el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="120px">
 				<el-form-item label="名称" prop="goodsName">
-					<el-input v-model="ruleForm.goodsName"></el-input>
+					<el-input v-model="ruleForm.goodsName" placeholder="请填写商品名称"></el-input>
 				</el-form-item>
 				<el-form-item label="已售" prop="sold">
-					<el-input v-model="ruleForm.sold"></el-input>
+					<el-input v-model="ruleForm.sold" placeholder="自定义已售数量,留空表示还没有售出"></el-input>
 				</el-form-item>
 				<el-form-item label="库存" prop="stock">
-					<el-input v-model="ruleForm.stock"></el-input>
+					<el-input v-model="ruleForm.stock" placeholder="请填写库存,留空表示库存充足"></el-input>
 				</el-form-item>
 				<el-form-item label="分类" prop="categoryIdList">
 					<el-checkbox-group v-model="ruleForm.categoryIdList">
@@ -105,7 +105,7 @@
 							<span>按距离收费</span>
 						</el-radio>
 						<el-popover placement="top" width="100" trigger="hover" v-model="chargePopover">
-							<p>{{ shopInfo.extend.freeDistance }}公里内免运费,超过每加1公里运费加{{shopInfo.extend.freight}}元</p>
+							<p>{{ shopInfo.extend.freeDistance }}公里内免运费,超过每加1公里运费加{{shopInfo.extend.freight}}元</p>
 							<div style="text-align: right; margin-top: 10px">
 								<el-button size="mini" type="primary" @click="$util.pageTo({url: '/goods/freight'})">修改</el-button>
 							</div>
@@ -118,8 +118,8 @@
 					</el-radio-group>
 				</el-form-item>
 				<el-form-item>
-					<el-button type="primary" @click="submitForm('ruleForm', 1)">上架出售</el-button>
-					<el-button @click="submitForm('ruleForm', 0)">加入仓库</el-button>
+					<el-button type="primary" @click="submitForm('ruleForm', 1)">上架</el-button>
+					<el-button @click="submitForm('ruleForm', 0)">保存</el-button>
 				</el-form-item>
 			</el-form>
 		</div>
@@ -211,14 +211,11 @@ export default {
 			},
 
 			rules: {
-				goodsName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
+				goodsName: [{ required: true, message: '请填写名称', trigger: 'blur' }],
 				categoryIdList: [{ required: true, message: '请选择分类', trigger: 'blur' }],
-				stock: [{ required: true, message: '必填', trigger: 'blur' }],
-				price: [{ required: true, message: '必填', trigger: 'blur' }],
-				sold: [{ required: true, message: '必填', trigger: 'blur' }],
-				goodsStyle: [{ required: true, message: '必填', trigger: 'blur' }],
-				shopImg: [{ required: true, message: '必填', trigger: 'blur' }],
-				content: [{ required: true, message: '必填', trigger: 'blur' }]
+				price: [{ required: true, message: '请填写价格', trigger: 'blur' }],
+				goodsStyle: [{ required: true, message: '请选择款式', trigger: 'blur' }],
+				shopImg: [{ required: true, message: '请上传图片', trigger: 'blur' }],
 			},
 			// 图片展示
 			fileList_show: [],
@@ -263,6 +260,10 @@ export default {
 			if (this.pageParams.editType == '2') {
 				this.$service.goods.info({ id: this.pageParams.id }).then(res => {
 					this.ruleForm = res;
+					//库存 -1表示充足,页面展示用空表示
+					if(this.ruleForm.stock == -1){
+						this.ruleForm.stock = ''
+					}
 					this.fliterData(res);
 					console.log(this.ruleForm);
 				});

+ 2 - 2
shop/src/views/home.vue

@@ -460,7 +460,7 @@ export default {
 	.entry-wrap {
 		.entry-list-wrap {
 			@include disFlex(center, space-between);
-			padding: 0 32px;
+			padding: 0 40px;
 			color: $fontColor2;
 			.list {
 				text-align: center;
@@ -483,7 +483,7 @@ export default {
 	.all-total-wrap {
 		.all-total-list-wrap {
 			@include disFlex(center, space-between);
-			padding: 0 20px;
+			padding: 0 40px;
 			color: $fontColor2;
 			.list {
 				text-align: center;

+ 6 - 0
shop/src/views/staff/role-list.vue

@@ -85,6 +85,10 @@ export default {
 	methods: {
 		// api
 		delBtnFn(item) {
+
+			this.$message.success('即将开通...')
+			return false
+
 			this.$confirm('是否删除该角色?', '提示', {
 				confirmButtonText: '确定',
 				cancelButtonText: '取消',
@@ -100,6 +104,8 @@ export default {
 		},
 		// operate
 		authBtnFn(item) {
+			this.$message.success('即将开通...')
+			return false
 			this.modifyData = item;
 			this.roleShow = true;
 		},

+ 18 - 2
store/src/admin/goodsManage/add.vue

@@ -24,7 +24,7 @@
 					</div>
 				</tui-list-cell>
 				<tui-list-cell class="line-cell" :hover="false">
-					<div class="tui-title">价格</div>
+					<div class="tui-title required">价格</div>
 					<input v-model="form.price" placeholder-class="phcolor" class="tui-input" name="price" placeholder="请输入" maxlength="50" type="number" />
 					<div class="tui-prompt">元</div>
 				</tui-list-cell>
@@ -81,7 +81,7 @@
 			</div>
 			<!-- button -->
 			<div class="app-footer">
-				<button class="admin-button-com middle default" formType="submit" @click="status = 1">上架出售</button>
+				<button class="admin-button-com middle default" formType="submit" @click="status = 1">上架</button>
 				<button class="admin-button-com middle blue" formType="submit" @click="status = 0">加入仓库</button>
 			</div>
 		</form>
@@ -145,6 +145,17 @@ export default {
 		},
 		// 确认
 		confirmFn() {
+
+			if(this.form.categoryIdList == 0){
+				this.$msg('请选择分类')
+				return false
+			}
+
+			if(this.form.shopImg.length == 0){
+				this.$msg('请上传图片')
+				return false
+			}
+
 			let host = this.option.id ? updateB : addB
 			let form = JSON.parse(JSON.stringify(this.form))
 			form.shopImg = this.$util.imgSubstr(form.shopImg)
@@ -182,6 +193,11 @@ export default {
 					name: 'goodsName',
 					rule: ['required'],
 					msg: ['请输入商品名']
+				},
+				{
+					name: 'price',
+					rule: ['required'],
+					msg: ['请输入价格']
 				}
 			]
 			// 进行表单检查