Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mini-program-wepy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
mini-program-wepy
Commits
2f5706ae
Commit
2f5706ae
authored
Jun 17, 2020
by
ziyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 代码赞长存
parent
9c8e7a7f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
57 deletions
+52
-57
api.js
src/common/api.js
+4
-1
wxRequest.js
src/common/wxRequest.js
+1
-1
goodsList.wpy
src/components/custom/goodsList.wpy
+45
-54
prizeList.wpy
src/components/custom/prizeList.wpy
+1
-0
index.wpy
src/pages/index.wpy
+1
-1
No files found.
src/common/api.js
View file @
2f5706ae
...
...
@@ -53,5 +53,8 @@ module.exports = {
},
checkCornCode
(
params
)
{
return
http
.
post
(
'
/api/user/addCoins
'
,
params
);
}
},
getGoodsList
(
params
)
{
return
http
.
post
(
`/api/goods/list/
${
params
}
`
);
},
};
src/common/wxRequest.js
View file @
2f5706ae
import
wepy
from
'
@wepy/core
'
;
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
'
;
if
(
env
===
'
test
'
)
{
baseUrl
=
'
https://luckii-qa.liangkebang.net
'
;
...
...
src/components/custom/goodsList.wpy
View file @
2f5706ae
...
...
@@ -14,17 +14,18 @@
>
<!--bindtouchstart="touchStart"
bindtouchend="touchEnd"-->
<!-- {{item.select?'delete':''}} -->
<swiper-item wx:for="{{list}}" wx:key="index">
<view
data-itemid="{{index}}"
bindtap="toViewPage"
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.im
gsrc
}}" class="img"></image>
<view class="t
ext">{{item.text
}}</view>
<p class="price">{{item.price}}</p>
<p class="buy">{{item.
people
}}人购买</p>
<image src="{{item.im
ages
}}" class="img"></image>
<view class="t
itle">{{item.title
}}</view>
<p class="price">
¥
{{item.price}}</p>
<p class="buy">{{item.
saleCount
}}人购买</p>
</view>
</swiper-item>
</swiper>
...
...
@@ -32,39 +33,29 @@
</template>
<script>
import wepy from '@wepy/core';
let touchDotX = 0;
let touchDotY = 0;
import { getGoodsList } from '../../common/api'
let touchDotX = 0, touchDotY = 0, page = 0, goodsIds = [], isListDone = false;
const goodsNum = 20;
wepy.component({
props: {
goodsList: {
type: Array,
default: []
}
},
data: {
swiperItem: 2,
current: 1,
currentIndex: 1, // 商品当前滑动到第几个
circular: false, // 商品是否无限循环
topPage: 0,
lastPage: 0,
list: []
},
watch: {
goodsList(val) {
/* let list = val || [];
this.list = list; */
}
},
created() {
// 获取推荐的商品列表
this.list = [{value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 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'},
{value: 13, text: '白色条纹马克杯,马克吐温同款13', imgsrc: '/static/images/peo1.jpg', price: '¥39.08', people: 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'},
{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'},
{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'}
];
/*this.list = [{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'},
{sourceId: 13, title: '白色条纹马克杯,马克吐温同款13', images: '/static/images/peo1.jpg', price: '¥39.08', saleCount: 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'},
{sourceId: 15, title: '白色条纹马克杯,马克吐温同款15', images: '/static/images/peo3.jpg', price: '¥2399.01', saleCount: 2200, sku: 'https://u.jd.com/EToRju'},
{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: {
moveSwiper(e) {
...
...
@@ -88,39 +79,38 @@
if (e.$wx.detail.source === 'touch') {
let current = e.$wx.detail.current;
let totalPage = 0;
let nextlist = [
{value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: '100004549235'},
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: '100004549235'},
{value: 13, text: '白色条纹马克杯,马克吐温同款13', imgsrc: '/static/images/peo1.jpg', price: '¥39.08', people: 2200, sku: '100004549235'},
{value: 14, text: '白色条纹马克杯,马克吐温同款14', imgsrc: '/static/images/peo2.jpg', price: '¥599.20', people: 2200, sku: '100004549235'},
{value: 15, text: '白色条纹马克杯,马克吐温同款15', imgsrc: '/static/images/peo3.jpg', price: '¥2399.01', people: 2200, sku: '100004549235'}
];
/*let nextlist = [
{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'},
{sourceId: 13, title: '白色条纹马克杯,马克吐温同款13', images: '/static/images/peo1.jpg', price: '¥39.08', saleCount: 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'},
{sourceId: 15, title: '白色条纹马克杯,马克吐温同款15', images: '/static/images/peo3.jpg', price: '¥2399.01', saleCount: 2200, sku: 'https://u.jd.com/EToRju'}
];*/
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) {
debounce(setTimeout(function() {
that.lastPage += 1;
if (that.lastPage + that.topPage >= totalPage) {
that.getList();
// 当新得到的list长度不足20个时,表明商品全部得到,开启无限循环
/*if(nextlist.length < goodsNum) {
that.circular = true;
}
that.list = [...that.list, ...nextlist];
that.list = [...that.list, ...nextlist];
*/
}, 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) {
let item = e.$wx.currentTarget.dataset.item;
wx.navigateToMiniProgram({
...
...
@@ -251,14 +241,15 @@
margin:0 auto;
border-radius: 10rpx;
}
.list-item .t
ext
{
.list-item .t
itle
{
font-size: @font-small;
t
ext
-overflow: ellipsis;
t
itle
-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2; //行数
-webkit-box-orient: vertical;
overflow: hidden;
line-height:24rpx;
word-break:break-all;
margin-top:10rpx;
}
.list-item .price{
...
...
src/components/custom/prizeList.wpy
View file @
2f5706ae
...
...
@@ -91,6 +91,7 @@
binderror="onError"
bindtimeupdate="onTimeUpdate"
@tap="videoTap"
custom-cache="{{false}}"
v-if="item.showType && item.showType.value === 2"
>
<video-loading v-if="item.time === 0" :snapshot="item.videoSnapUrl"/>
...
...
src/pages/index.wpy
View file @
2f5706ae
...
...
@@ -182,7 +182,7 @@
<shared-popup v-if="showModal === 1" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"/>
<popup @showMenu="showMenu" :showMenus="showModal === 3"/>
<!--商品推荐列表-->
<
goods-list></goods-list
>
<
!--<goods-list></goods-list>--
>
<van-dialog id="van-dialog"/>
<van-notify id="van-notify"/>
<van-popup show="{{ cornModal }}" bind:close="cornModalClose" custom-style="background-color:transparent">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment