Commit 3d831121 authored by zhengke's avatar zhengke

修改商品页

parent 5723292a
<template> <template>
<u-popup <u-popup
mode="bottom" mode="bottom"
:border-radius="borderRadius" :border-radius="borderRadius"
:popup="false" :popup="false"
v-model="value" v-model="value"
:maskCloseAble="maskCloseAble" :maskCloseAble="maskCloseAble"
length="auto" length="auto"
:safeAreaInsetBottom="true" :safeAreaInsetBottom="true"
@close="popupClose" @close="popupClose"
:z-index="9999" :z-index="9999"
close-icon="cross" close-icon="cross"
> >
<view class="goodsku"> <view class="goodsku">
<view class="goods"> <view class="goods">
<image :src="goodimage" class="img"></image> <image :src="goodimage" class="img"></image>
<view class="chosen-info"> <view class="chosen-info">
<view class="price" :style="{ color: mc }"> <view class="price" :style="{ color: mc }">
<text class="small"></text> <text class="small"></text>
<text>{{ goodprice }}</text> <text>{{ goodprice }}</text>
</view> </view>
<view class="amount">库存 {{ goodamount }} {{ g.unit }}</view> <view class="amount">库存 {{ goodamount }} {{ g.unit }}</view>
<view class="sku">{{ skuObj ? "已选择" : "选择" }} {{ sku }}</view> <view class="sku">{{ skuObj ? '已选择' : '选择' }} {{ sku }}</view>
</view> </view>
</view> </view>
<view class="sku-box"> <view class="sku-box">
<view class="sku-item" v-for="(x, i) in g.attr_groups" :key="i"> <view class="sku-item" v-for="(x, i) in g.attr_groups" :key="i">
<view class="sku-title">{{ x.attr_group_name }}</view> <view class="sku-title">{{ x.attr_group_name }}</view>
<view> <view>
<view <view
class="sku-chi" class="sku-chi"
:style="{ :style="{
background: y.attr_id == x.checkId ? mc : '#eee', background: y.attr_id == x.checkId ? mc : '#eee',
color: y.attr_id == x.checkId ? '#FFF' : '#333', color: y.attr_id == x.checkId ? '#FFF' : '#333'
}" }"
:class="{ disable: notStockGood.indexOf(y.attr_id) != -1 }" :class="{ disable: notStockGood.indexOf(y.attr_id) != -1 }"
v-for="(y, yi) in x.attr_list" v-for="(y, yi) in x.attr_list"
:key="yi" :key="yi"
@click="clickSkuItemHandler(yi, i)" @click="clickSkuItemHandler(yi, i)"
> >
<image <image :src="y.pic_url" class="img" v-if="i == 0 && y.pic_url"></image>
:src="y.pic_url" <text class="val">{{ y.attr_name }}</text>
class="img" </view>
v-if="i == 0 && y.pic_url" </view>
></image> </view>
<text class="val">{{ y.attr_name }}</text> </view>
</view> <view class="count-box">
</view> <text class="label">购买数量</text>
</view> <u-number-box :disabled="!skuObj" v-model="gc" :min="1" :max="goodamount" @change="valChange"></u-number-box>
</view> </view>
<view class="count-box"> <view class="btn-box">
<text class="label">购买数量</text> <view style="flex: 1;" v-if="optionType != 1"><u-button @click="joinCar" :ripple="true" :hair-line="false" :custom-style="btn1">加入购物车</u-button></view>
<u-number-box <view style="flex: 1;" v-if="optionType != 0"><u-button @click="buy" :ripple="true" :hair-line="false" :custom-style="btn2">立即购买</u-button></view>
:disabled="!skuObj" </view>
v-model="gc" </view>
:min="1" </u-popup>
:max="goodamount"
@change="valChange"
></u-number-box>
</view>
<view class="btn-box">
<view style="flex: 1;" v-if="optionType != 1">
<u-button
@click="joinCar"
:ripple="true"
:hair-line="false"
:custom-style="btn1"
>加入购物车</u-button
>
</view>
<view style="flex: 1;" v-if="optionType != 0">
<u-button
@click="buy"
:ripple="true"
:hair-line="false"
:custom-style="btn2"
>立即购买</u-button
>
</view>
</view>
</view>
</u-popup>
</template> </template>
<script> <script>
export default { export default {
model: {}, model: {},
props: { props: {
borderRadius: { borderRadius: {
type: [String, Number], type: [String, Number],
default: 0, default: 0
}, },
value: { value: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
maskCloseAble: { maskCloseAble: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
safeAreaInsetBottom: { safeAreaInsetBottom: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
good: { good: {
type: Object, type: Object,
default: {}, default: {}
}, },
optionType: { optionType: {
type: [String, Number], type: [String, Number],
default: 0, default: 0
}, },
skued: { skued: {
type: Object, type: Object,
default: {}, default: {}
}, }
}, },
data() { data() {
return { return {
goodimage: "", goodimage: '',
goodprice: "", goodprice: '',
goodamount: "", goodamount: '',
mc: "", mc: '',
secondary: "", secondary: '',
gc: 1, gc: 1,
bian: false, bian: false,
btn1: { btn1: {
flex: 1, flex: 1,
height: "100%", height: '100%',
borderRadius: "40px", borderRadius: '40px',
border: "none", border: 'none',
color: "#FFF", color: '#FFF',
fontSize: "13px", fontSize: '13px',
width: "100%", width: '100%'
}, },
btn2: { btn2: {
flex: 1, flex: 1,
height: "100%", height: '100%',
borderRadius: "40px", borderRadius: '40px',
border: "none", border: 'none',
color: "#FFF", color: '#FFF',
fontSize: "13px", fontSize: '13px',
width: "100%", width: '100%'
}, },
sku: "", sku: '',
g: {}, g: {},
skuObj: null, skuObj: null,
notStockGood: [], notStockGood: [],
forms:{ forms: {
list: [ list: [
{ {
mch_id: 0, mch_id: 0,
goods_list: [], goods_list: [],
distance: 0, distance: 0,
remark: "", remark: '',
order_form: [], order_form: [],
use_integral: 0, use_integral: 0,
user_coupon_id: 0, user_coupon_id: 0
}, }
], ],
address_id: 0, address_id: 0
} }
}; };
}, },
mounted() { mounted() {
this.g = this.good; this.request2(
this.mc = this.$uiConfig.mainColor; {
this.secondary = this.$uiConfig.secondary; url: '/api/AppletGoods/GetAppletGoodsInfo',
this.skuObj = this.skued.id ? this.skued : null; data: {
if (this.skuObj) { GoodsId: this.good.id
this.goodimage = this.skuObj.pic_url || this.g.cover_pic; }
this.goodprice = (parseFloat(this.skuObj.price) * 1).toFixed(2); },
this.goodamount = this.skuObj.stock; res => {
} else { console.log(res, 'resssssss');
this.goodimage = this.g.cover_pic; this.g = res.data.goods;
this.goodprice = this.g.price_min && this.g.price_min!="" ?this.g.price_min:this.g.price_content; this.goodimage = this.g.cover_pic;
this.goodamount = this.g.goods_stock;
}
this.bian = this.$utils.is_biang;
this.btn1.background = this.secondary;
this.btn2.background = this.mc;
if (this.optionType == 2) {
this.btn1.borderRadius = "40px 0 0 40px";
this.btn2.borderRadius = "0 40px 40px 0";
}
console.log(this.skued);
this.g.attr_groups.forEach((x) => {
if (!this.skuObj) {
(x.checkId = 0), (x.checkName = x.attr_group_name);
} else {
let sign = `:${this.skuObj.sign_id}:`;
x.attr_list.forEach((y) => {
if (sign.indexOf(`:${y.attr_id}:`) != -1) {
x.checkId = y.attr_id;
x.checkName = y.attr_name;
}
});
}
});
this.formatDisableSku();
this.formatChosenTips();
},
methods: {
joinCar() {
let h = this.apiheader();
h["content-type"] = "application/x-www-form-urlencoded";
if (this.skuObj && this.skuObj.id) {
this.request(
{
url: "",
data: {
r: "api/cart/add",
goods_id: this.g.id,
attr: this.skuObj.id,
num: this.gc == 0 ? 1 : this.gc,
},
header: h,
method: "POST",
},
(res) => {
uni.showToast({
title: "加入购物车成功",
icon: "success",
duration: 2000,
});
this.popupClose();
}
);
} else {
uni.showToast({
title: "请选择商品",
position: "bottom",
icon: "none",
duration: 2000,
});
}
},
buy() {
if (this.skuObj && this.skuObj.id) {
let g = {
id: this.skuObj.goods_id,
num: this.gc,
cart_id: 0,
goods_attr_id: this.skuObj.id,
attr: [],
};
this.skuObj.attr_list.forEach((x) => {
g.attr.push({
attr_id: x.attr_id,
attr_group_id: x.attr_group_id,
});
});
this.forms.list[0].goods_list.push(g)
this.forms.list[0].mch_id=this.g.mch_id
uni.navigateTo({
url:
"/pages/order-submit/order-submit?formData=" + encodeURIComponent(JSON.stringify(this.forms)),
complete(res) {
console.log(res);
},
});
} else {
uni.showToast({
title: "请选择商品",
position: "bottom",
icon: "none",
duration: 2000,
});
}
},
close() {
this.popupClose();
},
clickSkuItemHandler(index, groupRow) {
let temp = this.g.attr_groups[groupRow].attr_list[index];
if (this.notStockGood.indexOf(temp.attr_id) == -1) {
if (this.g.attr_groups[groupRow].checkId != temp.attr_id) {
this.g.attr_groups[groupRow].checkId = temp.attr_id;
this.g.attr_groups[groupRow].checkName = temp.attr_name;
} else {
this.g.attr_groups[groupRow].checkId = 0;
this.g.attr_groups[groupRow].checkName = this.g.attr_groups[
groupRow
].attr_group_name;
}
this.formatDisableSku();
this.$forceUpdate();
this.formatChosenTips();
}
},
formatChosenTips() {
let unchosen = "";
let chosen = "";
this.g.attr_groups.forEach((x) => {
if (x.checkId != 0) {
chosen += (chosen == "" ? "" : ",") + x.checkName;
} else {
unchosen += (unchosen == "" ? "" : ",") + x.attr_group_name;
}
});
if (unchosen != "") {
this.sku = unchosen;
this.skuObj = null;
this.goodimage = this.g.cover_pic;
this.goodprice = this.g.price_min && this.g.price_min!="" ?this.g.price_min:this.g.price_content;
this.goodamount = this.g.goods_stock;
} else {
this.sku = chosen;
this.formatSku();
}
},
formatDisableSku() {
let sign = [];
this.g.attr_groups.forEach((x) => {
if (x.checkId != 0) {
sign.push(`${x.checkId}`);
}
});
if (sign.length == this.g.attr_groups.length - 1) { this.mc = this.$uiConfig.mainColor;
this.formatDisable(sign); this.secondary = this.$uiConfig.secondary;
} else if (sign.length == this.g.attr_groups.length) { this.skuObj = this.skued.id ? this.skued : null;
let t = sign.join(":"); if (this.skuObj) {
let len = -1; this.goodimage = this.skuObj.pic_url || this.g.cover_pic;
this.g.attr.forEach((x) => { this.goodprice = (parseFloat(this.skuObj.price) * 1).toFixed(2);
if (x.sign_id == t && x.stock == 0) { this.goodamount = this.skuObj.stock;
len = this.g.attr_groups.length - 1; } else {
} this.goodimage = this.g.cover_pic;
}); this.goodprice = this.g.price_min && this.g.price_min != '' ? this.g.price_min : this.g.price_content;
if (len != -1) { this.goodamount = this.g.goods_stock;
this.g.attr_groups[len].checkId = 0; }
this.g.attr_groups[len].checkName = this.g.attr_groups[len].attr_name; this.bian = this.$utils.is_biang;
this.formatDisableSku(); this.btn1.background = this.secondary;
} else { this.btn2.background = this.mc;
this.formatDisable(sign.splice(sign.length - 1, 1)); if (this.optionType == 2) {
} this.btn1.borderRadius = '40px 0 0 40px';
} this.btn2.borderRadius = '0 40px 40px 0';
}, }
formatDisable(sign) { if (this.g.attr_groups && this.g.attr_groups.length > 0) {
this.notStockGood = []; this.g.attr_groups.forEach(x => {
this.g.attr.forEach((x) => { if (!this.skuObj) {
if (x.stock == 0) { //(x.checkId = 0), (x.checkName = x.attr_group_name);
let t = x.sign_id.split(":"); (x.checkId = 0), (x.checkName = x.attr_list[0].attr_name);
let t1 = []; x.checkId = x.attr_list[0].attr_id;
t.forEach((x) => { } else {
if (sign.indexOf(x) == -1) { let sign = `:${this.skuObj.sign_id}:`;
t1.push(x); x.attr_list.forEach(y => {
} if (sign.indexOf(`:${y.attr_id}:`) != -1) {
}); x.checkId = y.attr_id;
if (t1.length == 1) { x.checkName = y.attr_name;
this.notStockGood.push(parseInt(t1[0])); }
} });
} }
}); });
this.$forceUpdate(); }
}, this.formatDisableSku();
formatSku() { this.formatChosenTips();
let sign = ""; }
this.g.attr_groups.forEach((x) => { );
if (x.checkId != 0) { // this.g = this.good;
sign += (sign == "" ? "" : ":") + x.checkId; },
} methods: {
}); joinCar() {
this.g.attr.forEach((x) => { let h = this.apiheader();
if (x.sign_id == sign) { h['content-type'] = 'application/x-www-form-urlencoded';
this.skuObj = x; if (this.skuObj && this.skuObj.id) {
} this.request(
}); {
if (this.skuObj != null) { url: '',
this.goodimage = this.skuObj.pic_url || this.g.cover_pic; data: {
this.goodprice = ( r: 'api/cart/add',
parseFloat(this.skuObj.price) * parseFloat(this.gc) goods_id: this.g.id,
).toFixed(2); attr: this.skuObj.id,
this.goodamount = this.skuObj.stock; num: this.gc == 0 ? 1 : this.gc
} },
}, header: h,
// 弹窗关闭 method: 'POST'
popupClose() { },
this.$emit("close", this.skuObj); res => {
this.$emit("input", false); uni.showToast({
}, title: '加入购物车成功',
valChange(e) { icon: 'success',
this.gc = e.value; duration: 2000
if (this.skuObj) { });
this.goodprice = ( this.popupClose();
parseFloat(this.skuObj.price) * parseFloat(this.gc) }
).toFixed(2); );
} } else {
}, uni.showToast({
}, title: '请选择商品',
position: 'bottom',
icon: 'none',
duration: 2000
});
}
},
buy() {
if (this.skuObj && this.skuObj.id) {
let g = {
id: this.skuObj.goods_id,
num: this.gc,
cart_id: 0,
goods_attr_id: this.skuObj.id,
attr: []
};
this.skuObj.attr_list.forEach(x => {
g.attr.push({
attr_id: x.attr_id,
attr_group_id: x.attr_group_id
});
});
this.forms.list[0].goods_list.push(g);
this.forms.list[0].mch_id = this.g.mch_id;
uni.navigateTo({
url: '/pages/order-submit/order-submit?formData=' + encodeURIComponent(JSON.stringify(this.forms)),
complete(res) {
console.log(res);
}
});
} else {
uni.showToast({
title: '请选择商品',
position: 'bottom',
icon: 'none',
duration: 2000
});
}
},
close() {
this.popupClose();
},
clickSkuItemHandler(index, groupRow) {
let temp = this.g.attr_groups[groupRow].attr_list[index];
if (this.notStockGood.indexOf(temp.attr_id) == -1) {
if (this.g.attr_groups[groupRow].checkId != temp.attr_id) {
this.g.attr_groups[groupRow].checkId = temp.attr_id;
this.g.attr_groups[groupRow].checkName = temp.attr_name;
} else {
this.g.attr_groups[groupRow].checkId = 0;
this.g.attr_groups[groupRow].checkName = this.g.attr_groups[groupRow].attr_group_name;
}
this.formatDisableSku();
this.$forceUpdate();
this.formatChosenTips();
}
},
formatChosenTips() {
let unchosen = '';
let chosen = '';
if (this.g.attr_groups && this.g.attr_groups.length > 0) {
this.g.attr_groups.forEach(x => {
// if (x.checkId != 0) {
if (x.checkId != -1) {
chosen += (chosen == '' ? '' : ',') + x.checkName;
} else {
unchosen += (unchosen == '' ? '' : ',') + x.attr_group_name;
}
});
}
if (unchosen != '') {
this.sku = unchosen;
this.skuObj = null;
this.goodimage = this.g.cover_pic;
this.goodprice = this.g.price_min && this.g.price_min != '' ? this.g.price_min : this.g.price_content;
this.goodamount = this.g.goods_stock;
} else {
this.sku = chosen;
this.formatSku();
}
},
formatDisableSku() {
let sign = [];
if (this.g.attr_groups && this.g.attr_groups.length > 0) {
this.g.attr_groups.forEach(x => {
if (x.checkId != 0) {
sign.push(`${x.checkId}`);
}
});
if (sign.length == this.g.attr_groups.length - 1) {
this.formatDisable(sign);
} else if (sign.length == this.g.attr_groups.length) {
let t = sign.join(':');
let len = -1;
this.g.attr.forEach(x => {
if (x.sign_id == t && x.stock == 0) {
len = this.g.attr_groups.length - 1;
}
});
if (len != -1) {
this.g.attr_groups[len].checkId = 0;
this.g.attr_groups[len].checkName = this.g.attr_groups[len].attr_name;
this.formatDisableSku();
} else {
this.formatDisable(sign.splice(sign.length - 1, 1));
}
}
}
},
formatDisable(sign) {
this.notStockGood = [];
this.g.attr.forEach(x => {
if (x.stock == 0) {
let t = x.sign_id.split(':');
let t1 = [];
t.forEach(x => {
if (sign.indexOf(x) == -1) {
t1.push(x);
}
});
if (t1.length == 1) {
this.notStockGood.push(parseInt(t1[0]));
}
}
});
this.$forceUpdate();
},
formatSku() {
let sign = '';
if (this.g.attr_groups && this.g.attr_groups.length > 0) {
this.g.attr_groups.forEach(x => {
if (x.checkId != -1) {
sign += (sign == '' ? '' : ':') + x.checkId;
}
});
}
if (this.g.attr && this.g.attr.length) {
this.g.attr.forEach(x => {
if (x.sign_id == sign) {
this.skuObj = x;
}
});
}
if (this.skuObj != null) {
this.goodimage = this.skuObj.pic_url || this.g.cover_pic;
this.goodprice = (parseFloat(this.skuObj.price) * parseFloat(this.gc)).toFixed(2);
this.goodamount = this.skuObj.stock;
}
},
// 弹窗关闭
popupClose() {
this.$emit('close', this.skuObj);
this.$emit('input', false);
},
valChange(e) {
this.gc = e.value;
if (this.skuObj) {
this.goodprice = (parseFloat(this.skuObj.price) * parseFloat(this.gc)).toFixed(2);
}
}
}
}; };
</script> </script>
<style> <style>
.goodsku { .goodsku {
position: relative; position: relative;
padding: 10px; padding: 10px;
padding-bottom: 0; padding-bottom: 0;
} }
.goodsku .goods { .goodsku .goods {
display: flex; display: flex;
background: transparent; background: transparent;
padding-bottom: 10px; padding-bottom: 10px;
} }
.goodsku .goods .img { .goodsku .goods .img {
width: 116px; width: 116px;
height: 116px; height: 116px;
border-radius: 4px; border-radius: 4px;
margin-top: -45px; margin-top: -45px;
border: 2px solid #fff; border: 2px solid #fff;
} }
.goodsku .goods .chosen-info { .goodsku .goods .chosen-info {
margin-left: 15px; margin-left: 15px;
flex: 1; flex: 1;
width: 1px; width: 1px;
} }
.goodsku .goods .chosen-info .price { .goodsku .goods .chosen-info .price {
font-size: 24px; font-size: 24px;
font-family: "oswald"; font-family: 'oswald';
font-weight: unset; font-weight: unset;
} }
.goodsku .goods .chosen-info .price .small { .goodsku .goods .chosen-info .price .small {
font-size: 16px; font-size: 16px;
margin-right: 5px; margin-right: 5px;
} }
.goodsku .goods .chosen-info .amount { .goodsku .goods .chosen-info .amount {
font-size: 13px; font-size: 13px;
color: gray; color: gray;
} }
.goodsku .goods .chosen-info .sku { .goodsku .goods .chosen-info .sku {
font-size: 13px; font-size: 13px;
margin-top: 5px; margin-top: 5px;
} }
.goodsku .sku-box { .goodsku .sku-box {
padding: 0; padding: 0;
max-height: 300px; max-height: 300px;
overflow: hidden; overflow: hidden;
overflow-y: auto; overflow-y: auto;
display: block; display: block;
} }
.goodsku .sku-box .sku-item { .goodsku .sku-box .sku-item {
padding: 15px 0; padding: 15px 0;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
width: 100%; width: 100%;
} }
.goodsku .sku-box .sku-item .sku-title { .goodsku .sku-box .sku-item .sku-title {
color: #333; color: #333;
font-size: 14px; font-size: 14px;
} }
.goodsku .sku-box .sku-item .sku-chi { .goodsku .sku-box .sku-item .sku-chi {
background: #eee; background: #eee;
border-radius: 3px; border-radius: 3px;
padding: 3px; padding: 3px;
display: flex; display: flex;
color: #111; color: #111;
display: inline-block; display: inline-block;
margin-top: 10px; margin-top: 10px;
margin-right: 10px; margin-right: 10px;
font-size: 13px; font-size: 13px;
} }
.goodsku .sku-box .sku-item .sku-chi.disable { .goodsku .sku-box .sku-item .sku-chi.disable {
background: #eee !important; background: #eee !important;
color: #ddd !important; color: #ddd !important;
} }
.goodsku .sku-box .sku-item .sku-chi .val { .goodsku .sku-box .sku-item .sku-chi .val {
width: 1px; width: 1px;
height: 24px; height: 24px;
line-height: 24px; line-height: 24px;
padding: 0 7px; padding: 0 7px;
} }
.goodsku .sku-box .sku-item .sku-chi .img { .goodsku .sku-box .sku-item .sku-chi .img {
width: 24px; width: 24px;
height: 24px; height: 24px;
border-radius: 2px; border-radius: 2px;
margin-right: 5px; margin-right: 5px;
vertical-align: bottom; vertical-align: bottom;
} }
.goodsku .count-box { .goodsku .count-box {
display: flex; display: flex;
padding: 15px 0; padding: 15px 0;
} }
.goodsku .count-box .label { .goodsku .count-box .label {
font-size: 14px; font-size: 14px;
color: #333; color: #333;
width: 1px; width: 1px;
flex: 1; flex: 1;
} }
.goodsku .btn-box { .goodsku .btn-box {
display: flex; display: flex;
background: #fff; background: #fff;
height: 60px; height: 60px;
align-items: center; align-items: center;
border-top: 1px solid #eee; border-top: 1px solid #eee;
padding: 5px 10px; padding: 5px 10px;
} }
</style> </style>
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
</div> </div>
<div class="good-price-info"> <div class="good-price-info">
<span class="price" :style="{ color: mainColor }">{{ <span class="price" :style="{ color: mainColor }">{{
goodsInfo.showGoodsPrice ? item.price : "" goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</span> }}</span>
<span class="buy" v-if="goodsInfo.showBuyBtn" @click.stop="showSkuHandler(item)"> <span class="buy" v-if="goodsInfo.showBuyBtn" @click.stop="showSkuHandler(item)">
<u-icon <u-icon
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</view> </view>
<view class="good-price-info"> <view class="good-price-info">
<view class="price" :style="{'color':mainColor}">{{ <view class="price" :style="{'color':mainColor}">{{
goodsInfo.showGoodsPrice ? item.price : "" goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</view> }}</view>
<view class="buy" v-if="goodsInfo.showBuyBtn"> <view class="buy" v-if="goodsInfo.showBuyBtn">
<u-icon <u-icon
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</div> </div>
<div class="good-price-info"> <div class="good-price-info">
<view class="price" :style="{'color':mainColor}">{{ <view class="price" :style="{'color':mainColor}">{{
goodsInfo.showGoodsPrice ? item.price : "" goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</view> }}</view>
<view class="buy" v-if="goodsInfo.showBuyBtn" @click.stop="showSkuHandler(item)"> <view class="buy" v-if="goodsInfo.showBuyBtn" @click.stop="showSkuHandler(item)">
<u-icon <u-icon
......
...@@ -109,18 +109,18 @@ export default { ...@@ -109,18 +109,18 @@ export default {
this.showSku=true this.showSku=true
}, },
//格式化价格添加.00 //格式化价格添加.00
getPrice(value){ // getPrice(value){
var html,_val; // var html,_val;
value =Number(value).toFixed(2); // value =Number(value).toFixed(2);
if(value==0){ // if(value==0){
value=0; // value=0;
return html = "¥0"; // return html = "¥0";
}else if(value.split('.')[1].substring(1)==0){ // }else if(value.split('.')[1].substring(1)==0){
value = Number(value).toFixed(2); // value = Number(value).toFixed(2);
} // }
_val = value.split('.'); // _val = value.split('.');
return html = '¥'+_val[0]+'.'+_val[1]; // return html = '¥'+_val[0]+'.'+_val[1];
} // }
}, },
}; };
</script> </script>
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
</view> </view>
<view class="good-price-info"> <view class="good-price-info">
<view class="price" :style="{'color':mainColor}">{{ <view class="price" :style="{'color':mainColor}">{{
goodsInfo.showGoodsPrice ? item.price : "" goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</view> }}</view>
<view class="buy" v-if="goodsInfo.showBuyBtn"> <view class="buy" v-if="goodsInfo.showBuyBtn" @click.stop="showSkuHandler(item)">
<u-icon <u-icon
name="cart-o" name="cart-o"
size="40" size="40"
...@@ -78,17 +78,22 @@ ...@@ -78,17 +78,22 @@
</view> </view>
</view> </view>
</view> </view>
<view style="color:rgba(0,0,0,0);font-size:12px;">0</view> <good-sku v-if="showSku" :option-type="2" borderRadius="20" v-model="showSku" :good="sku"></good-sku>
</view> </view>
</template> </template>
<script> <script>
import goodSku from '../goods/goodsku'
export default { export default {
components:{
goodSku
},
props: ["goodList", "goodsInfo"], props: ["goodList", "goodsInfo"],
data() { data() {
return { return {
mainColor: "", mainColor: "",
activeKey: 0, activeKey: 0,
showSku:false,
sku:{}
}; };
}, },
created() { created() {
...@@ -98,6 +103,10 @@ export default { ...@@ -98,6 +103,10 @@ export default {
openGood(e) { openGood(e) {
console.log(e); console.log(e);
}, },
showSkuHandler(g){
this.sku=g
this.showSku=true
},
}, },
}; };
</script> </script>
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
}}</view> }}</view>
<view class="good-price-info"> <view class="good-price-info">
<view class="price" :style="{'color':mainColor}">{{ <view class="price" :style="{'color':mainColor}">{{
goodsInfo.showGoodsPrice ? item.price : "" goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</view> }}</view>
<view class="buy" v-if="goodsInfo.showBuyBtn"> <view class="buy" v-if="goodsInfo.showBuyBtn">
<u-icon <u-icon
......
...@@ -44,9 +44,9 @@ export default { ...@@ -44,9 +44,9 @@ export default {
'content-type': "application/json" 'content-type': "application/json"
}, },
data: { data: {
"MallBaseId": 1, MallBaseId: 1,
"TenantId": 1, TenantId: 1,
"OpenId": this.GetOpenId().OpenId, OpenId: this.GetOpenId().OpenId,
UserId:this.GetOpenId().UserId, UserId:this.GetOpenId().UserId,
MiniAppId: this.GetMiniAppId(), MiniAppId: this.GetMiniAppId(),
msg: param.data msg: param.data
...@@ -97,6 +97,11 @@ export default { ...@@ -97,6 +97,11 @@ export default {
return str; return str;
} }
} }
//价格返回.00
Vue.prototype.getPrice = function(val){
val =Number(val).toFixed(2);
return val
}
Vue.prototype.apiheader = function() { Vue.prototype.apiheader = function() {
return { return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment