Commit 56e88e64 authored by wildfirecode13's avatar wildfirecode13

1

parent d2245e7a
'use strict';
import resList from '../../resconfig/resList';
import resList from '../../resconfig/resList';
import API from '../../api';
Page({
data: {
// 购买楼层数
canBuyFloor:10,
canBuyFloor: 10,
// 购买记录弹窗显示隐藏
orderModalVisible:false,
orderModalVisible: false,
// 立即购买弹窗
orderNowModalVisible:false,
orderNowModalVisible: false,
// 倒计时
endTime:{
d:'',
h:'',
m:'',
s:'',
endTime: {
d: '',
h: '',
m: '',
s: '',
},
// 奖品列表数据
prizeList:[],
prizeList: [],
startTime:'',
endingTime:'',
startTime: '',
endingTime: '',
},
......@@ -39,78 +39,79 @@ Page({
// 减楼层
reduceFloor(){
let {canBuyFloor} = this.data
if(canBuyFloor > 1){
reduceFloor() {
let { canBuyFloor } = this.data
if (canBuyFloor > 1) {
this.setData({
canBuyFloor:canBuyFloor - 1
canBuyFloor: canBuyFloor - 1
})
}
},
// 加楼层
addFloor(){
let {canBuyFloor} = this.data;
if(canBuyFloor < 100){
addFloor() {
let { canBuyFloor } = this.data;
if (canBuyFloor < 100) {
this.setData({
canBuyFloor:canBuyFloor + 1
canBuyFloor: canBuyFloor + 1
})
}
},
// 购买记录弹窗
orderRecord(){
orderRecord() {
// let {orderModalVisible} = this.data
console.log('click',this.data)
console.log('click', this.data)
this.setData({
orderModalVisible:true
orderModalVisible: true
})
},
// 关闭弹窗
orderModalClose(){
orderModalClose() {
this.setData({
orderModalVisible:false
orderModalVisible: false
})
},
// 购买楼层
async buyFloors(){
async buyFloors() {
// 购买楼层数
let {canBuyFloor} = this.data
let { canBuyFloor } = this.data
// 判断会员等级
let {isVip,grade,gradeName,gradeCredits} = await API.getVipInfo() || {};
// let { data: { isVip, grade, gradeName, gradeCredits } } = await API.getVipInfo() || {};
API.submit({floor:canBuyFloor,grade:grade}).catch((res)=>{
console.log(res);
API.getVipInfo().then(({ data: { grade } }) => {
API.submit({ floor: canBuyFloor, grade: grade }).catch((res) => {
console.log(res);
})
})
// 显示
this.setData({
orderNowModalVisible:true
orderNowModalVisible: true
})
},
// 获取奖品列表数据
async getBaseInfo(){
async getBaseInfo() {
let listStyleArr = []
let {data} = await API.getActivityBaseInfoById() || {};
console.log(data,'data')
let { data } = await API.getActivityBaseInfoById() || {};
console.log(data, 'data')
let list = data.list;
let prize = data.prize;
// startTime = data.startTime;
// endingTime = data.endTime;
for(let i=0;i<list.length;i++){
for (let i = 0; i < list.length; i++) {
let listStyle = {
left: 200*i + 'rpx',
left: 200 * i + 'rpx',
width: 200 + 'rpx',
height: 200 + 'rpx',
position:'absolute',
color:'white',
textAlign:'center'
position: 'absolute',
color: 'white',
textAlign: 'center'
}
// listStyleArr.push(listStyle);
list[i].liststyle = listStyle;
......@@ -123,24 +124,24 @@ Page({
// }
// }
this.setData({
prizeList:list,
startTime:data.startTime,
endingTime:data.endingTime
prizeList: list,
startTime: data.startTime,
endingTime: data.endingTime
})
},
// 关闭立即购买
orderNowModalClose(){
orderNowModalClose() {
this.setData({
orderNowModalVisible:false
orderNowModalVisible: false
})
},
// 倒计时
getEndTime() {
let {prizeList,endingTime} = this.data
let { prizeList, endingTime } = this.data
if (!prizeList || !prizeList.length) return null
// const endTime = prizeList[0].expiredTime
// if (!endTime) return null
......@@ -166,27 +167,27 @@ Page({
let hh = t2.padStart(2, '0');
let mm = t3.padStart(2, '0');
let ss =t4.padStart(2, '0');
let timer = setTimeout(()=>{
let ss = t4.padStart(2, '0');
let timer = setTimeout(() => {
this.setData({
stringTime: stringTime - 1
})
console.log(stringTime,'stringTime');
console.log(stringTime, 'stringTime');
if(stringTime <= 0){
if (stringTime <= 0) {
clearTimeout(timer);
}
this.setData({
// endTime: t1 + " " + t2.padStart(2, '0') + ":" + t3.padStart(2, '0') + ":" + t4.padStart(2, '0')
endTime:{
d:d1,
h:hh,
m:mm,
s:ss
endTime: {
d: d1,
h: hh,
m: mm,
s: ss
}
})
},1000)
}, 1000)
}
......
......@@ -25,6 +25,7 @@ Page({
},
gotoVipPage() {
API.getVipInfo().then(res => {
// res.data.isVip=true;
if (!res.data.isVip)
navigateToOutside(res.data.url)
else
......
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