| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <template>
- <view class="goodsCard" @click="goGoodsDetail(data)">
- <view class="pic">
- <u-image width="360rpx" height="360rpx" mode="aspectFit" :src="data.cover" error-icon="../../../static/img/quesheng.png"></u-image>
- </view>
- <view class="inner">
- <view class="title">{{ data.title }}</view>
- <view class="titlesm" v-if="data.publish">{{data.publish}}</view>
- <view class="info">
- <view class="money">
- <view class="now">
- <text>¥</text>
- <text>{{ data.price_selling }}</text>
- </view>
- <!-- <view class="old" v-if="showOldMoney">
- <text>¥{{ data.oldMoney }}</text>
- </view> -->
- </view>
- <!-- <view class="sale">
- <text>月销</text>
- <text>{{ $replaceSale(data.num) }}</text>
- </view> -->
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
- // 数据源
- data: {
- type: Object,
- default: () => {
- return {};
- }
- },
- // 是否显示原价
- showOldMoney: {
- type: Boolean,
- default: false
- }
- },
- methods: {
- goGoodsDetail(item) {
- uni.navigateTo({
- url: '/pages-mall/pages/goods/detail?goodsId='+item.id
- });
- },
- addCart(item){
- this.$u.api.addCartAjax({
- goods_id:item.id,
- nums: 1,
- sku_id:1,//1是测试,应该传入skuId,外层没有返回,需要接口返回一下
- }).then(({code})=>{
- if(code==1){
- this.$u.toast('添加购物车成功')
- }
- })
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .goodsCard {
- width: 340rpx;
- background-color: $app-theme-bg-color;
- overflow: hidden;
- margin-bottom: 16rpx;
- background-color: #fff;
- border-radius: 10rpx 10rpx 0 0;
- .pic {
- overflow: hidden;
- width: 100%;
- background-color: #fff;
- }
- .inner {
- padding: 22rpx 18rpx 26rpx 24rpx;
- }
- .title {
- width: 100%;
- height: 3em;
- line-height: 1.5;
- word-break: break-all;
- white-space: pre-wrap;
- font-size: 28rpx;
- color: $app-theme-text-black-color;
- margin-bottom: 8rpx;
- // 默认单行,如果需要瀑布流则改成多行
- display: -webkit-box;
- overflow: hidden;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .titlesm{
- font-size: 24rpx;
- font-weight: 400;
- color: #999;
- margin-bottom: 8rpx;
- display: -webkit-box;
- overflow: hidden;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .info {
- display: flex;
- justify-content: space-between;
- align-items: flex-end;
- .money {
- display: flex;
- align-items: flex-end;
- .now {
- font-weight: bold;
- text:nth-child(1) {
- font-size: 20rpx;
- color: $app-theme-text-money-color;
- }
- text:nth-child(2) {
- font-size: 30rpx;
- color: $app-theme-text-money-color;
- }
- }
- .old {
- text {
- font-size: 20rpx;
- color: $app-theme-card-gray-color;
- text-decoration-line: line-through;
- }
- }
- }
- .sale {
- font-size: 24rpx;
- font-weight: 400;
- color: $app-theme-card-gray-color;
- }
- }
- }
- </style>
|