领取水晶增加队列处理,增加批量领取
This commit is contained in:
@@ -28,11 +28,29 @@ const thawlog = (data) => {
|
|||||||
url: 'user/account/thawlog',
|
url: 'user/account/thawlog',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data
|
data
|
||||||
|
}, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取新的一批水晶
|
||||||
|
const crystalsBefore = (data) => {
|
||||||
|
return request({
|
||||||
|
url: 'user/account/crystals/before',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量领取水晶
|
||||||
|
const allThawall = (data) => {
|
||||||
|
return request({
|
||||||
|
url: 'user/account/thawall',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
chain,
|
chain,
|
||||||
crystals,
|
crystals,
|
||||||
thawlog
|
thawlog,
|
||||||
|
crystalsBefore,
|
||||||
|
allThawall
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,13 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="text">发权证<uni-icons type="arrowright" color="#FFFFFF" size="12"></uni-icons>
|
<view class="text">发权证<uni-icons type="arrowright" color="#FFFFFF" size="12"></uni-icons>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="oct-float ore-item-key" @click="getAllThawall" v-if="crystalArr.length > 1">
|
||||||
|
<view class="oct-icon">
|
||||||
|
<image src="@/static/icons/crystals-icon.png" mode="widthFix" class="icon" />
|
||||||
|
</view>
|
||||||
|
<view class="text">一键领取<uni-icons type="arrowright" color="#FFFFFF" size="12"></uni-icons>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
@@ -120,38 +127,38 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { chain, crystals, thawlog } from '@/apis/interfaces/chain'
|
import { chain, crystals, thawlog, crystalsBefore, allThawall } from '@/apis/interfaces/chain'
|
||||||
import F2 from '@/uni_modules/lime-f2/components/lime-f2/f2.min.js'
|
import F2 from '@/uni_modules/lime-f2/components/lime-f2/f2.min.js'
|
||||||
import lF2 from '@/uni_modules/lime-f2/components/lime-f2/'
|
import lF2 from '@/uni_modules/lime-f2/components/lime-f2/'
|
||||||
|
import Queue from '@/public/queue'
|
||||||
|
let queue = new Queue()
|
||||||
export default {
|
export default {
|
||||||
components: { lF2 },
|
components: { lF2 },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isAuth: false,
|
isAuth: false,
|
||||||
chains: { // 区块链统计
|
chains: { // 区块链统计
|
||||||
balance: 0,
|
balance : 0,
|
||||||
height: 0,
|
height : 0,
|
||||||
number: 0,
|
number : 0,
|
||||||
score: 0,
|
score : 0,
|
||||||
up: 0,
|
up : 0,
|
||||||
stone: 0
|
stone : 0
|
||||||
},
|
},
|
||||||
account: { // 账户
|
account: { // 账户
|
||||||
coin: 0,
|
coin : 0,
|
||||||
crystal: 0
|
crystal : 0
|
||||||
},
|
},
|
||||||
crystalArr: [], // 待领取
|
crystalArr : [], // 待领取
|
||||||
allIds: [], // 可领取ids
|
categoryArr : [], // 推荐列表
|
||||||
categoryArr: [], // 推荐列表
|
help : {}, // 帮助信息
|
||||||
help: {}, // 帮助信息
|
userAuth : { // 用户认证状态
|
||||||
userAuth: { // 用户认证状态
|
|
||||||
certification: false,
|
certification: false,
|
||||||
company: false,
|
company : false,
|
||||||
vip: false
|
vip : false
|
||||||
},
|
},
|
||||||
// 领取贡献值队列
|
// 领取贡献值队列
|
||||||
queueData : [],
|
queueState : false
|
||||||
queueState : false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
@@ -224,37 +231,100 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 领取贡献值
|
// 领取贡献值
|
||||||
ledCrystal(index) {
|
ledCrystal(index) {
|
||||||
// 播放音频
|
this.playAudio()
|
||||||
const innerAudioContext = uni.createInnerAudioContext();
|
|
||||||
innerAudioContext.autoplay = true;
|
// 领取提示信息
|
||||||
innerAudioContext.src = require('@/static/mp3/crystal.mp3');
|
uni.showToast({
|
||||||
// 请求接口
|
image: require('@/static/icons/crystal-icon.png'),
|
||||||
thawlog({
|
title: '+' + this.crystalArr[index].amount,
|
||||||
thaw_id: this.crystalArr[index].log_id,
|
duration: 2000
|
||||||
all_ids: this.allIds
|
})
|
||||||
}).then(res => {
|
|
||||||
uni.showToast({
|
// 处理领取队列
|
||||||
image: require('@/static/icons/crystal-icon.png'),
|
queue.enqueue(this.crystalArr[index].log_id)
|
||||||
title: '+' + this.crystalArr[index].amount,
|
if(!this.queueState){
|
||||||
duration: 2000
|
let queueTime
|
||||||
})
|
this.queueState = true
|
||||||
this.$set(this.account, 'crystal', res.crystal)
|
this.startQueue(queueTime)
|
||||||
this.ids = res.all_ids
|
}
|
||||||
if (JSON.stringify(res.last) === '[]') {
|
|
||||||
this.$set(this.crystalArr, index, {
|
// 移出贡献值数据
|
||||||
amount: null
|
this.crystalArr.splice(index, 1)
|
||||||
})
|
},
|
||||||
return
|
// 领取贡献值队列
|
||||||
}
|
startQueue(outTime){
|
||||||
this.$set(this.crystalArr, index, res.last)
|
outTime = setInterval(() => {
|
||||||
}).catch(err => {
|
if(queue.isNull()){
|
||||||
uni.showToast({
|
clearInterval(outTime)
|
||||||
icon: 'none',
|
this.queueState = false
|
||||||
title: err
|
this.getCrystalsBefore()
|
||||||
})
|
return
|
||||||
})
|
}
|
||||||
},
|
queue.front().then(val => {
|
||||||
|
thawlog({
|
||||||
|
thaw_id: val,
|
||||||
|
}).then(res => {
|
||||||
|
this.$set(this.account, 'crystal', res.crystal)
|
||||||
|
}).catch(err => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: err.message
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
queue.dequeue()
|
||||||
|
}, 500)
|
||||||
|
},
|
||||||
|
// 批量领取贡献值
|
||||||
|
getAllThawall(){
|
||||||
|
let ids = []
|
||||||
|
let amounts = 0
|
||||||
|
|
||||||
|
ids = this.crystalArr.map(val => {
|
||||||
|
amounts += Number(val.amount)
|
||||||
|
return val.log_id
|
||||||
|
})
|
||||||
|
|
||||||
|
allThawall({
|
||||||
|
all_ids: ids
|
||||||
|
}).then(res => {
|
||||||
|
this.playAudio()
|
||||||
|
// 领取提示信息
|
||||||
|
uni.showToast({
|
||||||
|
image: require('@/static/icons/crystals-icon.png'),
|
||||||
|
title: '+' + amounts.toFixed(2),
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
this.crystalArr = []
|
||||||
|
this.$set(this.account, 'crystal', res.crystal)
|
||||||
|
this.getCrystalsBefore()
|
||||||
|
}).catch(err => {
|
||||||
|
uni.showToast({
|
||||||
|
icon : 'none',
|
||||||
|
title: err.message
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 刷新贡献值
|
||||||
|
getCrystalsBefore(){
|
||||||
|
if(this.crystalArr.length <= 0){
|
||||||
|
crystalsBefore().then(res => {
|
||||||
|
this.crystalArr = res.crystal_array
|
||||||
|
}).catch(err => {
|
||||||
|
uni.showToast({
|
||||||
|
title: err.message,
|
||||||
|
icon : 'none'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 播放领取提示信息
|
||||||
|
playAudio(){
|
||||||
|
const innerAudioContext = uni.createInnerAudioContext();
|
||||||
|
innerAudioContext.autoplay = true;
|
||||||
|
innerAudioContext.src = require('@/static/mp3/crystal.mp3');
|
||||||
|
},
|
||||||
// occ信息
|
// occ信息
|
||||||
getIndex() {
|
getIndex() {
|
||||||
Promise.all([crystals(), chain()]).then(res => {
|
Promise.all([crystals(), chain()]).then(res => {
|
||||||
@@ -626,6 +696,12 @@
|
|||||||
@extend .oct-float-item;
|
@extend .oct-float-item;
|
||||||
right: $margin;
|
right: $margin;
|
||||||
top: 12%;
|
top: 12%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ore-item-key{
|
||||||
|
@extend .oct-float-item;
|
||||||
|
left: $margin;
|
||||||
|
top: 20%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ore-item {
|
.ore-item {
|
||||||
|
|||||||
BIN
static/icons/crystals-icon.png
Normal file
BIN
static/icons/crystals-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
249
unpackage/dist/dev/app-plus/app-service.js
vendored
249
unpackage/dist/dev/app-plus/app-service.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user