| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <template>
- <view class="content">
- <view class="recommend">
- <view class="recommend-item" v-for="item in recommendList" :key="item.id" @click="navToDetailPage(item)">
- <view class="image-wrapper">
- <image :src="item.image" mode=""></image>
- </view>
- <view class="info-wrapper">
- <view class="title">{{ item.store_name}}</view>
- <view class="details">{{ item.details }}</view>
- <view class="price-box">
- <view class="price">
- <view class="current-price">
- ¥{{item.vip_price}}
- </view>
- <view class="old-price">
- ¥{{item.price}}
- </view>
- </view>
- <view class="buyNow">
- 立即购买
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- productIndexs
- } from '@/api/index.js';
- export default{
- data(){
- return{
- recommendList:[]
- }
- },
- onLoad() {
- this.loadData()
- },
- methods:{
- // 获取首页数据
- loadData() {
- productIndexs({},1).then(({
- data
- }) => {
- this.recommendList = data.list; // 为你推荐
- console.log('为你推荐',this.recommendList)
- })
- },
- // 跳转热销商品
- navToDetailPage(item) {
- uni.navigateTo({
- url: '/pages/product/product?id=' + item.id
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .content{
- width: 100%;
- height: 100%;
- }
- .recommend{
- padding: 0 24rpx;
- .recommend-item{
- width: 100%;
- display: flex;
- background-color: #fff;
- align-items: center;
- margin-top: 16rpx;
- border-radius: 12rpx;
- // padding: ;
- }
- }
- .image-wrapper{
- margin-left: 20rpx;
- width: 160rpx;
- height: 160rpx;
- // background-color: pink;
- flex-shrink: 0;
- // padding: 24rpx;
- image{
- width: 160rpx;
- height: 160rpx;
- opacity: 1;
- }
- }
- .info-wrapper{
- margin-left: 24rpx;
- width: 100%;
- display: flex;
- flex-direction: column;
- padding: 33rpx 18rpx 28rpx 0;
- }
- .title{
- font-size: 30rpx;
- color: #333;
- font-weight: 700;
- word-break: break-all;
- display: -webkit-box;
- -webkit-line-clamp: 1;
- -webkit-box-orient: vertical;
- overflow: hidden;
- }
- .details{
- color: #FE6A42;
- font-size: 24rpx;
- margin-top: 6rpx;
- }
- .price-box{
- display: flex;
- margin-top: 38rpx;
- justify-content: space-between;
- }
- .price{
- display: flex;
- margin-top: 12rpx;
- }
- .current-price{
- color: #FF0000;
- font-size: 32rpx;
- }
- .old-price{
- color:#999999;
- font-size: 24rpx;
- margin-top: 8rpx;
- margin-left: 12rpx;
- text-decoration: line-through;
- }
- .buyNow{
- background: linear-gradient(180deg, #FD4646, #FF3535);
- box-shadow: 0px 2rpx 20rpx 0px rgba(253, 67, 67, 0.5);
- border-radius: 30rpx;
- color: #FFFFFF;
- padding: 12rpx 24rpx;
- }
- </style>
|