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
b8b162ca
Commit
b8b162ca
authored
Jun 10, 2020
by
付清曌
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/beta2' into 'master'
Feature/beta2 See merge request
!41
parents
7d17444f
c5216180
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
401 additions
and
345 deletions
+401
-345
.eslintcache
.eslintcache
+1
-1
activityList.wpy
src/components/custom/activityList.wpy
+106
-0
goodsList.wpy
src/components/custom/goodsList.wpy
+274
-0
index.wpy
src/pages/index.wpy
+13
-335
myraffles.wpy
src/pages/myraffles.wpy
+0
-1
prize.wpy
src/pages/prize.wpy
+6
-7
raffle.wpy
src/pages/raffle.wpy
+1
-1
No files found.
.eslintcache
View file @
b8b162ca
This diff is collapsed.
Click to expand it.
src/components/custom/activityList.wpy
0 → 100644
View file @
b8b162ca
<template>
<view class="content {{isActiveDone}}" >
<view class="leftcont">
<swiper
class="list-wrapper"
vertical="{{true}}"
circular="{{true}}"
display-multiple-items="{{activityDisplayItems}}"
bindchange="onActivityChange"
autoplay="{{isAuto}}"
interval="1500">
<swiper-item wx:for="{{list}}" wx:key="index" catch:touchmove>
<view class="imgwrap">
<image class="img" src="{{item.avatarUrl}}"></image>
<view class="text">{{item.content}}</view>
</view>
</swiper-item>
</swiper>
</view>
</view>
</template>
<script>
import wepy from '@wepy/core';
wepy.component({
props: {
activityList: {
type: Array,
default: []
}
},
data: {
activityDisplayItems: 2,
isActiveDone: '',
isAuto: true,
list: []
},
watch: {
activityList(val) {
let list = val || [];
this.list = list;
}
},
methods: {
onActivityChange(e) {
const lastIndex = this.list.length - this.activityDisplayItems;
if (e.$wx.detail.current === lastIndex) {
this.isActiveDone = 'anima';
setTimeout(() => {
this.isActiveDone = 'anima hide';
this.isAuto = false;
}, 2000);
}
}
}
});
</script>
<style lang="less">
@import "../../style/common";
.content{
position: absolute;
z-index: 9;
bottom: 400rpx;
width: 100%;
color: @whitecolor;
clear: both;
&.anima {
animation:fadeout 2s;
}
&.hide {
display: none;
}
}
.leftcont {
width: 44%;
float: left;
font-size: @font-normal;
margin-left: 30rpx;
}
.list-wrapper {
height: 120rpx;
}
.leftcont .img {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
vertical-align: middle;
}
.leftcont .text {
max-width: 200rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-left: 10rpx;
vertical-align: middle;
border-radius: 20rpx;
display: inline-block;
font-size: @font-small;
box-sizing: border-box;
padding:6rpx 15rpx;
background-color:rgba(238, 238, 238, 0.2);
}
</style>
<config>
{}
</config>
src/components/custom/goodsList.wpy
0 → 100644
View file @
b8b162ca
<wxs module="tools" src="../../common/common.wxs"></wxs>
<template>
<view class="footer">
<swiper
class="footswiper"
display-multiple-items="{{swiperItem}}"
current="{{current}}"
bindchange="moveSwiper"
bindanimationfinish="swipermoveDone"
circular="{{circular}}"
previous-margin="140rpx"
next-margin="120rpx"
catch:touchmove
>
<!--bindtouchstart="touchStart"
bindtouchend="touchEnd"-->
<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)}}"
>
<image src="{{item.imgsrc}}"></image>
<view class="text">{{item.text}}</view>
<p class="price">{{item.price}}</p>
<p class="buy">{{item.people}}人购买</p>
</view>
</swiper-item>
</swiper>
</view>
</template>
<script>
import wepy from '@wepy/core';
let touchDotX = 0;
let touchDotY = 0;
wepy.component({
props: {
goodsList: {
type: Array,
default: []
}
},
data: {
swiperItem: 2,
current: 5,
currentIndex: 5, // 商品当前滑动到第几个
circular: false, // 商品是否无限循环
topPage: 0,
lastPage: 0,
list: []
},
watch: {
goodsList(val) {
let list = val || [];
this.list = list;
}
},
methods: {
moveSwiper(e) {
if (e.$wx.detail.source === 'touch') {
let current = e.$wx.detail.current;
this.currentIndex = current;
}
},
swipermoveDone(e) {
function debounce(func, wait) {
let timeout;
return function () {
if (timeout) clearTimeout(timeout);
let callNow = !timeout;
timeout = setTimeout(func, wait);
if (callNow) func();
};
}
if (e.$wx.detail.source === 'touch') {
let current = e.$wx.detail.current;
let totalPage = 3;
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 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.circular = true;
return;
}
that.list = [...that.list, ...nextlist];
}, 1000), 500);
}
}
},
toViewPage(e) {
let item = e.$wx.currentTarget.dataset.item;
wx.navigateToMiniProgram({
appId: 'wx91d27dbf599dff74',
path: 'pages/item/detail/detail?sku=' + item.sku, // 跳转小程序的路径
// 有效值 develop(开发版),trial(体验版),release(正式版)
envVersion: 'release',
success(res) {
// console.log('跳转成功');
}
});
},
touchStart (event) {
touchDotX = event.touches[0].pageX; // 获取触摸时的原点
touchDotY = event.touches[0].pageY;
// console.log("起始点的坐标X:" + touchDotX);
// console.log("起始点的坐标Y:" + touchDotY);
},
touchMove(event) {
let touchX = event.touches[0].pageX;
let touchY = event.touches[0].pageY;
// 如果元素拖动到购物车范围
let {left, top, bottom, right} = this.shopcarPosition;
if (touchX > left - 10 && touchX < right + 10) {
if (touchY > top - 10 && touchY < bottom + 10) {
this.bigshop = true;
}
}
},
// 移动结束处理动画
touchEnd(event) {
// 手指离开屏幕时记录的坐标
let touchMoveX = event.changedTouches[0].pageX;
let touchMoveY = event.changedTouches[0].pageY;
let current = event.currentTarget.dataset;
// 起始点的坐标(x0,y0)和手指离开时的坐标(x1,y1)之差
let tmX = touchMoveX - touchDotX;
let tmY = touchMoveY - touchDotY;
// 两点横纵坐标差的绝对值
let absX = Math.abs(tmX);
let absY = Math.abs(tmY);
// 起始点的坐标(x0,y0)和手指离开时的坐标(x1,y1)之间的距离
let delta = Math.sqrt(absX * absX + absY * absY);
// console.log('起始点和离开点距离:' + delta + 'px');
// 如果delta超过60px(可以视情况自己微调),判定为手势触发
if (delta >= 40) {
// 如果 |x0-x1|<|y0-y1|,即absX<abxY,判定为上下滑动
if (absX < absY) {
// 如更tmX<0,即(离开点的X)-(起始点X)小于0 ,判定为下滑
if (tmY < 0) {
this.deleteAnimation(current);
// console.log("上滑=====");
// 如更tmX>0,即(离开点的X)-(起始点X)大于0 ,判定为上滑
} else {
// console.log("下滑=====");
}
}
} else {
// console.log("手势未触发=====");
}
},
deleteAnimation (current) {
if (current && current.itemid !== undefined) {
let list = this.list;
list = list.map((item, index) => {
item.select = '';
if (index === +current.itemid) {
item.select = true;
}
return item;
});
this.list = list;
let that = this;
// 如果剩下4个就不让他循环了,这时候就一屏显示出来了
if (list.length <= 4) {
this.circular = false;
}
if (current.itemid >= list.length - 1) {
this.current = this.currentIndex - 1;
}
setTimeout(function() {
let newlist = that.list.filter((item, index) => index !== +current.itemid);
// 正常情况下,current.itemid都会比current大一个,因为current有个隐藏元素,当相等或小于的时候就有问题,要重新设置current,最小不能超过0
if (current.itemid <= that.current) {
that.current = Math.max(that.current - 1, 0);
}
that.list = newlist;
}, 500);
}
}
}
});
</script>
<style lang="less">
@import "../../style/common";
.footer {
position: absolute;
z-index: 9;
bottom: 20rpx;
width: 100%;
}
.footswiper {
height: 360rpx;
}
.list-item{
width:220rpx;
/*height: 330rpx;*/
background-color:@whiteback;
border-radius: 10rpx;
transform: scale(0.7,0.7) translateY(65rpx);
transition: all 0.5s;
padding:10rpx 10rpx 5rpx 10rpx;
margin:0 auto;
margin-top: 2rpx;
position: relative;
}
.list-item image {
width: 210rpx;
display: block;
height: 210rpx;
margin:0 auto;
border-radius: 10rpx;
}
.list-item .text {
font-size: @font-small;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2; //行数
-webkit-box-orient: vertical;
overflow: hidden;
line-height:24rpx;
margin-top:10rpx;
}
.list-item .price{
color:@maincolor;
font-size:@font-common;
margin-top:2rpx;
}
.list-item .buy{
font-size: 16rpx;
color:@darkgrey;
}
.list-item.subright {
transform: scale(0.85,0.85) translateY(26rpx) translateX(25rpx);
}
.list-item.subleft {
transform: scale(0.85,0.85) translateY(26rpx) translateX(-25rpx);
}
.list-item.select{
transform: scale(1,1);
bottom: 2rpx;
}
.list-item.delete {
opacity:0;
transform:translateY(-220rpx)
}
</style>
<config>
{}
</config>
src/pages/index.wpy
View file @
b8b162ca
This diff is collapsed.
Click to expand it.
src/pages/myraffles.wpy
View file @
b8b162ca
...
@@ -77,7 +77,6 @@
...
@@ -77,7 +77,6 @@
<van-image use-loading-slot src="{{item.prize.photoUrl}}" class="item-img" width="150rpx" height="150rpx" radius="10rpx" fit="cover">
<van-image use-loading-slot src="{{item.prize.photoUrl}}" class="item-img" width="150rpx" height="150rpx" radius="10rpx" fit="cover">
<van-loading slot="loading" type="spinner" size="20" vertical />
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
</van-image>
<!--<image src="{{item.prize.photoUrl}}" class="item-img"></image>-->
<view class="item-right">
<view class="item-right">
<view class="item-title">{{item.prize.name}}</view>
<view class="item-title">{{item.prize.name}}</view>
<view class="item-corn">花费: {{item.quantity}}克币</view>
<view class="item-corn">花费: {{item.quantity}}克币</view>
...
...
src/pages/prize.wpy
View file @
b8b162ca
...
@@ -201,11 +201,13 @@
...
@@ -201,11 +201,13 @@
},
},
onLoad (query) {
onLoad (query) {
let joinRecordId = query.joinRecordId || '';
this.joinRecordId = query.joinRecordId;
this.joinRecordId = joinRecordId;
if (this.joinRecordId === '' || this.joinRecordId === undefined) {
if (!joinRecordId) Notify({message: '缺少参数错误!'});
Notify({message: '缺少参数错误!'});
return;
}
// 请求接口得到数据
// 请求接口得到数据
getOneRaffle({joinRecordId: joinRecordId}).then(data => {
getOneRaffle({joinRecordId:
this.
joinRecordId}).then(data => {
let dat = data || {};
let dat = data || {};
this.prize = dat.prize;
this.prize = dat.prize;
this.quantity = dat.quantity;
this.quantity = dat.quantity;
...
@@ -215,9 +217,6 @@
...
@@ -215,9 +217,6 @@
this.phone = data.phone;
this.phone = data.phone;
});
});
this.areaList = area.areaList;
this.areaList = area.areaList;
/* this.prize = {cash:false,name:'Nintendo Switch任天堂游戏机Nintendo Switch任天堂游戏机',photoUrl:'/static/images/test2.png',coinQuantity:5000};
this.quantity = 300;
this.chance = raffle.getProbability(this.quantity,this.prize.coinQuantity); */
}
}
});
});
</script>
</script>
...
...
src/pages/raffle.wpy
View file @
b8b162ca
...
@@ -306,9 +306,9 @@
...
@@ -306,9 +306,9 @@
async confirmRaff() {
async confirmRaff() {
let title = ['参与成功!', '参与失败!', '参与失败!'];
let title = ['参与成功!', '参与失败!', '参与失败!'];
let message = ['参与成功,坐等开奖。', '当前抽奖已结束。', '当前奖品已经没有库存了。'];
let message = ['参与成功,坐等开奖。', '当前抽奖已结束。', '当前奖品已经没有库存了。'];
// 如果用户还未注册
// 用户抽奖之前一定要注册
// 用户抽奖之前一定要注册
let isRegister = wx.getStorageSync('isRegister');
let isRegister = wx.getStorageSync('isRegister');
// 如果用户还未注册
if (isRegister === false) {
if (isRegister === false) {
await register(store.state.userInfo);
await register(store.state.userInfo);
wx.setStorageSync('isRegister', true);
wx.setStorageSync('isRegister', true);
...
...
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