Commit 3d831121 authored by zhengke's avatar zhengke

修改商品页

parent 5723292a
<template>
<u-popup
mode="bottom"
:border-radius="borderRadius"
:popup="false"
v-model="value"
:maskCloseAble="maskCloseAble"
length="auto"
:safeAreaInsetBottom="true"
@close="popupClose"
:z-index="9999"
close-icon="cross"
>
<view class="goodsku">
<view class="goods">
<image :src="goodimage" class="img"></image>
<view class="chosen-info">
<view class="price" :style="{ color: mc }">
<text class="small"></text>
<text>{{ goodprice }}</text>
</view>
<view class="amount">库存 {{ goodamount }} {{ g.unit }}</view>
<view class="sku">{{ skuObj ? "已选择" : "选择" }} {{ sku }}</view>
</view>
</view>
<view class="sku-box">
<view class="sku-item" v-for="(x, i) in g.attr_groups" :key="i">
<view class="sku-title">{{ x.attr_group_name }}</view>
<view>
<view
class="sku-chi"
:style="{
background: y.attr_id == x.checkId ? mc : '#eee',
color: y.attr_id == x.checkId ? '#FFF' : '#333',
}"
:class="{ disable: notStockGood.indexOf(y.attr_id) != -1 }"
v-for="(y, yi) in x.attr_list"
:key="yi"
@click="clickSkuItemHandler(yi, i)"
>
<image
:src="y.pic_url"
class="img"
v-if="i == 0 && y.pic_url"
></image>
<text class="val">{{ y.attr_name }}</text>
</view>
</view>
</view>
</view>
<view class="count-box">
<text class="label">购买数量</text>
<u-number-box
:disabled="!skuObj"
v-model="gc"
:min="1"
: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>
<u-popup
mode="bottom"
:border-radius="borderRadius"
:popup="false"
v-model="value"
:maskCloseAble="maskCloseAble"
length="auto"
:safeAreaInsetBottom="true"
@close="popupClose"
:z-index="9999"
close-icon="cross"
>
<view class="goodsku">
<view class="goods">
<image :src="goodimage" class="img"></image>
<view class="chosen-info">
<view class="price" :style="{ color: mc }">
<text class="small"></text>
<text>{{ goodprice }}</text>
</view>
<view class="amount">库存 {{ goodamount }} {{ g.unit }}</view>
<view class="sku">{{ skuObj ? '已选择' : '选择' }} {{ sku }}</view>
</view>
</view>
<view class="sku-box">
<view class="sku-item" v-for="(x, i) in g.attr_groups" :key="i">
<view class="sku-title">{{ x.attr_group_name }}</view>
<view>
<view
class="sku-chi"
:style="{
background: y.attr_id == x.checkId ? mc : '#eee',
color: y.attr_id == x.checkId ? '#FFF' : '#333'
}"
:class="{ disable: notStockGood.indexOf(y.attr_id) != -1 }"
v-for="(y, yi) in x.attr_list"
:key="yi"
@click="clickSkuItemHandler(yi, i)"
>
<image :src="y.pic_url" class="img" v-if="i == 0 && y.pic_url"></image>
<text class="val">{{ y.attr_name }}</text>
</view>
</view>
</view>
</view>
<view class="count-box">
<text class="label">购买数量</text>
<u-number-box :disabled="!skuObj" v-model="gc" :min="1" :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>
<script>
export default {
model: {},
props: {
borderRadius: {
type: [String, Number],
default: 0,
},
value: {
type: Boolean,
default: false,
},
maskCloseAble: {
type: Boolean,
default: true,
},
safeAreaInsetBottom: {
type: Boolean,
default: true,
},
good: {
type: Object,
default: {},
},
optionType: {
type: [String, Number],
default: 0,
},
skued: {
type: Object,
default: {},
},
},
model: {},
props: {
borderRadius: {
type: [String, Number],
default: 0
},
value: {
type: Boolean,
default: false
},
maskCloseAble: {
type: Boolean,
default: true
},
safeAreaInsetBottom: {
type: Boolean,
default: true
},
good: {
type: Object,
default: {}
},
optionType: {
type: [String, Number],
default: 0
},
skued: {
type: Object,
default: {}
}
},
data() {
return {
goodimage: "",
goodprice: "",
goodamount: "",
mc: "",
secondary: "",
gc: 1,
bian: false,
btn1: {
flex: 1,
height: "100%",
borderRadius: "40px",
border: "none",
color: "#FFF",
fontSize: "13px",
width: "100%",
},
btn2: {
flex: 1,
height: "100%",
borderRadius: "40px",
border: "none",
color: "#FFF",
fontSize: "13px",
width: "100%",
},
sku: "",
g: {},
skuObj: null,
notStockGood: [],
forms:{
list: [
{
mch_id: 0,
goods_list: [],
distance: 0,
remark: "",
order_form: [],
use_integral: 0,
user_coupon_id: 0,
},
],
address_id: 0,
}
};
},
mounted() {
this.g = this.good;
this.mc = this.$uiConfig.mainColor;
this.secondary = this.$uiConfig.secondary;
this.skuObj = this.skued.id ? this.skued : null;
if (this.skuObj) {
this.goodimage = this.skuObj.pic_url || this.g.cover_pic;
this.goodprice = (parseFloat(this.skuObj.price) * 1).toFixed(2);
this.goodamount = this.skuObj.stock;
} 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;
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}`);
}
});
data() {
return {
goodimage: '',
goodprice: '',
goodamount: '',
mc: '',
secondary: '',
gc: 1,
bian: false,
btn1: {
flex: 1,
height: '100%',
borderRadius: '40px',
border: 'none',
color: '#FFF',
fontSize: '13px',
width: '100%'
},
btn2: {
flex: 1,
height: '100%',
borderRadius: '40px',
border: 'none',
color: '#FFF',
fontSize: '13px',
width: '100%'
},
sku: '',
g: {},
skuObj: null,
notStockGood: [],
forms: {
list: [
{
mch_id: 0,
goods_list: [],
distance: 0,
remark: '',
order_form: [],
use_integral: 0,
user_coupon_id: 0
}
],
address_id: 0
}
};
},
mounted() {
this.request2(
{
url: '/api/AppletGoods/GetAppletGoodsInfo',
data: {
GoodsId: this.good.id
}
},
res => {
console.log(res, 'resssssss');
this.g = res.data.goods;
this.goodimage = this.g.cover_pic;
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 = "";
this.g.attr_groups.forEach((x) => {
if (x.checkId != 0) {
sign += (sign == "" ? "" : ":") + x.checkId;
}
});
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);
}
},
},
this.mc = this.$uiConfig.mainColor;
this.secondary = this.$uiConfig.secondary;
this.skuObj = this.skued.id ? this.skued : null;
if (this.skuObj) {
this.goodimage = this.skuObj.pic_url || this.g.cover_pic;
this.goodprice = (parseFloat(this.skuObj.price) * 1).toFixed(2);
this.goodamount = this.skuObj.stock;
} 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;
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';
}
if (this.g.attr_groups && this.g.attr_groups.length > 0) {
this.g.attr_groups.forEach(x => {
if (!this.skuObj) {
//(x.checkId = 0), (x.checkName = x.attr_group_name);
(x.checkId = 0), (x.checkName = x.attr_list[0].attr_name);
x.checkId = x.attr_list[0].attr_id;
} 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();
}
);
// this.g = this.good;
},
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 = '';
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>
<style>
.goodsku {
position: relative;
padding: 10px;
padding-bottom: 0;
position: relative;
padding: 10px;
padding-bottom: 0;
}
.goodsku .goods {
display: flex;
background: transparent;
padding-bottom: 10px;
display: flex;
background: transparent;
padding-bottom: 10px;
}
.goodsku .goods .img {
width: 116px;
height: 116px;
border-radius: 4px;
margin-top: -45px;
border: 2px solid #fff;
width: 116px;
height: 116px;
border-radius: 4px;
margin-top: -45px;
border: 2px solid #fff;
}
.goodsku .goods .chosen-info {
margin-left: 15px;
flex: 1;
width: 1px;
margin-left: 15px;
flex: 1;
width: 1px;
}
.goodsku .goods .chosen-info .price {
font-size: 24px;
font-family: "oswald";
font-weight: unset;
font-size: 24px;
font-family: 'oswald';
font-weight: unset;
}
.goodsku .goods .chosen-info .price .small {
font-size: 16px;
margin-right: 5px;
font-size: 16px;
margin-right: 5px;
}
.goodsku .goods .chosen-info .amount {
font-size: 13px;
color: gray;
font-size: 13px;
color: gray;
}
.goodsku .goods .chosen-info .sku {
font-size: 13px;
margin-top: 5px;
font-size: 13px;
margin-top: 5px;
}
.goodsku .sku-box {
padding: 0;
max-height: 300px;
overflow: hidden;
overflow-y: auto;
display: block;
padding: 0;
max-height: 300px;
overflow: hidden;
overflow-y: auto;
display: block;
}
.goodsku .sku-box .sku-item {
padding: 15px 0;
border-bottom: 1px solid #eee;
width: 100%;
padding: 15px 0;
border-bottom: 1px solid #eee;
width: 100%;
}
.goodsku .sku-box .sku-item .sku-title {
color: #333;
font-size: 14px;
color: #333;
font-size: 14px;
}
.goodsku .sku-box .sku-item .sku-chi {
background: #eee;
border-radius: 3px;
padding: 3px;
display: flex;
color: #111;
display: inline-block;
margin-top: 10px;
margin-right: 10px;
font-size: 13px;
background: #eee;
border-radius: 3px;
padding: 3px;
display: flex;
color: #111;
display: inline-block;
margin-top: 10px;
margin-right: 10px;
font-size: 13px;
}
.goodsku .sku-box .sku-item .sku-chi.disable {
background: #eee !important;
color: #ddd !important;
background: #eee !important;
color: #ddd !important;
}
.goodsku .sku-box .sku-item .sku-chi .val {
width: 1px;
height: 24px;
line-height: 24px;
padding: 0 7px;
width: 1px;
height: 24px;
line-height: 24px;
padding: 0 7px;
}
.goodsku .sku-box .sku-item .sku-chi .img {
width: 24px;
height: 24px;
border-radius: 2px;
margin-right: 5px;
vertical-align: bottom;
width: 24px;
height: 24px;
border-radius: 2px;
margin-right: 5px;
vertical-align: bottom;
}
.goodsku .count-box {
display: flex;
padding: 15px 0;
display: flex;
padding: 15px 0;
}
.goodsku .count-box .label {
font-size: 14px;
color: #333;
width: 1px;
flex: 1;
font-size: 14px;
color: #333;
width: 1px;
flex: 1;
}
.goodsku .btn-box {
display: flex;
background: #fff;
height: 60px;
align-items: center;
border-top: 1px solid #eee;
padding: 5px 10px;
display: flex;
background: #fff;
height: 60px;
align-items: center;
border-top: 1px solid #eee;
padding: 5px 10px;
}
</style>
......@@ -46,7 +46,7 @@
</div>
<div class="good-price-info">
<span class="price" :style="{ color: mainColor }">{{
goodsInfo.showGoodsPrice ? item.price : ""
goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</span>
<span class="buy" v-if="goodsInfo.showBuyBtn" @click.stop="showSkuHandler(item)">
<u-icon
......
......@@ -43,7 +43,7 @@
</view>
<view class="good-price-info">
<view class="price" :style="{'color':mainColor}">{{
goodsInfo.showGoodsPrice ? item.price : ""
goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</view>
<view class="buy" v-if="goodsInfo.showBuyBtn">
<u-icon
......
......@@ -43,7 +43,7 @@
</div>
<div class="good-price-info">
<view class="price" :style="{'color':mainColor}">{{
goodsInfo.showGoodsPrice ? item.price : ""
goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</view>
<view class="buy" v-if="goodsInfo.showBuyBtn" @click.stop="showSkuHandler(item)">
<u-icon
......
......@@ -109,18 +109,18 @@ export default {
this.showSku=true
},
//格式化价格添加.00
getPrice(value){
var html,_val;
value =Number(value).toFixed(2);
if(value==0){
value=0;
return html = "¥0";
}else if(value.split('.')[1].substring(1)==0){
value = Number(value).toFixed(2);
}
_val = value.split('.');
return html = '¥'+_val[0]+'.'+_val[1];
}
// getPrice(value){
// var html,_val;
// value =Number(value).toFixed(2);
// if(value==0){
// value=0;
// return html = "¥0";
// }else if(value.split('.')[1].substring(1)==0){
// value = Number(value).toFixed(2);
// }
// _val = value.split('.');
// return html = '¥'+_val[0]+'.'+_val[1];
// }
},
};
</script>
......
......@@ -40,9 +40,9 @@
</view>
<view class="good-price-info">
<view class="price" :style="{'color':mainColor}">{{
goodsInfo.showGoodsPrice ? item.price : ""
goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</view>
<view class="buy" v-if="goodsInfo.showBuyBtn">
<view class="buy" v-if="goodsInfo.showBuyBtn" @click.stop="showSkuHandler(item)">
<u-icon
name="cart-o"
size="40"
......@@ -78,17 +78,22 @@
</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>
</template>
<script>
import goodSku from '../goods/goodsku'
export default {
components:{
goodSku
},
props: ["goodList", "goodsInfo"],
data() {
return {
mainColor: "",
activeKey: 0,
showSku:false,
sku:{}
};
},
created() {
......@@ -98,6 +103,10 @@ export default {
openGood(e) {
console.log(e);
},
showSkuHandler(g){
this.sku=g
this.showSku=true
},
},
};
</script>
......
......@@ -38,7 +38,7 @@
}}</view>
<view class="good-price-info">
<view class="price" :style="{'color':mainColor}">{{
goodsInfo.showGoodsPrice ? item.price : ""
goodsInfo.showGoodsPrice ? getPrice(item.price) : ""
}}</view>
<view class="buy" v-if="goodsInfo.showBuyBtn">
<u-icon
......
......@@ -44,9 +44,9 @@ export default {
'content-type': "application/json"
},
data: {
"MallBaseId": 1,
"TenantId": 1,
"OpenId": this.GetOpenId().OpenId,
MallBaseId: 1,
TenantId: 1,
OpenId: this.GetOpenId().OpenId,
UserId:this.GetOpenId().UserId,
MiniAppId: this.GetMiniAppId(),
msg: param.data
......@@ -97,6 +97,11 @@ export default {
return str;
}
}
//价格返回.00
Vue.prototype.getPrice = function(val){
val =Number(val).toFixed(2);
return val
}
Vue.prototype.apiheader = function() {
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