123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <template>
- <view class="container">
- <!-- 空白页 -->
- <empty v-if="favoriteList.length < 1"></empty>
- <view class="favorites flex" v-for="ls in favoriteList" @click="toproduct(ls.pid)">
- <view class="favorites_img"><image :src="ls.image"></image></view>
- <view class="favorites_list">
- <view class="favorites_name">{{ ls.store_name }}</view>
- <view class="favorites_peice flex">
- <view>
- <text>¥{{ ls.price }}</text>
- </view>
- <view class="icon_del" @click.prevent.stop="del(ls.pid)" v-show="delshow">
- <text class="iconfont icondelete"></text>
- <text>取消</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { getcollectList, delcollect } from '@/api/user.js';
- import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
- import empty from '@/components/empty';
- export default {
- components: {
- uniLoadMore,
- empty
- },
- data() {
- return {
- tabCurrentIndex: 0,
- favoriteList: '',
- delshow: true
- };
- },
- onLoad() {
- this.loadData();
- },
- methods: {
- //获取收藏夹列表
- loadData() {
- let obj = this;
- getcollectList({
- page: '1',
- limit: '10'
- })
- .then(function(e) {
- obj.favoriteList = e.data;
- console.log(obj.favoriteList);
- })
- .catch(function(e) {
- console.log(e);
- });
- },
- //跳转商品详情页
- toproduct(item) {
- let id = item;
- uni.navigateTo({
- url: `/pages/product/product?id=${id}`
- })
- },
- //删除收藏夹商品
- del(item) {
- let obj = this;
- uni.showModal({
- title: '提示',
- content: '是否取消收藏该商品',
- success: e => {
- if (e.confirm) {
- delcollect({
- id: item,
- category: 'product'
- })
- .then(function(e) {
- uni.showToast({
- title: '已取消收藏',
- duration: 1500,
- });
- obj.loadData();
- })
- .catch(function(e) {
- console.log(e);
- });
- }
- }
- });
- },
- }
- }
- </script>
- <style lang="scss">
- page {
- height: 100%;
- }
- %flex-center {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- }
- %section {
- display: flex;
- justify-content: space-around;
- align-content: center;
- background: #fff;
- border-radius: 10rpx;
- }
- .container {
- height: 100%;
- background-color: $page-color-base;
- padding: 15rpx 0rpx;
- font-size: 28rpx;
- }
- .favorites {
- width: 90%;
- background-color: #ffffff;
- border-radius: 15rpx;
- margin: 15rpx auto;
- padding: 25rpx 25rpx;
- margin-bottom: 25rpx;
- }
- .favorites_img {
- width: 80px !important;
- height: 80px;
- }
- .favorites_img image {
- width: 100%;
- height: 100%;
- }
- .favorites_list {
- width: 70%;
- padding-left: 20rpx;
- }
- .icon_del {
- color: $font-color-base;
- z-index: 9999;
- font-weight: bold;
- }
- .favorites_name {
- height: 80rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertial;
- -webkit-line-clamp: 2;
- }
- .favorites_peice {
- margin-top: 25rpx;
- color: #db1935;
- font-weight: bold;
- }
- </style>
|