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
109aa81b
Commit
109aa81b
authored
Jun 15, 2020
by
ziyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 克币充值
parent
32b474b8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
79 deletions
+133
-79
api.js
src/common/api.js
+4
-1
goodsList.wpy
src/components/custom/goodsList.wpy
+21
-8
sign.wpy
src/components/custom/sign.wpy
+5
-2
index.wpy
src/pages/index.wpy
+103
-68
corn.png
static/images/corn.png
+0
-0
cornback.png
static/images/cornback.png
+0
-0
No files found.
src/common/api.js
View file @
109aa81b
...
@@ -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
);
},
};
};
src/components/custom/goodsList.wpy
View file @
109aa81b
...
@@ -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"
...
@@ -20,6 +19,8 @@
...
@@ -20,6 +19,8 @@
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)}}"
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>
...
@@ -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);
}
}
}
}
...
@@ -194,11 +205,13 @@
...
@@ -194,11 +205,13 @@
}
}
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
// that.current = Math.max(that.current - 1, 0);
if (current.itemid <= that.current) {
// 正常情况下,current.itemid都会比current大一个,当相等或小于的时候就有问题,要重新设置current,最小不能超过0
that.list = newlist;
if (current.itemid - that.current !==1 ) {
that.current = Math.max(that.current - 1, 0);
that.current = Math.max(that.current - 1, 0);
}
}
that.list = newlist;
console.log(that.current,current.itemid,11)
}, 500);
}, 500);
}
}
}
}
...
...
src/components/custom/sign.wpy
View file @
109aa81b
...
@@ -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>
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
authmodal: {
authmodal: {
type: Boolean,
type: Boolean,
default: false
default: false
}
}
,
},
},
computed: {
computed: {
...mapState(['safeAreaStyle']),
...mapState(['safeAreaStyle']),
...
@@ -174,6 +174,9 @@
...
@@ -174,6 +174,9 @@
} else {
} else {
this.$emit('getAwards');
this.$emit('getAwards');
}
}
},
showCornModal() {
this.$emit('showCorn');
}
}
},
},
});
});
...
...
src/pages/index.wpy
View file @
109aa81b
...
@@ -92,67 +92,56 @@
...
@@ -92,67 +92,56 @@
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;
position: absolute;
height:474rpx;
z-index: 9;
background: url("https://activitystatic.xyqb.com/cornback.png") no-repeat;
bottom: 20rpx;
background-size: 100%;
width: 100%;
.corn-title {
}
font-size: 34rpx;
.footswiper {
text-align: center;
height: 360rpx;
padding-top:50rpx;
}
}
.list-item{
.corn-input{
width:220rpx;
width:300rpx;
/*height: 330rpx;*/
height:70rpx;
background-color:@whiteback;
margin:0 auto;
border-radius: 10rpx;
margin-top:30rpx;
transform: scale(0.7,0.7) translateY(65rpx);
background-color: #ddd;
transition: all 0.5s;
line-height:70rpx;
padding:10rpx 10rpx 5rpx 10rpx;
font-size: 32rpx;
margin:0 auto;
border-radius:35rpx;
margin-top: 2rpx;
padding:0 30rpx;
position: relative;
}
}
.error-text {
.list-item image {
color:@redcolor;
width: 210rpx;
font-size: 22rpx;
display: block;
width:360rpx;
height: 210rpx;
margin:0 auto;
margin:0 auto;
padding:13rpx 0;
border-radius: 10rpx;
&.hidden {
}
visibility: hidden;
.list-item .text {
}
font-size: @font-small;
}
text-overflow: ellipsis;
.corn-icon{
display: -webkit-box;
width: 74rpx;
-webkit-line-clamp: 2; //行数
height:80rpx;
-webkit-box-orient: vertical;
margin:0 auto;
overflow: hidden;
display: block;
line-height:24rpx;
}
margin-top:10rpx;
.corn-button {
}
width:280rpx;
.list-item .price{
height:80rpx;
color:@maincolor;
margin:0 auto;
font-size:@font-common;
display: block;
margin-top:2rpx;
background-color: @whiteback;
}
text-align: center;
.list-item .buy{
line-height:80rpx;
font-size: 16rpx;
color:@maincolor;
color:@darkgrey;
font-size: 34rpx;
}
border-radius: 10rpx;
.list-item.subright {
margin-top:10rpx;
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>
</style>
<template>
<template>
...
@@ -168,7 +157,7 @@
...
@@ -168,7 +157,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"
@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 +168,18 @@
...
@@ -179,9 +168,18 @@
<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">
<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 +189,7 @@
...
@@ -191,7 +189,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 +202,23 @@
...
@@ -204,13 +202,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) {
...
@@ -381,8 +389,34 @@
...
@@ -381,8 +389,34 @@
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;
} else {
const msgindex = data.code+2;
this.cornText = msg[msgindex];
this.cornTextShow = true;
}
});
},
},
},
async onLoad (options) {
async onLoad (options) {
// 获取分享人openid
// 获取分享人openid
...
@@ -447,7 +481,8 @@
...
@@ -447,7 +481,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
...
...
static/images/corn.png
0 → 100644
View file @
109aa81b
3.78 KB
static/images/cornback.png
0 → 100644
View file @
109aa81b
20.6 KB
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