Widget:RedeemCodePageTableTools
<style>
.redeem-code-table {
width:100%;
text-align:center;
}
.redeem-code-item-input {
display:none;
width:100%;
}
.redeem-code-item-input[data-show="block"] {
display:block;
}
.redeem-code-item-input[data-show="none"] {
display:none;
}
.redeem-code-item__editButtonList {
text-align:center;
}
.edit-button,
.delete-button,
.before-add-button,
.after-add-button {
padding:5px;
}
.edit-button:hover,
.before-add-button:hover,
.after-add-button:hover {
color:#0084ff;
}
.edit-button.active {
color:#ffa500;
}
.delete-button:hover {
color:#ff0000;
}
.item-box_text {
position: absolute;
left: 0;
bottom: -5px;
width: 100%;
padding: 0 3px;
font-weight: 700;
font-size: 10px;
text-align: center;
line-height: 19px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.item-box_star {
position: absolute;
bottom: 8px;
left: 3px;
width: 100%;
}
.item-box:hover {
border: 1px solid #fff;
}
</style> <script type='text/javascript' src="https://wiki.biligame.com/dhmmr/MediaWiki:Vue3.js?action=raw&ctype=text/javascript"></script>
| 兑换码 | 时效信息 | 兑换内容 | 说明信息 | 编辑用户 | 执行操作 |
|---|---|---|---|---|---|
<input class="redeem-code-item-input"
type="text"
placeholder="请输入兑换码!"
:data-show="item.hasOwnProperty('isEdit') && item.isEdit ? 'block' : 'none' "
v-show="item.hasOwnProperty('isEdit') && item.isEdit"
v-model="redeemCodeDataList[index].value"
/>
|
<input class="redeem-code-item-input"
type="text"
placeholder="请输入兑换码的生效时间!"
:data-show="item.hasOwnProperty('isEdit') && item.isEdit ? 'block' : 'none' "
v-show="item.hasOwnProperty('isEdit') && item.isEdit"
v-model="redeemCodeDataList[index].time"
/>
|
<input class="redeem-code-item-input"
type="text"
placeholder="请输入兑换码奖励物品的名称以英文“,”分隔!"
:data-show="item.hasOwnProperty('isEdit') && item.isEdit ? 'block' : 'none' "
v-show="item.hasOwnProperty('isEdit') && item.isEdit"
v-model="redeemCodeDataList[index].reward.item"
@change="editRewardInputHandle($event, index, 'item')"
/>
<input class="redeem-code-item-input"
type="text"
placeholder="请输入兑换码奖励物品的数量以英文“,”分隔!"
:data-show="item.hasOwnProperty('isEdit') && item.isEdit ? 'block' : 'none' "
v-show="item.hasOwnProperty('isEdit') && item.isEdit"
v-model="redeemCodeDataList[index].reward.count"
@change="editRewardInputHandle($event, index, 'count')"
/>
|
<input class="redeem-code-item-input"
type="text"
placeholder="请输入说明信息!"
:data-show="item.hasOwnProperty('isEdit') && item.isEdit ? 'block' : 'none' "
v-show="item.hasOwnProperty('isEdit') && item.isEdit"
v-model="redeemCodeDataList[index].desc"
/>
|
|
|
<script type='text/javascript'>
// 越写越乱 等待重构
(window.RLQ = window.RLQ || []).push([["jquery"], () => {
$(function () {
console.log("埋点:RedeemCodePageTableTools")
const Counter = {
data() {
return {
defaultRedeemCodeMap: {
"id": 0,
"key": "redeemCode",
"value": "",
"time": "",
"desc": "",
"user": [],
"reward": {
"item": [],
"count": []
},
"createTime": ""
},
redeemCodeDataList: [],
rewardItemNameList: [],
editUserUidList: [],
rewardItemHtmlTemplateList: [],
editUserHtmlTemplateList: [],
allRedeemCodeRewardItemTemplateList: [],
allEditUserHeadPortraitTemplateList: [],
biliUserUid: mw.config.get("wgUserName"),
isAdmin: mw.config.get('wgUserGroups').includes('interface-admin'),
isUserLogin: mw.config.get("wgUserGroups").includes('user') || mw.config.get("wgUserGroups").includes('bilibili'),
apiConfig: {
urls: {
index: "https://wiki.biligame.com/dhmmr/index.php",
api: "https://wiki.biligame.com/dhmmr/api.php"
},
params: {
parse: {
action: "parse",
text: "",
prop: "text",
utf8: 1,
formatversion: 2,
format: "json",
_t: ""
},
getRedeemCode: {
action: "raw",
title: "Data:RedeemCode.json",
ctype: "json",
_t: ""
}
}
},
}
},
methods: {
getRedeemCodeDataList() {
this.apiConfig.params.getRedeemCode["_t"] = new Date().getTime();
$.getJSON(this.apiConfig.urls.index, this.apiConfig.params.getRedeemCode, (res) => {
const dataList = res && Array.isArray(res) && res.length ? res : [$.extend(true,{},this.defaultRedeemCodeMap)];
const rewardItemNameList = Array.from(new Set(dataList.flatMap(item => item.reward.item)));
const editUserUidList = Array.from(new Set(dataList.flatMap(item => item.user)));
editUserUidList.push(this.biliUserUid + "");
this.redeemCodeDataList = dataList.sort((a, b) => b.id - a.id);
this.rewardItemNameList = rewardItemNameList;
this.editUserUidList = editUserUidList;
this.doParseTemplateData();
})
},
getAllRedeemCodeRewardItemTemplate() {
if (Array.isArray(this.redeemCodeDataList) && this.redeemCodeDataList.length) {
this.redeemCodeDataList.map((itemMap, itemIdx) => {
if (typeof itemMap !== "object" || "id" in itemMap && itemMap.id === 0) return;
if ("reward" in itemMap && "item" in itemMap["reward"] && "count" in itemMap["reward"]) {
let rewardItemTemplateHtmlString = "";
itemMap["reward"]["item"].map((itemName,itemIndex) => {
const templateMap = this.rewardItemHtmlTemplateList.find(item => item.id == itemName);
if (typeof templateMap === "object" && "html" in templateMap) {
const templateHtmlString = typeof templateMap["html"] === "string"
? templateMap["html"].match(/OvO/)
? templateMap["html"].replace("OvO", itemMap["reward"]["count"][itemIndex]) : ""
: "";
rewardItemTemplateHtmlString += templateHtmlString;
};
});
this.allRedeemCodeRewardItemTemplateList.push({
id: itemMap.id,
template: rewardItemTemplateHtmlString
});
};
});
};
},
getAllRedeemCodeEditUserHeadPortraitTemplate() {
this.allEditUserHeadPortraitTemplateList = [];
if (Array.isArray(this.redeemCodeDataList) && this.redeemCodeDataList.length) {
this.redeemCodeDataList.map((itemMap, itemIdx) => {
if (typeof itemMap !== "object" || "id" in itemMap && itemMap.id === 0) return;
if ("user" in itemMap && Array.isArray(itemMap["user"]) && itemMap["user"].length) {
let editUserTemplateHtmlString = "";
itemMap["user"].map(userUid => {
const templateMap = this.editUserHtmlTemplateList.find(item => item.id == userUid);
if (typeof templateMap === "object" && "html" in templateMap) {
editUserTemplateHtmlString += typeof templateMap["html"] === "string"
? templateMap["html"] : ""
};
});
this.allEditUserHeadPortraitTemplateList.push({
id: itemMap.id,
template: editUserTemplateHtmlString
});
};
});
};
},
doParseTemplateData() {
// 解析兑换物品模板html
this.getParsedTemplateHtmlString({
dataArray: this.rewardItemNameList || rewardItemNameList ,
template: "
",
selector: ".item-box",
cacheArray: this.rewardItemHtmlTemplateList,
callback: this.getAllRedeemCodeRewardItemTemplate
});
// 解析用户小头像模板html
this.getParsedTemplateHtmlString({
dataArray: this.editUserUidList || editUserUidList ,
template: "
",
selector: ".bwiki-custom-bili-user-little-info-box",
cacheArray: this.editUserHtmlTemplateList,
callback: this.getAllRedeemCodeEditUserHeadPortraitTemplate
});
},
getParsedTemplateHtmlString({dataArray, template, selector, cacheArray, callback}) {
if (Array.isArray(dataArray) && dataArray.length) {
dataArray.map((item, index) => {
const isExist = cacheArray.filter(cacheItem => cacheItem.id == item);
if (isExist.length) {callback();return;};
const params = $.extend(true, {}, this.apiConfig.params.parse);
params.text = template.replace("$1", item);
params["_t"] = new Date().getTime();
$.post(this.apiConfig.urls.api, params, ({ parse: { text } }) => {
// const templateHtml = text.match(/.*(?<=output"\>)(.*)(?=\n

沪公网安备 31011002002714 号