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
9996925a
Commit
9996925a
authored
May 28, 2020
by
付清曌
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into 'master'
Feature/optimize See merge request
!18
parents
1b8b2769
4b3e0854
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
42 deletions
+74
-42
api.js
src/common/api.js
+2
-2
help.wpy
src/pages/help.wpy
+1
-0
index.wpy
src/pages/index.wpy
+1
-1
myraffles.wpy
src/pages/myraffles.wpy
+8
-4
prize.wpy
src/pages/prize.wpy
+13
-7
raffle.wpy
src/pages/raffle.wpy
+49
-28
No files found.
src/common/api.js
View file @
9996925a
...
@@ -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/
list
'
,
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
'
);
...
@@ -45,6 +45,6 @@ module.exports = {
...
@@ -45,6 +45,6 @@ module.exports = {
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/pri
ce/receive
'
,
params
);
return
http
.
post
(
'
/api/user/pri
ze/receive
'
,
params
,
{
'
content-type
'
:
'
application/json
'
}
);
}
}
};
};
src/pages/help.wpy
View file @
9996925a
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
.help-title{
.help-title{
font-size: 30rpx;
font-size: 30rpx;
color:#333;
color:#333;
font-weight:bold;
padding-top:30rpx;
padding-top:30rpx;
}
}
.help-info {
.help-info {
...
...
src/pages/index.wpy
View file @
9996925a
...
@@ -223,7 +223,7 @@
...
@@ -223,7 +223,7 @@
</swiper-item>
</swiper-item>
</swiper>
</swiper>
</view> -->
</view> -->
<view class="authmodal" v-
show
="authmodal">
<view class="authmodal" v-
if
="authmodal">
<view class="wrap">
<view class="wrap">
<view class="text">来到lukii,再平凡的人,<br>也有幸运的权利!</view>
<view class="text">来到lukii,再平凡的人,<br>也有幸运的权利!</view>
<button open-type="getUserInfo" bindgetuserinfo="getUserInfo">授权并进入</button>
<button open-type="getUserInfo" bindgetuserinfo="getUserInfo">授权并进入</button>
...
...
src/pages/myraffles.wpy
View file @
9996925a
...
@@ -12,10 +12,7 @@
...
@@ -12,10 +12,7 @@
padding:30rpx 0 0 30rpx;
padding:30rpx 0 0 30rpx;
overflow: hidden;
overflow: hidden;
.item-img{
.item-img{
width:150rpx;
height:150rpx;
float: left;
float: left;
border-radius: 10rpx;
}
}
.item-right{
.item-right{
margin-left:170rpx;
margin-left:170rpx;
...
@@ -86,7 +83,10 @@
...
@@ -86,7 +83,10 @@
<template>
<template>
<view class="raffles-list">
<view class="raffles-list">
<view class="raffle-item" wx:for="{{list}}" wx:key="index">
<view class="raffle-item" wx:for="{{list}}" wx:key="index">
<image src="{{item.prize.photoUrl}}" class="item-img"></image>
<van-image use-loading-slot src="{{item.prize.photoUrl}}" class="item-img" width="150rpx" height="150rpx" radius="10rpx" fit="cover">
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
<!--<image src="{{item.prize.photoUrl}}" class="item-img"></image>-->
<view class="item-right">
<view class="item-right">
<view class="item-title">{{item.prize.name}}</view>
<view class="item-title">{{item.prize.name}}</view>
<view class="item-corn">花费: {{item.quantity}}克币</view>
<view class="item-corn">花费: {{item.quantity}}克币</view>
...
@@ -124,5 +124,9 @@
...
@@ -124,5 +124,9 @@
<config>
<config>
{
{
navigationBarTitleText: '我的抽奖',
navigationBarTitleText: '我的抽奖',
"usingComponents": {
"van-image": "../components/vant/image/index",
"van-loading": "../components/vant/loading/index",
}
}
}
</config>
</config>
src/pages/prize.wpy
View file @
9996925a
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
<import src="../components/vant/picker/toolbar.wxml" />
<import src="../components/vant/picker/toolbar.wxml" />
<view class="prize-wrapper">
<view class="prize-wrapper">
<view class="prize-top">
<view class="prize-top">
<van-image use-loading-slot src="{{prize.photoUrl}}" class="img" width="400rpx" height="400rpx" radius="10rpx">
<van-image use-loading-slot src="{{prize.photoUrl}}" class="img" width="400rpx" height="400rpx" radius="10rpx"
fit="cover"
>
<van-loading slot="loading" type="spinner" size="20" vertical />
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
</van-image>
<view class="goodsname">{{prize.name}}</view>
<view class="goodsname">{{prize.name}}</view>
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
</van-popup>
</van-popup>
<view class="footerheight"></view>
<view class="footerheight"></view>
<view class="footer">
<view class="footer">
<button class="getprize" bindtap="goprize">
领取
</button>
<button class="getprize" bindtap="goprize">
{{btnfont}}
</button>
</view>
</view>
<van-dialog id="van-dialog" confirmButtonColor="#FF5D15"/>
<van-dialog id="van-dialog" confirmButtonColor="#FF5D15"/>
<van-notify id="van-notify" />
<van-notify id="van-notify" />
...
@@ -110,12 +110,13 @@
...
@@ -110,12 +110,13 @@
address:'',
address:'',
province:'',
province:'',
city:'',
city:'',
count
r
y:'',
county:'',
cityValue:'',
cityValue:'',
areaList:[],
areaList:[],
showAddress:false,
showAddress:false,
joinRecordId:null,
joinRecordId:null,
chance:''
chance:'',
btnfont:'领取'
},
},
methods: {
methods: {
goprize() {
goprize() {
...
@@ -148,19 +149,24 @@
...
@@ -148,19 +149,24 @@
phone:this.phone,
phone:this.phone,
province:this.province,
province:this.province,
city:this.city,
city:this.city,
count
ry:this.countr
y,
count
y:this.count
y,
address:this.address,
address:this.address,
};
};
let message = '您所领取的奖品我们将在3到5个工作日内寄出,请您耐心等待,感谢您的参与!';
let message = '您所领取的奖品我们将在3到5个工作日内寄出,请您耐心等待,感谢您的参与!';
let cashmeg = '您所领取的奖品我们将会在几分钟内发出,请您耐心等待,感谢您的参与!';
let cashmeg = '您所领取的奖品我们将会在几分钟内发出,请您耐心等待,感谢您的参与!';
let that = this;
let that = this;
this.btnfont = '提交中...'
if(this.btnfont!=='领取') return;
getPrize(params).then(()=>{
getPrize(params).then(()=>{
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(()=>{
this.btnfont = '领取';
});
});
},
},
onClose() {
onClose() {
...
@@ -175,7 +181,7 @@
...
@@ -175,7 +181,7 @@
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.count
r
y = 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()
}
}
...
@@ -189,7 +195,7 @@
...
@@ -189,7 +195,7 @@
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
[0]
;
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);
...
...
src/pages/raffle.wpy
View file @
9996925a
...
@@ -130,7 +130,7 @@
...
@@ -130,7 +130,7 @@
<image src="{{imgsrc}}" class="checkimg"></image>
<image src="{{imgsrc}}" class="checkimg"></image>
<text class="checktext">我同意花费所有克币参与抽奖,并承诺购买的商品不再退货。</text>
<text class="checktext">我同意花费所有克币参与抽奖,并承诺购买的商品不再退货。</text>
</view>
</view>
<button class="joinin" open-type="{{opentype}}" bindtap="joinin" bindgetphonenumber="getPhoneNumber"
>立即参与
</button>
<button class="joinin" open-type="{{opentype}}" bindtap="joinin" bindgetphonenumber="getPhoneNumber"
>{{btnfont}}
</button>
<van-notify id="van-notify" />
<van-notify id="van-notify" />
<van-dialog id="van-dialog" confirmButtonColor="#FF5D15"/>
<van-dialog id="van-dialog" confirmButtonColor="#FF5D15"/>
</view>
</view>
...
@@ -139,40 +139,68 @@
...
@@ -139,40 +139,68 @@
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 } from '../common/api'
import { updateUserPhone, confirmRaffle, register
,getUserPhone
} from '../common/api'
import store from '../store';
import store from '../store';
wepy.page({
wepy.page({
store,
store,
data: {
data: {
progress: '0%',
progress: '0%',
progressStyle: '',
progressStyle: '',
isCheck:
fals
e,
isCheck:
tru
e,
batchId: null,
batchId: null,
quantity: '',
quantity: '',
name: '',
name: '',
chance: '',
chance: '',
photoUrl: '',
photoUrl: '',
btnfont:'立即参与',
hasPhone:false,
},
},
methods: {
methods: {
check() {
check() {
this.isCheck = !this.isCheck;
this.isCheck = !this.isCheck;
},
},
async getPhoneNumber(e) {
async getPhoneNumber(e) {
if(this.btnfont !== '立即参与') {return;}
let that = this;
let that = this;
let title = ['参与成功!','参与失败!','参与失败!'];
let message = ['','当前抽奖已结束。','当前奖品已经没有库存了。']
let detail = e.$wx.detail || {};
let detail = e.$wx.detail || {};
let isRegister = wx.getStorageSync('isRegister');
function goprize() {
//如果用户还未注册
updateUserPhone(detail).then(()=>{
if(isRegister === false) {
that.confirmRaff();
await register(store.state.userInfo);
wx.setStorageSync('hasPhone',true);
that.hasPhone = true;
}).catch(()=>{
that.btnfont = '立即参与';
});
}
}
this.btnfont = '提交中...';
if(detail.encryptedData) {
if(detail.encryptedData) {
wx.checkSession({
wx.checkSession({
success () {
success () {
updateUserPhone(detail).then(()=>{
goprize();
confirmRaffle({batchId:that.batchId}).then(data=>{
},
let code = data[0].joinCode;
async fail () {
await wepy.wx.login();
goprize();
}
});
}else {
Notify({message: '参与失败,请重新授权!',background:'#FF5D15'})
}
},
async confirmRaff() {
let title = ['参与成功!','参与失败!','参与失败!'];
let message = ['参与成功,坐等开奖。','当前抽奖已结束。','当前奖品已经没有库存了。'];
//如果用户还未注册
let isRegister = wx.getStorageSync('isRegister');
if(isRegister === false) {
await register(store.state.userInfo);
wx.setStorageSync('isRegister', true);
}
this.btnfont = '提交中...';
confirmRaffle({batchId:this.batchId}).then(data=>{
this.btnfont = '立即参与';
let code = data.joinCode;
if(code === undefined) code = 3;
Dialog.alert({
Dialog.alert({
title: title[code],
title: title[code],
message: message[code],
message: message[code],
...
@@ -180,25 +208,17 @@
...
@@ -180,25 +208,17 @@
wx.reLaunch({url:'/pages/index'})
wx.reLaunch({url:'/pages/index'})
});
});
}).catch(()=>{
}).catch(()=>{
Notify({message: '参与失败,请重新点击参与!',background:'#FF5D15'})
this.btnfont = '立即参与';
})
})
}).catch(()=>{
Notify({message: '参与失败,请重新点击参与!',background:'#FF5D15'})
});
},
fail () {
wx.login();
}
});
}else {
Notify({message: '参与失败,请重新授权!',background:'#FF5D15'})
}
},
},
joinin() {
joinin() {
if(!this.isCheck) {
if(!this.isCheck) {
Notify({message: '请先勾选!', background:'#FF5D15'})
Notify({message: '请先勾选!', background:'#FF5D15'})
return;
return;
}
}
if(this.hasPhone) {
this.confirmRaff();
}
}
}
},
},
computed: {
computed: {
...
@@ -212,7 +232,7 @@
...
@@ -212,7 +232,7 @@
return imgsrc;
return imgsrc;
},
},
opentype() {
opentype() {
if (this.isCheck) {
if (this.isCheck
&& !this.hasPhone
) {
return 'getPhoneNumber';
return 'getPhoneNumber';
} else {
} else {
return '';
return '';
...
@@ -225,8 +245,9 @@
...
@@ -225,8 +245,9 @@
this.progress = progress;
this.progress = progress;
this.progressStyle = 'width:' + progress;
this.progressStyle = 'width:' + progress;
}
}
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