|
@@ -64,20 +64,23 @@
|
|
|
<!-- 头部商品信息 -->
|
|
|
<view class="grace-product-attr-info">
|
|
|
<image class= "grace-product-attr-info-image" mode="widthFix"
|
|
|
- src="https://img13.360buyimg.com/n7/jfs/t1/9085/2/12381/146200/5c371c5bE08328383/4f4ba51aed682207.jpg"></image>
|
|
|
+ :src="item.goods.pic_cover"></image>
|
|
|
<view class="grace-product-attr-info-body">
|
|
|
- <text class="grace-product-attr-info-title">{{product.name}}</text>
|
|
|
- <text class="grace-product-attr-info-stone">库存 : 1999件</text>
|
|
|
+ <text class="grace-product-attr-info-title">{{item.goods.name}}</text>
|
|
|
+ <view class="grace-nowrap grace-flex-vcenter">
|
|
|
+ <text class="grace-product-price">¥{{payPrice}}</text>
|
|
|
+ <text class="grace-text grace-gray" style="margin-left:30rpx;">库存:{{kuNum}}件</text>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 属性列表区 -->
|
|
|
- <scroll-view style="height:700rpx;" scroll-y>
|
|
|
- <view class="grace-title grace-margin-top">选择颜色</view>
|
|
|
- <view><graceSelectTags selectedColor="#FF0036" :items="colorTips" type="radio" @change="change1"></graceSelectTags></view>
|
|
|
- <view class="grace-title grace-margin-top">选择类型</view>
|
|
|
- <view><graceSelectTags selectedColor="#FF0036" :items="typeTips" type="radio" @change="change2"></graceSelectTags></view>
|
|
|
+ <scroll-view style="height:700rpx;" scroll-y>
|
|
|
+ <block v-for="(v, k) in item.goods.sell_attr" :key="k">
|
|
|
+ <view class="grace-title grace-margin-top">{{v.name}}</view>
|
|
|
+ <view><graceSelectTags selectedColor="#FF0036" :items="v.option_sku" type="radio" @change="change"></graceSelectTags></view>
|
|
|
+ </block>
|
|
|
<view class="grace-margin-top"><text class="grace-title">购买数量</text></view>
|
|
|
- <view>
|
|
|
+ <view style="margin-bottom: 40rpx;">
|
|
|
<graceNumberBox :value="buyNum" v-on:change="buyNumChange"></graceNumberBox>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
@@ -88,22 +91,10 @@
|
|
|
</graceBottomDialog>
|
|
|
</view>
|
|
|
<!-- 底部 -->
|
|
|
- <view class="grace-space-between grace-flex-vcenter grace-bg-white" slot="gFooter">
|
|
|
- <view class="grace-grids grace-nowrap" style="width:250rpx;">
|
|
|
- <view class="grace-grids-items grace-relative" @tap="gohome">
|
|
|
- <text class="grace-grids-icon grace-icons icon-home"></text>
|
|
|
- <text class="grace-grids-text grace-grids-text">首页</text>
|
|
|
- </view>
|
|
|
- <view class="grace-grids-items grace-relative">
|
|
|
- <text class="grace-grids-icon grace-grids-icon grace-icons icon-shoucang grace-footer-active"></text>
|
|
|
- <text class="grace-grids-text grace-grids-text grace-footer-active">收藏</text>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="grace-flex-end" style="width:460rpx;">
|
|
|
- <button type="warn" class="grace-footer-button" style="background:#E55D52;" @tap="buyNow">立即购买</button>
|
|
|
- <button type="warn" class="grace-footer-button" style="background:#F37B1D;" @tap="buyNow">加入购物车</button>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
+ <view class="grace-space-between grace-flex-vcenter grace-bg-white" slot="gFooter">
|
|
|
+ <view class="page-buy" @tap="buyNow">买</view>
|
|
|
+ </view>
|
|
|
+
|
|
|
</gracePage>
|
|
|
</template>
|
|
|
|
|
@@ -128,26 +119,9 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- // 轮播图
|
|
|
- swiperItems : [
|
|
|
- 'http://i1.mifile.cn/f/i/2019/C76029A6/part6-2.jpg',
|
|
|
- 'http://i1.mifile.cn/f/i/2019/C76029A6/part6-2.jpg',
|
|
|
- 'http://i1.mifile.cn/f/i/2019/C76029A6/part6-2.jpg'
|
|
|
- ],
|
|
|
// 切换导航
|
|
|
navItems : ['商品详情', '相关评论'],
|
|
|
active:0,
|
|
|
- product : {
|
|
|
- name: "小米 MIX3 一面科技 一面艺术 ( 磁动力滑盖全面屏 | 故宫特别版 )",
|
|
|
- logo : "../../static/logo.png",
|
|
|
- price : 3188,
|
|
|
- priceMarket : 3200,
|
|
|
- imgs : [
|
|
|
- 'https://img30.360buyimg.com/sku/jfs/t21838/18/2275707529/311540/cba1d04c/5b4f155fNac3aa2f0.jpg',
|
|
|
- 'https://img30.360buyimg.com/sku/jfs/t22021/327/2281785192/48707/57806074/5b4f1579Nae7adb49.jpg',
|
|
|
- 'https://img30.360buyimg.com/sku/jfs/t21682/256/2344553276/204456/cf7a2ddb/5b4ffbbfN48c54307.jpg'
|
|
|
- ]
|
|
|
- },
|
|
|
// 模拟评论数据 (实际项目来自api请求)
|
|
|
commentContents : [
|
|
|
{
|
|
@@ -175,19 +149,14 @@ export default {
|
|
|
}
|
|
|
],
|
|
|
// 购买选择属性层展示
|
|
|
- attrIsShow : false,
|
|
|
- colorTips : [
|
|
|
- { name: '灰色', value: '灰色', checked: true },
|
|
|
- { name: '银色', value: '银色', checked: false}
|
|
|
- ],
|
|
|
- colorSelected : "灰色",
|
|
|
- typeTips : [
|
|
|
- { name: '套餐一', value: '套餐一', checked: true },
|
|
|
- { name: '套餐二', value: '套餐二', checked: false},
|
|
|
- { name: '套餐三', value: '套餐三', checked: false}
|
|
|
- ],
|
|
|
- typeSelected : "套餐一",
|
|
|
- buyNum : 1
|
|
|
+ attrIsShow : false,
|
|
|
+ attr : '',
|
|
|
+ attrKey : '',
|
|
|
+ skuId : 0,
|
|
|
+ attrSelect : {},
|
|
|
+ payPrice : 0,
|
|
|
+ buyNum : 1,
|
|
|
+ kuNum : 9999,
|
|
|
}
|
|
|
},
|
|
|
onLoad:function () {},
|
|
@@ -207,27 +176,53 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
//打开属性视图
|
|
|
- buyNow : function(){this.attrIsShow = true;},
|
|
|
+ buyNow : function() {
|
|
|
+ this.attrIsShow = true;
|
|
|
+ },
|
|
|
// 关闭属性
|
|
|
- closeAttr : function(){this.attrIsShow = false;},
|
|
|
- // 颜色选择
|
|
|
- change1 : function (e) {this.colorSelected = e;},
|
|
|
- // 类型选择
|
|
|
- change2 : function (e) {this.typeSelected = e;},
|
|
|
+ closeAttr : function() {
|
|
|
+ this.attrIsShow = false;
|
|
|
+ },
|
|
|
+ // 属性选择
|
|
|
+ change : function (e) {
|
|
|
+ var temp = e.split('-');
|
|
|
+ this.attrSelect[temp[0]] = e;
|
|
|
+ this.getAttrKey();
|
|
|
+ },
|
|
|
// 购买数量变化
|
|
|
buyNumChange : function (e) {
|
|
|
- this.buyNum = e[0];
|
|
|
+ this.buyNum = e[0];
|
|
|
+ this.getAttrKey();
|
|
|
},
|
|
|
// 属性提交
|
|
|
- attrSubmit : function(e){
|
|
|
+ attrSubmit : function(e) {
|
|
|
//后续操作
|
|
|
uni.showToast({
|
|
|
title:"属性已经收集,请观察控制台",
|
|
|
icon:"none"
|
|
|
- });
|
|
|
- console.log("颜色 : " + this.colorSelected, "类型 : " + this.typeSelected , '数量 : ' + this.buyNum);
|
|
|
+ });
|
|
|
+ var data = {};
|
|
|
+ data.goods = this.item.goods.id;
|
|
|
+ data.price = this.payPrice;
|
|
|
+ data.num = this.buyNum;
|
|
|
+ data.sku = this.skuId;
|
|
|
+ console.log(data);
|
|
|
//如果想关闭属性
|
|
|
- this.closeAttr();
|
|
|
+ //this.closeAttr();
|
|
|
+ },
|
|
|
+ // 获取属性key
|
|
|
+ getAttrKey : function() {
|
|
|
+ var key = [];
|
|
|
+ for (var i in this.attrSelect) {
|
|
|
+ key.push(this.attrSelect[i]);
|
|
|
+ }
|
|
|
+ this.attrKey = key.join('_');
|
|
|
+
|
|
|
+ if (this.item.goods.price.list[this.attrKey]) {
|
|
|
+ this.payPrice = parseFloat(this.item.goods.price.list[this.attrKey].price) * this.buyNum;
|
|
|
+ this.kuNum = this.item.goods.price.list[this.attrKey].num;
|
|
|
+ this.skuId = this.item.goods.price.list[this.attrKey].id;
|
|
|
+ }
|
|
|
},
|
|
|
// 返回首页
|
|
|
gohome : function(){
|
|
@@ -258,5 +253,20 @@ export default {
|
|
|
.grace-grids-items{padding:6rpx 0; width:120rpx;}
|
|
|
.grace-grids-icon{height:50rpx; line-height:50rpx; font-size:40rpx; color:#6B7375;}
|
|
|
.grace-grids-text{line-height:28rpx; font-size:20rpx; margin-top:2px; color:#6B7375;}
|
|
|
-.grace-footer-active{color:#FF0036;}
|
|
|
+.grace-footer-active{color:#FF0036;}
|
|
|
+
|
|
|
+.page-buy {
|
|
|
+ position: fixed;
|
|
|
+ right: 120rpx;
|
|
|
+ bottom: 30rpx;
|
|
|
+ width: 80rpx;
|
|
|
+ height: 80rpx;
|
|
|
+ background: rgb(229, 93, 82);
|
|
|
+ border-radius: 80rpx;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 30rpx;
|
|
|
+ line-height: 80rpx;
|
|
|
+ text-align: center;
|
|
|
+ z-index: 2000;
|
|
|
+}
|
|
|
</style>
|