|
@@ -38,11 +38,7 @@
|
|
|
<div v-else @click="getaddress" class="kong clear">添加地址</div>
|
|
|
<div class="product-footer clear">
|
|
|
<div class="fl">
|
|
|
- <input-number
|
|
|
- :numb="num || goodsNum"
|
|
|
- :max="stock"
|
|
|
- @backNum="backNum"
|
|
|
- />
|
|
|
+ <input-number :numb="num" :max="stock" @backNum="backNum" />
|
|
|
</div>
|
|
|
<van-button
|
|
|
type="info"
|
|
@@ -58,46 +54,46 @@
|
|
|
|
|
|
<script>
|
|
|
import { Dialog } from "vant";
|
|
|
-import { mapGetters } from "vuex";
|
|
|
import resToken from "@/mixins/resToken";
|
|
|
import asyncRequest from "@/apis/product/index";
|
|
|
+import { getGoodsUnit, getGoodsNum, getAd } from "@/utils/auth";
|
|
|
export default {
|
|
|
mixins: [resToken],
|
|
|
- computed: {
|
|
|
- ...mapGetters(["ad", "goodsNum", "goodsUnit"]),
|
|
|
- },
|
|
|
data() {
|
|
|
return {
|
|
|
- num: this.goodsNum,
|
|
|
+ num: 0,
|
|
|
total: 0,
|
|
|
- radioV: "1",
|
|
|
+ radioV: "",
|
|
|
address: [],
|
|
|
unitist: [],
|
|
|
productList: [],
|
|
|
stock: 0,
|
|
|
+ ad: null,
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
+ this.ad = getAd() ? JSON.parse(getAd()) : {};
|
|
|
+ this.num = isNaN(getGoodsNum()) ? 0 : parseInt(getGoodsNum());
|
|
|
if (this.ad && this.ad.id) {
|
|
|
this.initData(this.ad.id);
|
|
|
}
|
|
|
- this.getUnitist();
|
|
|
this.getStock();
|
|
|
+
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
changePitem(index) {
|
|
|
this.radioV = this.productList[index].id;
|
|
|
this.stock = this.productList[index].stock;
|
|
|
+
|
|
|
if (this.num > this.stock) {
|
|
|
this.num = this.stock;
|
|
|
}
|
|
|
},
|
|
|
async getaddress() {
|
|
|
- let numRes = await this.set_user_goodsNum(this.num || this.goodsNum);
|
|
|
- let unitRes = await this.set_user_goodsUnit(
|
|
|
- this.radioV || this.goodsUnit
|
|
|
- );
|
|
|
+ let numRes = await this.set_user_goodsNum(this.num);
|
|
|
+ console.log("保存时单位:" + this.radioV);
|
|
|
+ let unitRes = await this.set_user_goodsUnit(this.radioV);
|
|
|
if (numRes && numRes.code === 0 && unitRes && unitRes.code === 0) {
|
|
|
window.vm.$router.push({
|
|
|
path: "/address",
|
|
@@ -112,12 +108,11 @@ export default {
|
|
|
let res = await asyncRequest.get_stock({});
|
|
|
if (res && res.code == 0) {
|
|
|
this.total = parseInt(res.data.stock);
|
|
|
- this.distributeGoods();
|
|
|
+ await this.getUnitist();
|
|
|
} else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
await this.logout();
|
|
|
} else {
|
|
|
this.total = 0;
|
|
|
- // this.show_title("获取个人信息失败!");
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -148,9 +143,10 @@ export default {
|
|
|
};
|
|
|
this.productList.push(item);
|
|
|
});
|
|
|
- let index = this.productList.findIndex(v1 => {
|
|
|
- return v1.id == this.goodsUnit+"";
|
|
|
+ let index = this.productList.findIndex((v1) => {
|
|
|
+ return v1.id == getGoodsUnit() + "";
|
|
|
});
|
|
|
+
|
|
|
this.changePitem(index === -1 ? 0 : index);
|
|
|
}
|
|
|
},
|
|
@@ -160,9 +156,9 @@ export default {
|
|
|
} else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
await this.logout();
|
|
|
} else {
|
|
|
- this.$store.dispatch("user/set_ad", {}).then((res) => {
|
|
|
- });
|
|
|
+ this.$store.dispatch("user/set_ad", {}).then((res) => {});
|
|
|
}
|
|
|
+ console.log(11);
|
|
|
},
|
|
|
backNum(e) {
|
|
|
this.num = e;
|
|
@@ -170,7 +166,7 @@ export default {
|
|
|
async placeOrder() {
|
|
|
if (!this.loading) {
|
|
|
if (this.ad && this.ad.id) {
|
|
|
- this.num = this.num || this.goodsNum;
|
|
|
+ this.num = this.num;
|
|
|
if (isNaN(this.num)) {
|
|
|
this.num = 0;
|
|
|
}
|
|
@@ -378,5 +374,4 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
</style>
|