diff --git a/api/chat.py b/api/chat.py index c5f95fa..7badbfd 100644 --- a/api/chat.py +++ b/api/chat.py @@ -312,6 +312,12 @@ class ChatHandler(tornado.websocket.WebSocketHandler): gift_data['totalCoin'] = 1245000 gift_data['giftName'] = '小电视飞船' self.send_cmd_data(Command.ADD_GIFT, gift_data) + gift_data['id'] = uuid.uuid4().hex + gift_data['totalCoin'] = 0 + gift_data['totalFreeCoin'] = 1000 + gift_data['giftName'] = '辣条' + gift_data['num'] = 10 + self.send_cmd_data(Command.ADD_GIFT, gift_data) class RoomInfoHandler(api.base.ApiHandler): diff --git a/frontend/src/api/chat/ChatClientDirectOpenLive.js b/frontend/src/api/chat/ChatClientDirectOpenLive.js index 3c6a163..5503353 100644 --- a/frontend/src/api/chat/ChatClientDirectOpenLive.js +++ b/frontend/src/api/chat/ChatClientDirectOpenLive.js @@ -182,16 +182,14 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase { sendGiftCallback(command) { let data = command.data - if (!data.paid) { // 丢人 - return - } - + let totalCoin = data.price * data.gift_num data = new chatModels.AddGiftMsg({ id: data.msg_id, avatarUrl: chat.processAvatarUrl(data.uface), timestamp: data.timestamp, authorName: data.uname, - totalCoin: data.price * data.gift_num, + totalCoin: data.paid ? totalCoin : 0, + totalFreeCoin: !data.paid ? totalCoin : 0, giftName: data.gift_name, num: data.gift_num }) diff --git a/frontend/src/api/chat/ChatClientDirectWeb.js b/frontend/src/api/chat/ChatClientDirectWeb.js index 44c3e13..7883b8a 100644 --- a/frontend/src/api/chat/ChatClientDirectWeb.js +++ b/frontend/src/api/chat/ChatClientDirectWeb.js @@ -107,15 +107,13 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase { sendGiftCallback(command) { let data = command.data - if (data.coin_type !== 'gold') { // 丢人 - return - } - + let isPaidGift = data.coin_type === 'gold' data = new chatModels.AddGiftMsg({ avatarUrl: chat.processAvatarUrl(data.face), timestamp: data.timestamp, authorName: data.uname, - totalCoin: data.total_coin, + totalCoin: isPaidGift ? data.total_coin : 0, + totalFreeCoin: !isPaidGift ? data.total_coin : 0, giftName: data.giftName, num: data.num }) diff --git a/frontend/src/api/chat/ChatClientRelay.js b/frontend/src/api/chat/ChatClientRelay.js index 5aa89c9..479c0fa 100644 --- a/frontend/src/api/chat/ChatClientRelay.js +++ b/frontend/src/api/chat/ChatClientRelay.js @@ -144,10 +144,6 @@ export default class ChatClientRelay { break } case COMMAND_ADD_GIFT: { - // TODO 显示免费礼物 - if (data.totalCoin === 0) { // 丢人 - return - } data = new chatModels.AddGiftMsg(data) this.msgHandler.onAddGift(data) break diff --git a/frontend/src/api/chat/ChatClientTest.js b/frontend/src/api/chat/ChatClientTest.js index cd59203..e819e46 100644 --- a/frontend/src/api/chat/ChatClientTest.js +++ b/frontend/src/api/chat/ChatClientTest.js @@ -87,6 +87,7 @@ function randGuardInfo() { } const GIFT_INFO_LIST = [ + { giftName: '辣条', totalFreeCoin: 1000, num: 10 }, { giftName: 'B坷垃', totalCoin: 9900 }, { giftName: '礼花', totalCoin: 28000 }, { giftName: '花式夸夸', totalCoin: 39000 }, diff --git a/frontend/src/api/chat/models.js b/frontend/src/api/chat/models.js index 1b9c855..eaf6712 100644 --- a/frontend/src/api/chat/models.js +++ b/frontend/src/api/chat/models.js @@ -43,6 +43,7 @@ export class AddGiftMsg { timestamp = new Date().getTime() / 1000, authorName = '', totalCoin = 0, + totalFreeCoin = 0, giftName = '', num = 1, } = {}) { @@ -51,6 +52,7 @@ export class AddGiftMsg { this.timestamp = timestamp this.authorName = authorName this.totalCoin = totalCoin + this.totalFreeCoin = totalFreeCoin this.giftName = giftName this.num = num } diff --git a/frontend/src/api/chatConfig.js b/frontend/src/api/chatConfig.js index a508936..63c966c 100644 --- a/frontend/src/api/chatConfig.js +++ b/frontend/src/api/chatConfig.js @@ -3,7 +3,7 @@ import _ from 'lodash' import { mergeConfig } from '@/utils' export const DEFAULT_CONFIG = { - minGiftPrice: 7, // $1 + minGiftPrice: 0.1, showDanmaku: true, showGift: true, showGiftName: false, diff --git a/frontend/src/components/ChatRenderer/PaidMessage.vue b/frontend/src/components/ChatRenderer/PaidMessage.vue index d13e8ea..842b240 100644 --- a/frontend/src/components/ChatRenderer/PaidMessage.vue +++ b/frontend/src/components/ChatRenderer/PaidMessage.vue @@ -18,7 +18,7 @@
@@ -44,6 +44,7 @@ export default { avatarUrl: String, authorName: String, price: Number, // 价格,人民币 + priceText: String, time: Date, content: String }, @@ -54,8 +55,8 @@ export default { color() { return this.priceConfig.colors }, - priceText() { - return `CN¥${utils.formatCurrency(this.price)}` + showPriceText() { + return this.priceText || `CN¥${utils.formatCurrency(this.price)}` }, timeText() { return utils.getTimeTextHourMin(this.time) diff --git a/frontend/src/components/ChatRenderer/constants.js b/frontend/src/components/ChatRenderer/constants.js index 69b61b2..a5380cb 100644 --- a/frontend/src/components/ChatRenderer/constants.js +++ b/frontend/src/components/ChatRenderer/constants.js @@ -138,6 +138,20 @@ export const PRICE_CONFIGS = [ pinTime: 0, priceLevel: 1, }, + // $0淡蓝 + { + price: 0, + colors: { + contentBg: 'rgba(153, 236, 255, 1)', + headerBg: 'rgba(153, 236, 255, 1)', + header: 'rgba(255,255,255,1)', + authorName: 'rgba(255,255,255,0.701961)', + time: 'rgba(255,255,255,0.501961)', + content: 'rgba(255,255,255,1)' + }, + pinTime: 0, + priceLevel: 0, + }, ] export function getPriceConfig(price) { @@ -174,6 +188,10 @@ export function getGiftShowContent(message, showGiftName) { return i18n.i18n.t('chat.sendGift', { giftName: message.giftName, num: message.num }) } +export function getGiftShowNameAndNum(message) { + return `${message.giftName}x${message.num}` +} + export function getShowAuthorName(message) { if (message.authorNamePronunciation && message.authorNamePronunciation !== message.authorName) { return `${message.authorName}(${message.authorNamePronunciation})` diff --git a/frontend/src/components/ChatRenderer/index.vue b/frontend/src/components/ChatRenderer/index.vue index bc91778..49ca933 100644 --- a/frontend/src/components/ChatRenderer/index.vue +++ b/frontend/src/components/ChatRenderer/index.vue @@ -26,7 +26,8 @@ :avatarUrl="message.avatarUrl" :authorName="getShowAuthorName(message)" :price="message.price" - :content="getGiftShowContent(message)" + :priceText="message.price <= 0 ? getGiftShowNameAndNum(message) : ''" + :content="message.price <= 0 ? '' : getGiftShowContent(message)" >