|
@@ -9,19 +9,17 @@
|
|
|
<span>藏金</span><span>.</span><span>1745产品</span>
|
|
|
</div>
|
|
|
<ul class="productPack clear">
|
|
|
- <li
|
|
|
- @click="changePitem(index)"
|
|
|
- v-for="(item, index) in productList"
|
|
|
- :key="item.id"
|
|
|
- >
|
|
|
+ <!-- @click="changePitem(index)" -->
|
|
|
+ <li v-for="(item, index) in productList" :key="item.id">
|
|
|
<div class="box" :class="{ selected: item.id == radioV }">
|
|
|
<img :src="item.img" alt="" />
|
|
|
<p>{{ item.name }}</p>
|
|
|
<span
|
|
|
- >可用库存:{{ item.stock }}{{ item.unit }}/{{
|
|
|
- item.weight
|
|
|
- }}kg</span
|
|
|
- >
|
|
|
+ v-if="
|
|
|
+ (index === 0 && admin === '1') || (index === 1 && admin === '2')
|
|
|
+ "
|
|
|
+ >可用库存:{{ item.stock }}份</span
|
|
|
+ ><span v-else> </span>
|
|
|
</div>
|
|
|
</li>
|
|
|
</ul>
|
|
@@ -59,7 +57,7 @@
|
|
|
import { Dialog } from "vant";
|
|
|
import resToken from "@/mixins/resToken";
|
|
|
import asyncRequest from "@/apis/product/index";
|
|
|
-import { getGoodsUnit, getGoodsNum, getAd } from "@/utils/auth";
|
|
|
+import { getGoodsNum, getAd, getAdmin } from "@/utils/auth";
|
|
|
export default {
|
|
|
mixins: [resToken],
|
|
|
data() {
|
|
@@ -79,11 +77,13 @@ export default {
|
|
|
canStockBox: "",
|
|
|
canStockBag: "",
|
|
|
isce: "",
|
|
|
+ admin: "",
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
this.ad = getAd() ? JSON.parse(getAd()) : {};
|
|
|
this.num = isNaN(getGoodsNum()) ? 0 : parseInt(getGoodsNum());
|
|
|
+ this.admin = getAdmin();
|
|
|
if (this.ad && this.ad.id) {
|
|
|
this.initData(this.ad.id);
|
|
|
} else {
|
|
@@ -93,14 +93,14 @@ export default {
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
- changePitem(index) {
|
|
|
- this.radioV = this.productList[index].id;
|
|
|
- this.stock = this.productList[index].stock;
|
|
|
+ // changePitem(index) {
|
|
|
+ // this.radioV = this.productList[index].id;
|
|
|
+ // this.stock = this.productList[index].stock;
|
|
|
|
|
|
- if (this.num > this.stock) {
|
|
|
- this.num = this.stock;
|
|
|
- }
|
|
|
- },
|
|
|
+ // if (this.num > this.stock) {
|
|
|
+ // this.num = this.stock;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
async getaddress() {
|
|
|
let numRes = await this.set_user_goodsNum(this.num);
|
|
|
let unitRes = await this.set_user_goodsUnit(this.radioV);
|
|
@@ -117,14 +117,8 @@ export default {
|
|
|
if (!this.loading) {
|
|
|
let res = await asyncRequest.get_stock({});
|
|
|
if (res && res.code == 0) {
|
|
|
- let { limit, stock } = res.data;
|
|
|
- if (!(limit && limit.length > 0)) {
|
|
|
- limit = [];
|
|
|
- }
|
|
|
- this.canStockBag = res.data.stock;
|
|
|
- this.canStockBox = res.data.stock;
|
|
|
-
|
|
|
- this.distributeGoods(limit);
|
|
|
+ let { stock } = res.data;
|
|
|
+ this.distributeGoods(stock);
|
|
|
// await this.getUnitist(limit);
|
|
|
this.total = parseInt(stock + "");
|
|
|
} else if (res && res.code >= 100 && res.code <= 104) {
|
|
@@ -147,25 +141,24 @@ export default {
|
|
|
// }
|
|
|
// }
|
|
|
// },
|
|
|
- distributeGoods(list) {
|
|
|
- if (list.length > 0) {
|
|
|
- this.productList = [];
|
|
|
- list.forEach((v1) => {
|
|
|
- let item = {
|
|
|
- id: v1.id,
|
|
|
- name: v1.id === "1" ? "藏金·1745-实惠装" : "藏金·1745-礼盒装",
|
|
|
- img: require(`@/assets/images/product/unit${v1.id}.png`),
|
|
|
- stock: parseInt(v1.limit_num + ""),
|
|
|
- weight: v1.weight,
|
|
|
- unit: v1.name,
|
|
|
- };
|
|
|
- this.productList.push(item);
|
|
|
- });
|
|
|
- let index = this.productList.findIndex((v1) => {
|
|
|
- return v1.id == getGoodsUnit() + "";
|
|
|
- });
|
|
|
-
|
|
|
- this.changePitem(index === -1 ? 0 : index);
|
|
|
+ distributeGoods(stock) {
|
|
|
+ this.productList = [
|
|
|
+ {
|
|
|
+ name: "红运稻",
|
|
|
+ img: require(`@/assets/images/product/unit1.png`),
|
|
|
+ stock: 0,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "悦享泰康",
|
|
|
+ img: require(`@/assets/images/product/unit2.png`),
|
|
|
+ stock: 0,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ console.log(this.admin);
|
|
|
+ if (this.admin) {
|
|
|
+ this.productList[this.admin === "1" ? 0 : 1].stock = parseInt(
|
|
|
+ stock + ""
|
|
|
+ );
|
|
|
}
|
|
|
},
|
|
|
async initData(id) {
|
|
@@ -255,7 +248,7 @@ export default {
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
.product {
|
|
|
- background: #fcfcf0 !important;
|
|
|
+ background: #fff !important;
|
|
|
position: relative;
|
|
|
.bgImg {
|
|
|
width: 100%;
|
|
@@ -268,10 +261,10 @@ export default {
|
|
|
|
|
|
.product-baozhuang {
|
|
|
width: 100%;
|
|
|
- padding: 0 0 150px 0;
|
|
|
+ padding: 0 16px 150px 16px;
|
|
|
box-sizing: border-box;
|
|
|
position: absolute;
|
|
|
- top: 180px;
|
|
|
+ top: 145px;
|
|
|
left: 0;
|
|
|
.product-title {
|
|
|
font-size: 16px;
|
|
@@ -286,7 +279,7 @@ export default {
|
|
|
vertical-align: top;
|
|
|
&:nth-child(2) {
|
|
|
line-height: 33px;
|
|
|
- padding:0 0 0 2px;
|
|
|
+ padding: 0 0 0 2px;
|
|
|
font-size: 30px;
|
|
|
}
|
|
|
}
|
|
@@ -309,7 +302,7 @@ export default {
|
|
|
float: right;
|
|
|
}
|
|
|
.box {
|
|
|
- background: #e6e6dc;
|
|
|
+ background: #f5f5f5;
|
|
|
border-radius: 13px;
|
|
|
padding: 5px 5px 10px 5px;
|
|
|
img {
|
|
@@ -397,7 +390,7 @@ export default {
|
|
|
.product-footer {
|
|
|
position: fixed;
|
|
|
width: 100%;
|
|
|
- background: #e6e6dc;
|
|
|
+ background: #eee;
|
|
|
left: 0;
|
|
|
bottom: 50px;
|
|
|
z-index: 3;
|
|
@@ -408,8 +401,8 @@ export default {
|
|
|
color: #111111;
|
|
|
}
|
|
|
button {
|
|
|
- background: #e6e6dc;
|
|
|
- color: #292929;
|
|
|
+ background: #C42323;
|
|
|
+ color: #fff;
|
|
|
padding: 0;
|
|
|
border: 0px;
|
|
|
line-height: 56px;
|