迁移奖励金币弹窗脚本
This commit is contained in:
@@ -47,6 +47,10 @@ export function userCardComponent() {
|
||||
selectedGiftId: giftDefaults.defaultGiftId,
|
||||
giftCount: 1,
|
||||
sendingGift: false,
|
||||
showGiftPanel: false,
|
||||
showGiftGoldPanel: false,
|
||||
giftGoldAmount: "",
|
||||
giftGoldSending: false,
|
||||
|
||||
// 职务奖励金币
|
||||
rewardAmount: 0,
|
||||
@@ -518,6 +522,55 @@ export function userCardComponent() {
|
||||
this.sendingGift = false;
|
||||
},
|
||||
|
||||
/** 切换礼物面板,和赠送金币面板互斥显示 */
|
||||
toggleGiftPanel() {
|
||||
this.showGiftPanel = !this.showGiftPanel;
|
||||
this.showGiftGoldPanel = false;
|
||||
},
|
||||
|
||||
/** 切换赠送金币面板,和礼物面板互斥显示 */
|
||||
toggleGiftGoldPanel() {
|
||||
this.showGiftGoldPanel = !this.showGiftGoldPanel;
|
||||
this.showGiftPanel = false;
|
||||
},
|
||||
|
||||
/** 给用户赠送自己的金币 */
|
||||
async sendGiftGold() {
|
||||
const amount = Number.parseInt(this.giftGoldAmount, 10);
|
||||
if (this.giftGoldSending || !amount || amount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.giftGoldSending = true;
|
||||
|
||||
try {
|
||||
const response = await fetch("/gift/gold", {
|
||||
method: "POST",
|
||||
headers: this._headers(),
|
||||
body: JSON.stringify({
|
||||
to_user: this.userInfo.username,
|
||||
room_id: window.chatContext.roomId,
|
||||
amount,
|
||||
}),
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (data.status === "success") {
|
||||
window.chatContext.myGold = data.data?.my_jjb ?? window.chatContext.myGold;
|
||||
this.showGiftGoldPanel = false;
|
||||
this.giftGoldAmount = "";
|
||||
this.$alert(data.message, "赠送成功 💝", "#d97706");
|
||||
return;
|
||||
}
|
||||
|
||||
this.$alert(data.message, "赠送失败", "#cc4444");
|
||||
} catch (error) {
|
||||
this.$alert("网络异常", "错误", "#cc4444");
|
||||
}
|
||||
|
||||
this.giftGoldSending = false;
|
||||
},
|
||||
|
||||
/** 职务奖励:向用户发放金币(凭空产生,记入履职记录) */
|
||||
async sendReward() {
|
||||
if (this.sendingReward) return;
|
||||
|
||||
Reference in New Issue
Block a user