Add annual vip quick receive

This commit is contained in:
the1812 2019-11-21 18:32:49 +08:00
parent 792b786959
commit 8c4fedc731
10 changed files with 95 additions and 21 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -52,7 +52,7 @@
"hide-recommend-live.min.js": "C85A3478FFE38AF91A5369F278F23C5B501BE385A451962F222680E81B86CC05",
"superchat-translate.min.css": "F4874FE716A750AE0D21DA44393F286E5AABFFA949476E2FA06CDBE2748CF095",
"default-video-speed.min.js": "34E3D2BC8BD5BBC2534EDE6D7B02DE6D5F4A01879641A9E128B4C24124759D77",
"custom-navbar.min.css": "05D33FCC833F1E2FBD9B97AE0C2EDE6FB73B7736CB6D72DBDBDA81C9216DD625",
"custom-navbar.min.css": "A7BF1FCF6A7004991640C8505DD31D700A263ACC26AADF01B7EFF3F9D46FD13C",
"frame-playback.min.js": "57B34757FD03B9164B27DB48A1D6F4E3633086C27CD1E3246FCEDDCD7768F05E",
"feeds-apis.min.js": "ED1FFDEBC22680C5089F9D30CF667535FB99881C96A969DB47BC70BF095A99E8",
"favorites-redirect.min.js": "70D6ECCE0402AA76387D2A3288C1148C60CC88D5378B7A2BDC813F3F78E4EE84",
@ -159,7 +159,7 @@
"scrollbar.min.css": "9792340121B6EE6E618A3F62AABD9C992D9C325803DF4879C8A74F02DA0E2213",
"full-tweets-title.min.css": "13A0CF1C96F374CED3FA59A532E28B4B620D7A4C374385A363F32AD1A7656764",
"i18n.zh-TW.min.js": "803F67270809E3258E2B302ADE542B12EF222C83EDC67FB8C68301C5F4E3A1CC",
"custom-navbar.min.js": "08735D849BB09CA5082C6A02958146122E1BAA6C66B44DC93FDF80743E5C0DBA",
"custom-navbar.min.js": "4704A82478B92601832F69A218DE999B1B124AF2BFE644C65F69C4AE288AA3B8",
"screenshot.min.css": "6310BD2E77013EAAB38675DCD00761C2B7132C79A529B4FE25C8E86EC7E2F967",
"mdi.min.js": "8A22F2F37F88F74FC07CE2FECA7CE135182058BE24409BAF3DEF0D5845B0BE1A",
"feeds-filter.min.js": "10557E498B8BADA3C1C03E8C1DCD6FB24DBA2DA27A5A03BD861054F7E2989D46",

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -55,12 +55,12 @@ const attributes = {
Vue.component("order-item", {
props: ["item"],
template: /*html*/`
<li v-on:mouseenter="viewBorder(true)"
v-on:mouseleave="viewBorder(false)"
v-bind:class="{hidden: hidden()}">
<li @mouseenter="viewBorder(true)"
@mouseleave="viewBorder(false)"
:class="{hidden: hidden()}">
<i class="mdi mdi-menu"></i>
{{item.displayName}}
<button v-on:click="toggleHidden()">
<button @click="toggleHidden()">
<i v-if="hidden()" class="mdi mdi-eye-off"></i>
<i v-else class="mdi mdi-eye"></i>
</button>
@ -594,15 +594,23 @@ class UserInfo extends NavbarComponent {
<div v-if="isLogin" class="logged-in">
<a class="name" target="_blank" href="https://space.bilibili.com/">{{uname}}</a>
<a class="type" target="_blank" href="https://account.bilibili.com/account/big">{{userType}}</a>
<div class="privileges row" v-if="this.vipType === 2">
<div class="b-coin" :class="{received: privileges.bCoin.received}" @click="privilegeReceive(1)" :title="'有效期限: ' + privileges.bCoin.expire">
{{privileges.bCoin.received ? '已领取B币' : '领取B币'}}
</div>
<div class="coupons" :class="{received: privileges.coupons.received}" @click="privilegeReceive(2)" :title="'有效期限: ' + privileges.coupons.expire">
{{privileges.coupons.received ? '已领取优惠券' : '领取优惠券'}}
</div>
</div>
<div class="level-info row">
<a target="_blank" title="等级" href="https://account.bilibili.com/account/record"
class="level">
<i class="custom-navbar-iconfont-extended" v-bind:class="'custom-navbar-icon-lv' + level_info.current_level"></i>
<i class="custom-navbar-iconfont-extended" :class="'custom-navbar-icon-lv' + level_info.current_level"></i>
</a>
<span class="level-progress-label">{{level_info.current_exp}} / {{level_info.next_exp}}</span>
</div>
<div class="level-progress separator">
<div class="level-progress-thumb" v-bind:style="levelProgressStyle"></div>
<div class="level-progress-thumb" :style="levelProgressStyle"></div>
</div>
<div class="items">
<a class="item" target="_blank" title="手机验证"
@ -666,10 +674,20 @@ class UserInfo extends NavbarComponent {
}
async init () {
const panel = await SpinQuery.select(".custom-navbar .user-info-panel");
new Vue({
const vm = new Vue({
el: panel,
data: {
...userInfo,
privileges: {
bCoin: {
received: false,
expire: '',
},
coupons: {
received: false,
expire: '',
},
},
},
computed: {
userType () {
@ -696,6 +714,33 @@ class UserInfo extends NavbarComponent {
};
}
},
methods: {
async privilegeReceive (type) {
const typeMapping = {
1: 'bCoin',
2: 'coupons'
}
if (this.privileges[typeMapping[type]].received) {
return
}
this.privileges[typeMapping[type]].received = true
const csrf = getCsrf()
const result = await (await fetch('https://api.bilibili.com/x/vip/privilege/receive',
{
credentials: 'include',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
body: `type=${type}&csrf=${csrf}`,
method: 'POST'
})).json()
console.log(result)
if (result.code === 0 || result.code === 69801) { // 领取成功 || 已领过
return
} else {
this.privileges[typeMapping[type]].received = false
logError(result.message)
}
},
},
});
const face = await SpinQuery.select(".custom-navbar .user-face-container .user-face");
if (userInfo.isLogin) {
@ -717,6 +762,17 @@ class UserInfo extends NavbarComponent {
}, ""));
// pendant.style.backgroundImage = `url('${userInfo.pendant.image}@116w_116h.jpg')`;
}
if (userInfo.vipType === 2) { // 年度大会员权益
const privileges = await Ajax.getJsonWithCredentials('https://api.bilibili.com/x/vip/privilege/my')
if (privileges.code === 0) {
const bCoin = privileges.data.list.find(it => it.type === 1)
vm.privileges.bCoin.received = bCoin.state === 1
vm.privileges.bCoin.expire = new Date(bCoin.expire_time * 1000).toLocaleDateString()
const coupons = privileges.data.list.find(it => it.type === 2)
vm.privileges.coupons.received = coupons.state === 1
vm.privileges.coupons.expire = new Date(coupons.expire_time * 1000).toLocaleDateString()
}
}
}
else {
face.setAttribute("src", "https://static.hdslb.com/images/akari.jpg");

View File

@ -447,6 +447,24 @@ li.nav-item[report-id="playpage_dynamic"] .i-frame,
.row.level-info {
margin-bottom: -5px;
}
.privileges {
justify-content: center;
& > * {
font-size: 11px;
background-color: #8882;
padding: 2px 4px;
margin: 0 2px;
border-radius: 4px;
cursor: pointer;
&.received {
cursor: default;
opacity: 0.5;
}
&:not(.received):hover {
background-color: #8884;
}
}
}
.operation {
height: 36px;
display: flex;