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