123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <template>
- <view>
- <view class="like-title">
- <image src="/static/images/tui.png" mode=""></image>
- <text class="text">精选药品</text>
- </view>
- <view class="like-list">
- <view class="item" v-for="(item,index) in list" :key="index" @click="showProduct(item)">
- <view class="img-box">
- <image :src="item.image" mode=""></image>
- </view>
- <view class="info-box">
- <view class="title ellipsis2">{{ item.productName }}</view>
- <view class="price-box">
- <view class="now">
- <text class="unit">¥</text>
- <text class="num">{{item.price.toFixed(2)}}</text>
- </view>
- <view class="old">¥{{item.otPrice.toFixed(2)}}</view>
- </view>
- </view>
- </view>
- </view>
- <Loading :loaded="loaded" :loading="loading"></Loading>
- </view>
- </template>
- <script>
- import {getTuiProducts} from '@/api/product'
- import Loading from "@/components/Loading";
- export default {
- components: {Loading },
- name: "likeProduct",
- data() {
- return {
- page:{
- page: 1,
- pageSize: 10
- },
- total:0,
- list:[],
- loaded: false,
- loading: false
- };
- },
- created() {
- },
- mounted() {
- this.getTuiProducts();
- },
-
- methods: {
- getTuiProducts(){
- console.log(1)
- var that=this;
- if (that.loaded == true || that.loading == true) return;
- that.loading = true;
- uni.showLoading({
- title:"加载中..."
- })
- getTuiProducts(that.page).then(
- res => {
- if(res.code==200){
- that.total=res.data.total;
- that.list.push.apply(that.list, res.data.list);
- that.loading = false;
- that.loaded = that.list.length<that.total?false:true;
- that.page.page = that.page.page + 1;
- uni.hideLoading()
- }
- },
- err => {
- uni.hideLoading()
- uni.showToast({
- title: err.msg ,
- icon: 'none',
- duration: 2000
- });
- }
- );
- },
- showProduct(item){
- uni.navigateTo({
- url: '/pages/shopping/productDetails?productId='+item.productId
- })
- },
- }
-
- };
- </script>
- <style lang="scss">
- .like-title{
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 15upx 0rpx 30upx 0rpx;
- image{
- width: 37upx;
- height: 37upx;
- margin-right: 20upx;
- }
- .text{
- font-size: 36upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #111111;
- line-height: 1;
- }
- }
- .like-list{
- display: flex;
- flex-wrap: wrap;
- .item{
- margin-right: 20rpx;
- margin-bottom: 20rpx;
- width: 345rpx;
- background: #FFFFFF;
- box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
- border-radius: 20rpx;
- overflow: hidden;
- &:nth-child(2n) {
- margin-right: 0;
- }
- .img-box{
- width: 100%;
- height: 334upx;
- image{
- width: 100%;
- height: 100%;
- }
- }
- .info-box{
- box-sizing: border-box;
- height: 182upx;
- padding: 20upx 20upx 30upx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .title{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #111111;
- line-height: 40upx;
- }
- .price-box{
- display: flex;
- align-items: flex-end;
- .now{
- display: flex;
- align-items: flex-end;
- margin-right: 20upx;
- .unit{
- font-size: 24upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FF6633;
- line-height: 1.2;
- margin-right: 4upx;
- }
- .num{
- font-size: 36upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FF6633;
- line-height: 1;
- }
- }
- .old{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- text-decoration: line-through;
- color: #BBBBBB;
- line-height: 1.1;
- }
- }
- }
- }
- }
- </style>
|