diff --git a/config/dev.js b/config/dev.js index 1e0d782..c616391 100644 --- a/config/dev.js +++ b/config/dev.js @@ -10,8 +10,8 @@ module.exports = { h5: { devServer: { //host: '0.0.0.0', - //host: '192.168.110.53', - host: '192.168.3.102', + host: '192.168.110.53', + //host: '192.168.3.102', port: 10086, // 设置代理来解决 H5 请求的跨域问题 proxy: { diff --git a/src/api/proto.js b/src/api/proto.js index 7ff0152..36731a7 100644 --- a/src/api/proto.js +++ b/src/api/proto.js @@ -1394,8 +1394,9 @@ export const api = $root.api = (() => { * Properties of a ResIdentity. * @memberof api * @interface IResIdentity - * @property {number|null} [status] ResIdentity status - * @property {string|null} [msg] ResIdentity msg + * @property {number|Long|null} [id] ResIdentity id + * @property {string|null} [username] ResIdentity username + * @property {string|null} [avatar] ResIdentity avatar */ /** @@ -1414,20 +1415,28 @@ export const api = $root.api = (() => { } /** - * ResIdentity status. - * @member {number} status + * ResIdentity id. + * @member {number|Long} id * @memberof api.ResIdentity * @instance */ - ResIdentity.prototype.status = 0; + ResIdentity.prototype.id = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** - * ResIdentity msg. - * @member {string} msg + * ResIdentity username. + * @member {string} username + * @memberof api.ResIdentity + * @instance + */ + ResIdentity.prototype.username = ""; + + /** + * ResIdentity avatar. + * @member {string} avatar * @memberof api.ResIdentity * @instance */ - ResIdentity.prototype.msg = ""; + ResIdentity.prototype.avatar = ""; /** * Creates a new ResIdentity instance using the specified properties. @@ -1453,10 +1462,12 @@ export const api = $root.api = (() => { ResIdentity.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.status != null && Object.hasOwnProperty.call(message, "status")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.status); - if (message.msg != null && Object.hasOwnProperty.call(message, "msg")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.msg); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.id); + if (message.username != null && Object.hasOwnProperty.call(message, "username")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.username); + if (message.avatar != null && Object.hasOwnProperty.call(message, "avatar")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.avatar); return writer; }; @@ -1491,12 +1502,16 @@ export const api = $root.api = (() => { while (reader.pos < end) { let tag = reader.uint32(); switch (tag >>> 3) { - case 1: { - message.status = reader.int32(); + case 3: { + message.id = reader.int64(); break; } - case 2: { - message.msg = reader.string(); + case 4: { + message.username = reader.string(); + break; + } + case 5: { + message.avatar = reader.string(); break; } default: @@ -1534,12 +1549,15 @@ export const api = $root.api = (() => { ResIdentity.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.status != null && message.hasOwnProperty("status")) - if (!$util.isInteger(message.status)) - return "status: integer expected"; - if (message.msg != null && message.hasOwnProperty("msg")) - if (!$util.isString(message.msg)) - return "msg: string expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high))) + return "id: integer|Long expected"; + if (message.username != null && message.hasOwnProperty("username")) + if (!$util.isString(message.username)) + return "username: string expected"; + if (message.avatar != null && message.hasOwnProperty("avatar")) + if (!$util.isString(message.avatar)) + return "avatar: string expected"; return null; }; @@ -1555,10 +1573,19 @@ export const api = $root.api = (() => { if (object instanceof $root.api.ResIdentity) return object; let message = new $root.api.ResIdentity(); - if (object.status != null) - message.status = object.status | 0; - if (object.msg != null) - message.msg = String(object.msg); + if (object.id != null) + if ($util.Long) + (message.id = $util.Long.fromValue(object.id)).unsigned = false; + else if (typeof object.id === "string") + message.id = parseInt(object.id, 10); + else if (typeof object.id === "number") + message.id = object.id; + else if (typeof object.id === "object") + message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber(); + if (object.username != null) + message.username = String(object.username); + if (object.avatar != null) + message.avatar = String(object.avatar); return message; }; @@ -1576,13 +1603,23 @@ export const api = $root.api = (() => { options = {}; let object = {}; if (options.defaults) { - object.status = 0; - object.msg = ""; + if ($util.Long) { + let long = new $util.Long(0, 0, false); + object.id = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.id = options.longs === String ? "0" : 0; + object.username = ""; + object.avatar = ""; } - if (message.status != null && message.hasOwnProperty("status")) - object.status = message.status; - if (message.msg != null && message.hasOwnProperty("msg")) - object.msg = message.msg; + if (message.id != null && message.hasOwnProperty("id")) + if (typeof message.id === "number") + object.id = options.longs === String ? String(message.id) : message.id; + else + object.id = options.longs === String ? $util.Long.prototype.toString.call(message.id) : options.longs === Number ? new $util.LongBits(message.id.low >>> 0, message.id.high >>> 0).toNumber() : message.id; + if (message.username != null && message.hasOwnProperty("username")) + object.username = message.username; + if (message.avatar != null && message.hasOwnProperty("avatar")) + object.avatar = message.avatar; return object; }; @@ -3579,6 +3616,181 @@ export const api = $root.api = (() => { return ReqReadyStart; })(); + api.ReqCancelReady = (function() { + + /** + * Properties of a ReqCancelReady. + * @memberof api + * @interface IReqCancelReady + */ + + /** + * Constructs a new ReqCancelReady. + * @memberof api + * @classdesc Represents a ReqCancelReady. + * @implements IReqCancelReady + * @constructor + * @param {api.IReqCancelReady=} [properties] Properties to set + */ + function ReqCancelReady(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new ReqCancelReady instance using the specified properties. + * @function create + * @memberof api.ReqCancelReady + * @static + * @param {api.IReqCancelReady=} [properties] Properties to set + * @returns {api.ReqCancelReady} ReqCancelReady instance + */ + ReqCancelReady.create = function create(properties) { + return new ReqCancelReady(properties); + }; + + /** + * Encodes the specified ReqCancelReady message. Does not implicitly {@link api.ReqCancelReady.verify|verify} messages. + * @function encode + * @memberof api.ReqCancelReady + * @static + * @param {api.IReqCancelReady} message ReqCancelReady message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqCancelReady.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ReqCancelReady message, length delimited. Does not implicitly {@link api.ReqCancelReady.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqCancelReady + * @static + * @param {api.IReqCancelReady} message ReqCancelReady message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqCancelReady.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqCancelReady message from the specified reader or buffer. + * @function decode + * @memberof api.ReqCancelReady + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqCancelReady} ReqCancelReady + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqCancelReady.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqCancelReady(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqCancelReady message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqCancelReady + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqCancelReady} ReqCancelReady + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqCancelReady.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqCancelReady message. + * @function verify + * @memberof api.ReqCancelReady + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqCancelReady.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ReqCancelReady message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqCancelReady + * @static + * @param {Object.} object Plain object + * @returns {api.ReqCancelReady} ReqCancelReady + */ + ReqCancelReady.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqCancelReady) + return object; + return new $root.api.ReqCancelReady(); + }; + + /** + * Creates a plain object from a ReqCancelReady message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqCancelReady + * @static + * @param {api.ReqCancelReady} message ReqCancelReady + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqCancelReady.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ReqCancelReady to JSON. + * @function toJSON + * @memberof api.ReqCancelReady + * @instance + * @returns {Object.} JSON object + */ + ReqCancelReady.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqCancelReady + * @function getTypeUrl + * @memberof api.ReqCancelReady + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqCancelReady.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqCancelReady"; + }; + + return ReqCancelReady; + })(); + api.ReqKickOutTable = (function() { /** @@ -5599,6 +5811,937 @@ export const api = $root.api = (() => { return Card; })(); + api.ReqGameStart = (function() { + + /** + * Properties of a ReqGameStart. + * @memberof api + * @interface IReqGameStart + */ + + /** + * Constructs a new ReqGameStart. + * @memberof api + * @classdesc Represents a ReqGameStart. + * @implements IReqGameStart + * @constructor + * @param {api.IReqGameStart=} [properties] Properties to set + */ + function ReqGameStart(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new ReqGameStart instance using the specified properties. + * @function create + * @memberof api.ReqGameStart + * @static + * @param {api.IReqGameStart=} [properties] Properties to set + * @returns {api.ReqGameStart} ReqGameStart instance + */ + ReqGameStart.create = function create(properties) { + return new ReqGameStart(properties); + }; + + /** + * Encodes the specified ReqGameStart message. Does not implicitly {@link api.ReqGameStart.verify|verify} messages. + * @function encode + * @memberof api.ReqGameStart + * @static + * @param {api.IReqGameStart} message ReqGameStart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqGameStart.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ReqGameStart message, length delimited. Does not implicitly {@link api.ReqGameStart.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqGameStart + * @static + * @param {api.IReqGameStart} message ReqGameStart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqGameStart.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqGameStart message from the specified reader or buffer. + * @function decode + * @memberof api.ReqGameStart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqGameStart} ReqGameStart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqGameStart.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqGameStart(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqGameStart message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqGameStart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqGameStart} ReqGameStart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqGameStart.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqGameStart message. + * @function verify + * @memberof api.ReqGameStart + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqGameStart.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ReqGameStart message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqGameStart + * @static + * @param {Object.} object Plain object + * @returns {api.ReqGameStart} ReqGameStart + */ + ReqGameStart.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqGameStart) + return object; + return new $root.api.ReqGameStart(); + }; + + /** + * Creates a plain object from a ReqGameStart message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqGameStart + * @static + * @param {api.ReqGameStart} message ReqGameStart + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqGameStart.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ReqGameStart to JSON. + * @function toJSON + * @memberof api.ReqGameStart + * @instance + * @returns {Object.} JSON object + */ + ReqGameStart.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqGameStart + * @function getTypeUrl + * @memberof api.ReqGameStart + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqGameStart.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqGameStart"; + }; + + return ReqGameStart; + })(); + + api.ResBigBlindChip = (function() { + + /** + * Properties of a ResBigBlindChip. + * @memberof api + * @interface IResBigBlindChip + * @property {number|null} [chip] ResBigBlindChip chip + */ + + /** + * Constructs a new ResBigBlindChip. + * @memberof api + * @classdesc Represents a ResBigBlindChip. + * @implements IResBigBlindChip + * @constructor + * @param {api.IResBigBlindChip=} [properties] Properties to set + */ + function ResBigBlindChip(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResBigBlindChip chip. + * @member {number} chip + * @memberof api.ResBigBlindChip + * @instance + */ + ResBigBlindChip.prototype.chip = 0; + + /** + * Creates a new ResBigBlindChip instance using the specified properties. + * @function create + * @memberof api.ResBigBlindChip + * @static + * @param {api.IResBigBlindChip=} [properties] Properties to set + * @returns {api.ResBigBlindChip} ResBigBlindChip instance + */ + ResBigBlindChip.create = function create(properties) { + return new ResBigBlindChip(properties); + }; + + /** + * Encodes the specified ResBigBlindChip message. Does not implicitly {@link api.ResBigBlindChip.verify|verify} messages. + * @function encode + * @memberof api.ResBigBlindChip + * @static + * @param {api.IResBigBlindChip} message ResBigBlindChip message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResBigBlindChip.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.chip != null && Object.hasOwnProperty.call(message, "chip")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.chip); + return writer; + }; + + /** + * Encodes the specified ResBigBlindChip message, length delimited. Does not implicitly {@link api.ResBigBlindChip.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResBigBlindChip + * @static + * @param {api.IResBigBlindChip} message ResBigBlindChip message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResBigBlindChip.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResBigBlindChip message from the specified reader or buffer. + * @function decode + * @memberof api.ResBigBlindChip + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResBigBlindChip} ResBigBlindChip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResBigBlindChip.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ResBigBlindChip(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.chip = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResBigBlindChip message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResBigBlindChip + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResBigBlindChip} ResBigBlindChip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResBigBlindChip.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResBigBlindChip message. + * @function verify + * @memberof api.ResBigBlindChip + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResBigBlindChip.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.chip != null && message.hasOwnProperty("chip")) + if (!$util.isInteger(message.chip)) + return "chip: integer expected"; + return null; + }; + + /** + * Creates a ResBigBlindChip message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResBigBlindChip + * @static + * @param {Object.} object Plain object + * @returns {api.ResBigBlindChip} ResBigBlindChip + */ + ResBigBlindChip.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResBigBlindChip) + return object; + let message = new $root.api.ResBigBlindChip(); + if (object.chip != null) + message.chip = object.chip | 0; + return message; + }; + + /** + * Creates a plain object from a ResBigBlindChip message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResBigBlindChip + * @static + * @param {api.ResBigBlindChip} message ResBigBlindChip + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResBigBlindChip.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) + object.chip = 0; + if (message.chip != null && message.hasOwnProperty("chip")) + object.chip = message.chip; + return object; + }; + + /** + * Converts this ResBigBlindChip to JSON. + * @function toJSON + * @memberof api.ResBigBlindChip + * @instance + * @returns {Object.} JSON object + */ + ResBigBlindChip.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResBigBlindChip + * @function getTypeUrl + * @memberof api.ResBigBlindChip + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResBigBlindChip.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResBigBlindChip"; + }; + + return ResBigBlindChip; + })(); + + api.ResSmallBlindChip = (function() { + + /** + * Properties of a ResSmallBlindChip. + * @memberof api + * @interface IResSmallBlindChip + * @property {number|null} [chip] ResSmallBlindChip chip + */ + + /** + * Constructs a new ResSmallBlindChip. + * @memberof api + * @classdesc Represents a ResSmallBlindChip. + * @implements IResSmallBlindChip + * @constructor + * @param {api.IResSmallBlindChip=} [properties] Properties to set + */ + function ResSmallBlindChip(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResSmallBlindChip chip. + * @member {number} chip + * @memberof api.ResSmallBlindChip + * @instance + */ + ResSmallBlindChip.prototype.chip = 0; + + /** + * Creates a new ResSmallBlindChip instance using the specified properties. + * @function create + * @memberof api.ResSmallBlindChip + * @static + * @param {api.IResSmallBlindChip=} [properties] Properties to set + * @returns {api.ResSmallBlindChip} ResSmallBlindChip instance + */ + ResSmallBlindChip.create = function create(properties) { + return new ResSmallBlindChip(properties); + }; + + /** + * Encodes the specified ResSmallBlindChip message. Does not implicitly {@link api.ResSmallBlindChip.verify|verify} messages. + * @function encode + * @memberof api.ResSmallBlindChip + * @static + * @param {api.IResSmallBlindChip} message ResSmallBlindChip message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResSmallBlindChip.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.chip != null && Object.hasOwnProperty.call(message, "chip")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.chip); + return writer; + }; + + /** + * Encodes the specified ResSmallBlindChip message, length delimited. Does not implicitly {@link api.ResSmallBlindChip.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResSmallBlindChip + * @static + * @param {api.IResSmallBlindChip} message ResSmallBlindChip message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResSmallBlindChip.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResSmallBlindChip message from the specified reader or buffer. + * @function decode + * @memberof api.ResSmallBlindChip + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResSmallBlindChip} ResSmallBlindChip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResSmallBlindChip.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ResSmallBlindChip(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.chip = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResSmallBlindChip message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResSmallBlindChip + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResSmallBlindChip} ResSmallBlindChip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResSmallBlindChip.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResSmallBlindChip message. + * @function verify + * @memberof api.ResSmallBlindChip + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResSmallBlindChip.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.chip != null && message.hasOwnProperty("chip")) + if (!$util.isInteger(message.chip)) + return "chip: integer expected"; + return null; + }; + + /** + * Creates a ResSmallBlindChip message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResSmallBlindChip + * @static + * @param {Object.} object Plain object + * @returns {api.ResSmallBlindChip} ResSmallBlindChip + */ + ResSmallBlindChip.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResSmallBlindChip) + return object; + let message = new $root.api.ResSmallBlindChip(); + if (object.chip != null) + message.chip = object.chip | 0; + return message; + }; + + /** + * Creates a plain object from a ResSmallBlindChip message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResSmallBlindChip + * @static + * @param {api.ResSmallBlindChip} message ResSmallBlindChip + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResSmallBlindChip.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) + object.chip = 0; + if (message.chip != null && message.hasOwnProperty("chip")) + object.chip = message.chip; + return object; + }; + + /** + * Converts this ResSmallBlindChip to JSON. + * @function toJSON + * @memberof api.ResSmallBlindChip + * @instance + * @returns {Object.} JSON object + */ + ResSmallBlindChip.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResSmallBlindChip + * @function getTypeUrl + * @memberof api.ResSmallBlindChip + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResSmallBlindChip.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResSmallBlindChip"; + }; + + return ResSmallBlindChip; + })(); + + api.ReqDismissGameTable = (function() { + + /** + * Properties of a ReqDismissGameTable. + * @memberof api + * @interface IReqDismissGameTable + */ + + /** + * Constructs a new ReqDismissGameTable. + * @memberof api + * @classdesc Represents a ReqDismissGameTable. + * @implements IReqDismissGameTable + * @constructor + * @param {api.IReqDismissGameTable=} [properties] Properties to set + */ + function ReqDismissGameTable(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new ReqDismissGameTable instance using the specified properties. + * @function create + * @memberof api.ReqDismissGameTable + * @static + * @param {api.IReqDismissGameTable=} [properties] Properties to set + * @returns {api.ReqDismissGameTable} ReqDismissGameTable instance + */ + ReqDismissGameTable.create = function create(properties) { + return new ReqDismissGameTable(properties); + }; + + /** + * Encodes the specified ReqDismissGameTable message. Does not implicitly {@link api.ReqDismissGameTable.verify|verify} messages. + * @function encode + * @memberof api.ReqDismissGameTable + * @static + * @param {api.IReqDismissGameTable} message ReqDismissGameTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqDismissGameTable.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ReqDismissGameTable message, length delimited. Does not implicitly {@link api.ReqDismissGameTable.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqDismissGameTable + * @static + * @param {api.IReqDismissGameTable} message ReqDismissGameTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqDismissGameTable.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqDismissGameTable message from the specified reader or buffer. + * @function decode + * @memberof api.ReqDismissGameTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqDismissGameTable} ReqDismissGameTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqDismissGameTable.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqDismissGameTable(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqDismissGameTable message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqDismissGameTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqDismissGameTable} ReqDismissGameTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqDismissGameTable.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqDismissGameTable message. + * @function verify + * @memberof api.ReqDismissGameTable + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqDismissGameTable.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ReqDismissGameTable message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqDismissGameTable + * @static + * @param {Object.} object Plain object + * @returns {api.ReqDismissGameTable} ReqDismissGameTable + */ + ReqDismissGameTable.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqDismissGameTable) + return object; + return new $root.api.ReqDismissGameTable(); + }; + + /** + * Creates a plain object from a ReqDismissGameTable message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqDismissGameTable + * @static + * @param {api.ReqDismissGameTable} message ReqDismissGameTable + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqDismissGameTable.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ReqDismissGameTable to JSON. + * @function toJSON + * @memberof api.ReqDismissGameTable + * @instance + * @returns {Object.} JSON object + */ + ReqDismissGameTable.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqDismissGameTable + * @function getTypeUrl + * @memberof api.ReqDismissGameTable + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqDismissGameTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqDismissGameTable"; + }; + + return ReqDismissGameTable; + })(); + + api.ResDismissGameTable = (function() { + + /** + * Properties of a ResDismissGameTable. + * @memberof api + * @interface IResDismissGameTable + */ + + /** + * Constructs a new ResDismissGameTable. + * @memberof api + * @classdesc Represents a ResDismissGameTable. + * @implements IResDismissGameTable + * @constructor + * @param {api.IResDismissGameTable=} [properties] Properties to set + */ + function ResDismissGameTable(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new ResDismissGameTable instance using the specified properties. + * @function create + * @memberof api.ResDismissGameTable + * @static + * @param {api.IResDismissGameTable=} [properties] Properties to set + * @returns {api.ResDismissGameTable} ResDismissGameTable instance + */ + ResDismissGameTable.create = function create(properties) { + return new ResDismissGameTable(properties); + }; + + /** + * Encodes the specified ResDismissGameTable message. Does not implicitly {@link api.ResDismissGameTable.verify|verify} messages. + * @function encode + * @memberof api.ResDismissGameTable + * @static + * @param {api.IResDismissGameTable} message ResDismissGameTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResDismissGameTable.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ResDismissGameTable message, length delimited. Does not implicitly {@link api.ResDismissGameTable.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResDismissGameTable + * @static + * @param {api.IResDismissGameTable} message ResDismissGameTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResDismissGameTable.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResDismissGameTable message from the specified reader or buffer. + * @function decode + * @memberof api.ResDismissGameTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResDismissGameTable} ResDismissGameTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResDismissGameTable.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ResDismissGameTable(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResDismissGameTable message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResDismissGameTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResDismissGameTable} ResDismissGameTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResDismissGameTable.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResDismissGameTable message. + * @function verify + * @memberof api.ResDismissGameTable + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResDismissGameTable.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ResDismissGameTable message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResDismissGameTable + * @static + * @param {Object.} object Plain object + * @returns {api.ResDismissGameTable} ResDismissGameTable + */ + ResDismissGameTable.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResDismissGameTable) + return object; + return new $root.api.ResDismissGameTable(); + }; + + /** + * Creates a plain object from a ResDismissGameTable message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResDismissGameTable + * @static + * @param {api.ResDismissGameTable} message ResDismissGameTable + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResDismissGameTable.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ResDismissGameTable to JSON. + * @function toJSON + * @memberof api.ResDismissGameTable + * @instance + * @returns {Object.} JSON object + */ + ResDismissGameTable.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResDismissGameTable + * @function getTypeUrl + * @memberof api.ResDismissGameTable + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResDismissGameTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResDismissGameTable"; + }; + + return ResDismissGameTable; + })(); + return api; })(); diff --git a/src/api/websocket.js b/src/api/websocket.js index d798baa..6f1307d 100644 --- a/src/api/websocket.js +++ b/src/api/websocket.js @@ -1,7 +1,10 @@ +import store from '@/store/index' + import proto from '@/api/proto'; import { fetchOpMap } from '@/api/api' -import { getStorage } from '@/utils/storage'; +import { getStorage, removeStorage } from '@/utils/storage'; import { showToast } from '@/utils/application'; +import { setUserInfo } from '@/store/user' const { api } = proto @@ -26,7 +29,6 @@ const websocket = { this.opPathMap = opPathMap || {}; this.nameOpMap = nameOpMap || {}; // window.proto = proto; - // websocket test const ws = new WebSocket("ws://localhost:9999/api/conn/ws") this.conn = ws @@ -39,6 +41,11 @@ const websocket = { // const reqBuffer = api.ReqIdentity.encode(req).finish() this.send(req, res => { this.status = 2; + // const dispatch = useDispatch(); + // window.res = res; + // console.log(store, setUserInfo(res)) + store.dispatch(setUserInfo(res.toJSON())); + console.log('identity success:', res) // 依次发送等待连接的消息队列 @@ -49,6 +56,7 @@ const websocket = { } } }, err => { + removeStorage('_t') showToast({title: err}) console.error('连接认证失败:', err) }) diff --git a/src/api/wsapi.js b/src/api/wsapi.js index 317d69d..8e73a80 100644 --- a/src/api/wsapi.js +++ b/src/api/wsapi.js @@ -11,3 +11,14 @@ export const reqGameFullStatus = () => sendPromise(api.ReqGameFullStatus.create( export const reqJoinTable = tableNo => sendPromise(api.ReqJoinTable.create({tableNo})); export const reqKickOutTable = playerId => sendPromise(api.ReqKickOutTable.create({playerId})); + +export const reqLeaveTable = () => sendPromise(api.ReqLeaveTable.create()); + +// 准备 +export const reqReadyStart = () => sendPromise(api.ReqReadyStart.create()); +// 取消准备 +export const reqCancelReady = () => sendPromise(api.ReqCancelReady.create()); +// 解散 +export const reqDismissGameTable = () => sendPromise(api.ReqDismissGameTable.create()); +// 开始牌局 +export const reqGameStart = () => sendPromise(api.ReqGameStart.create()); diff --git a/src/components/card.jsx b/src/components/card.jsx index 8b4b19c..9586933 100644 --- a/src/components/card.jsx +++ b/src/components/card.jsx @@ -40,7 +40,7 @@ function Card(props) { left: Taro.pxTransform(w / 8), }}> {dots[dot || 0]} diff --git a/src/components/style/title.scss b/src/components/style/title.scss index 9b50459..dc99533 100644 --- a/src/components/style/title.scss +++ b/src/components/style/title.scss @@ -30,16 +30,23 @@ color: #ffffff; } + .title-avatar-wrap { + width: 48px; + height: 48px; + display: flex; + flex-direction: row; + } .avatar { width: 41px; height: 41px; + // width: 32px; + // height: 32px; border-radius: 50%; margin-top: 2px; } - - .blank { - width: 48px; - height: 48px; + .username { + font-size: 12px; + font-weight: normal; } } } diff --git a/src/components/title.jsx b/src/components/title.jsx index 4c606cb..e90f201 100644 --- a/src/components/title.jsx +++ b/src/components/title.jsx @@ -7,7 +7,7 @@ import './style/title.scss' import { useSelector } from 'react-redux' function Title(props) { - const {username, nickname, avatar} = useSelector(state => state.user); + const {username, nickname, avatar, defaultAvatar} = useSelector(state => state.user); const { leftSolt, leftIcon, onLeftClick, rightSolt } = props; return ( @@ -15,8 +15,15 @@ function Title(props) { {/* */} {leftSolt || } - {props.title} - {rightSolt || } + + {username} + {props.title} + + { + rightSolt || + + + } {props.topNull ? '' : } diff --git a/src/pages/lobby/lobby.jsx b/src/pages/lobby/lobby.jsx index 0f78b55..2604f61 100644 --- a/src/pages/lobby/lobby.jsx +++ b/src/pages/lobby/lobby.jsx @@ -33,9 +33,9 @@ class Lobby extends Component { } componentDidMount() { - setTimeout(() => { + // setTimeout(() => { this.handleReqLobbyView(); - }, 1500) + // }, 1500) // fetchLobbyView() // .then(res => { // console.log('lobby', res) diff --git a/src/pages/table/table.jsx b/src/pages/table/table.jsx index b3fe59d..03d271e 100644 --- a/src/pages/table/table.jsx +++ b/src/pages/table/table.jsx @@ -3,7 +3,11 @@ import { View, Text, Image, Input, Button } from '@tarojs/components' import { connect } from 'react-redux' import cnames from 'classnames' -import { reqGameFullStatus, reqKickOutTable } from '@/api/wsapi' +import { + reqGameFullStatus, reqKickOutTable, reqLeaveTable, + reqReadyStart, reqDismissGameTable, reqGameStart, + reqCancelReady +} from '@/api/wsapi' import { addMsgListen, removeMsgListener } from '@/api/websocket' import { ifEmpty } from '@/utils/validator' @@ -20,10 +24,11 @@ import Taro from '@tarojs/taro' import { showToast, redirectTo } from '@/utils/application' import { isIn } from '@/utils/collect' -function PlayerStatus() { +function PlayerStatus(props) { + const { text, color } = props; return ( - - Ready + + {text} ) } @@ -62,20 +67,24 @@ class Table extends Component { componentWillUnmount() { // 取消监听消息 - removeMsgListener('api.ResGameFullStatus') - removeMsgListener('api.ResKickOutTable') + removeMsgListener('api.ResGameFullStatus'); + removeMsgListener('api.ResKickOutTable'); } componentDidMount() { // setTimeout(() => { // 监听状态变化消息 - addMsgListen('api.ResGameFullStatus', res => this.handleResGameFullStatus(res)); + addMsgListen('api.ResGameFullStatus', this.handleResGameFullStatus); // 牌桌状态变化 + // 被房主踢出 addMsgListen('api.ResKickOutTable', res => { - console.log('listener level table', res); - redirectTo({url: '/pages/lobby/lobby', complete() { - showToast({title: '您被请出牌桌'}) - }}); + showToast({title: '您被请出牌桌'}); + setTimeout(() => redirectTo({url: '/pages/lobby/lobby'}), 800); }); + // 牌桌解散 + addMsgListen('api.ResDismissGameTable', res => { + showToast({title: '牌桌已解散'}); + setTimeout(() => redirectTo({url: '/pages/lobby/lobby'}), 800); + }) // 查询当前牌桌状态 reqGameFullStatus() @@ -92,7 +101,6 @@ class Table extends Component { } handleResGameFullStatus = res => { - console.log('res game...++', this, res) this.setState({ playerId: res.playerId, inGame: !!res.inGame, @@ -126,11 +134,65 @@ class Table extends Component { showToast({title: err}) }) } + }); + } + + // 退出 + handleLeaveTable() { + Taro.showModal({ + title: '提示', + content: "是否离开牌桌?", + success: res => { + if (!res.confirm) { + return; + } + reqLeaveTable() + .then(_ => { + redirectTo({url: '/pages/lobby/lobby'}) + }) + .catch(err => showToast({title: err})) + } + }) + } + + // 准备开始 + handleReadyStart(playerStatus) { + (playerStatus === 1 ? reqReadyStart() : reqCancelReady()) + .then(res => { + console.log('ready res:', res); + }) + .catch(err => showToast({title: err})); + } + + // 解散牌桌 + handleResDismissGameTable() { + Taro.showModal({ + title: '提示', + content: "是否解散牌桌?", + success: res => { + if (!res.confirm) { + return; + } + reqDismissGameTable() + .then(_ => { + redirectTo({url: '/pages/lobby/lobby'}) + }) + .catch(err => showToast({title: err})); + } }) } + // 开始游戏 + handleGameStart() { + reqGameStart() + .then(res => { + console.log('game start...', res) + }) + .catch(err => showToast({title: err})); + } + render() { - const { username, nickname, avatar } = this.props.user; // useSelector(state => state.user); + const { username, nickname, avatar, defaultAvatar } = this.props.user; // useSelector(state => state.user); // const players = [1, 2, 3, 4, 5, 6]; const players = this.state.players.map((player, index) => ({player, index})); const {playerId, tableNo, stage, chip, roundTimes} = this.state; @@ -160,13 +222,10 @@ class Table extends Component { row.map(({index, player}, j) => ( {console.log(p)}).bind(this, player)}> { - j % 2 === 0 && - - - + player.status === 2 && Ready! } - #{index} + 1})}>#{index} { stage === 1 && selfPlayer.master && player.id ? @@ -233,14 +292,14 @@ class Table extends Component { { existsCard(selfPlayer.handCard[0]) && [1, 2, 3, 4, 5].map((_, i) => ( - + )) } - + {selfPlayer.username} @@ -261,13 +320,13 @@ class Table extends Component { stage === 1 ? ( // 是房主: 关闭牌桌, 开始游戏 selfPlayer.master ? - - + + // 是玩家:退出, 准备 : - - + + ) : diff --git a/src/pages/table/table.scss b/src/pages/table/table.scss index afd741e..c23b634 100644 --- a/src/pages/table/table.scss +++ b/src/pages/table/table.scss @@ -14,25 +14,14 @@ display: flex; } - .player-state-wrap { - height: 53px; - width: 39px; - // background-color: #F1D09F; + .p-status-ready { position: absolute; - left: -40px; - top: 10px; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - } - - .state-left { - position: absolute; - left: 157px; - top: 10px; + top: -25px; + left: 30px; + color: #EE914E; + font-weight: bold; + font-size: 12px; } - .player-no { position: absolute; top: -25px; diff --git a/src/store/user.js b/src/store/user.js index 26350f0..7b8e107 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -3,13 +3,19 @@ import { createSlice } from '@reduxjs/toolkit'; const userSlice = createSlice({ name: 'user', initialState: { - username: 'Prometheus', - nickname: 'PrometheusNick', - avatar: 'https://img0.baidu.com/it/u=2477829979,2171947490&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', + id: 0, + username: 'Prom', + nickname: 'PromNick', + avatar: '', + defaultAvatar: 'https://img0.baidu.com/it/u=2477829979,2171947490&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', }, reducers: { - setUserInfo(state, action) { - return {...state, ...action.payload} + setUserInfo: (state, {payload}) => { + console.log('setUserInfo', state, payload) + state.id = payload.id; + state.username = payload.username; + state.avatar = payload.avatar; + // return {...state, ...action.payload} } } })