Commit 2f5706ae authored by ziyu's avatar ziyu

feat: 代码赞长存

parent 9c8e7a7f
...@@ -53,5 +53,8 @@ module.exports = { ...@@ -53,5 +53,8 @@ module.exports = {
}, },
checkCornCode(params) { checkCornCode(params) {
return http.post('/api/user/addCoins', params); return http.post('/api/user/addCoins', params);
} },
getGoodsList(params) {
return http.post(`/api/goods/list/${params}`);
},
}; };
import wepy from '@wepy/core'; import wepy from '@wepy/core';
import Notify from '../components/vant/notify/notify'; import Notify from '../components/vant/notify/notify';
const env = 'test'; // 每次上线手动切换成 prod/test const env = 'prod'; // 每次上线手动切换成 prod/test
let baseUrl = 'https://api-luckii.q-gp.com'; let baseUrl = 'https://api-luckii.q-gp.com';
if (env === 'test') { if (env === 'test') {
baseUrl = 'https://luckii-qa.liangkebang.net'; baseUrl = 'https://luckii-qa.liangkebang.net';
......
...@@ -14,17 +14,18 @@ ...@@ -14,17 +14,18 @@
> >
<!--bindtouchstart="touchStart" <!--bindtouchstart="touchStart"
bindtouchend="touchEnd"--> bindtouchend="touchEnd"-->
<!-- {{item.select?'delete':''}} -->
<swiper-item wx:for="{{list}}" wx:key="index"> <swiper-item wx:for="{{list}}" wx:key="index">
<view <view
data-itemid="{{index}}" data-itemid="{{index}}"
bindtap="toViewPage" bindtap="toViewPage"
data-item="{{item}}" data-item="{{item}}"
class="list-item {{item.select?'delete':''}} {{tools.computClass(currentIndex,index,list.length,circular)}}" class="list-item {{tools.computClass(currentIndex,index,list.length,circular)}}"
> >
<image src="{{item.imgsrc}}" class="img"></image> <image src="{{item.images}}" class="img"></image>
<view class="text">{{item.text}}</view> <view class="title">{{item.title}}</view>
<p class="price">{{item.price}}</p> <p class="price">{{item.price}}</p>
<p class="buy">{{item.people}}人购买</p> <p class="buy">{{item.saleCount}}人购买</p>
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>
...@@ -32,39 +33,29 @@ ...@@ -32,39 +33,29 @@
</template> </template>
<script> <script>
import wepy from '@wepy/core'; import wepy from '@wepy/core';
let touchDotX = 0; import { getGoodsList } from '../../common/api'
let touchDotY = 0; let touchDotX = 0, touchDotY = 0, page = 0, goodsIds = [], isListDone = false;
const goodsNum = 20;
wepy.component({ wepy.component({
props: {
goodsList: {
type: Array,
default: []
}
},
data: { data: {
swiperItem: 2, swiperItem: 2,
current: 1, current: 1,
currentIndex: 1, // 商品当前滑动到第几个 currentIndex: 1, // 商品当前滑动到第几个
circular: false, // 商品是否无限循环 circular: false, // 商品是否无限循环
topPage: 0,
lastPage: 0,
list: [] list: []
}, },
watch: {
goodsList(val) {
/* let list = val || [];
this.list = list; */
}
},
created() { created() {
// 获取推荐的商品列表 // 获取推荐的商品列表
this.list = [{value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: 'https://u.jd.com/EToRju'}, /*this.list = [{sourceId: 11, title: '白色条纹马克杯,马克吐温同款11', images: '/static/images/test1.jpg', price: '¥9.89', saleCount: 2200, sku: 'https://u.jd.com/EToRju'},
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: 'https://u.jd.com/EToRju'}, {sourceId: 12, title: '白色条纹马克杯,马克吐温同款12', images: '/static/images/test2.png', price: '¥19.20', saleCount: '2200', sku: 'https://u.jd.com/EToRju'},
{value: 13, text: '白色条纹马克杯,马克吐温同款13', imgsrc: '/static/images/peo1.jpg', price: '¥39.08', people: 2200, sku: 'https://u.jd.com/EToRju'}, {sourceId: 13, title: '白色条纹马克杯,马克吐温同款13', images: '/static/images/peo1.jpg', price: '¥39.08', saleCount: 2200, sku: 'https://u.jd.com/EToRju'},
{value: 14, text: '白色条纹马克杯,马克吐温同款14', imgsrc: '/static/images/peo2.jpg', price: '¥599.20', people: 2200, sku: 'https://u.jd.com/EToRju'}, {sourceId: 14, title: '白色条纹马克杯,马克吐温同款14', images: '/static/images/peo2.jpg', price: '¥599.20', saleCount: 2200, sku: 'https://u.jd.com/EToRju'},
{value: 15, text: '白色条纹马克杯,马克吐温同款15', imgsrc: '/static/images/peo3.jpg', price: '¥2399.01', people: 2200, sku: 'https://union-click.jd.com/jdc?e=&p=AyIGZRtdFQMRB1IcWREyFw9cHlgcBRUOUBJrUV1KWQorAlBHU0VeBUVOWk1RAk8ECllHGAdFBwtaV1MJBAJQXk8JF0EfGQcaDlAYUhIFGwJcDBsZdXtdBm8oQF5lBT1IL2YCRXAKeCh1ZnlFIkM%2FRXtxVVNsOXVSZnM1HCxNYnFzMW9dYkp2YiJCDlRhYG8NbBJAXWV%2BMX8vXFdFYB18JHV2YkUCTTBecRNvU20iQHRyYyZFLWd2cmQ2bAd1e0t1NUIJHWIQZzB4Am0FZU8xfi9mV1Z%2FLEk5YnFHRSFECXZ7cGdBGS4lfWpAVBsnVAFxfgV%2FOxRyQQ4ReC1IRB4LZRprFQMTBFwZXhcAFjdlG1wlQ3wHVBtaFwEbBmUaaxUGGgRWElIUAxIAVx5rEgIbNw5ONRMFGwZcS14UUkEFAhxrJTIRN2UrWxYyETcXdVoXChMBUxILRwsVAVBMWRJSE1BSSw5GUkcOURxbQFBFN1caWhEL'}, {value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: 'https://union-click.jd.com/jdc?e=&p=AyIGZRtdFQMRB1IcWREyFw9cHlgcBRUOUBJrUV1KWQorAlBHU0VeBUVOWk1RAk8ECllHGAdFBwtaV1MJBAJQXk8JF0EfGQcaDlAYUhIFGwJcDBsZdXtdBm8oQF5lBT1IL2YCRXAKeCh1ZnlFIkM%2FRXtxVVNsOXVSZnM1HCxNYnFzMW9dYkp2YiJCDlRhYG8NbBJAXWV%2BMX8vXFdFYB18JHV2YkUCTTBecRNvU20iQHRyYyZFLWd2cmQ2bAd1e0t1NUIJHWIQZzB4Am0FZU8xfi9mV1Z%2FLEk5YnFHRSFECXZ7cGdBGS4lfWpAVBsnVAFxfgV%2FOxRyQQ4ReC1IRB4LZRprFQMTBFwZXhcAFjdlG1wlQ3wHVBtaFwEbBmUaaxUGGgRWElIUAxIAVx5rEgIbNw5ONRMFGwZcS14UUkEFAhxrJTIRN2UrWxYyETcXdVoXChMBUxILRwsVAVBMWRJSE1BSSw5GUkcOURxbQFBFN1caWhEL'}, {sourceId: 15, title: '白色条纹马克杯,马克吐温同款15', images: '/static/images/peo3.jpg', price: '¥2399.01', saleCount: 2200, sku: 'https://u.jd.com/EToRju'},
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: 'https://union-click.jd.com/jdc?e=&p=AyIGZRtdFQMRB1IcWREyFw9cHlgcBRUOUBJrUV1KWQorAlBHU0VeBUVOWk1RAk8ECllHGAdFBwtaV1MJBAJQXk8JF0EfGQcaDlAYUhIFGwJcDBsZdXtdBm8oQF5lBT1IL2YCRXAKeCh1ZnlFIkM%2FRXtxVVNsOXVSZnM1HCxNYnFzMW9dYkp2YiJCDlRhYG8NbBJAXWV%2BMX8vXFdFYB18JHV2YkUCTTBecRNvU20iQHRyYyZFLWd2cmQ2bAd1e0t1NUIJHWIQZzB4Am0FZU8xfi9mV1Z%2FLEk5YnFHRSFECXZ7cGdBGS4lfWpAVBsnVAFxfgV%2FOxRyQQ4ReC1IRB4LZRprFQMTBFwZXhcAFjdlG1wlQ3wHVBtaFwEbBmUaaxUGGgRWElIUAxIAVx5rEgIbNw5ONRMFGwZcS14UUkEFAhxrJTIRN2UrWxYyETcXdVoXChMBUxILRwsVAVBMWRJSE1BSSw5GUkcOURxbQFBFN1caWhEL'} {sourceId: 11, title: '白色条纹马克杯,马克吐温同款11', images: '/static/images/test1.jpg', price: '¥9.89', saleCount: 2200, sku: 'https://u.jd.com/EToRju'},
]; {sourceId: 12, title: '白色条纹马克杯,马克吐温同款12', images: '/static/images/test2.png', price: '¥19.20', saleCount: '2200', sku: 'https://u.jd.com/EToRju'}
];*/
this.getList();
goodsIds = this.list.map(item => item.sourceId);
}, },
methods: { methods: {
moveSwiper(e) { moveSwiper(e) {
...@@ -88,39 +79,38 @@ ...@@ -88,39 +79,38 @@
if (e.$wx.detail.source === 'touch') { if (e.$wx.detail.source === 'touch') {
let current = e.$wx.detail.current; let current = e.$wx.detail.current;
let totalPage = 0; /*let nextlist = [
let nextlist = [ {sourceId: 11, title: '白色条纹马克杯,马克吐温同款11', images: '/static/images/test1.jpg', price: '¥9.89', saleCount: 2200, sku: 'https://u.jd.com/EToRju'},
{value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: '100004549235'}, {sourceId: 12, title: '白色条纹马克杯,马克吐温同款12', images: '/static/images/test2.png', price: '¥19.20', saleCount: '2200', sku: 'https://u.jd.com/EToRju'},
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: '100004549235'}, {sourceId: 13, title: '白色条纹马克杯,马克吐温同款13', images: '/static/images/peo1.jpg', price: '¥39.08', saleCount: 2200, sku: 'https://u.jd.com/EToRju'},
{value: 13, text: '白色条纹马克杯,马克吐温同款13', imgsrc: '/static/images/peo1.jpg', price: '¥39.08', people: 2200, sku: '100004549235'}, {sourceId: 14, title: '白色条纹马克杯,马克吐温同款14', images: '/static/images/peo2.jpg', price: '¥599.20', saleCount: 2200, sku: 'https://u.jd.com/EToRju'},
{value: 14, text: '白色条纹马克杯,马克吐温同款14', imgsrc: '/static/images/peo2.jpg', price: '¥599.20', people: 2200, sku: '100004549235'}, {sourceId: 15, title: '白色条纹马克杯,马克吐温同款15', images: '/static/images/peo3.jpg', price: '¥2399.01', saleCount: 2200, sku: 'https://u.jd.com/EToRju'}
{value: 15, text: '白色条纹马克杯,马克吐温同款15', imgsrc: '/static/images/peo3.jpg', price: '¥2399.01', people: 2200, sku: '100004549235'} ];*/
];
let that = this; let that = this;
/* if(current <= 2) {
debounce(setTimeout(function(){
that.topPage +=1;
if(that.lastPage+that.topPage >= totalPage) {
that.circular = true;
return;
}
that.list = [...newlist, ...that.list];
// that.current = current+1;
// that.currentIndex = current+1;
},1000),500);
} */
if (current >= this.list.length - 3) { if (current >= this.list.length - 3) {
debounce(setTimeout(function() { debounce(setTimeout(function() {
that.lastPage += 1; that.getList();
if (that.lastPage + that.topPage >= totalPage) { // 当新得到的list长度不足20个时,表明商品全部得到,开启无限循环
/*if(nextlist.length < goodsNum) {
that.circular = true; that.circular = true;
} }
that.list = [...that.list, ...nextlist]; that.list = [...that.list, ...nextlist];*/
}, 1000), 500); }, 1000), 500);
} }
} }
}, },
getList() {
if(isListDone) return;
page++;
getGoodsList(page).then(data => {
if(data.length < goodsNum) {
//如果小于4个商品,一行就能显示,不用循环
this.list.length>4 && (this.circular = true)
isListDone = true;
}
this.list = [...this.list,...data];
});
},
toViewPage(e) { toViewPage(e) {
let item = e.$wx.currentTarget.dataset.item; let item = e.$wx.currentTarget.dataset.item;
wx.navigateToMiniProgram({ wx.navigateToMiniProgram({
...@@ -251,14 +241,15 @@ ...@@ -251,14 +241,15 @@
margin:0 auto; margin:0 auto;
border-radius: 10rpx; border-radius: 10rpx;
} }
.list-item .text { .list-item .title {
font-size: @font-small; font-size: @font-small;
text-overflow: ellipsis; title-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
-webkit-line-clamp: 2; //行数 -webkit-line-clamp: 2; //行数
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
overflow: hidden; overflow: hidden;
line-height:24rpx; line-height:24rpx;
word-break:break-all;
margin-top:10rpx; margin-top:10rpx;
} }
.list-item .price{ .list-item .price{
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
binderror="onError" binderror="onError"
bindtimeupdate="onTimeUpdate" bindtimeupdate="onTimeUpdate"
@tap="videoTap" @tap="videoTap"
custom-cache="{{false}}"
v-if="item.showType && item.showType.value === 2" v-if="item.showType && item.showType.value === 2"
> >
<video-loading v-if="item.time === 0" :snapshot="item.videoSnapUrl"/> <video-loading v-if="item.time === 0" :snapshot="item.videoSnapUrl"/>
......
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
<shared-popup v-if="showModal === 1" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"/> <shared-popup v-if="showModal === 1" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"/>
<popup @showMenu="showMenu" :showMenus="showModal === 3"/> <popup @showMenu="showMenu" :showMenus="showModal === 3"/>
<!--商品推荐列表--> <!--商品推荐列表-->
<goods-list></goods-list> <!--<goods-list></goods-list>-->
<van-dialog id="van-dialog"/> <van-dialog id="van-dialog"/>
<van-notify id="van-notify"/> <van-notify id="van-notify"/>
<van-popup show="{{ cornModal }}" bind:close="cornModalClose" custom-style="background-color:transparent"> <van-popup show="{{ cornModal }}" bind:close="cornModalClose" custom-style="background-color:transparent">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment