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
e9e43939
Commit
e9e43939
authored
Jul 22, 2020
by
zhijie.xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复抽奖概率 undefined
parent
3925e313
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
utils.js
src/common/utils.js
+23
-0
video.wpy
src/components/custom/video.wpy
+3
-2
No files found.
src/common/utils.js
View file @
e9e43939
...
...
@@ -55,3 +55,26 @@ export function compressShareImage(url) {
}
return
url
;
}
function
getCommonDivisor
(
firstNum
,
secondNum
)
{
if
(
secondNum
===
0
)
return
firstNum
;
var
remainder
=
parseInt
(
firstNum
%
secondNum
);
return
getCommonDivisor
(
secondNum
,
remainder
);
}
export
function
getProbability
(
quantity
,
coinQuantity
)
{
if
(
!
quantity
)
return
0
;
// 如果用户克币数是0
if
(
quantity
===
0
)
{
return
'
0%
'
;
}
var
divisor
=
getCommonDivisor
(
quantity
,
coinQuantity
);
var
value
=
quantity
/
divisor
;
var
value2
=
coinQuantity
/
divisor
;
// 如果分子比分母大说明中奖概率是100%,那么返回中奖概率
if
(
value
>=
value2
)
{
return
'
100%
'
;
}
else
{
return
value
+
'
/
'
+
value2
;
}
}
src/components/custom/video.wpy
View file @
e9e43939
...
...
@@ -53,6 +53,7 @@
<script>
import wepy from '@wepy/core';
import { getAwardsDetail, getPrizeList } from '../../common/api.js';
import {getProbability} from '../../common/utils';
wepy.component({
props: {
videoList: {
...
...
@@ -230,12 +231,12 @@
},
updateAwardsInfo(current) {
if (this.curQueue[current]) {
const { id, photoUrl, name,
probabil
ity } = this.curQueue[current];
const { id, photoUrl, name,
coinQuant
ity } = this.curQueue[current];
this.$emit('getAwardsInfo', {
id,
photoUrl: encodeURIComponent(photoUrl),
name,
chance:
probability
chance:
getProbability(this.userAccount, coinQuantity)
});
}
},
...
...
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