Commit 9996925a authored by 付清曌's avatar 付清曌

Merge branch 'feature/optimize' into 'master'

Feature/optimize

See merge request !18
parents 1b8b2769 4b3e0854
......@@ -33,7 +33,7 @@ module.exports = {
return http.post('/api/user/join/list');
},
getOneRaffle(params) {
return http.post('/api/user/join/list', params);
return http.post('/api/user/join/info',params);
},
getUserPhone() {
return http.post('/api/user/get/phone');
......@@ -45,6 +45,6 @@ module.exports = {
return http.post('/api/user/update/phone', params);
},
getPrize(params){
return http.post('/api/user/price/receive', params);
return http.post('/api/user/prize/receive', params, { 'content-type': 'application/json' });
}
};
......@@ -6,6 +6,7 @@
.help-title{
font-size: 30rpx;
color:#333;
font-weight:bold;
padding-top:30rpx;
}
.help-info {
......
......@@ -223,7 +223,7 @@
</swiper-item>
</swiper>
</view> -->
<view class="authmodal" v-show="authmodal">
<view class="authmodal" v-if="authmodal">
<view class="wrap">
<view class="text">来到lukii,再平凡的人,<br>也有幸运的权利!</view>
<button open-type="getUserInfo" bindgetuserinfo="getUserInfo">授权并进入</button>
......
......@@ -12,10 +12,7 @@
padding:30rpx 0 0 30rpx;
overflow: hidden;
.item-img{
width:150rpx;
height:150rpx;
float: left;
border-radius: 10rpx;
}
.item-right{
margin-left:170rpx;
......@@ -86,7 +83,10 @@
<template>
<view class="raffles-list">
<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-title">{{item.prize.name}}</view>
<view class="item-corn">花费: {{item.quantity}}克币</view>
......@@ -124,5 +124,9 @@
<config>
{
navigationBarTitleText: '我的抽奖',
"usingComponents": {
"van-image": "../components/vant/image/index",
"van-loading": "../components/vant/loading/index",
}
}
</config>
......@@ -67,7 +67,7 @@
<import src="../components/vant/picker/toolbar.wxml" />
<view class="prize-wrapper">
<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-image>
<view class="goodsname">{{prize.name}}</view>
......@@ -88,7 +88,7 @@
</van-popup>
<view class="footerheight"></view>
<view class="footer">
<button class="getprize" bindtap="goprize">领取</button>
<button class="getprize" bindtap="goprize">{{btnfont}}</button>
</view>
<van-dialog id="van-dialog" confirmButtonColor="#FF5D15"/>
<van-notify id="van-notify" />
......@@ -110,12 +110,13 @@
address:'',
province:'',
city:'',
country:'',
county:'',
cityValue:'',
areaList:[],
showAddress:false,
joinRecordId:null,
chance:''
chance:'',
btnfont:'领取'
},
methods: {
goprize() {
......@@ -148,19 +149,24 @@
phone:this.phone,
province:this.province,
city:this.city,
country:this.country,
county:this.county,
address:this.address,
};
let message = '您所领取的奖品我们将在3到5个工作日内寄出,请您耐心等待,感谢您的参与!';
let cashmeg = '您所领取的奖品我们将会在几分钟内发出,请您耐心等待,感谢您的参与!';
let that = this;
this.btnfont = '提交中...'
if(this.btnfont!=='领取') return;
getPrize(params).then(()=>{
this.btnfont = '领取';
Dialog.alert({
title: '领取成功',
message: that.prize.cash?cashmeg:message,
}).then(() => {
wx.reLaunch({url:'/pages/index'})
});
}).catch(()=>{
this.btnfont = '领取';
});
},
onClose() {
......@@ -175,7 +181,7 @@
let detail = event.$wx.detail.values;
this.province = detail[0].name;
this.city = detail[1].name;
this.country = detail[2].name;
this.county = detail[2].name;
this.cityValue = detail[0].name+detail[1].name+detail[2].name
this.onClose()
}
......@@ -189,7 +195,7 @@
if(!joinRecordId) Notify({message: '缺少参数错误!', background:'#FF5D15'});
//请求接口得到数据
getOneRaffle({joinRecordId:joinRecordId}).then(data=>{
let dat = data[0];
let dat = data|| {};
this.prize = dat.prize;
this.quantity = dat.quantity;
this.chance = raffle.getProbability(dat.quantity,dat.prize.coinQuantity);
......
......@@ -130,7 +130,7 @@
<image src="{{imgsrc}}" class="checkimg"></image>
<text class="checktext">我同意花费所有克币参与抽奖,并承诺购买的商品不再退货。</text>
</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-dialog id="van-dialog" confirmButtonColor="#FF5D15"/>
</view>
......@@ -139,40 +139,68 @@
import wepy from '@wepy/core';
import Notify from '../components/vant/notify/notify';
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';
wepy.page({
store,
data: {
progress: '0%',
progressStyle: '',
isCheck: false,
isCheck: true,
batchId: null,
quantity: '',
name: '',
chance: '',
photoUrl: '',
btnfont:'立即参与',
hasPhone:false,
},
methods: {
check() {
this.isCheck = !this.isCheck;
},
async getPhoneNumber(e) {
if(this.btnfont !== '立即参与') {return;}
let that = this;
let title = ['参与成功!','参与失败!','参与失败!'];
let message = ['','当前抽奖已结束。','当前奖品已经没有库存了。']
let detail = e.$wx.detail || {};
let isRegister = wx.getStorageSync('isRegister');
//如果用户还未注册
if(isRegister === false) {
await register(store.state.userInfo);
function goprize() {
updateUserPhone(detail).then(()=>{
that.confirmRaff();
wx.setStorageSync('hasPhone',true);
that.hasPhone = true;
}).catch(()=>{
that.btnfont = '立即参与';
});
}
this.btnfont = '提交中...';
if(detail.encryptedData) {
wx.checkSession({
success () {
updateUserPhone(detail).then(()=>{
confirmRaffle({batchId:that.batchId}).then(data=>{
let code = data[0].joinCode;
goprize();
},
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({
title: title[code],
message: message[code],
......@@ -180,25 +208,17 @@
wx.reLaunch({url:'/pages/index'})
});
}).catch(()=>{
Notify({message: '参与失败,请重新点击参与!',background:'#FF5D15'})
this.btnfont = '立即参与';
})
}).catch(()=>{
Notify({message: '参与失败,请重新点击参与!',background:'#FF5D15'})
});
},
fail () {
wx.login();
}
});
}else {
Notify({message: '参与失败,请重新授权!',background:'#FF5D15'})
}
},
joinin() {
if(!this.isCheck) {
Notify({message: '请先勾选!', background:'#FF5D15'})
return;
}
if(this.hasPhone) {
this.confirmRaff();
}
}
},
computed: {
......@@ -212,7 +232,7 @@
return imgsrc;
},
opentype() {
if (this.isCheck) {
if (this.isCheck && !this.hasPhone) {
return 'getPhoneNumber';
} else {
return '';
......@@ -225,8 +245,9 @@
this.progress = progress;
this.progressStyle = 'width:' + progress;
}
this.hasPhone = wx.getStorageSync('hasPhone');
this.batchId = batchId;
this.quantity = quantity;
this.quantity = quantity||'';
this.name = name;
this.chance = chance;
this.photoUrl = photoUrl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment