| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <template>
- <view class="similar-goods">
- <view class="goods" @click="goDetail(goods.goods_id)">
- <image :src="goods.goods_img" mode=""></image>
- <view class="goods-intro">
- <view>{{goods.goodsName}}</view>
- <view>{{goods.goods_sn}}</view>
- <view>¥{{goods.goods_price | unitPrice}}</view>
- </view>
- <!-- <button>找相似</button> -->
- </view>
- <view class="title">相似好货 为您推荐</view>
- <view class="scroll-con">
- <view v-if="nomsg">没有相似商品</view>
- <view v-else class="con" v-for="(item,index) in goodsList" :key="index" @click="goDetail(item)">
- <image :src="item.thumbnail" mode=""></image>
- <view class="nowrap">{{item.name}}</view>
- <view>
- <text>¥{{item.price | unitPrice}}
- <!-- <text v-if="item.point">+{{item.point || 0}}积分</text> -->
- </text>
- <text>¥{{item.mktprice}}</text>
- </view>
- <view>
- <text>已售{{item.buy_count}}件</text>
- <text>{{item.grade}}%好评</text>
- </view>
- </view>
- </view>
- <uni-load-more :status="loadStatus"></uni-load-more>
- </view>
- </template>
- <script>
- import {
- getGoodsList
- } from '@/api/goods.js';
- export default {
- data() {
- return {
- loadStatus: 'more',
- params: {
- pageNumber: 1,
- pageSize: 10,
- keyword: ''
- },
- goods: {},
- goodsList: [],
- nomsg: false,
- };
- },
- methods: {
- getList() {
- uni.showLoading({
- title: "加载中"
- })
- this.params.keyword = this.goods.goodsName;
- getGoodsList(this.params).then(res => {
- uni.hideLoading()
- if (res.statusCode == 200) {
- let data = res.data;
- if (data.data_total == 0) {
- // this.nomsg = true;
- this.loadStatus = 'noMore';
- } else if (data.data_total < 10) {
- this.loadStatus = 'noMore'
- this.goodsList.push(...data.data)
- } else {
- this.goodsList.push(...data.data);
- if (data.data.length < 10) this.loadStatus = 'noMore'
- }
- }
- })
- },
- goDetail(item) {
- uni.navigateTo({
- url: '/pages/product/goods?id=' + item.id + "&goodsId=" +item.goodsId
- })
- },
- loadData() {
- if(this.loadStatus!='noMore'){
- this.params.pageNumber++;
- this.getList()
- }
- },
- },
- onLoad(option) {
- this.goods = JSON.parse(decodeURIComponent(option.goods))
-
- this.getList()
- },
- onReachBottom() { //触底事件,页面整个滚动使用
- this.loadData()
- }
- }
- </script>
- <style lang="scss" scoped>
- @import './collect.scss';
- .title {
- height: 110rpx;
- line-height: 110rpx;
- text-align: center;
- color: #333;
- background-color: #F1F1F1;
- margin-top: 20rpx;
- font-size: $font-base;
- }
- .goods {
- padding: 0 30rpx;
- }
- .scroll-con {
- width: 750rpx;
- flex-wrap: wrap;
- .con {
- width: 345rpx;
- margin: 20rpx 0 0 20rpx;
- background-color: #FFFFFF;
- border-radius: 10rpx;
- box-sizing: border-box;
- display: inline-block;
- font-size: $font-sm;
- // line-height: 1.5em;
- image {
- width: 100%;
- height: 320rpx;
- border-radius: 8rpx 8rpx 0 0;
- }
- view{
- padding: 0 20rpx;
- &::after{
- content: '';
- display: block;
- clear: right;
- }
- text {
- display: inline-block;
- color: #999;
- }
-
- text:nth-child(2) {
- float: right;
- text-align: right;
- }
- }
- view:last-child{
- margin-bottom: 20rpx;
- }
- .nowrap {
- position: relative;
- line-height: 1.4em;
- max-height: 2.8em; //height是line-height的整数倍,防止文字显示不全
- overflow: hidden;
- }
-
- view:nth-child(2) {
- font-size: 26rpx;
- }
- view:nth-child(3) {
- margin-top: 10rpx;
- font-weight: bold;
- text:nth-child(1) {
- color: #f56c6c;
- }
- text:nth-child(2) {
- color: #d7d7d7;
- text-decoration: line-through;
- }
- }
- view:nth-child(4) {
- margin-top: 10rpx;
- }
- }
- }
- </style>
|