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
59228abc
Commit
59228abc
authored
May 27, 2020
by
付清曌
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into 'master'
Feature/optimize See merge request
!12
parents
194143ef
8f4b89b0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
52 deletions
+122
-52
raffleProbability.js
src/common/raffleProbability.js
+23
-0
openAnimation.wpy
src/components/custom/openAnimation.wpy
+2
-1
popup.wpy
src/components/custom/popup.wpy
+18
-2
help.wpy
src/pages/help.wpy
+2
-2
index.wpy
src/pages/index.wpy
+1
-1
myraffles.wpy
src/pages/myraffles.wpy
+3
-3
prize.wpy
src/pages/prize.wpy
+55
-27
raffle.wpy
src/pages/raffle.wpy
+18
-16
No files found.
src/common/raffleProbability.js
0 → 100644
View file @
59228abc
function
getCommonDivisor
(
FirstNum
,
SecondNum
)
{
if
(
SecondNum
==
0
)
return
FirstNum
;
var
remainder
=
parseInt
(
FirstNum
%
SecondNum
)
;
return
getCommonDivisor
(
SecondNum
,
remainder
);
}
function
getProbability
(
quantity
,
coinQuantity
)
{
var
divisor
=
getCommonDivisor
(
quantity
,
coinQuantity
);
var
value
=
quantity
/
divisor
;
var
value2
=
coinQuantity
/
divisor
;
//如果分子比分母大说明中奖概率是100%,那么返回中奖概率
if
(
value
>=
value2
)
{
return
coinQuantity
+
"
/
"
+
coinQuantity
}
else
{
return
value
+
"
/
"
+
value2
}
}
module
.
exports
=
{
getProbability
:
getProbability
};
src/components/custom/openAnimation.wpy
View file @
59228abc
...
...
@@ -90,7 +90,8 @@
go() {
this.showAnimation = false;
//如果得奖了走
wx.navigateTo({url:'/pages/prize'})
let id = 7;
wx.navigateTo({url:'/pages/prize?joinRecordId='+id})
//如果没得奖走
//wx.navigateTo({url:'/pages/myraffles'})
}
...
...
src/components/custom/popup.wpy
View file @
59228abc
...
...
@@ -5,6 +5,11 @@
<image class="image" :src="item.img"></image>
<span class="desc">{{item.title}}</span>
</div>
<div class="popup-item">
<button class="help-button" open-type="contact"></button>
<image class="image" src="/static/images/help@2x.png"></image>
<span class="desc">问题反馈</span>
</div>
</div>
</div>
</template>
...
...
@@ -22,7 +27,6 @@
menus: [
{ img: '/static/images/awards@2x.png', title: '我的抽奖', path: '/pages/myraffles' },
{ img: '/static/images/feedback@2x.png', title: '规则与帮助', path: '/pages/help' },
{ img: '/static/images/help@2x.png', title: '问题反馈', path: '/pages/help' }
],
show: false,
popupStyle: ''
...
...
@@ -98,6 +102,7 @@
display: flex;
flex-direction: column;
align-items: center;
position: relative;
.image {
width: 50rpx;
height: 50rpx;
...
...
@@ -109,7 +114,18 @@
}
}
}
.help-button {
width: 100%;
height:100%;
position: absolute;
background-color: transparent;
border:none;
top:0;
left:0;
}
.help-button::after{
border:none;
}
.popup-wrapper_show{
animation: menuShow .3s linear forwards;
}
...
...
src/pages/help.wpy
View file @
59228abc
...
...
@@ -67,7 +67,7 @@
</view>
<view class="help-more">
<van-cell title="问题反馈" is-link><button open-type="contact" class="help-button"></button></van-cell>
<
van-cell title="更多问题" is-link bindtap="tomorehelp"></van-cell
>
<
!--<van-cell title="更多问题" is-link bindtap="tomorehelp"></van-cell>--
>
</view>
</view>
</template>
...
...
@@ -84,7 +84,7 @@
}
},
onLoad (
query
) {
onLoad () {
},
});
...
...
src/pages/index.wpy
View file @
59228abc
...
...
@@ -658,7 +658,7 @@
},
onShow() {
// 从其他小程序回来可以在当前生命周期检测到,但是这个方法,自己的小程序页面返回也会进入
console.log('页面show!!');
//
console.log('页面show!!');
}
});
</script>
...
...
src/pages/myraffles.wpy
View file @
59228abc
...
...
@@ -101,11 +101,11 @@
methods: {
goprize(event) {
let detail = event.$wx.currentTarget;
let id = detail.dataset.id || ''
wx.navigateTo({url:'/pages/prize?
prizei
d='+id});
let id = detail.dataset.id || ''
;
wx.navigateTo({url:'/pages/prize?
joinRecordI
d='+id});
}
},
onLoad (
query
) {
onLoad () {
this.list = [
{id:1,status:{name:'待开奖',value:1},quantity:500,prize:{name:'Nintendo Switch任天堂游戏机任天堂游戏机',photoUrl:'/static/images/test1.jpg'}},
{id:2,status:{name:'未中奖',value:2},quantity:200,prize:{name:'Nintendo Switch任天堂游戏机任天堂游戏机',photoUrl:'/static/images/test1.jpg'}},
...
...
src/pages/prize.wpy
View file @
59228abc
...
...
@@ -3,12 +3,12 @@
background-color: #fff;
padding:30rpx 50rpx;
.img{
width: 400rpx;
height: 400rpx;
border-radius: 10rpx;
display: block;
margin:0 auto;
box-shadow:0px 3rpx 13rpx 1rpx rgba(163,163,163,0.38);
width: 400rpx;
.van-image {
box-shadow:0px 3rpx 13rpx 1rpx rgba(163,163,163,0.38);
}
}
.goodsname{
padding:25rpx 0;
...
...
@@ -65,17 +65,19 @@
<template>
<view class="prize-wrapper">
<view class="prize-top">
<image class="img" src="{{goodsimg}}"></image>
<view class="goodsname">Nintendo Switch任天堂游戏机Nintendo Switch任天堂游戏机</view>
<view class="prize-info">中奖概率: 1/300</view>
<van-image use-loading-slot src="{{prize.photoUrl}}" class="img" width="400rpx" height="400rpx" radius="10rpx">
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
<view class="goodsname">{{prize.name}}</view>
<view class="prize-info">中奖概率: {{chance}}</view>
<view class="prize-info">中奖结果: <text class="red">已中奖</text></view>
</view>
<view class="prize-address">
<view class="prize-address"
v-show="!prize.cash"
>
<view class="address-title">添加收货地址</view>
<view class="address-cont">
<van-field value="{{name}}" data-form="name" placeholder="收货人" bind:input ="setValue"></van-field>
<van-field value="{{phone}}" data-form="phone" placeholder="手机号码" bind:input ="setValue"></van-field>
<van-field value="{{city}}" placeholder="所在地区" bindtap="onClose" is-link readonly></van-field>
<van-field value="{{city
Value
}}" placeholder="所在地区" bindtap="onClose" is-link readonly></van-field>
<van-field value="{{address}}" data-form="address" placeholder="详细地址:如街道、小区、门牌号、楼栋号等" bind:input ="setValue"></van-field>
</view>
</view>
...
...
@@ -94,34 +96,48 @@
import wepy from '@wepy/core';
import Dialog from '../components/vant/dialog/dialog';
import Notify from '../components/vant/notify/notify';
var raffle = require('../common/raffleProbability');
var area = require('../components/custom/china.js');
wepy.page({
data: {
goodsimg:'/static/images/test2.png',
quantity:0,
prize:{},
name:'',
phone:'',
address:'',
province:'',
city:'',
country:'',
cityValue:'',
areaList:[],
showAddress:false,
joinRecordId:null,
chance:''
},
methods: {
goprize() {
if(!this.name){
Notify({message: '请填写收货人', background:'#FF5D15'});
return;
}
if(!this.phone){
Notify({message: '请填写手机号码', background:'#FF5D15'});
return;
}
if(!this.city){
Notify({message: '请选择所在地区', background:'#FF5D15'});
return;
}
if(!this.address){
Notify({message: '请填写详细地址', background:'#FF5D15'});
return;
if(!this.prize.cash) {
if(!this.name){
Notify({message: '请填写收货人', background:'#FF5D15'});
return;
}
let reg = /^1\d{10}$/
if(!this.phone){
Notify({message: '请填写手机号码', background:'#FF5D15'});
return;
}
if(!reg.test(this.phone)) {
Notify({message: '请填写正确的手机号码', background:'#FF5D15'});
return;
}
if(!this.city){
Notify({message: '请选择所在地区', background:'#FF5D15'});
return;
}
if(!this.address){
Notify({message: '请填写详细地址', background:'#FF5D15'});
return;
}
}
Dialog.alert({
title: '领取成功',
...
...
@@ -142,7 +158,10 @@
},
getaddress(event) {
let detail = event.$wx.detail.values;
this.city = detail[0].name+detail[1].name+detail[2].name
this.province = detail[0].name;
this.city = detail[1].name;
this.country = detail[2].name;
this.cityValue = detail[0].name+detail[1].name+detail[2].name
this.onClose()
}
},
...
...
@@ -150,7 +169,14 @@
},
onLoad (query) {
let joinRecordId = query.joinRecordId || '';
this.joinRecordId = joinRecordId;
if(!joinRecordId) Notify({message: '缺少参数错误!', background:'#FF5D15'});
//请求接口得到数据
this.prize = {cash:false,name:'Nintendo Switch任天堂游戏机Nintendo Switch任天堂游戏机',photoUrl:'/static/images/test2.png',coinQuantity:5000};
this.quantity = 300;
this.areaList = area.areaList;
this.chance = raffle.getProbability(this.quantity,this.prize.coinQuantity);
},
});
</script>
...
...
@@ -163,7 +189,9 @@
"van-area": "../components/vant/area/index",
"van-popup": "../components/vant/popup/index",
'van-dialog': '../components/vant/dialog/index',
"van-notify": "../components/vant/notify/index"
"van-notify": "../components/vant/notify/index",
"van-image": "../components/vant/image/index",
"van-loading": "../components/vant/loading/index",
}
}
</config>
src/pages/raffle.wpy
View file @
59228abc
...
...
@@ -18,10 +18,7 @@
padding:50rpx 50rpx 40rpx 50rpx;
border-radius: 10rpx;
box-shadow:0px 2rpx 20rpx 0px rgba(188,188,188,0.75);
.img {
width:610rpx;
height:610rpx;
border-radius: 10rpx;
.img .van-image {
box-shadow:0px 3rpx 13rpx 1rpx rgba(163,163,163,0.38);
}
}
...
...
@@ -114,10 +111,12 @@
<template>
<view class="raffle-wrapper">
<view class="raffle-content">
<image class="img" src="{{goodsimg}}"></image>
<van-image use-loading-slot src="{{photoUrl}}" class="img" width="610rpx" height="610rpx" radius="10rpx">
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
<view class="goodsinfo">
<text class="text">{{
goods
}}</text>
<text class="money">{{
corn
}}克币</text>
<text class="text">{{
name
}}</text>
<text class="money">{{
quantity
}}克币</text>
</view>
<view class="raffle-chance">中奖概率: {{chance}}</view>
<view class="raffle-progress">中奖进度:
...
...
@@ -144,10 +143,11 @@
progressStyle: '',
isCheck: false,
id: null,
corn
: '',
goods
: '',
quantity
: '',
name
: '',
chance: '',
goodsimg: ''
photoUrl: '',
batchId:null,
},
methods: {
check() {
...
...
@@ -165,7 +165,7 @@
},
joinin() {
if(!this.isCheck) {
Notify({message: '请先勾选
协议
!', background:'#FF5D15'})
Notify({message: '请先勾选!', background:'#FF5D15'})
}
}
},
...
...
@@ -188,17 +188,17 @@
}
},
onLoad (query) {
console.log(query)
;
this.batchId = query.batchId
;
let {id, corn, goods, chance, imgsrc, progress} = query;
if (progress) {
this.progress = progress;
this.progressStyle = 'width:' + progress + '%';
}
this.id = id;
this.
corn
= corn;
this.
goods
= goods;
this.
quantity
= corn;
this.
name
= goods;
this.chance = chance;
this.
goodsimg
= imgsrc;
this.
photoUrl
= imgsrc;
}
});
</script>
...
...
@@ -206,7 +206,9 @@
{
navigationBarTitleText: '参与抽奖',
"usingComponents": {
"van-notify": "../components/vant/notify/index"
"van-notify": "../components/vant/notify/index",
"van-image": "../components/vant/image/index",
"van-loading": "../components/vant/loading/index",
}
}
</config>
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