dengrui/components/twocoluList.vue

67 lines
2.2 KiB
Vue
Raw Normal View History

2021-08-26 01:49:06 +00:00
<template>
<view class="padding-zy20 disba flw">
<view v-if="dataList.length!=0" class="discc radius10 padding20 margin-x20" v-for="(item,index) in dataList" :key="index"
style="background-color: #FFFFFF;width: 43%;box-shadow: 0 0 30rpx rgba(0,0,0,0.1);">
<image @tap="goDetail(item.spu_id)" class="pimg radius10 margin-s10" :src="item.src" mode="aspectFill"></image>
<view class="clips2 margin-s10 width100" style="font-size: 27rpx;height: 68rpx;text-align: left;">{{item.title}}</view>
<view class="disba width100 margin-sx10">
<view class="disac fon24 colorf78">
<view><text class="fon36 bold">{{item.price}}</text>.00</view>
<view class="flexs radius16 colorb fon24 margin-z10" style="background-color: #4cc474;line-height: 30rpx;height: 30rpx;">
<view style="transform: scale(0.7);margin-top: -1rpx;">放心购</view>
</view>
</view>
2021-08-27 08:01:51 +00:00
<image v-if="user_type!='personal'" @tap="addChe(item.id)" class="pche" src="/static/img/public/gouwcar.png"></image>
2021-08-26 01:49:06 +00:00
</view>
</view>
<view v-if="dataList.length==0" class="kongk width100 text-center"></view>
</view>
</template>
<script>
export default {
props:{
dataList:{
type:Array,
default:function(){
return []
}
}
},
data() {
return {
2021-08-27 08:01:51 +00:00
user_type:uni.getStorageSync('user_type')//权限
2021-08-26 01:49:06 +00:00
};
},
methods:{
addChe(id){//加入购物车事件
// console.log(this.dataList);
if(uni.getStorageSync('is_active')==0) {
this.$toolAll.tools.showToast('您目前是游客,请授权登录')
setTimeout(()=>{
uni.navigateTo({url:'/pages/login/login'})
},1500)
} else {
this.$emit('addChe')
this.$requst.post('order/shopping-cart-add',{sku_id:id,num:1}).then(res=>{
if(res.code==0){
this.$toolAll.tools.showToast('添加购物车成功(*^▽^*)')
}
},error=>{})
}
},
goDetail(index){
// console.log('进入详情页'+index);
uni.navigateTo({
url:'/pagesA/productDetail/productDetail?id='+index
})
}
},
}
</script>
<style>
</style>