Authored by lea guo

求购

... ... @@ -16,12 +16,12 @@
type="number"
placeholder="定价需以9结尾 例如1999"
:maxlength="8"
class="ipt-number"
:class="errorTip ? 'ipt-number show-error' : 'ipt-number'"
v-model="chgPrice"
>
<span class="prepend" slot="prepend">¥</span>
</InputUfo>
<p class="error-tip">{{ this.errorTip }}</p>
<p class="error-tip">{{ errorTip }}</p>
<p
:class="
i === computePriceList.length - 1
... ... @@ -43,7 +43,7 @@ import { createNamespacedHelpers } from "vuex";
import InputUfo from "../price-change/components/input-ufo";
import { debounce } from "lodash";
const { mapActions } = createNamespacedHelpers("order/orderList");
const { mapActions, mapMutations } = createNamespacedHelpers("order/orderList");
export default {
components: { InputUfo },
props: {
... ... @@ -54,18 +54,24 @@ export default {
goodsInfo: {
type: Object,
default: () => ({})
},
orderCode: {
type: Number,
default: 0
}
},
data() {
return {
chgPrice: "",
errorTip: ""
errorTip: "",
computePrice: null
};
},
computed: {
computePriceList() {
return this.computePriceInfo.promotionFormulaList.filter(
const priceInfo = this.computePrice || this.computePriceInfo;
return priceInfo.promotionFormulaList.filter(
({ promotion }) => promotion === "运费" || promotion === "实付金额"
);
}
... ... @@ -76,9 +82,22 @@ export default {
},
methods: {
...mapActions(["computeChangePrice", "changePrice"]),
onChange(price) {
...mapMutations(["setChangePrice"]),
async onChange(price) {
if (this.checkPrice(price)) {
this.computeChangePrice(price);
const res = await this.computeChangePrice({
price,
orderCode: this.orderCode
});
if (typeof res === "string") {
this.errorTip = res;
this.setChangePrice(0);
} else {
this.computePrice = res;
this.setChangePrice(price);
}
} else {
this.setChangePrice(0);
}
},
checkPrice(price) {
... ... @@ -91,19 +110,8 @@ export default {
this.errorTip = "价格只能为正整数";
} else if (!/9$/.test(price)) {
this.errorTip = "出售价格必须以9结尾";
} else if (
this.goodsInfo.bidHighestPrice &&
price > this.goodsInfo.bidHighestPrice
) {
this.errorTip = "您的出价格过高";
} else if (+price === this.goodsInfo.goodPrice) {
} else if (+price === +this.goodsInfo.goodPrice) {
this.errorTip = "前后价格没有变化";
} else if (
this.goodsInfo.leastPrice &&
price > this.goodsInfo.leastPrice
) {
this.errorTip = "您的出价高于最低售价";
valid = true;
} else {
this.errorTip = "";
valid = true;
... ... @@ -128,6 +136,10 @@ export default {
.ipt-number {
margin: 30px 0;
&.show-error {
margin-bottom: 0;
}
}
.error-tip {
... ...
... ... @@ -5,19 +5,24 @@ import { createNamespacedHelpers } from 'vuex';
import DialogConfirmInfo from '../../components/dialog-confirm-info';
import DialogChangeBidPrice from '../../components/dialog-change-bid-price';
const { mapActions, mapMutations } = createNamespacedHelpers('order/orderList');
const { mapActions, mapMutations, mapState } = createNamespacedHelpers(
'order/orderList',
);
const { mapMutations: inSaleMapMutations } = createNamespacedHelpers(
'order/inSaleOrderList',
);
export default {
computed: {
...mapState(['changePrice']),
},
methods: {
...mapActions([
'cancelTradeConfirmInfo',
'cancelTrade',
'deleteOrder',
'computeChangePrice',
'changePrice',
'confirmChangePrice',
]),
...mapMutations(['filterOrderList', 'resetData']),
...inSaleMapMutations(['filterInSaleOrderList']),
... ... @@ -158,16 +163,43 @@ export default {
price: goodPrice,
});
if (typeof computePriceInfo === 'string') {
this.$createToast({
type: 'alert',
txt: computePriceInfo,
mask: true,
}).show();
return;
}
this.$createDialog(
{
type: 'prompt',
confirmBtn: { text: '调整求购价' },
cancelBtn: { active: true },
onConfirm: async () => {
if (!this.changePrice) {
return;
}
const isOk = await this.confirmChangePrice({
price: this.changePrice,
orderCode,
});
if (isOk) {
this.resetData();
this.fetchData(this.$route.params);
}
},
},
createElement => {
return [
createElement(DialogChangeBidPrice, {
props: { computePriceInfo, goodsInfo },
props: {
computePriceInfo,
goodsInfo,
orderCode,
},
slot: 'content',
}),
];
... ...
... ... @@ -10,6 +10,9 @@ const initailData = () => ({
currentStatus: null,
routeParamStatus: null,
isShowEmpty: false,
// 求购调价
changePrice: 0,
});
export default function() {
... ... @@ -49,6 +52,9 @@ export default function() {
state.pagetotal = 0;
state.pullUpLoad = true;
},
setChangePrice(state, price) {
state.changePrice = price;
},
resetData(state) {
const s = initailData();
... ... @@ -168,16 +174,19 @@ export default function() {
},
);
return res.code === 200 ? res.data : null;
return res.code === 200 ? res.data : res.message || '';
},
// 买家调价
async changePrice(_, { orderCode, price }) {
async confirmChangePrice({ commit }, { orderCode, price }) {
const res = await this.$api.post('/api/order/buyerask/changeprice', {
orderCode: `${orderCode}`,
price: +price,
});
if (res.code) {
commit('setChangePrice', 0);
}
return res.code === 200 ? res.data : null;
},
},
... ...