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
e799d829
Commit
e799d829
authored
Jun 03, 2020
by
zhijie.xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码整理
parent
b2c2a087
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
426 additions
and
152 deletions
+426
-152
.eslintcache
.eslintcache
+1
-1
.eslintignore
.eslintignore
+3
-1
.eslintrc.js
.eslintrc.js
+4
-2
package-lock.json
package-lock.json
+270
-0
package.json
package.json
+10
-4
app.wpy
src/app.wpy
+0
-2
api.js
src/common/api.js
+2
-2
raffleProbability.js
src/common/raffleProbability.js
+16
-17
china.js
src/components/custom/china.js
+1
-1
videolist.wpy
src/components/custom/videolist.wpy
+1
-1
help.wpy
src/pages/help.wpy
+3
-8
index.wpy
src/pages/index.wpy
+27
-26
myraffles.wpy
src/pages/myraffles.wpy
+6
-6
prize.wpy
src/pages/prize.wpy
+57
-56
raffle.wpy
src/pages/raffle.wpy
+25
-25
No files found.
.eslintcache
View file @
e799d829
This diff is collapsed.
Click to expand it.
.eslintignore
View file @
e799d829
dist/*
dist/*
src/components/vant/*
src/components/vant/*
weapp/*
static/*
\ No newline at end of file
.eslintrc.js
View file @
e799d829
module
.
exports
=
{
module
.
exports
=
{
root
:
true
,
root
:
true
,
globals
:
{
wx
:
true
},
globals
:
{
wx
:
true
,
getCurrentPages
:
true
},
parser
:
'
babel-eslint
'
,
parser
:
'
babel-eslint
'
,
parserOptions
:
{
parserOptions
:
{
sourceType
:
'
module
'
sourceType
:
'
module
'
...
@@ -17,7 +20,6 @@ module.exports = {
...
@@ -17,7 +20,6 @@ module.exports = {
settings
:
{
settings
:
{
'
html/html-extensions
'
:
[
'
.html
'
,
'
.wpy
'
]
'
html/html-extensions
'
:
[
'
.html
'
,
'
.wpy
'
]
},
},
// add your custom rules here
'
rules
'
:
{
'
rules
'
:
{
// allow paren-less arrow functions
// allow paren-less arrow functions
'
arrow-parens
'
:
0
,
'
arrow-parens
'
:
0
,
...
...
package-lock.json
View file @
e799d829
This diff is collapsed.
Click to expand it.
package.json
View file @
e799d829
...
@@ -23,10 +23,12 @@
...
@@ -23,10 +23,12 @@
"
qs
"
:
"
^6.9.4
"
"
qs
"
:
"
^6.9.4
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@wepy/cli
"
:
"
^2.0.0-alpha.28
"
,
"
@babel/core
"
:
"
^7.1.0
"
,
"
@babel/core
"
:
"
^7.1.0
"
,
"
@babel/preset-env
"
:
"
^7.1.0
"
,
"
@babel/preset-env
"
:
"
^7.1.0
"
,
"
@wepy/babel-plugin-import-regenerator
"
:
"
0.0.2
"
,
"
@wepy/babel-plugin-import-regenerator
"
:
"
0.0.2
"
,
"
@wepy/cli
"
:
"
^2.0.0-alpha.28
"
,
"
@wepy/compiler-babel
"
:
"
^2.0.1
"
,
"
@wepy/compiler-less
"
:
"
^2.0.1
"
,
"
babel-eslint
"
:
"
^7.2.1
"
,
"
babel-eslint
"
:
"
^7.2.1
"
,
"
cross-env
"
:
"
^5.1.3
"
,
"
cross-env
"
:
"
^5.1.3
"
,
"
eslint
"
:
"
^3.18.0
"
,
"
eslint
"
:
"
^3.18.0
"
,
...
@@ -35,9 +37,13 @@
...
@@ -35,9 +37,13 @@
"
eslint-plugin-html
"
:
"
^2.0.1
"
,
"
eslint-plugin-html
"
:
"
^2.0.1
"
,
"
eslint-plugin-promise
"
:
"
^3.5.0
"
,
"
eslint-plugin-promise
"
:
"
^3.5.0
"
,
"
eslint-plugin-standard
"
:
"
^2.0.1
"
,
"
eslint-plugin-standard
"
:
"
^2.0.1
"
,
"
wepy-eslint
"
:
"
^1.5.3
"
,
"
husky
"
:
"
^4.2.5
"
,
"
less
"
:
"
^3.8.1
"
,
"
less
"
:
"
^3.8.1
"
,
"
@wepy/compiler-babel
"
:
"
^2.0.1
"
,
"
wepy-eslint
"
:
"
^1.5.3
"
"
@wepy/compiler-less
"
:
"
^2.0.1
"
},
"husky"
:
{
"hooks"
:
{
"pre-commit"
:
"npm run lint"
}
}
}
}
}
src/app.wpy
View file @
e799d829
...
@@ -11,8 +11,6 @@ import wepy from '@wepy/core';
...
@@ -11,8 +11,6 @@ import wepy from '@wepy/core';
import vuex from '@wepy/x';
import vuex from '@wepy/x';
import promisify from '@wepy/use-promisify';
import promisify from '@wepy/use-promisify';
import { login } from './common/api';
wepy.use(promisify);
wepy.use(promisify);
wepy.use(vuex);
wepy.use(vuex);
...
...
src/common/api.js
View file @
e799d829
...
@@ -33,7 +33,7 @@ module.exports = {
...
@@ -33,7 +33,7 @@ module.exports = {
return
http
.
post
(
'
/api/user/join/list
'
);
return
http
.
post
(
'
/api/user/join/list
'
);
},
},
getOneRaffle
(
params
)
{
getOneRaffle
(
params
)
{
return
http
.
post
(
'
/api/user/join/info
'
,
params
);
return
http
.
post
(
'
/api/user/join/info
'
,
params
);
},
},
getUserPhone
()
{
getUserPhone
()
{
return
http
.
post
(
'
/api/user/get/phone
'
);
return
http
.
post
(
'
/api/user/get/phone
'
);
...
@@ -44,7 +44,7 @@ module.exports = {
...
@@ -44,7 +44,7 @@ module.exports = {
updateUserPhone
(
params
)
{
updateUserPhone
(
params
)
{
return
http
.
post
(
'
/api/user/update/phone
'
,
params
);
return
http
.
post
(
'
/api/user/update/phone
'
,
params
);
},
},
getPrize
(
params
){
getPrize
(
params
)
{
return
http
.
post
(
'
/api/user/prize/receive
'
,
params
,
{
'
content-type
'
:
'
application/json
'
});
return
http
.
post
(
'
/api/user/prize/receive
'
,
params
,
{
'
content-type
'
:
'
application/json
'
});
}
}
};
};
src/common/raffleProbability.js
View file @
e799d829
function
getCommonDivisor
(
FirstNum
,
S
econdNum
)
{
function
getCommonDivisor
(
firstNum
,
s
econdNum
)
{
if
(
SecondNum
==
0
)
return
F
irstNum
;
if
(
secondNum
===
0
)
return
f
irstNum
;
var
remainder
=
parseInt
(
FirstNum
%
SecondNum
)
;
var
remainder
=
parseInt
(
firstNum
%
secondNum
)
;
return
getCommonDivisor
(
S
econdNum
,
remainder
);
return
getCommonDivisor
(
s
econdNum
,
remainder
);
}
}
function
getProbability
(
quantity
,
coinQuantity
)
{
function
getProbability
(
quantity
,
coinQuantity
)
{
// 如果用户克币数是0
//如果用户克币数是0
if
(
quantity
===
0
)
{
if
(
quantity
==
0
)
{
return
'
0/
'
+
coinQuantity
;
return
'
0/
'
+
coinQuantity
;
}
}
var
divisor
=
getCommonDivisor
(
quantity
,
coinQuantity
);
var
divisor
=
getCommonDivisor
(
quantity
,
coinQuantity
);
var
value
=
quantity
/
divisor
;
var
value
=
quantity
/
divisor
;
var
value2
=
coinQuantity
/
divisor
;
var
value2
=
coinQuantity
/
divisor
;
//如果分子比分母大说明中奖概率是100%,那么返回中奖概率
//
如果分子比分母大说明中奖概率是100%,那么返回中奖概率
if
(
value
>=
value2
)
{
if
(
value
>=
value2
)
{
return
coinQuantity
+
"
/
"
+
coinQuantity
return
coinQuantity
+
'
/
'
+
coinQuantity
;
}
else
{
}
else
{
return
value
+
"
/
"
+
value2
return
value
+
'
/
'
+
value2
;
}
}
}
}
module
.
exports
=
{
module
.
exports
=
{
getProbability
:
getProbability
getProbability
};
};
src/components/custom/china.js
View file @
e799d829
"
use strict
"
;
'
use strict
'
;
var
areaList
=
{
var
areaList
=
{
province_list
:
{
province_list
:
{
...
...
src/components/custom/videolist.wpy
View file @
e799d829
...
@@ -151,7 +151,7 @@
...
@@ -151,7 +151,7 @@
_invalidDown: 0,
_invalidDown: 0,
_videoContexts: [],
_videoContexts: [],
loading: false,
loading: false,
isFirstUp: true
,
isFirstUp: true
},
},
watch: {
watch: {
videoList () {
videoList () {
...
...
src/pages/help.wpy
View file @
e799d829
...
@@ -79,15 +79,10 @@
...
@@ -79,15 +79,10 @@
},
},
methods: {
methods: {
tomorehelp(){
tomorehelp()
{
wx.navigateTo({url: '/pages/morehelp'});
wx.navigateTo({url: '/pages/morehelp'})
}
}
}
},
onLoad () {
},
});
});
</script>
</script>
<config>
<config>
...
...
src/pages/index.wpy
View file @
e799d829
...
@@ -269,7 +269,8 @@
...
@@ -269,7 +269,8 @@
</template>
</template>
<script>
<script>
let touchDotX = 0, touchDotY = 0;
let touchDotX = 0;
let touchDotY = 0;
import store from '../store';
import store from '../store';
import { mapState, mapActions } from '@wepy/x';
import { mapState, mapActions } from '@wepy/x';
import wepy from '@wepy/core';
import wepy from '@wepy/core';
...
@@ -323,23 +324,12 @@
...
@@ -323,23 +324,12 @@
methods: {
methods: {
...mapActions([ 'setIsConnected', 'setUserInfo' ]),
...mapActions([ 'setIsConnected', 'setUserInfo' ]),
moveSwiper(e) {
moveSwiper(e) {
if (e.$wx.detail.source == 'touch') {
if (e.$wx.detail.source ==
=
'touch') {
let current = e.$wx.detail.current;
let current = e.$wx.detail.current;
this.currentIndex = current;
this.currentIndex = current;
}
}
},
},
swipermoveDone(e) {
swipermoveDone(e) {
if (e.$wx.detail.source == 'touch') {
let current = e.$wx.detail.current;
let totalPage = 3;
let nextlist = [
{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'}
];
let that = this;
function debounce(func, wait) {
function debounce(func, wait) {
let timeout;
let timeout;
return function () {
return function () {
...
@@ -351,6 +341,19 @@
...
@@ -351,6 +341,19 @@
if (callNow) func();
if (callNow) func();
};
};
}
}
if (e.$wx.detail.source === 'touch') {
let current = e.$wx.detail.current;
let totalPage = 3;
let nextlist = [
{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'}
];
let that = this;
/* if(current <= 2) {
/* if(current <= 2) {
debounce(setTimeout(function(){
debounce(setTimeout(function(){
that.topPage +=1;
that.topPage +=1;
...
@@ -370,7 +373,7 @@
...
@@ -370,7 +373,7 @@
that.circular = true;
that.circular = true;
return;
return;
}
}
that.list = [
...that.list, ...nextlist];
that.list = [...that.list, ...nextlist];
}, 1000), 500);
}, 1000), 500);
}
}
}
}
...
@@ -459,11 +462,11 @@
...
@@ -459,11 +462,11 @@
// }
// }
},
},
deleteAnimation (current) {
deleteAnimation (current) {
if (current && current.itemid != undefined) {
if (current && current.itemid !=
=
undefined) {
let list = this.list;
let list = this.list;
list = list.map((item, index) => {
list = list.map((item, index) => {
item.select = '';
item.select = '';
if (index ==
current.itemid) {
if (index ==
= +
current.itemid) {
item.select = true;
item.select = true;
}
}
return item;
return item;
...
@@ -478,7 +481,7 @@
...
@@ -478,7 +481,7 @@
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有个隐藏元素,当相等或小于的时候就有问题,要重新设置current,最小不能超过0
if (current.itemid <= that.current) {
if (current.itemid <= that.current) {
that.current = Math.max(that.current - 1, 0);
that.current = Math.max(that.current - 1, 0);
...
@@ -526,15 +529,15 @@
...
@@ -526,15 +529,15 @@
success (res) {
success (res) {
console.log('requestSubscribeMessage success', res);
console.log('requestSubscribeMessage success', res);
if (res.errMsg === 'requestSubscribeMessage:ok') {
if (res.errMsg === 'requestSubscribeMessage:ok') {
const rs = tmplIds.every(v => res[v] === 'accept');
// 兼容写法,有时响应中的模板id不是3个
const rs = tmplIds.every(v => res[v] === undefined || res[v] === 'accept');
if (rs) {
if (rs) {
that.sign = true;
that.sign = true;
setTimeout(async () => {
setTimeout(async () => {
const innerAudioContext = wx.createInnerAudioContext();
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.autoplay = true;
innerAudioContext.src = '/static/audio/supermarie.mp3';
innerAudioContext.src = '/static/audio/supermarie.mp3';
innerAudioContext.onPlay(() => {
innerAudioContext.onPlay(() => {});
});
innerAudioContext.onError((res) => {
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errMsg);
console.log(res.errCode);
console.log(res.errCode);
...
@@ -557,16 +560,14 @@
...
@@ -557,16 +560,14 @@
}
}
const openid = wx.getStorageSync('openId');
const openid = wx.getStorageSync('openId');
return {
return {
title: `${
this.$wepy.userInfo && this.$wepy.userInfo.nickName
|| '您的好朋友'}邀请您来抽奖啦~`,
title: `${
(this.$wepy.userInfo && this.$wepy.userInfo.nickName)
|| '您的好朋友'}邀请您来抽奖啦~`,
path: `/pages/index?openid=${openid}`,
path: `/pages/index?openid=${openid}`,
imageUrl: this.$wepy.awardsInfo.photoUrl,
imageUrl: this.$wepy.awardsInfo.photoUrl,
success: function(res) {
success: function(res) {
let shareId = res.shareTickets[0];
let shareId = res.shareTickets[0];
console.log('shareId', shareId);
console.log('shareId', shareId);
// 转发成功
},
},
fail: function(res) {
fail: function(res) {
// 转发失败
console.log(res);
console.log(res);
}
}
};
};
...
@@ -574,11 +575,11 @@
...
@@ -574,11 +575,11 @@
getAwards: function() {
getAwards: function() {
const { batchId, photoUrl, quantity, name, chance, progress } = this.awardsInfo;
const { batchId, photoUrl, quantity, name, chance, progress } = this.awardsInfo;
if (!batchId || !this.mainInfo || !this.mainInfo.account) {
if (!batchId || !this.mainInfo || !this.mainInfo.account) {
Notify({ message: '服务器异常,请稍后重试', background: '#FF5D15', safeAreaInsetTop: true});
Notify({ message: '服务器异常,请稍后重试', background: '#FF5D15', safeAreaInsetTop: true
});
return;
return;
}
}
if (this.mainInfo && this.mainInfo.account && this.mainInfo.account.quantity === 0) {
if (this.mainInfo && this.mainInfo.account && this.mainInfo.account.quantity === 0) {
Notify({ message: '您的克币数为0, 无法参与抽奖', background: '#FF5D15', safeAreaInsetTop: true});
Notify({ message: '您的克币数为0, 无法参与抽奖', background: '#FF5D15', safeAreaInsetTop: true
});
return;
return;
}
}
wx.navigateTo({
wx.navigateTo({
...
...
src/pages/myraffles.wpy
View file @
e799d829
...
@@ -101,24 +101,24 @@
...
@@ -101,24 +101,24 @@
</template>
</template>
<script>
<script>
import wepy from '@wepy/core';
import wepy from '@wepy/core';
import { getRaffles } from '../common/api'
import { getRaffles } from '../common/api'
;
wepy.page({
wepy.page({
data: {
data: {
list:[],
list:
[],
fonts:
['','待开奖','未中奖','待领取','未发货','已发货'],
fonts:
['', '待开奖', '未中奖', '待领取', '未发货', '已发货']
},
},
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?joinRecordId='+
id});
wx.navigateTo({url:
'/pages/prize?joinRecordId=' +
id});
}
}
},
},
onLoad () {
onLoad () {
getRaffles().then(res
=>
{
getRaffles().then(res
=>
{
this.list = res || [];
this.list = res || [];
});
});
}
,
}
});
});
</script>
</script>
<config>
<config>
...
...
src/pages/prize.wpy
View file @
e799d829
...
@@ -99,98 +99,98 @@
...
@@ -99,98 +99,98 @@
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';
import { getOneRaffle, getUserPhone, getPrize } from '../common/api'
import { getOneRaffle, getUserPhone, getPrize } from '../common/api'
;
var raffle = require('../common/raffleProbability');
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: {
quantity:0,
quantity:
0,
prize:{},
prize:
{},
name:'',
name:
'',
phone:'',
phone:
'',
address:'',
address:
'',
province:'',
province:
'',
city:'',
city:
'',
county:'',
county:
'',
cityValue:'',
cityValue:
'',
areaList:[],
areaList:
[],
showAddress:false,
showAddress:
false,
joinRecordId:null,
joinRecordId:
null,
chance:'',
chance:
'',
btnfont:'领取',
btnfont:
'领取',
idNumber:''
idNumber:
''
},
},
methods: {
methods: {
goprize() {
goprize() {
if(!this.prize.cash) {
if
(!this.prize.cash) {
if
(!this.name)
{
if
(!this.name)
{
Notify({message: '请填写收货人', background:'#FF5D15'});
Notify({message: '请填写收货人', background:
'#FF5D15'});
return;
return;
}
}
let reg = /^1\d{10}$/
let reg = /^1\d{10}$/
;
if
(!this.phone)
{
if
(!this.phone)
{
Notify({message: '请填写手机号码', background:'#FF5D15'});
Notify({message: '请填写手机号码', background:
'#FF5D15'});
return;
return;
}
}
if(!reg.test(this.phone)) {
if
(!reg.test(this.phone)) {
Notify({message: '请填写正确的手机号码', background:'#FF5D15'});
Notify({message: '请填写正确的手机号码', background:
'#FF5D15'});
return;
return;
}
}
if(!this.idNumber) {
if
(!this.idNumber) {
Notify({message: '请填写身份证号', background:'#FF5D15'});
Notify({message: '请填写身份证号', background:
'#FF5D15'});
return;
return;
}
}
if
(!this.city)
{
if
(!this.city)
{
Notify({message: '请选择所在地区', background:'#FF5D15'});
Notify({message: '请选择所在地区', background:
'#FF5D15'});
return;
return;
}
}
if
(!this.address)
{
if
(!this.address)
{
Notify({message: '请填写详细地址', background:'#FF5D15'});
Notify({message: '请填写详细地址', background:
'#FF5D15'});
return;
return;
}
}
}
}
let params = {
let params = {
joinRecordId:this.joinRecordId,
joinRecordId:
this.joinRecordId,
name:this.name,
name:
this.name,
phone:this.phone,
phone:
this.phone,
province:this.province,
province:
this.province,
city:this.city,
city:
this.city,
county:this.county,
county:
this.county,
address:this.address,
address:
this.address,
idNumber:
this.idNumber,
idNumber:
this.idNumber
};
};
let message = '您所领取的奖品我们将在3到5个工作日内寄出,请您耐心等待,感谢您的参与!';
let message = '您所领取的奖品我们将在3到5个工作日内寄出,请您耐心等待,感谢您的参与!';
let cashmeg = '您所领取的奖品我们将会在几分钟内发出,请您耐心等待,感谢您的参与!';
let cashmeg = '您所领取的奖品我们将会在几分钟内发出,请您耐心等待,感谢您的参与!';
let that = this;
let that = this;
if
(this.btnfont!==
'领取') return;
if
(this.btnfont !==
'领取') return;
this.btnfont = '...';
this.btnfont = '...';
getPrize(params).then(()
=>
{
getPrize(params).then(()
=>
{
this.btnfont = '领取';
this.btnfont = '领取';
Dialog.alert({
Dialog.alert({
title: '领取成功',
title: '领取成功',
message: that.prize.cash
?cashmeg:message,
message: that.prize.cash
? cashmeg : message
}).then(() => {
}).then(() => {
wx.reLaunch({url:
'/pages/index'})
wx.reLaunch({url:
'/pages/index'});
});
});
}).catch(()
=>
{
}).catch(()
=>
{
this.btnfont = '领取';
this.btnfont = '领取';
});
});
},
},
onClose() {
onClose() {
this.showAddress = !this.showAddress;
this.showAddress = !this.showAddress;
},
},
setValue(event){
setValue(event)
{
let value = event.$wx.detail;
let value = event.$wx.detail;
let form = event.$wx.currentTarget.dataset.form;
let form = event.$wx.currentTarget.dataset.form;
if(form) this[form] = value;
if
(form) this[form] = value;
},
},
getaddress(event) {
getaddress(event) {
let detail = event.$wx.detail.values;
let detail = event.$wx.detail.values;
this.province = detail[0].name;
this.province = detail[0].name;
this.city = detail[1].name;
this.city = detail[1].name;
this.county = detail[2].name;
this.county = detail[2].name;
this.cityValue = detail[0].name
+detail[1].name+detail[2].name
this.cityValue = detail[0].name
+ detail[1].name + detail[2].name;
this.onClose()
this.onClose()
;
}
}
},
},
computed: {
computed: {
...
@@ -199,22 +199,23 @@
...
@@ -199,22 +199,23 @@
onLoad (query) {
onLoad (query) {
let joinRecordId = query.joinRecordId || '';
let joinRecordId = query.joinRecordId || '';
this.joinRecordId = joinRecordId;
this.joinRecordId = joinRecordId;
if(!joinRecordId) Notify({message: '缺少参数错误!', background:'#FF5D15'});
if (!joinRecordId) Notify({message: '缺少参数错误!', background: '#FF5D15'});
//请求接口得到数据
// 请求接口得到数据
getOneRaffle({joinRecordId:joinRecordId}).then(data=>{
getOneRaffle({joinRecordId: joinRecordId}).then(data => {
let dat = data|| {};
console.log(555, data);
let dat = data || {};
this.prize = dat.prize;
this.prize = dat.prize;
this.quantity = dat.quantity;
this.quantity = dat.quantity;
this.chance = raffle.getProbability(
dat.quantity,
dat.prize.coinQuantity);
this.chance = raffle.getProbability(
+dat.quantity, +
dat.prize.coinQuantity);
});
});
getUserPhone().then(data
=>
{
getUserPhone().then(data
=>
{
this.phone = data.phone;
this.phone = data.phone;
});
});
this.areaList = area.areaList;
this.areaList = area.areaList;
/*this.prize = {cash:false,name:'Nintendo Switch任天堂游戏机Nintendo Switch任天堂游戏机',photoUrl:'/static/images/test2.png',coinQuantity:5000};
/*
this.prize = {cash:false,name:'Nintendo Switch任天堂游戏机Nintendo Switch任天堂游戏机',photoUrl:'/static/images/test2.png',coinQuantity:5000};
this.quantity = 300;
this.quantity = 300;
this.chance = raffle.getProbability(this.quantity,this.prize.coinQuantity);*/
this.chance = raffle.getProbability(this.quantity,this.prize.coinQuantity);
*/
}
,
}
});
});
</script>
</script>
<config>
<config>
...
...
src/pages/raffle.wpy
View file @
e799d829
...
@@ -139,7 +139,7 @@
...
@@ -139,7 +139,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 { updateUserPhone, confirmRaffle, register
,getUserPhone } from '../common/api'
import { updateUserPhone, confirmRaffle, register
} from '../common/api';
import store from '../store';
import store from '../store';
wepy.page({
wepy.page({
store,
store,
...
@@ -152,27 +152,27 @@
...
@@ -152,27 +152,27 @@
name: '',
name: '',
chance: '',
chance: '',
photoUrl: '',
photoUrl: '',
btnfont:'立即参与',
btnfont:
'立即参与',
hasPhone:
false,
hasPhone:
false
},
},
methods: {
methods: {
check() {
check() {
this.isCheck = !this.isCheck;
this.isCheck = !this.isCheck;
},
},
async getPhoneNumber(e) {
async getPhoneNumber(e) {
if
(this.btnfont !== '立即参与') {return;
}
if
(this.btnfont !== '立即参与') { return;
}
let that = this;
let that = this;
let detail = e.$wx.detail || {};
let detail = e.$wx.detail || {};
function goprize() {
function goprize() {
updateUserPhone(detail).then(()
=>
{
updateUserPhone(detail).then(()
=>
{
that.confirmRaff();
that.confirmRaff();
wx.setStorageSync('hasPhone',true);
wx.setStorageSync('hasPhone',
true);
that.hasPhone = true;
that.hasPhone = true;
}).catch(()
=>
{
}).catch(()
=>
{
that.btnfont = '立即参与';
that.btnfont = '立即参与';
});
});
}
}
if(detail.encryptedData) {
if
(detail.encryptedData) {
this.btnfont = '提交中...';
this.btnfont = '提交中...';
wx.checkSession({
wx.checkSession({
success () {
success () {
...
@@ -183,40 +183,40 @@
...
@@ -183,40 +183,40 @@
goprize();
goprize();
}
}
});
});
}else {
}
else {
Notify({message: '参与失败,请重新授权!',
background:'#FF5D15'})
Notify({message: '参与失败,请重新授权!',
background: '#FF5D15'});
}
}
},
},
async confirmRaff() {
async confirmRaff() {
let title = ['参与成功!',
'参与失败!',
'参与失败!'];
let title = ['参与成功!',
'参与失败!',
'参与失败!'];
let message = ['参与成功,坐等开奖。',
'当前抽奖已结束。',
'当前奖品已经没有库存了。'];
let message = ['参与成功,坐等开奖。',
'当前抽奖已结束。',
'当前奖品已经没有库存了。'];
//如果用户还未注册
//
如果用户还未注册
let isRegister = wx.getStorageSync('isRegister');
let isRegister = wx.getStorageSync('isRegister');
if(isRegister === false) {
if
(isRegister === false) {
await register(store.state.userInfo);
await register(store.state.userInfo);
wx.setStorageSync('isRegister', true);
wx.setStorageSync('isRegister', true);
}
}
this.btnfont = '提交中...';
this.btnfont = '提交中...';
confirmRaffle({batchId:
this.batchId}).then(data=>
{
confirmRaffle({batchId:
this.batchId}).then(data =>
{
this.btnfont = '立即参与';
this.btnfont = '立即参与';
let code = data.joinCode;
let code = data.joinCode;
if(code === undefined) code = 3;
if
(code === undefined) code = 3;
Dialog.alert({
Dialog.alert({
title: title[code],
title: title[code],
message: message[code]
,
message: message[code]
}).then(() => {
}).then(() => {
wx.reLaunch({url:
'/pages/index'})
wx.reLaunch({url:
'/pages/index'});
});
});
}).catch(()
=>
{
}).catch(()
=>
{
this.btnfont = '立即参与';
this.btnfont = '立即参与';
})
})
;
},
},
joinin() {
joinin() {
if(!this.isCheck) {
if
(!this.isCheck) {
Notify({message: '勾选同意后才可以抽奖!', background:
'#FF5D15'})
Notify({message: '勾选同意后才可以抽奖!', background:
'#FF5D15'});
return;
return;
}
}
if(this.hasPhone) {
if
(this.hasPhone) {
this.confirmRaff();
this.confirmRaff();
}
}
}
}
...
@@ -224,7 +224,7 @@
...
@@ -224,7 +224,7 @@
computed: {
computed: {
imgsrc() {
imgsrc() {
let imgsrc = '/static/images/selected.png';
let imgsrc = '/static/images/selected.png';
if(this.isCheck) {
if
(this.isCheck) {
imgsrc = '/static/images/selected.png';
imgsrc = '/static/images/selected.png';
} else {
} else {
imgsrc = '/static/images/selectno.png';
imgsrc = '/static/images/selectno.png';
...
@@ -247,7 +247,7 @@
...
@@ -247,7 +247,7 @@
}
}
this.hasPhone = wx.getStorageSync('hasPhone');
this.hasPhone = wx.getStorageSync('hasPhone');
this.batchId = batchId;
this.batchId = batchId;
this.quantity = quantity
||
'';
this.quantity = quantity
||
'';
this.name = name;
this.name = name;
this.chance = chance;
this.chance = chance;
this.photoUrl = photoUrl;
this.photoUrl = photoUrl;
...
...
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