Commit 530317d8 authored by 付清曌's avatar 付清曌

Merge branch 'feature/corn' into 'master'

Feature/corn

See merge request !53
parents 5912a589 1ef34785
......@@ -50,5 +50,8 @@ module.exports = {
},
checkInnerCode(params) {
return http.post('/api/user/inviteCode', params);
}
},
checkCornCode(params) {
return http.post('/api/user/addCoins', params);
},
};
function computClass (current,index,length) {
function computClass (current,index,length,circular) {
var allclass = "";
// 无限循环当current为最后一个的时候,select就应该是0 例如长度为10,当current为9时,select就应该是0
// if(current+1==index || (current==length-1 && index==0) ) allclass = "select";
// 无限循环当current为最后一个/两个的时候的时候,例如长度为10,当current为8/9时,select就应该是1/0
//if(current+2 == index|| (current>=length-2 && index==current-length+2))
//allclass='subright';
if(current-1 == index||(current == 0&&index==length-1))
//只有当无限循环的时候,才需要考虑末端的情况就是当current为0时,length-1在他的左边
if(current-1 == index || ( circular && current == 0 && index==length-1))
allclass='subleft';
if(current==index)
allclass='select';
if(current+1==index || (current==length-1 && index==0) )
if(current+1==index || ( circular && current==length-1 && index==0) )
allclass = "subright";
return allclass;
};
......
......@@ -6,7 +6,6 @@
display-multiple-items="{{swiperItem}}"
current="{{current}}"
bindchange="moveSwiper"
bindanimationfinish="swipermoveDone"
circular="{{circular}}"
previous-margin="140rpx"
next-margin="120rpx"
......@@ -19,7 +18,9 @@
data-itemid="{{index}}"
bindtap="toViewPage"
data-item="{{item}}"
class="list-item {{item.select?'delete':''}} {{tools.computClass(currentIndex,index,list.length)}}"
class="list-item {{item.select?'delete':''}} {{tools.computClass(currentIndex,index,list.length,circular)}}"
bindtouchstart="touchStart"
bindtouchend="touchEnd"
>
<image src="{{item.imgsrc}}" class="img"></image>
<view class="text">{{item.text}}</view>
......@@ -43,8 +44,8 @@
},
data: {
swiperItem: 2,
current: 5,
currentIndex: 5, // 商品当前滑动到第几个
current: 1,
currentIndex: 1, // 商品当前滑动到第几个
circular: false, // 商品是否无限循环
topPage: 0,
lastPage: 0,
......@@ -52,10 +53,20 @@
},
watch: {
goodsList(val) {
let list = val || [];
this.list = list;
/* let list = val || [];
this.list = list;*/
}
},
created() {
//获取推荐的商品列表
this.list = [{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'},{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'},
];
},
methods: {
moveSwiper(e) {
if (e.$wx.detail.source === 'touch') {
......@@ -78,7 +89,7 @@
if (e.$wx.detail.source === 'touch') {
let current = e.$wx.detail.current;
let totalPage = 3;
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'},
......@@ -107,7 +118,7 @@
that.circular = true;
return;
}
that.list = [...that.list, ...nextlist];
// that.list = [...that.list, ...nextlist];
}, 1000), 500);
}
}
......@@ -189,16 +200,22 @@
if (list.length <= 4) {
this.circular = false;
}
console.log(current.itemid,this.currentIndex,this.current,111)
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);
// 正常情况下,current.itemid都会比current大一个,当相等或小于的时候就有问题,要重新设置current,最小不能超过0
if(newlist.length <= that.swiperItem) {
that.swiperItem = newlist.length;
}
that.list = newlist;
if (current.itemid - that.current !==1 ) {
that.current = Math.max(that.current - 1, 0);
}
//删除完成之后
console.log(current.itemid,that.currentIndex,that.current,222)
}, 500);
}
}
......
......@@ -15,7 +15,7 @@
</template>
<script>
import wepy from '@wepy/core';
let showMenusTimer = null;
wepy.component({
props: {
showMenus: {
......@@ -34,7 +34,8 @@
watch: {
showMenus(v) {
if (!v) {
setTimeout(() => {
if (showMenusTimer) clearTimeout(showMenusTimer);
showMenusTimer = setTimeout(() => {
this.show = false;
}, 300);
} else {
......@@ -61,7 +62,7 @@
created() {
let statusHeight = this.$app.$options.globalData.statusBarHeight || '';
statusHeight && (this.popupStyle = 'top:' + (statusHeight + 56) + 'px');
}
},
});
</script>
<style lang="less">
......
......@@ -8,7 +8,7 @@
<div class="sign-shadow" v-if="!signComplete"></div>
<span class="title">{{des}}</span>
</div>
<div v-if="type === 'gold'" class="gold">
<div v-if="type === 'gold'" class="gold" bindtap="showCornModal">
<div class="add-gold" v-if="addGold">
<image class="add-gold-image" :src="addGoldUrl"></image>
<span class="add-gold-num">+{{addGoldNum}}</span>
......@@ -57,6 +57,7 @@
share: '/static/images/share@2x.png',
lottery: '/static/images/lottery@2x.png'
};
let addGoldTimer = null;
wepy.component({
store,
data: {
......@@ -98,7 +99,7 @@
authmodal: {
type: Boolean,
default: false
}
},
},
computed: {
...mapState(['safeAreaStyle']),
......@@ -126,7 +127,13 @@
},
watch: {
isReceive(newVal, oldVal) {
this.addGold = true;
this.addGold = newVal;
if (newVal) {
if (addGoldTimer) clearTimeout(addGoldTimer);
addGoldTimer = setTimeout(() => {
this.$emit('resetAddGold');
}, 1000);
}
},
des(newVal, oldVal) {
if (this.type === 'gold') {
......@@ -174,6 +181,9 @@
} else {
this.$emit('getAwards');
}
},
showCornModal() {
this.$emit('showCorn');
}
},
});
......
......@@ -92,67 +92,70 @@
padding:6rpx 15rpx;
background-color:rgba(238, 238, 238, 0.2);
}
.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;
.corn-cont {
width:550rpx;
height:474rpx;
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)
.imgs {
width:100%;
height:100%;
position: absolute;
top:0;left:0;
z-index:0;
}
.corn-title {
font-size: 34rpx;
text-align: center;
padding-top:50rpx;
position: relative;
z-index:2;
}
.corn-input{
width:300rpx;
height:70rpx;
margin:0 auto;
margin-top:30rpx;
background-color: #ddd;
line-height:70rpx;
font-size: 32rpx;
border-radius:35rpx;
padding:0 30rpx;
position: relative;
z-index: 2;
}
.error-text {
color:@redcolor;
font-size: 22rpx;
width:360rpx;
margin:0 auto;
padding:13rpx 0;
position: relative;
z-index: 2;
&.hidden {
visibility: hidden;
}
}
.corn-icon{
width: 74rpx;
height:80rpx;
margin:0 auto;
display: block;
position: relative;
z-index: 2;
}
.corn-button {
width:280rpx;
height:80rpx;
margin:0 auto;
display: block;
background-color: @whiteback;
text-align: center;
line-height:80rpx;
color:@maincolor;
font-size: 34rpx;
border-radius: 10rpx;
margin-top:10rpx;
}
}
</style>
<template>
......@@ -168,7 +171,7 @@
<image v-if="!authmodal" @tap="showMenu(!showModal)" :src="userInfo.avatarUrl" mode="cover" class="userimage"></image>
</view>
<view>
<gold type="gold" :des="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :gold="sign" :isReceive="isReceive"></gold>
<gold type="gold" :des="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :gold="sign" :isReceive="isReceive" @resetAddGold="resetAddGold" @showCorn="cornModalShow"></gold>
<sign type="sign" des="签到" :sign="sign" @sign-in="signIn"></sign>
<lottery type="lottery" des="抽奖" @getAwards="getAwards" @getUserInfo="getUserInfo" :authmodal="authmodal"></lottery>
<share type="share" des="分享"></share>
......@@ -179,9 +182,19 @@
<shared-popup v-if="showModal === 1" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"/>
<popup @showMenu="showMenu" :showMenus="showModal === 3"/>
<!--商品推荐列表-->
<!--<goods-list :goodsList="goodsList"></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">
<view class="corn-cont">
<image src="/static/images/cornback.png" class="imgs"></image>
<view class="corn-title">请输入充值码</view>
<view><input type="text" class="corn-input" v-model="cornCode"></view>
<view class="error-text {{!cornTextShow?'hidden':''}}">{{ cornText }}</view>
<image src="/static/images/corn.png" class="corn-icon"></image>
<button class="corn-button" bindtap="checkCode">确定</button>
</view>
</van-popup>
</view>
</template>
......@@ -191,7 +204,7 @@
import wepy from '@wepy/core';
import Notify from '../components/vant/notify/notify';
import Dialog from '../components/vant/dialog/dialog';
import { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed } from '../common/api.js';
import { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed, checkCornCode } from '../common/api.js';
wepy.page({
store,
data: {
......@@ -204,13 +217,23 @@
mainInfo: null,
showModal: 0, // 1: 展示领取金币弹窗 2: 展示抽奖弹窗 3: 头像菜单弹窗
awardsInfo: {},
isReceive: false // 是否显示领取克币动画
isReceive: false, // 是否显示领取克币动画
cornModal:false,
cornCode: '', //克币充值码
cornText:'充值码无效,请重新输入',
cornTextShow: false,
},
computed: {
...mapState([ 'isConnected', 'userInfo', 'safeAreaStyle' ])
},
watch: {
cornCode(val,oldval) {
if (val!==oldval && this.cornTextShow) {
this.cornTextShow = false;
}
}
},
methods: {
...mapActions([ 'setIsConnected', 'setUserInfo', 'setSafeAreaStyle' ]),
async getUserInfo (e, isFromLottery) {
......@@ -377,8 +400,39 @@
loginInfo = loginInfo || {};
wx.setStorageSync('openId', loginInfo.openid);
wx.setStorageSync('isRegister', loginInfo.register);
}
},
cornModalShow() {
this.cornTextShow = false;
this.cornCode = '';
this.cornModal = true;
},
cornModalClose() {
this.cornModal = false;
},
checkCode() {
if(this.cornCode == '') {
this.cornText = '请输入克币充值码';
this.cornTextShow = true;
return;
}
const msg = ['充值码无效,请重新输入','该充值码已被使用,请重新输入'];
checkCornCode({code:this.cornCode}).then(data=>{
if(data.code === 0){
//充值成功
this.cornModal = false;
this.mainInfo.account.quantity = data.accountCoins;
this.isReceive = true;
} else {
const msgindex = data.code+2;
this.cornText = msg[msgindex];
this.cornTextShow = true;
}
});
},
resetAddGold() {
this.isReceive = false;
}
},
async onLoad (options) {
// 获取分享人openid
......@@ -443,7 +497,8 @@
'shared-popup': '~@/components/custom/sharedPopup',
'van-dialog': '~@/components/vant/dialog/index',
'goods-list': '../components/custom/goodsList',
'activity-list': '../components/custom/activityList'
'activity-list': '../components/custom/activityList',
'van-popup':'../components/vant/popup/index'
},
navigationStyle: "custom",
disableScroll: true
......
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