Merge pull request 'xbx' (#50) from xbx into master

Reviewed-on: http://git.luyuan.tk/luyuan/deming/pulls/50
This commit is contained in:
luyuan 2020-07-07 14:47:13 +08:00
commit 77083c0404
4 changed files with 245 additions and 31 deletions

View File

@ -127,6 +127,11 @@ export default {
return vm.$u.post('Store/getStoreImgVideoList', { return vm.$u.post('Store/getStoreImgVideoList', {
id: id id: id
}); });
},
goodsInfo({id}){
return vm.$u.post('goods/goodsInfo', {
goods_id: id
});
} }
} }
} }

View File

@ -0,0 +1,64 @@
<template>
<view class="guige">
<view class="title">
{{title}}
</view>
<view class="item">
<text v-for="(i,j) in item" @click="select = j" :class="select == j ? 'xuanzhong' : ''" :key="j">
{{i}}
</text>
<!-- <text @click="select = 1" :class="select == 1 ? 'xuanzhong' : ''">S</text> -->
<!-- <text @click="select = 2" :class="select == 2 ? 'xuanzhong' : ''">M</text> -->
</view>
</view>
</template>
<style lang="scss" scoped>
.guige{
margin-top: 30rpx;
padding-bottom: 30rpx;
border-bottom: #ececec solid 2rpx;
.title{
font-size: 28rpx;
color: #333;
margin-bottom: 29rpx;
}
.item{
display: flex;
flex-wrap: wrap;
>text{
min-width: 120rpx;
height: 60rpx;
background-color: #ececec;
color: #999;
text-align: center;
line-height: 60rpx;
box-sizing: border-box;
border-radius: 6rpx;
margin-right: 26rpx;
}
.xuanzhong{
border: #ff780f 1rpx solid;
color: #FF780F;
background-color: #FFF1E6;
}
}
}
</style>
<script>
export default {
name:"guige",
data(){
return {
select:0
}
},
props:['item','title'],
watch:{
select(){
// console.log(this.select)
this.$emit("sel",this.select)
}
}
}
</script>

View File

@ -1,36 +1,109 @@
<template> <template>
<view class="tloos"> <view>
<view class="navs"> <view class="tloos">
<image></image> <view class="navs">
店铺 <image></image>
店铺
</view>
<view class="navs" style="margin-right:30rpx">
<image></image>
客服
</view>
<view class="button" style="background:rgba(253,211,96,0.6);">试穿试送</view>
<view class="button" style="background:rgba(253,211,96,1);" @click="buy(2)">加入购物车</view>
<view class="button" style="background:rgba(255,120,15,1);" @click="buy(1)">立即购买</view>
</view> </view>
<view class="navs" style="margin-right:30rpx"> <u-popup v-model="show" mode="bottom">
<image></image> <scroll-view scroll-y="true" class="popup">
客服 <view>
</view> <view class="head">
<view class="button" style="background:rgba(253,211,96,0.6);">试穿试送</view> <image class="image" :src="info.goods_image"></image>
<view class="button" style="background:rgba(253,211,96,1);" @click="addCart">加入购物车</view> <view class="info">
<view class="button" style="background:rgba(255,120,15,1);">立即购买</view> <text class="u-line-2">{{info.goods_name}}</text>
<u-toast ref="uToast" /> <text>{{info.goods_price}}</text>
</view>
</view>
<guige @sel="self" ref="guige" v-for="(item,index) in info.spec_value" :key="index" :title="info.spec_name[index]" :item="item"></guige>
<view class="num">
<text>购买数量</text>
<u-number-box v-model="value" @change="valChange"></u-number-box>
</view>
<view style="height:180rpx"></view>
</view>
<u-toast ref="uToast" />
</scroll-view>
</u-popup>
</view> </view>
</template> </template>
<script> <script>
import guige from "./guige"
export default { export default {
name:"tloos", name:"tloos",
props: ['id'], props: ['id','info'],
components:{
guige
},
data(){
return {
show:false,
value:1,
sel:"",
quanxuan:false
}
},
methods: { methods: {
addCart() { buy(type){
this.$u.api.addCart({ let that = this;
goods_id: this.id, if(this.show){
quantity: 1, if(this.info.spec_value == null){
}).then(res => { this.$emit("buy",{type,value:that.value})
this.$refs.uToast.show({ }else if(this.quanxuan){
title: res.message, this.$emit("buy",{type,value:that.value})
type: res.errCode == 0 ? 'success' : 'warning', }else{
}) this.$refs.uToast.show({
}) title: '请选择规格',
} type: 'warning',
}, })
}
}else{
this.show = true
}
},
valChange(e) {
console.log(this.value)
},
self(){
// console.log(this.$refs.guige)
let index = 0;
let arr = [];
for(let i in this.info.spec_value){
// console.log(i)
// console.log(this.$refs.guige[index++].select)
// index++;
let sel = this.$refs.guige[index++].select
if(sel != 0){
arr.push(sel)
}
}
// console.log(arr.length)
if(arr.length == index){
this.sel = arr.join("|")
this.quanxuan = true
// console.log(this.sel)
}
}
},
watch:{
sel(){
// console.log(this.sel)
this.$emit('xuanze',this.sel)
}
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -42,6 +115,7 @@ export default {
width: 100%; width: 100%;
bottom:0; bottom:0;
border-top: 1rpx solid #ececec; border-top: 1rpx solid #ececec;
z-index: 1000000;
.navs{ .navs{
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -67,5 +141,48 @@ export default {
color: #fff; color: #fff;
} }
} }
.popup{
padding: 30rpx;
box-sizing: border-box;
max-height: 750rpx;
.head{
display: flex;
margin-bottom: 30rpx;
.image{
width: 195rpx;
height: 195rpx;
border-radius: 10rpx;
flex-shrink: 0;
}
.info{
display: flex;
padding: 21rpx 0;
justify-content: space-between;
margin-left: 27rpx;
flex-direction: column;
>text:first-child{
font-size: 28rpx;
color: #333;
}
>text:last-child{
font-size: 30rpx;
color: #ff3131;
}
}
}
.num{
height: 84rpx;
display: flex;
border-bottom: #ececec solid 2rpx;
justify-content: space-between;
align-items: center;
>text{
font-size: 26rpx;
color: #666;
}
}
}
</style> </style>

View File

@ -23,18 +23,22 @@
<view class="rich"> <view class="rich">
<rich-text :nodes="goodsInfo.mobile_body"></rich-text> <rich-text :nodes="goodsInfo.mobile_body"></rich-text>
</view> </view>
<tloos :id="goodsInfo.goods_commonid"></tloos> <tloos @buy="buy" @xuanze="xuanze" :id="goodsInfo.goods_commonid" :info="info"></tloos>
<u-toast ref="uToast" />
</view> </view>
</template> </template>
<script> <script>
import navs from "../components/sdetails/navs" import navs from "../components/sdetails/navs"
import tloos from "../components/sdetails/tloos" import tloos from "../components/sdetails/tloos"
export default { export default {
name:"sdetails", name:"sdetails",
data() { data() {
return { return {
list: [], list: [],
goodsInfo: {}, goodsInfo: {},
info:{},
glist:[],
id:0
} }
}, },
components:{ components:{
@ -42,10 +46,25 @@ export default {
tloos tloos
}, },
onLoad(option) { onLoad(option) {
this.getGoodsDetails(option.id); this.getGoodsDetails(option.id);
}, },
methods: { methods: {
buy(info){
if(info.type == 2){
this.$u.api.addCart({
goods_id: this.id,
quantity: info.value,
}).then(res => {
this.$refs.uToast.show({
title: res.errCode[1],
type: res.errCode == 0 ? 'success' : 'warning',
})
})
}
},
getGoodsDetails(id) { getGoodsDetails(id) {
this.id = id;
this.$u.api.getGoodsDetails({ id: id }).then((res)=>{ this.$u.api.getGoodsDetails({ id: id }).then((res)=>{
if (res.errCode == 0) { if (res.errCode == 0) {
this.goodsInfo = res.data; this.goodsInfo = res.data;
@ -58,8 +77,17 @@ export default {
// console.log(this.goodsInfo.mobile_body); // console.log(this.goodsInfo.mobile_body);
} }
}) })
} this.$u.api.goodsInfo({id}).then((res)=>{
console.log(res)
this.info = res.data.goods;
this.glist = res.data.spec_list;
})
},
xuanze(id){
console.log(id)
this.getGoodsDetails(this.glist[id])
}
}, },
} }
</script> </script>