Commit 63e92af9 authored by 付清曌's avatar 付清曌

Merge branch 'optimize' into 'master'

Optimize

See merge request !14
parents fa28adbf 894a45b6
......@@ -27,5 +27,23 @@ module.exports = {
},
getPrizeList(params) {
return http.post('/api/prize/list', params, { 'content-type': 'application/json' });
},
getRaffles() {
return http.post('/api/user/join/list');
},
getOneRaffle(params) {
return http.post('/api/user/join/list',params);
},
getUserPhone() {
return http.post('/api/user/get/phone');
},
confirmRaffle(params) {
return http.post('/api/user/join/confirm',params);
},
updateUserPhone(params) {
return http.post('/api/user/update/phone',params);
},
getPrize(params){
return http.post('/api/user/price/receive',params);
}
};
import wepy from '@wepy/core';
import Notify from '../components/vant/notify/notify';
const baseUrl = 'https://luckiiapi.q-gp.com/yapi/mock/325';
const baseUrl = 'https://luckii-qa.liangkebang.net';
const request = async (url, options) => {
const pages = getCurrentPages();
......
......@@ -206,6 +206,8 @@
next-margin="120rpx"
catch:touchmove
>
bindtouchstart="touchStart"
bindtouchend="touchEnd"
<swiper-item wx:for="{{list}}" wx:key="index">
<view
data-itemid="{{index}}"
......@@ -228,8 +230,8 @@
</view>
</view>
<network v-if="isConnected === false"></network>
<!-- <open-animation v-if="showAwardsModal" :joinRecord="mainInfo && mainInfo.joinRecord"></open-animation>
<shared-popup v-if="showShareModal" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"></shared-popup> -->
<open-animation v-if="showAwardsModal" :joinRecord="mainInfo && mainInfo.joinRecord"></open-animation>
<shared-popup v-if="showShareModal" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"></shared-popup>
<popup @showMenu="showMenu" :showMenus="showMenus"></popup>
</view>
</template>
......@@ -521,7 +523,7 @@
getAwards: function() {
const { batchId, photoUrl, quantity, name, chance, progress } = this.awardsInfo;
wx.navigateTo({
url: `/pages/raffle?batchId=${batchId}&progress=${progress}&chance=${chance}&photoUrl=${photoUrl}}&quantity=${quantity}&name=${name}`
url: `/pages/raffle?batchId=${batchId}&progress=${progress}&chance=${chance}&photoUrl=${photoUrl}&quantity=${quantity}&name=${name}`
});
},
getAwardsInfo: function(v) {
......@@ -668,5 +670,9 @@
'video-loading': '~@/components/custom/loading'
},
navigationStyle: "custom",
"navigateToMiniProgramAppIdList":[
"wx91d27dbf599dff74"
],
}
</config>
......@@ -33,7 +33,8 @@
.item-corn{
color:#FF5D15;
font-size: 28rpx;
margin-top: 45rpx;
position: absolute;
bottom:30rpx;
}
.item-status {
position: absolute;
......@@ -86,7 +87,7 @@
<view class="item-corn">花费: {{item.quantity}}克币</view>
<view class="item-status">
<button data-id="{{item.id}}" class="item-button" bindtap="goprize" v-if="item.status.value==3">领取</button>
<text class="{{prize.computClass(item.status)}}" v-else>{{item.status.name}}</text>
<text class="{{prize.computClass(item.status)}}" v-else>{{fonts[item.status.value]}}</text>
</view>
</view>
</view>
......@@ -94,9 +95,11 @@
</template>
<script>
import wepy from '@wepy/core';
import { getRaffles } from '../common/api'
wepy.page({
data: {
list:[]
list:[],
fonts:['','待开奖','未中奖','待领取','未发货','已发货'],
},
methods: {
goprize(event) {
......@@ -106,13 +109,9 @@
}
},
onLoad () {
this.list = [
{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:3,status:{name:'待领取',value:3},quantity:300,prize:{name:'Nintendo Switch任天堂游戏机任天堂游戏机',photoUrl:'/static/images/test1.jpg'}},
{id:4,status:{name:'未发货',value:4},quantity:400,prize:{name:'Nintendo Switch任天堂游戏机任天堂游戏机',photoUrl:'/static/images/test1.jpg'}},
{id:5,status:{name:'已发货',value:5},quantity:500,prize:{name:'Nintendo Switch任天堂游戏机任天堂游戏机',photoUrl:'/static/images/test1.jpg'}},
];
getRaffles().then(res=>{
this.list = res || [];
});
},
});
</script>
......
......@@ -98,6 +98,7 @@
import wepy from '@wepy/core';
import Dialog from '../components/vant/dialog/dialog';
import Notify from '../components/vant/notify/notify';
import { getOneRaffle, getUserPhone, getPrize } from '../common/api'
var raffle = require('../common/raffleProbability');
var area = require('../components/custom/china.js');
wepy.page({
......@@ -141,14 +142,26 @@
return;
}
}
Dialog.alert({
title: '领取成功',
message: '您所领取的奖品我们将在3到5个工作日内寄出,请您耐心等待,感谢您的参与!',
}).then(() => {
wx.reLaunch({url:'/pages/index'})
// on confirm
let params = {
joinRecordId:this.joinRecordId,
name:this.name,
phone:this.phone,
province:this.province,
city:this.city,
country:this.country,
address:this.address,
};
let message = '您所领取的奖品我们将在3到5个工作日内寄出,请您耐心等待,感谢您的参与!';
let cashmeg = '您所领取的奖品我们将会在几分钟内发出,请您耐心等待,感谢您的参与!';
let that = this;
getPrize(params).then(()=>{
Dialog.alert({
title: '领取成功',
message: that.prize.cash?cashmeg:message,
}).then(() => {
wx.reLaunch({url:'/pages/index'})
});
});
console.log(this.name,this.phone,this.address);
},
onClose() {
this.showAddress = !this.showAddress;
......@@ -175,10 +188,19 @@
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;
getOneRaffle({joinRecordId:joinRecordId}).then(data=>{
let dat = data[0];
this.prize = dat.prize;
this.quantity = dat.quantity;
this.chance = raffle.getProbability(dat.quantity,dat.prize.coinQuantity);
});
getUserPhone().then(data=>{
this.phone = data.phone;
});
this.areaList = area.areaList;
this.chance = raffle.getProbability(this.quantity,this.prize.coinQuantity);
/*this.prize = {cash:false,name:'Nintendo Switch任天堂游戏机Nintendo Switch任天堂游戏机',photoUrl:'/static/images/test2.png',coinQuantity:5000};
this.quantity = 300;
this.chance = raffle.getProbability(this.quantity,this.prize.coinQuantity);*/
},
});
</script>
......
......@@ -111,7 +111,7 @@
<template>
<view class="raffle-wrapper">
<view class="raffle-content">
<van-image use-loading-slot src="{{photoUrl}}" class="img" width="610rpx" height="610rpx" radius="10rpx">
<van-image use-loading-slot src="{{photoUrl}}" class="img" width="610rpx" height="610rpx" radius="10rpx" fit="cover">
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
<view class="goodsinfo">
......@@ -123,7 +123,7 @@
<view class="progress">
<view class="orange" style="{{progressStyle}}"></view>
</view>
<text class="pronumber">{{progress}}%</text>
<text class="pronumber">{{progress}}</text>
</view>
</view>
<view class="user-wish" bindtap="check">
......@@ -132,33 +132,64 @@
</view>
<button class="joinin" open-type="{{opentype}}" bindtap="joinin" bindgetphonenumber="getPhoneNumber" >立即参与</button>
<van-notify id="van-notify" />
<van-dialog id="van-dialog" confirmButtonColor="#FF5D15"/>
</view>
</template>
<script>
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 store from '../store';
wepy.page({
store,
data: {
progress: 0,
progress: '0%',
progressStyle: '',
isCheck: false,
id: null,
batchId: null,
quantity: '',
name: '',
chance: '',
photoUrl: '',
batchId:null,
},
methods: {
check() {
this.isCheck = !this.isCheck;
},
getPhoneNumber(e) {
async getPhoneNumber(e) {
let that = this;
let title = ['参与成功!','参与失败!','参与失败!'];
let message = ['','当前抽奖已结束。','当前奖品已经没有库存了。']
let detail = e.$wx.detail || {};
//调用接口将加密数据传给后端,e.$wx.detail整体都传过去
//如果数据得到了就跳转
let isRegister = wx.getStorageSync('isRegister');
//如果用户还未注册
if(isRegister === false) {
await register(store.state.userInfo);
}
if(detail.encryptedData) {
Notify({message: '恭喜您参与成功!',background:'#FF5D15'})
wx.checkSession({
success () {
updateUserPhone(detail).then(()=>{
confirmRaffle({batchId:that.batchId}).then(data=>{
let code = data[0].joinCode;
Dialog.alert({
title: title[code],
message: message[code],
}).then(() => {
wx.reLaunch({url:'/pages/index'})
});
}).catch(()=>{
Notify({message: '参与失败,请重新点击参与!',background:'#FF5D15'})
})
}).catch(()=>{
Notify({message: '参与失败,请重新点击参与!',background:'#FF5D15'})
});
},
fail () {
wx.login();
}
});
}else {
Notify({message: '参与失败,请重新授权!',background:'#FF5D15'})
}
......@@ -166,6 +197,7 @@
joinin() {
if(!this.isCheck) {
Notify({message: '请先勾选!', background:'#FF5D15'})
return;
}
}
},
......@@ -188,17 +220,16 @@
}
},
onLoad (query) {
this.batchId = query.batchId;
let {id, corn, goods, chance, imgsrc, progress} = query;
let {batchId, quantity, name, chance, photoUrl, progress} = query;
if (progress) {
this.progress = progress;
this.progressStyle = 'width:' + progress + '%';
this.progressStyle = 'width:' + progress;
}
this.id = id;
this.quantity = corn;
this.name = goods;
this.batchId = batchId;
this.quantity = quantity;
this.name = name;
this.chance = chance;
this.photoUrl = imgsrc;
this.photoUrl = photoUrl;
}
});
</script>
......@@ -209,6 +240,7 @@
"van-notify": "../components/vant/notify/index",
"van-image": "../components/vant/image/index",
"van-loading": "../components/vant/loading/index",
"van-dialog": "../components/vant/dialog/index",
}
}
</config>
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