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
11ce226e
Commit
11ce226e
authored
May 27, 2020
by
ziyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 流程细节优化
parent
d6de1426
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
38 deletions
+85
-38
raffleProbability.js
src/common/raffleProbability.js
+23
-0
openAnimation.wpy
src/components/custom/openAnimation.wpy
+2
-1
myraffles.wpy
src/pages/myraffles.wpy
+3
-3
prize.wpy
src/pages/prize.wpy
+50
-27
raffle.wpy
src/pages/raffle.wpy
+7
-7
No files found.
src/common/raffleProbability.js
0 → 100644
View file @
11ce226e
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 @
11ce226e
...
@@ -90,7 +90,8 @@
...
@@ -90,7 +90,8 @@
go() {
go() {
this.showAnimation = false;
this.showAnimation = false;
//如果得奖了走
//如果得奖了走
wx.navigateTo({url:'/pages/prize'})
let id = 7;
wx.navigateTo({url:'/pages/prize?joinRecordId='+id})
//如果没得奖走
//如果没得奖走
//wx.navigateTo({url:'/pages/myraffles'})
//wx.navigateTo({url:'/pages/myraffles'})
}
}
...
...
src/pages/myraffles.wpy
View file @
11ce226e
...
@@ -101,11 +101,11 @@
...
@@ -101,11 +101,11 @@
methods: {
methods: {
goprize(event) {
goprize(event) {
let detail = event.$wx.currentTarget;
let detail = event.$wx.currentTarget;
let id = detail.dataset.id || ''
let id = detail.dataset.id || ''
;
wx.navigateTo({url:'/pages/prize?
prizei
d='+id});
wx.navigateTo({url:'/pages/prize?
joinRecordI
d='+id});
}
}
},
},
onLoad (
query
) {
onLoad () {
this.list = [
this.list = [
{id:1,status:{name:'待开奖',value:1},quantity:500,prize:{name:'Nintendo Switch任天堂游戏机任天堂游戏机',photoUrl:'/static/images/test1.jpg'}},
{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'}},
{id:2,status:{name:'未中奖',value:2},quantity:200,prize:{name:'Nintendo Switch任天堂游戏机任天堂游戏机',photoUrl:'/static/images/test1.jpg'}},
...
...
src/pages/prize.wpy
View file @
11ce226e
...
@@ -3,13 +3,13 @@
...
@@ -3,13 +3,13 @@
background-color: #fff;
background-color: #fff;
padding:30rpx 50rpx;
padding:30rpx 50rpx;
.img{
.img{
width: 400rpx;
height: 400rpx;
border-radius: 10rpx;
display: block;
display: block;
margin:0 auto;
margin:0 auto;
width: 400rpx;
.van-image {
box-shadow:0px 3rpx 13rpx 1rpx rgba(163,163,163,0.38);
box-shadow:0px 3rpx 13rpx 1rpx rgba(163,163,163,0.38);
}
}
}
.goodsname{
.goodsname{
padding:25rpx 0;
padding:25rpx 0;
font-size: 28rpx;
font-size: 28rpx;
...
@@ -65,17 +65,19 @@
...
@@ -65,17 +65,19 @@
<template>
<template>
<view class="prize-wrapper">
<view class="prize-wrapper">
<view class="prize-top">
<view class="prize-top">
<image class="img" src="{{goodsimg}}"></image>
<van-image use-loading-slot src="{{prize.photoUrl}}" class="img" width="400rpx" height="400rpx" radius="10rpx">
<view class="goodsname">Nintendo Switch任天堂游戏机Nintendo Switch任天堂游戏机</view>
<van-loading slot="loading" type="spinner" size="20" vertical />
<view class="prize-info">中奖概率: 1/300</view>
</van-image>
<view class="goodsname">{{prize.name}}</view>
<view class="prize-info">中奖概率: {{chance}}</view>
<view class="prize-info">中奖结果: <text class="red">已中奖</text></view>
<view class="prize-info">中奖结果: <text class="red">已中奖</text></view>
</view>
</view>
<view class="prize-address">
<view class="prize-address"
v-show="!prize.cash"
>
<view class="address-title">添加收货地址</view>
<view class="address-title">添加收货地址</view>
<view class="address-cont">
<view class="address-cont">
<van-field value="{{name}}" data-form="name" placeholder="收货人" bind:input ="setValue"></van-field>
<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="{{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>
<van-field value="{{address}}" data-form="address" placeholder="详细地址:如街道、小区、门牌号、楼栋号等" bind:input ="setValue"></van-field>
</view>
</view>
</view>
</view>
...
@@ -94,19 +96,27 @@
...
@@ -94,19 +96,27 @@
import wepy from '@wepy/core';
import wepy from '@wepy/core';
import Dialog from '../components/vant/dialog/dialog';
import Dialog from '../components/vant/dialog/dialog';
import Notify from '../components/vant/notify/notify';
import Notify from '../components/vant/notify/notify';
var raffle = require('../common/raffleProbability');
var area = require('../components/custom/china.js');
var area = require('../components/custom/china.js');
wepy.page({
wepy.page({
data: {
data: {
goodsimg:'/static/images/test2.png',
quantity:0,
prize:{},
name:'',
name:'',
phone:'',
phone:'',
address:'',
address:'',
province:'',
city:'',
city:'',
country:'',
cityValue:'',
areaList:[],
areaList:[],
showAddress:false,
showAddress:false,
joinRecordId:null,
chance:''
},
},
methods: {
methods: {
goprize() {
goprize() {
if(!this.prize.cash) {
if(!this.name){
if(!this.name){
Notify({message: '请填写收货人', background:'#FF5D15'});
Notify({message: '请填写收货人', background:'#FF5D15'});
return;
return;
...
@@ -123,6 +133,7 @@
...
@@ -123,6 +133,7 @@
Notify({message: '请填写详细地址', background:'#FF5D15'});
Notify({message: '请填写详细地址', background:'#FF5D15'});
return;
return;
}
}
}
Dialog.alert({
Dialog.alert({
title: '领取成功',
title: '领取成功',
message: '您所领取的奖品我们将在3到5个工作日内寄出,请您耐心等待,感谢您的参与!',
message: '您所领取的奖品我们将在3到5个工作日内寄出,请您耐心等待,感谢您的参与!',
...
@@ -142,7 +153,10 @@
...
@@ -142,7 +153,10 @@
},
},
getaddress(event) {
getaddress(event) {
let detail = event.$wx.detail.values;
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()
this.onClose()
}
}
},
},
...
@@ -150,7 +164,14 @@
...
@@ -150,7 +164,14 @@
},
},
onLoad (query) {
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.areaList = area.areaList;
this.chance = raffle.getProbability(this.quantity,this.prize.coinQuantity);
},
},
});
});
</script>
</script>
...
@@ -163,7 +184,9 @@
...
@@ -163,7 +184,9 @@
"van-area": "../components/vant/area/index",
"van-area": "../components/vant/area/index",
"van-popup": "../components/vant/popup/index",
"van-popup": "../components/vant/popup/index",
'van-dialog': '../components/vant/dialog/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>
</config>
src/pages/raffle.wpy
View file @
11ce226e
...
@@ -18,10 +18,7 @@
...
@@ -18,10 +18,7 @@
padding:50rpx 50rpx 40rpx 50rpx;
padding:50rpx 50rpx 40rpx 50rpx;
border-radius: 10rpx;
border-radius: 10rpx;
box-shadow:0px 2rpx 20rpx 0px rgba(188,188,188,0.75);
box-shadow:0px 2rpx 20rpx 0px rgba(188,188,188,0.75);
.img {
.img .van-image {
width:610rpx;
height:610rpx;
border-radius: 10rpx;
box-shadow:0px 3rpx 13rpx 1rpx rgba(163,163,163,0.38);
box-shadow:0px 3rpx 13rpx 1rpx rgba(163,163,163,0.38);
}
}
}
}
...
@@ -114,7 +111,9 @@
...
@@ -114,7 +111,9 @@
<template>
<template>
<view class="raffle-wrapper">
<view class="raffle-wrapper">
<view class="raffle-content">
<view class="raffle-content">
<image class="img" src="{{goodsimg}}"></image>
<van-image use-loading-slot src="{{goodsimg}}" class="img" width="610rpx" height="610rpx" radius="10rpx">
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
<view class="goodsinfo">
<view class="goodsinfo">
<text class="text">{{goods}}</text>
<text class="text">{{goods}}</text>
<text class="money">{{corn}}克币</text>
<text class="money">{{corn}}克币</text>
...
@@ -188,7 +187,6 @@
...
@@ -188,7 +187,6 @@
}
}
},
},
onLoad (query) {
onLoad (query) {
console.log(query);
let {id, corn, goods, chance, imgsrc, progress} = query;
let {id, corn, goods, chance, imgsrc, progress} = query;
if (progress) {
if (progress) {
this.progress = progress;
this.progress = progress;
...
@@ -206,7 +204,9 @@
...
@@ -206,7 +204,9 @@
{
{
navigationBarTitleText: '参与抽奖',
navigationBarTitleText: '参与抽奖',
"usingComponents": {
"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>
</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