邓平艺 4 years ago
parent
commit
060c694247
  1. 32
      components/lf-waterfall-shopdetails/lf-waterfall.vue
  2. 69
      pages/shop/goodsdetail.vue
  3. 76
      pages/user/my/collect.vue

32
components/lf-waterfall-shopdetails/lf-waterfall.vue

@ -3,56 +3,56 @@
<u-waterfall v-model="dataList" ref="uWaterfall" v-for="itemFather of listlength" :key="itemFather" v-if="itemFather == tabindex">
<template v-slot:left="{leftList}">
<view class="list-warter" v-for="(item, index) in leftList" :key="index">
<view v-if="!item.is_ad" @click="onClick(item.id)">
<u-lazy-load threshold="-450" border-radius="8px 8px 0 0" :height="!ifsale?333:0" :img-mode="ifsale?'aspectFill':''" :image="item.picture" :index="index">
<view class="list-label" v-if="ifsale">已售{{item.sale}}</view>
<view @click="onClick(item.id)">
<u-lazy-load threshold="-450" border-radius="8px 8px 0 0" :height="!ifsale?333:0" :img-mode="ifsale?'aspectFill':''" :image="item.collectable.img" :index="index">
<view class="list-label" v-if="ifsale">已售{{item.collectable.sale_count}}</view>
</u-lazy-load>
<view class="lf-p-20">
<view class="list-title">
{{item.title}}
{{item.collectable.name}}
</view>
<view class="list-price">
<!-- <text>{{item.price}}</text> -->
<lf-price :price="item.price"></lf-price>
<text class="lf-m-l-20 lf-font-24 lf-color-666 lf-line-through">{{item.original_price}}</text>
<lf-price :price="item.collectable.sell_price"></lf-price>
<text class="lf-m-l-20 lf-font-24 lf-color-666 lf-line-through">{{item.collectable.market_price}}</text>
</view>
</view>
</view>
<view v-else @click="goAd(item.type,item.url)">
<!-- <view v-else @click="goAd(item.type,item.url)">
<u-lazy-load threshold="-450" border-radius="8px 8px 0 0" :image="item.picture" :index="index"></u-lazy-load>
<view class="lf-p-20">
<view class="list-title">
{{item.title}}
</view>
</view>
</view>
</view> -->
</view>
</template>
<template v-slot:right="{rightList}">
<view class="list-warter" v-for="(item, index) in rightList" :key="index">
<view v-if="!item.is_ad" @click="onClick(item.id)">
<u-lazy-load threshold="-450" border-radius="8px 8px 0 0" :height="!ifsale?333:0" :img-mode="ifsale?'aspectFill':''" :image="item.picture" :index="index">
<view class="list-label" v-if="ifsale">已售{{item.sale}}</view>
<view @click="onClick(item.id)">
<u-lazy-load threshold="-450" border-radius="8px 8px 0 0" :height="!ifsale?333:0" :img-mode="ifsale?'aspectFill':''" :image="item.collectable.img" :index="index">
<view class="list-label" v-if="ifsale">已售{{item.collectable.sale_count}}</view>
</u-lazy-load>
<view class="lf-p-20">
<view class="list-title">
{{item.title}}
{{item.collectable.name}}
</view>
<view class="list-price">
<!-- <text>{{item.price}}</text> -->
<lf-price :price="item.price"></lf-price>
<text class="lf-m-l-20 lf-font-24 lf-color-666 lf-line-through">{{item.original_price}}</text>
<lf-price :price="item.collectable.sell_price"></lf-price>
<text class="lf-m-l-20 lf-font-24 lf-color-666 lf-line-through">{{item.collectable.market_price}}</text>
</view>
</view>
</view>
<view v-else @click="goAd(item.type,item.url)">
<!-- <view v-else @click="goAd(item.type,item.url)">
<u-lazy-load threshold="-450" border-radius="8px 8px 0 0" :image="item.picture" :index="index"></u-lazy-load>
<view class="lf-p-20">
<view class="list-title">
{{item.title}}
</view>
</view>
</view>
</view> -->
</view>
</template>
</u-waterfall>

69
pages/shop/goodsdetail.vue

@ -289,7 +289,6 @@
this.goods_id = options.goods_id;
this.type = options.type || 'mail';
console.log('商品',this.goods_id)
// this.getGoodsDetail();
this.getNewdetail();
},
computed: {
@ -300,6 +299,34 @@
}
},
methods: {
//
switchCollect(){
let userInfo = this.$cookieStorage.get('user_token') || {};
if(!userInfo){
this.$url('/pages/login/index');
return;
}
this.addCollcet()
},
//
addCollcet() {
console.log('当前的商品id',this.goods_detail.id)
this.$http.post({
api: 'api/collect/create',
data: {
type:'jc_goods',
collect_id: this.goods_detail.id,
},
header: {
Authorization: this.$cookieStorage.get('user_token')
}
}).then(res => {
this.$msg(res.data.data);
this.getNewdetail();
}).catch(err => {
console.log("====", err);
})
},
showFreight(){
this.show_freight = true;
},
@ -362,52 +389,22 @@
})
},
getGoodsDetail(){
this.$http(this.API.API_ADVICEDETAILS, {id: this.goods_id}).then(res => {
this.skeletonLoading = false;
this.goods_detail = res.data;
this.is_collect = Boolean(res.data.is_collect) || false;
}).catch(err => {
this.skeletonLoading = false;
setTimeout(() => {
this.$toBack();
}, 1000);
})
},
getNewdetail(){
this.$http.get({
api: '/api/store/detail/4'
api: '/api/store/detail/'+this.goods_id,
header: {
Authorization: this.$cookieStorage.get('user_token')
}
}).then(res => {
console.log("===---", res);
this.goods_detail = res.data.data;
this.pictures = [res.data.data.img];
this.is_collect = Boolean(res.data.data.is_collect) || false;
console.log("this.pictures", this.pictures);
}).catch(err => {
console.log("====", err);
})
},
//
switchCollect(){
let userInfo = uni.getStorageSync('userinfo') || {};
if(!userInfo.id || !userInfo.nickname || !userInfo.avatar){
this.$url('/pages/login/index?type=userinfo');
return;
}
if(this.is_collect) {
this.$http(this.API.API_DELCOLLECT, {agent_product_id:this.goods_id}).then(res => {
this.$msg('取消收藏成功!')
this.is_collect = false
console.log(res)
})
}else {
this.$http(this.API.API_ADDCOLLECT, {agent_product_id:this.goods_id}).then(res => {
this.$msg('添加收藏成功!')
this.is_collect = true
console.log(res)
})
}
},
//
makePhoneCall(phoneStr){
uni.makePhoneCall({

76
pages/user/my/collect.vue

@ -1,8 +1,8 @@
<template>
<view>
<lf-nav :spreadOut="true" :showIcon="true" bgColor="#fff" title="收藏"></lf-nav>
<view v-if="title_tab.length">
<u-tabs :list="title_tab" active-color="#15716E" inactive-color='#777777' :is-scroll="true" :current="title_current" @change="titletabChange"></u-tabs>
<view v-if="tab_list.length">
<u-tabs :list="tab_list" active-color="#15716E" inactive-color='#777777' :is-scroll="true" :current="title_current" @change="titletabChange"></u-tabs>
</view>
<view v-if="title_current==0">
@ -20,7 +20,7 @@
</view>
</view>
<view class="lf-p-b-30 lf-m-t-30" v-else>
<lf-waterfall :list="list" :ifsale="false" ref="uWaterfall"></lf-waterfall>
<lf-waterfall :list="tab_list[0].list" :ifsale="false" ref="uWaterfall"></lf-waterfall>
<!-- <u-loadmore v-if="recomm_list.length" status="已加载全部数据~" @loadmore="addRandomData"></u-loadmore> -->
<view class="loading-more">
<text :class="{'loading-more-text': loading_class}" v-if="list.length">{{ loading_text }}</text>
@ -35,10 +35,24 @@
import lfWaterfall from '@/components/lf-waterfall-shopdetails/lf-waterfall.vue';
export default {
data() {
let _public = {
page: 1,
isPage: true,
loadingClass: true,
loadingText: '正在加载中'
}
return {
title_tab: [
{name:'推荐'},
{name:'商品'}
tab_list: [
{
name:'品牌',
type: 'jc_brand',
..._public
},
{
name:'商品',
type: 'jc_goods',
..._public
}
],
title_current:0,
list: [
@ -85,8 +99,9 @@
],
show_count: 0,
windowHeight: 0,
loading_text: '没有更多数据啦~',
loading_class: false
scrollH: 0,
nav_height: 0,
isRefresher: true
}
},
components: {
@ -94,20 +109,55 @@
},
onShow(){
this.windowHeight = getApp().globalData.windowHeight;
this.getData();
},
methods: {
titletabChange(index){
this.title_current = index;
},
getData() {
let tab_item = this.tab_list[this.current];
let isPage = false;
getData(options = {}) {
let tab_item = this.tab_list[this.title_current];
this.$http
.get({
api: 'api/collect',
data: {
type: 'jc_goods'
},
header: {
Authorization: this.$cookieStorage.get('user_token')
},
})
.then(res => {
console.log(res.data)
if (res.data.code == 200) {
let isPage = res.data.data.next_page_url == null?false:true;
tab_item.isPage = isPage;
if(!isPage){
if(!isPage) {
tab_item.loadingClass = false;
tab_item.loadingText = '没有更多数据啦~';
}
tab_item.isRefresher = false;
if(options.type == 'pageRefresh') {
uni.stopPullDownRefresh();
}else if(options.type == 'scrollRefresh') {
this.isRefresher = false;
}
if(tab_item.page == 1) {
tab_item.list = res.data.data.data;
}else {
tab_item.list.push(...res.data.data.data);
}
console.log('当前列表数据',tab_item.list)
} else {
wx.showModal({
content: '请下拉页面刷新重试',
showCancel: false
});
}
wx.hideLoading();
})
.catch(() => {
wx.hideLoading();
});
},
//
swiperChange(event){

Loading…
Cancel
Save