领取水晶增加队列处理,增加批量领取
This commit is contained in:
@@ -28,11 +28,29 @@ const thawlog = (data) => {
|
||||
url: 'user/account/thawlog',
|
||||
method: 'POST',
|
||||
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 {
|
||||
chain,
|
||||
crystals,
|
||||
thawlog
|
||||
thawlog,
|
||||
crystalsBefore,
|
||||
allThawall
|
||||
}
|
||||
|
||||
@@ -36,6 +36,13 @@
|
||||
<view class="text">发权证<uni-icons type="arrowright" color="#FFFFFF" size="12"></uni-icons>
|
||||
</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>
|
||||
</block>
|
||||
<block v-else>
|
||||
@@ -120,37 +127,37 @@
|
||||
</template>
|
||||
|
||||
<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 lF2 from '@/uni_modules/lime-f2/components/lime-f2/'
|
||||
import Queue from '@/public/queue'
|
||||
let queue = new Queue()
|
||||
export default {
|
||||
components: { lF2 },
|
||||
data() {
|
||||
return {
|
||||
isAuth: false,
|
||||
chains: { // 区块链统计
|
||||
balance: 0,
|
||||
height: 0,
|
||||
number: 0,
|
||||
score: 0,
|
||||
up: 0,
|
||||
stone: 0
|
||||
balance : 0,
|
||||
height : 0,
|
||||
number : 0,
|
||||
score : 0,
|
||||
up : 0,
|
||||
stone : 0
|
||||
},
|
||||
account: { // 账户
|
||||
coin: 0,
|
||||
crystal: 0
|
||||
coin : 0,
|
||||
crystal : 0
|
||||
},
|
||||
crystalArr: [], // 待领取
|
||||
allIds: [], // 可领取ids
|
||||
categoryArr: [], // 推荐列表
|
||||
help: {}, // 帮助信息
|
||||
userAuth: { // 用户认证状态
|
||||
crystalArr : [], // 待领取
|
||||
categoryArr : [], // 推荐列表
|
||||
help : {}, // 帮助信息
|
||||
userAuth : { // 用户认证状态
|
||||
certification: false,
|
||||
company: false,
|
||||
vip: false
|
||||
company : false,
|
||||
vip : false
|
||||
},
|
||||
// 领取贡献值队列
|
||||
queueData : [],
|
||||
queueState : false
|
||||
};
|
||||
},
|
||||
@@ -225,35 +232,98 @@
|
||||
},
|
||||
// 领取贡献值
|
||||
ledCrystal(index) {
|
||||
// 播放音频
|
||||
this.playAudio()
|
||||
|
||||
// 领取提示信息
|
||||
uni.showToast({
|
||||
image: require('@/static/icons/crystal-icon.png'),
|
||||
title: '+' + this.crystalArr[index].amount,
|
||||
duration: 2000
|
||||
})
|
||||
|
||||
// 处理领取队列
|
||||
queue.enqueue(this.crystalArr[index].log_id)
|
||||
if(!this.queueState){
|
||||
let queueTime
|
||||
this.queueState = true
|
||||
this.startQueue(queueTime)
|
||||
}
|
||||
|
||||
// 移出贡献值数据
|
||||
this.crystalArr.splice(index, 1)
|
||||
},
|
||||
// 领取贡献值队列
|
||||
startQueue(outTime){
|
||||
outTime = setInterval(() => {
|
||||
if(queue.isNull()){
|
||||
clearInterval(outTime)
|
||||
this.queueState = false
|
||||
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');
|
||||
// 请求接口
|
||||
thawlog({
|
||||
thaw_id: this.crystalArr[index].log_id,
|
||||
all_ids: this.allIds
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
image: require('@/static/icons/crystal-icon.png'),
|
||||
title: '+' + this.crystalArr[index].amount,
|
||||
duration: 2000
|
||||
})
|
||||
this.$set(this.account, 'crystal', res.crystal)
|
||||
this.ids = res.all_ids
|
||||
if (JSON.stringify(res.last) === '[]') {
|
||||
this.$set(this.crystalArr, index, {
|
||||
amount: null
|
||||
})
|
||||
return
|
||||
}
|
||||
this.$set(this.crystalArr, index, res.last)
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: err
|
||||
})
|
||||
})
|
||||
},
|
||||
// occ信息
|
||||
getIndex() {
|
||||
@@ -628,6 +698,12 @@
|
||||
top: 12%;
|
||||
}
|
||||
|
||||
.ore-item-key{
|
||||
@extend .oct-float-item;
|
||||
left: $margin;
|
||||
top: 20%;
|
||||
}
|
||||
|
||||
.ore-item {
|
||||
@extend .oct-float-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