提交 8221453d 作者: 张梦磊

抖音sdk对接

上级 aab71575
'use strict';var __awaiter=this&&this["\u005f\u005f\u0061\u0077\u0061\u0069\u0074\u0065\u0072"]||function(_0x222d5f,_0x24ad14,_0x36be25,_0x447a29){function _0x3634b3(_0x172b5d){return _0x172b5d instanceof _0x36be25?_0x172b5d:new _0x36be25(function(_0x1b1133){_0x1b1133(_0x172b5d);});}return new(_0x36be25||(_0x36be25=Promise))(function(_0x17785c,_0x4adfb8){function _0x186237(_0x1d7046){try{_0x5e9693(_0x447a29["\u006e\u0065\u0078\u0074"](_0x1d7046));}catch(_0x40ad62){_0x4adfb8(_0x40ad62);}}function _0xb36101(_0x10829f){try{_0x5e9693(_0x447a29["\u0074\u0068\u0072\u006f\u0077"](_0x10829f));}catch(_0x1c6974){_0x4adfb8(_0x1c6974);}}function _0x5e9693(_0x58a959){_0x58a959["\u0064\u006f\u006e\u0065"]?_0x17785c(_0x58a959["\u0076\u0061\u006c\u0075\u0065"]):_0x3634b3(_0x58a959["\u0076\u0061\u006c\u0075\u0065"])["\u0074\u0068\u0065\u006e"](_0x186237,_0xb36101);}_0x5e9693((_0x447a29=_0x447a29["\u0061\u0070\u0070\u006c\u0079"](_0x222d5f,_0x24ad14||[]))["\u006e\u0065\u0078\u0074"]());});};var __generator=this&&this["\u005f\u005f\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u006f\u0072"]||function(_0x2c57a5,_0x575938){var _0x31a3ef={"\u006c\u0061\u0062\u0065\u006c":0x0,'sent':function(){if(_0x39c17e[0x76d57^0x76d57]&(0x90ab3^0x90ab2))throw _0x39c17e[0x29347^0x29346];return _0x39c17e[0x6c05f^0x6c05e];},"\u0074\u0072\u0079\u0073":[],'ops':[]},_0x2e7d3d,_0x326beb,_0x39c17e,_0x5ddc1b;return _0x5ddc1b={"\u006e\u0065\u0078\u0074":_0xaf46ef(0x8ecbe^0x8ecbe),"\u0074\u0068\u0072\u006f\u0077":_0xaf46ef(0xc5630^0xc5631),"\u0072\u0065\u0074\u0075\u0072\u006e":_0xaf46ef(0x4f71f^0x4f71d)},typeof Symbol==='function'&&(_0x5ddc1b[Symbol["\u0069\u0074\u0065\u0072\u0061\u0074\u006f\u0072"]]=function(){return this;}),_0x5ddc1b;function _0xaf46ef(_0x31ad03){return function(_0x49637f){return _0x3279af([_0x31ad03,_0x49637f]);};}function _0x3279af(_0x15ed07){if(_0x2e7d3d)throw new TypeError(".gnitucexe ydaerla si rotareneG".split("").reverse().join(""));while(_0x31a3ef)try{if(_0x2e7d3d=0xf3719^0xf3718,_0x326beb&&(_0x39c17e=_0x15ed07[0xa5225^0xa5225]&(0xdb506^0xdb504)?_0x326beb['return']:_0x15ed07[0xe6608^0xe6608]?_0x326beb["\u0074\u0068\u0072\u006f\u0077"]||((_0x39c17e=_0x326beb['return'])&&_0x39c17e['call'](_0x326beb),0x0):_0x326beb['next'])&&!(_0x39c17e=_0x39c17e['call'](_0x326beb,_0x15ed07[0x1]))["\u0064\u006f\u006e\u0065"])return _0x39c17e;if(_0x326beb=0x0,_0x39c17e)_0x15ed07=[_0x15ed07[0xc127f^0xc127f]&0x2,_0x39c17e["\u0076\u0061\u006c\u0075\u0065"]];switch(_0x15ed07[0x87d78^0x87d78]){case 0x8fad2^0x8fad2:case 0xb70d2^0xb70d3:_0x39c17e=_0x15ed07;break;case 0x4:_0x31a3ef['label']++;return{'value':_0x15ed07[0x97baf^0x97bae],'done':![]};case 0x5:_0x31a3ef['label']++;_0x326beb=_0x15ed07[0x1c10f^0x1c10e];_0x15ed07=[0x0];continue;case 0xe81b2^0xe81b5:_0x15ed07=_0x31a3ef['ops']["\u0070\u006f\u0070"]();_0x31a3ef['trys']["\u0070\u006f\u0070"]();continue;default:if(!(_0x39c17e=_0x31a3ef['trys'],_0x39c17e=_0x39c17e["\u006c\u0065\u006e\u0067\u0074\u0068"]>0x0&&_0x39c17e[_0x39c17e["\u006c\u0065\u006e\u0067\u0074\u0068"]-0x1])&&(_0x15ed07[0x0]===(0x79d50^0x79d56)||_0x15ed07[0xa1e8c^0xa1e8c]===(0x50f3d^0x50f3f))){_0x31a3ef=0xecbab^0xecbab;continue;}if(_0x15ed07[0x5124e^0x5124e]===(0xcbadb^0xcbad8)&&(!_0x39c17e||_0x15ed07[0x28a00^0x28a01]>_0x39c17e[0x0]&&_0x15ed07[0x1]<_0x39c17e[0x3])){_0x31a3ef['label']=_0x15ed07[0xcb370^0xcb371];break;}if(_0x15ed07[0x0]===0x6&&_0x31a3ef['label']<_0x39c17e[0xb4d7c^0xb4d7d]){_0x31a3ef['label']=_0x39c17e[0xaf102^0xaf103];_0x39c17e=_0x15ed07;break;}if(_0x39c17e&&_0x31a3ef["\u006c\u0061\u0062\u0065\u006c"]<_0x39c17e[0x2e1d6^0x2e1d4]){_0x31a3ef["\u006c\u0061\u0062\u0065\u006c"]=_0x39c17e[0x3aa54^0x3aa56];_0x31a3ef['ops']['push'](_0x15ed07);break;}if(_0x39c17e[0x300cc^0x300ce])_0x31a3ef["\u006f\u0070\u0073"]["\u0070\u006f\u0070"]();_0x31a3ef["\u0074\u0072\u0079\u0073"]["\u0070\u006f\u0070"]();continue;}_0x15ed07=_0x575938['call'](_0x2c57a5,_0x31a3ef);}catch(_0x2319c3){_0x15ed07=[0x6,_0x2319c3];_0x326beb=0x1c5fe^0x1c5fe;}finally{_0x2e7d3d=_0x39c17e=0x0;}if(_0x15ed07[0xd1f2f^0xd1f2f]&(0x6af24^0x6af21))throw _0x15ed07[0xce26e^0xce26f];return{'value':_0x15ed07[0x79e83^0x79e83]?_0x15ed07[0x1]:void 0x0,"\u0064\u006f\u006e\u0065":!![]};}};exports['__esModule']=!![];var zwsdk=function(){function _0x2ec601(){this['VERSION']=_0x2ec601["\u0053\u0044\u004b\u0056\u0065\u0072\u0073\u0069\u006f\u006e"];var _0x2095f3=arguments['length']>0x0&&void 0x0!==arguments[0xc590d^0xc590d]?arguments[0x0]:null;_0x2ec601['VERSION']=this["\u0056\u0045\u0052\u0053\u0049\u004f\u004e"];var _0x1e8a0a=tt["\u0067\u0065\u0074\u004c\u0061\u0075\u006e\u0063\u0068\u004f\u0070\u0074\u0069\u006f\u006e\u0073\u0053\u0079\u006e\u0063"]()["\u0071\u0075\u0065\u0072\u0079"];if(_0x2095f3){_0x2ec601['default']["\u0061\u0070\u0070\u0049\u0064"]=_0x2095f3["\u0061\u0070\u0070\u005f\u0069\u0064"];_0x2ec601["\u0064\u0065\u0066\u0061\u0075\u006c\u0074"]["\u0067\u0061\u006d\u0065\u0049\u0064"]=_0x2095f3["\u0067\u0061\u006d\u0065\u005f\u0069\u0064"];_0x2ec601["\u0064\u0065\u0066\u0061\u0075\u006c\u0074"]['os']=_0x2ec601['getSystemOS']();_0x2ec601["\u0064\u0065\u0066\u0061\u0075\u006c\u0074"]["\u0062\u0061\u0073\u0065\u0055\u0072\u006c"]=_0x2095f3["\u0064\u0065\u0076"]?"ipa/pot.30jklwwz.sz//:sptth".split("").reverse().join(""):"ipa/moc.nawgnahzow.uoyz//:sptth".split("").reverse().join("");_0x2ec601['default']['query']=_0x1e8a0a;_0x2ec601['default']['state']=_0x2ec601['getState'](_0x1e8a0a);var _0x578ee2=tt['getSystemInfoSync']()['SDKVersion'];console["\u006c\u006f\u0067"](":noisrev bil".split("").reverse().join("")+_0x578ee2);if(_0x2ec601['selfCompareVersion'](_0x578ee2,"0.0.1".split("").reverse().join(""))>=0x0){tt['setKeepScreenOn']({"\u006b\u0065\u0065\u0070\u0053\u0063\u0072\u0065\u0065\u006e\u004f\u006e":!![]});console["\u006c\u006f\u0067"]("\u5C4F\u606F\u4E0D\u7F6E\u8BBE".split("").reverse().join(""));}else{}}}_0x2ec601["\u0073\u0065\u006c\u0066\u0043\u006f\u006d\u0070\u0061\u0072\u0065\u0056\u0065\u0072\u0073\u0069\u006f\u006e"]=function(_0x2a1be1,_0x24e2b5){_0x2a1be1=_0x2a1be1["\u0073\u0070\u006c\u0069\u0074"]("\u002e");_0x24e2b5=_0x24e2b5["\u0073\u0070\u006c\u0069\u0074"]("\u002e");var _0x185024=Math['max'](_0x2a1be1['length'],_0x24e2b5['length']);while(_0x2a1be1["\u006c\u0065\u006e\u0067\u0074\u0068"]<_0x185024){_0x2a1be1['push']("\u0030");}while(_0x24e2b5["\u006c\u0065\u006e\u0067\u0074\u0068"]<_0x185024){_0x24e2b5["\u0070\u0075\u0073\u0068"]('0');}for(var _0x482256=0x0;_0x482256<_0x185024;_0x482256++){var _0x51e703=parseInt(_0x2a1be1[_0x482256]);var _0x5c8472=parseInt(_0x24e2b5[_0x482256]);if(_0x51e703>_0x5c8472){return 0x1;}else if(_0x51e703<_0x5c8472){return-0x1;}}return 0x0;};_0x2ec601['prototype']["\u0067\u0065\u0074\u0047\u0061\u006d\u0065\u0043\u006f\u006e\u0066"]=function(){return new Promise(function(_0x478f49,_0x471bde){_0x2ec601["\u0061\u006a\u0061\u0078"]("fnoCteg/emag/kds_kotkit/".split("").reverse().join(""),{'app_id':_0x2ec601["\u0064\u0065\u0066\u0061\u0075\u006c\u0074"]["\u0061\u0070\u0070\u0049\u0064"],"\u0067\u0061\u006d\u0065\u005f\u0069\u0064":_0x2ec601["\u0064\u0065\u0066\u0061\u0075\u006c\u0074"]["\u0067\u0061\u006d\u0065\u0049\u0064"],'app_version':'1.1'})['then'](function(_0x4f00e4){if(_0x4f00e4['status_code']===(0xe3531^0xe3530)){_0x2ec601['default']['gameConfig']=_0x4f00e4["\u0064\u0061\u0074\u0061"]["\u0064\u0061\u0074\u0061"];}_0x478f49(_0x4f00e4);});});};_0x2ec601["\u0070\u0072\u006f\u0074\u006f\u0074\u0079\u0070\u0065"]['login']=function(){var _0x30cebf=arguments["\u006c\u0065\u006e\u0067\u0074\u0068"]>(0xe82e0^0xe82e0)&&void 0x0!==arguments[0x0]?arguments[0x0]:{};return new Promise(function(_0x4f2d52,_0x5c313a){tt["\u006c\u006f\u0067\u0069\u006e"]({"\u0066\u006f\u0072\u0063\u0065":!![],'success':function(_0xc9034f){var _0x3f079e=_0xc9034f["\u0063\u006f\u0064\u0065"],_0x4103cb=_0xc9034f['anonymousCode'],_0x5b14ae=_0xc9034f['isLogin'];var _0x46b6bd={'is_login':_0x5b14ae,'state':_0x2ec601['default']['state'],'query':_0x2ec601['default']['query'],'app_id':_0x2ec601['default']['appId'],'game_id':_0x2ec601['default']['gameId'],'os':_0x2ec601['default']['os'],'device_number':_0x2ec601["\u0064\u0065\u0066\u0061\u0075\u006c\u0074"]['device_brand'],'device_brand':_0x2ec601['default']['device_brand']};_0x46b6bd['code']=_0x3f079e;_0x46b6bd['anonymous_code']=_0x4103cb;_0x2ec601["\u0061\u006a\u0061\u0078"]('/tiktok_sdk/auth/login',_0x46b6bd)['then'](function(_0x4ea294){var _0x3f84c3=_0x4ea294;if(_0x4ea294['status_code']===(0x413f8^0x413f9)){_0x2ec601['default']["\u0075\u0073\u0065\u0072\u0054\u006f\u006b\u0065\u006e"]=_0x4ea294['data']['data']['user_token'];_0x2ec601['default']["\u006d\u0065\u006d\u0062\u0065\u0072\u0049\u0064"]=_0x4ea294['data']["\u0064\u0061\u0074\u0061"]['member_id'];_0x2ec601['initShare']();_0x4f2d52(_0x3f84c3);}else{tt['showModal']({'title':'异常',"\u0063\u006f\u006e\u0074\u0065\u006e\u0074":_0x4ea294["\u006d\u0073\u0067"],'confirmText':'我知道了','showCancel':![]});}});}});});};_0x2ec601['prototype']['updateUserInfo']=function(){var _0x509291=arguments['length']>0x0&&void 0x0!==arguments[0xa3ebb^0xa3ebb]?arguments[0xb880e^0xb880e]:{};return new Promise(function(_0x2c5004,_0x407d8a){_0x2ec601['ajax']("ofnIetadpu/rebmem/kds_kotkit/".split("").reverse().join(""),{'app_id':_0x2ec601['default']['appId'],'game_id':_0x2ec601["\u0064\u0065\u0066\u0061\u0075\u006c\u0074"]['gameId'],'member_id':_0x2ec601['default']["\u006d\u0065\u006d\u0062\u0065\u0072\u0049\u0064"],"\u0072\u0061\u0077\u005f\u0064\u0061\u0074\u0061":_0x509291["\u0072\u0061\u0077\u005f\u0064\u0061\u0074\u0061"]||"".split("").reverse().join(""),"\u0073\u0069\u0067\u006e\u0061\u0074\u0075\u0072\u0065":_0x509291['signature']||"".split("").reverse().join(""),"\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u005f\u0064\u0061\u0074\u0061":_0x509291['encrypted_data']||"".split("").reverse().join(""),'iv':_0x509291['iv']||"",'user_info':_0x509291["\u0075\u0073\u0065\u0072\u005f\u0069\u006e\u0066\u006f"]||''})['then'](function(_0x26bb45){_0x2ec601['default']['roleId']=_0x26bb45['data']['data']['role_id']||"".split("").reverse().join("");_0x2c5004(_0x26bb45);});});};_0x2ec601['prototype']['createOrder']=function(){var _0x4a4188=this;var _0x444f4c=arguments['length']>0x0&&void 0x0!==arguments[0xa7814^0xa7814]?arguments[0x0]:{};return new Promise(function(_0x4fe9c1,_0x582525){return __awaiter(_0x4a4188,void 0x0,void 0x0,function(){var _0xb7533e,_0x2016a9,_0x26e581,_0x39f422,_0x5e463c,_0x4d8970,_0x21e102,_0x4cfe2a,_0x4d9f5e,_0x5e289c,_0x53d0ca;return __generator(this,function(_0x56297b){switch(_0x56297b['label']){case 0x0:return[0x4,_0x2ec601['ajax']("etaerc/redro/kds_kotkit/".split("").reverse().join(""),{'app_id':_0x2ec601['default']['appId'],'game_id':_0x2ec601['default']['gameId'],'member_id':_0x2ec601['default']['memberId'],'os':_0x2ec601['default']['os'],'device_number':_0x2ec601['default']['device_number'],'device_brand':_0x2ec601['default']['device_brand'],'order':_0x444f4c["\u006f\u0072\u0064\u0065\u0072"]||{},"\u0072\u006f\u006c\u0065":_0x444f4c['role']||{},'role_id':_0x2ec601['default']['roleId']})];case 0x1:_0xb7533e=_0x56297b['sent']();if(_0xb7533e['status_code']===(0x56ff9^0x56ff8)){_0x4fe9c1({"\u0073\u0074\u0061\u0074\u0075\u0073\u005f\u0063\u006f\u0064\u0065":_0xb7533e['status_code'],'msg':_0xb7533e['msg'],'data':{'data':{"\u006f\u0072\u0064\u0065\u0072\u005f\u0069\u0064":_0xb7533e['data']['data']['order_id']}}});_0x2016a9=_0xb7533e['data']["\u0064\u0061\u0074\u0061"]['pay_type'];if(_0x2016a9==='douyinminipay'){_0x26e581=_0xb7533e['data']['data']['dy_pay'],_0x39f422=_0x26e581["\u006d\u006f\u0064\u0065"],_0x5e463c=_0x26e581['env'],_0x4d8970=_0x26e581['offer_id'],_0x21e102=_0x26e581['currency_type'],_0x4cfe2a=_0x26e581['platform'],_0x4d9f5e=_0x26e581['buy_quantity'],_0x5e289c=_0x26e581['zone_id'],_0x53d0ca=_0x26e581['extra_info'];tt['requestGamePayment']({'mode':_0x39f422,'env':_0x5e463c,"\u0063\u0075\u0072\u0072\u0065\u006e\u0063\u0079\u0054\u0079\u0070\u0065":_0x21e102,'platform':_0x4cfe2a,'buyQuantity':_0x4d9f5e,'zoneId':_0x5e289c,'customId':_0xb7533e['data']['data']['order_id'],'extraInfo':_0x53d0ca,'success':function(_0x5bf208){console['log']('success\x20payInfo:',_0x5bf208);_0x2ec601["\u0061\u006a\u0061\u0078"]('/tiktok_sdk/pay/dypayCallback',{'order_id':_0xb7533e['data']['data']['order_id']||'','status':!![],'code':_0x5bf208['errCode'],'msg':_0x5bf208['errMsg']})['then'](function(_0x3090f9){console['log']('/tiktok_sdk/pay/dypayCallback:',_0x3090f9);});},"\u0066\u0061\u0069\u006c":function(_0x5157de){console["\u006c\u006f\u0067"]('fail\x20payInfo:',_0x5157de);_0x2ec601['ajax']('/tiktok_sdk/pay/dypayCallback',{"\u006f\u0072\u0064\u0065\u0072\u005f\u0069\u0064":_0xb7533e['data']['data']['order_id']||"".split("").reverse().join(""),'status':![],'code':_0x5157de['errCode'],'msg':_0x5157de["\u0065\u0072\u0072\u004d\u0073\u0067"]})["\u0074\u0068\u0065\u006e"](function(_0x5bb914){console['log'](":kcabllaCyapyd/yap/kds_kotkit/".split("").reverse().join(""),_0x5bb914);});}});}}else{_0x4fe9c1(_0xb7533e);}return[0x2];}});});});};_0x2ec601['prototype']['checkOrder']=function(){var _0x59493c=arguments['length']>0x0&&void 0x0!==arguments[0x0]?arguments[0x4dde0^0x4dde0]:{};return new Promise(function(_0x2be438,_0x1cd5f4){_0x2ec601['ajax']("sutatSyaPteg/redro/kds_kotkit/".split("").reverse().join(""),{'order':_0x59493c['order']})['then'](function(_0x2644f8){_0x2be438(_0x2644f8);});});};_0x2ec601['initShare']=function(){_0x2ec601['ajax']('/tiktok_sdk/share/getShareInfo',{'game_id':_0x2ec601['default']['gameId'],'member_id':_0x2ec601['default']['memberId'],'app_id':_0x2ec601['default']['appId']})['then'](function(_0xc78e51){if(_0xc78e51['status_code']&&_0xc78e51['status_code']===0x1){tt["\u006f\u006e\u0053\u0068\u0061\u0072\u0065\u0041\u0070\u0070\u004d\u0065\u0073\u0073\u0061\u0067\u0065"](function(){_0x2ec601["\u006c\u006f\u0067"]('系统转发:onShareAppMessage',{'params':{'game_id':_0x2ec601['default']['gameId'],'member_id':_0x2ec601["\u0064\u0065\u0066\u0061\u0075\u006c\u0074"]['memberId'],'app_id':_0x2ec601['default']['appId']},'result':_0xc78e51});_0x2ec601['reportShare']({'share_id':_0xc78e51['data']['data']['share_id']});return{'title':_0xc78e51['data']['data']['title'],"\u0069\u006d\u0061\u0067\u0065\u0055\u0072\u006c":_0xc78e51['data']['data']['share_img'],'query':'state='+_0xc78e51['data']['data']['state']};});tt['showShareMenu']({'success':function(){console['log']("sseccus:uneMerahSwohs".split("").reverse().join(""));},'fail':function(){console['log']("liaf:uneMerahSwohs".split("").reverse().join(""));}});}});};_0x2ec601['prototype']['getShareInfo']=function(){var _0x36bf96=arguments['length']>0x0&&void 0x0!==arguments[0x0]?arguments[0x3bf99^0x3bf99]:{};_0x2ec601['ajax']('/tiktok_sdk/share/getShareInfo',{'game_id':_0x2ec601['default']['gameId'],'member_id':_0x2ec601['default']['memberId'],'app_id':_0x2ec601['default']["\u0061\u0070\u0070\u0049\u0064"],'path':_0x36bf96['path']||''})['then'](function(_0xf87b6b){if(_0xf87b6b['status_code']&&_0xf87b6b['status_code']===(0x3893c^0x3893d)){tt['onShareAppMessage'](function(){_0x2ec601['log']('系统转发:onShareAppMessage',{'params':{'game_id':_0x2ec601['default']['gameId'],'member_id':_0x2ec601['default']['memberId'],'app_id':_0x2ec601['default']['appId'],'path':_0x36bf96['path']||''},'result':_0xf87b6b});_0x2ec601["\u0072\u0065\u0070\u006f\u0072\u0074\u0053\u0068\u0061\u0072\u0065"]({'share_id':_0xf87b6b['data']['data']["\u0073\u0068\u0061\u0072\u0065\u005f\u0069\u0064"]});return{'title':_0xf87b6b['data']["\u0064\u0061\u0074\u0061"]['title'],'imageUrl':_0xf87b6b['data']['data']['share_img'],'query':"=etats".split("").reverse().join("")+_0xf87b6b['data']['data']['state']};});tt["\u0073\u0068\u006f\u0077\u0053\u0068\u0061\u0072\u0065\u004d\u0065\u006e\u0075"]({'success':function(){console['log']("sseccus:uneMerahSwohs".split("").reverse().join(""));},'fail':function(){console['log']("liaf:uneMerahSwohs".split("").reverse().join(""));}});if(_0x36bf96['shareAppMessage']||_0x36bf96["\u0073\u0068\u0061\u0072\u0065\u0041\u0070\u0070\u004d\u0065\u0073\u0073\u0061\u0067\u0065"]===undefined){tt['shareAppMessage']({'title':_0xf87b6b["\u0064\u0061\u0074\u0061"]["\u0064\u0061\u0074\u0061"]['title'],"\u0069\u006d\u0061\u0067\u0065\u0055\u0072\u006c":_0xf87b6b['data']['data']['share_img'],'query':'state='+_0xf87b6b['data']["\u0064\u0061\u0074\u0061"]['state']});_0x2ec601['reportShare']({'share_id':_0xf87b6b['data']["\u0064\u0061\u0074\u0061"]['share_id']});_0x2ec601['log']('主动转发:shareAppMessage',{'share_id':_0xf87b6b["\u0064\u0061\u0074\u0061"]['data']['share_id']});}}});};_0x2ec601['reportShare']=function(){var _0x280fe7=arguments['length']>(0x5c8cc^0x5c8cc)&&void 0x0!==arguments[0x477f0^0x477f0]?arguments[0x0]:{};_0x2ec601["\u0061\u006a\u0061\u0078"]("\u002f\u0074\u0069\u006b\u0074\u006f\u006b\u005f\u0073\u0064\u006b\u002f\u0073\u0068\u0061\u0072\u0065\u002f\u0072\u0065\u0070\u006f\u0072\u0074",{'game_id':_0x2ec601['default']['gameId'],"\u006d\u0065\u006d\u0062\u0065\u0072\u005f\u0069\u0064":_0x2ec601['default']['memberId'],'app_id':_0x2ec601['default']['appId'],'share_id':_0x280fe7['share_id']||"".split("").reverse().join(""),'ext':_0x280fe7["\u0065\u0078\u0074"]||''})['then'](function(_0x2452e1){console["\u006c\u006f\u0067"](_0x2452e1);});};_0x2ec601['prototype']['updateRole']=function(){var _0xfd1007=arguments['length']>(0x2cf8d^0x2cf8d)&&void 0x0!==arguments[0x0]?arguments[0x0]:{};return new Promise(function(_0x541c44,_0x3abf78){_0x2ec601['ajax']("troper/elor/kds_kotkit/".split("").reverse().join(""),{'app_id':_0x2ec601['default']['appId'],'game_id':_0x2ec601['default']['gameId'],'member_id':_0x2ec601["\u0064\u0065\u0066\u0061\u0075\u006c\u0074"]["\u006d\u0065\u006d\u0062\u0065\u0072\u0049\u0064"],"\u006f\u0073":_0x2ec601['default']['os'],'device_number':_0x2ec601['default']['device_number'],'device_brand':_0x2ec601['default']['device_brand'],'role':_0xfd1007["\u0072\u006f\u006c\u0065"]||{}})['then'](function(_0xb917db){_0x541c44(_0xb917db);});});};_0x2ec601['prototype']['checkMsg']=function(){var _0x39b1a7=arguments['length']>0x0&&void 0x0!==arguments[0x0]?arguments[0x0]:{};return new Promise(function(_0x38e6d0,_0x320c01){_0x2ec601["\u0061\u006a\u0061\u0078"]('/tiktok_sdk/check/message',{'game_id':_0x2ec601['default']['gameId'],'member_id':_0x2ec601['default']['memberId'],'app_id':_0x2ec601['default']['appId'],'content':_0x39b1a7['content']||"".split("").reverse().join("")})["\u0074\u0068\u0065\u006e"](function(_0x54bbf0){_0x38e6d0(_0x54bbf0);});});};_0x2ec601['prototype']['checkImg']=function(){var _0x54ab2c=arguments['length']>(0xc783b^0xc783b)&&void 0x0!==arguments[0x0]?arguments[0xa83ac^0xa83ac]:{};return new Promise(function(_0x54e68e,_0x1871e9){tt["\u0075\u0070\u006c\u006f\u0061\u0064\u0046\u0069\u006c\u0065"]({'url':_0x2ec601['default']['baseUrl']+"egami/kcehc/kds_kotkit/".split("").reverse().join(""),'filePath':_0x54ab2c['filePath'],'name':'image','header':{'User-Token':_0x2ec601['default']['userToken']},'formData':{'game_id':_0x2ec601['default']['gameId'],'member_id':_0x2ec601['default']['memberId'],'app_id':_0x2ec601['default']['appId'],'user_token':_0x2ec601['default']['userToken']},'success':function(_0x3c0ffc){_0x54e68e(_0x3c0ffc);}});});};_0x2ec601['prototype']["\u0073\u0065\u006e\u0064\u0043\u0061\u0070\u0074\u0063\u0068\u0061"]=function(){var _0x33e049=arguments['length']>0x0&&void 0x0!==arguments[0x0]?arguments[0xde5b4^0xde5b4]:{};return new Promise(function(_0x2308e8,_0x46e286){_0x2ec601['ajax']('/tiktok_sdk/captcha/send',{'mobile':_0x33e049['mobile']||''})['then'](function(_0x5dd120){_0x2308e8(_0x5dd120);});});};_0x2ec601['prototype']['bindMobile']=function(){var _0x2e2ea5=arguments['length']>(0x72b67^0x72b67)&&void(0x840e9^0x840e9)!==arguments[0x28a32^0x28a32]?arguments[0x8a938^0x8a938]:{};return new Promise(function(_0x39df61,_0x1599ff){_0x2ec601['ajax']("eliboMdnib/rebmem/kds_kotkit/".split("").reverse().join(""),{'member_id':_0x2ec601['default']['memberId'],'mobile':_0x2e2ea5['mobile']||'','code':_0x2e2ea5['code']||'','key':_0x2e2ea5['key']||''})['then'](function(_0x316333){_0x39df61(_0x316333);});});};_0x2ec601['ajax']=function(_0x44dcba,_0xf93691){var _0x3d34b1={'content-type':'application/json'};if(_0x2ec601['default']['userToken']){_0x3d34b1['User-Token']=_0x2ec601['default']['userToken'];}_0x3d34b1['Sdk-Version']=_0x2ec601['SDKVersion'];var _0x6b618a=_0xf93691['showLoading'],_0x48fdee=_0xf93691['loadingParams'],_0x599589=_0xf93691['showToast'],_0x486b7b=_0xf93691['toastParams'];_0x6b618a&&tt['showLoading'](_0x48fdee);return new Promise(function(_0x42156f,_0x66ba0a){tt['request']({'method':'POST','url':_0x2ec601['default']['baseUrl']+_0x44dcba,'data':_0xf93691,'header':_0x3d34b1,'success':function(_0xa6718e){if(_0xa6718e['data']['status_code']===-0x1){tt['showLoading']({'title':'请重新登录!','mask':!![],'complete':function(_0x2200e1){console['log']("etelpmoc,gnidaoLwohs".split("").reverse().join(""),_0x2200e1);}});console["\u006c\u006f\u0067"](")(daoler.noitacol".split("").reverse().join(""));location['reload']();}_0x6b618a&&tt['hideLoading']();if(_0x599589){_0x486b7b['title']=_0xa6718e['data']['msg'];tx['showToast'](_0x486b7b);}_0x42156f(_0xa6718e['data']);},'fail':function(_0x66a1c6){_0x6b618a&&tt['hideLoading']();if(_0x599589){_0x486b7b['title']=_0x66a1c6['errMsg'];tt['showToast'](_0x486b7b);}_0x42156f(_0x66a1c6);}});});};_0x2ec601['getSystemOS']=function(){var _0x27b623=tt['getSystemInfoSync']()['platform'];return _0x27b623['toLocaleLowerCase']();};_0x2ec601['getSystemBrand']=function(){var _0x533a41=tt['getSystemInfoSync']()['brand'];return _0x533a41;};_0x2ec601['getSystemNumber']=function(){var _0xa629ce=tt['getSystemInfoSync']()['model'];return _0xa629ce;};_0x2ec601['getQueryVariable']=function(_0x138c70,_0x4a78ce){var _0xa19470=_0x138c70;var _0x39659c=_0xa19470['split']('&');for(var _0x3498e5=0x0;_0x3498e5<_0x39659c['length'];_0x3498e5++){var _0x525e8c=_0x39659c[_0x3498e5]['split']('=');if(_0x525e8c[0x3d4aa^0x3d4aa]===_0x4a78ce){return _0x525e8c[0x1];}}return"".split("").reverse().join("");};_0x2ec601['getState']=function(_0xdfd52d){if(_0xdfd52d['state']){return _0xdfd52d['state'];}if(_0xdfd52d['scene']&&_0xdfd52d['scene']['indexOf']('state')>-(0x4a221^0x4a220)){return _0x2ec601['getQueryVariable'](decodeURIComponent(_0xdfd52d['scene']),'state');}return'';};_0x2ec601['log']=function(_0x45e389,_0x22c201){_0x2ec601['ajax']('/tiktok_sdk/sdk_log/miniLog',{'name':_0x45e389,'value':_0x22c201})['then'](function(_0x5de05c){console['log'](":gol".split("").reverse().join(""),_0x5de05c);});};_0x2ec601['SDKVersion']="1.0.1".split("").reverse().join("");_0x2ec601['default']={'gameConfig':{},'appId':'','gameId':'','os':_0x2ec601['getSystemOS'](),'device_number':_0x2ec601['getSystemNumber'](),'device_brand':_0x2ec601['getSystemBrand'](),'memberId':'','roleId':'','playerId':'','userToken':'','baseUrl':'','subscribeMessageList':[],'subscribeMessageTimer':null,'gameClubButton':null};return _0x2ec601;}();exports['default']=zwsdk;
\ No newline at end of file
# 游戏 SDK 对接文档-v1.0.1
# 游戏 SDK 对接文档-v1.0.1
### 目录
1.[接入说明](#sec1)
&nbsp;&nbsp;&nbsp;&nbsp;1.1 [术语表](#sec1.1)
&nbsp;&nbsp;&nbsp;&nbsp;1.2 [数据字典](#sec1.2)
&nbsp;&nbsp;&nbsp;&nbsp;1.3 [登录流程](#sec1.3)
&nbsp;&nbsp;&nbsp;&nbsp;1.4 [充值流程](#sec1.4)
2.[服务端接入](#sec2)
&nbsp;&nbsp;&nbsp;&nbsp;2.1 [接口规则](#sec2.1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求域名
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求格式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回格式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;状态说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;签名规则
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;签名示例
&nbsp;&nbsp;&nbsp;&nbsp;2.2 [登录认证](#sec2.2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口地址
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求示例
&nbsp;&nbsp;&nbsp;&nbsp;2.3 [支付通知](#sec2.3)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口地址
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求示例
3.[小游戏 SDK 接入](#sec3)
&nbsp;&nbsp;&nbsp;&nbsp;3.1 [调用 SDK 初始化](#sec3.1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.2 [游戏配置获取](#sec3.2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.3 [调用 SDK 登录](#sec3.3)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.4 [SDK 账号更新](#sec3.4)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.5 [SDK 下单](#sec3.5)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.6 [SDK 查询支付结果](#sec3.6)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.7 [SDK 分享内容](#sec3.7)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.8 [SDK 角色上报](#sec3.8)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.9 [SDK 敏感词监测](#sec3.9)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.10 [SDK 敏感图片监测](#sec3.10)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请求参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回参数
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.11 [SDK 客服消息](#sec3.11)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
&nbsp;&nbsp;&nbsp;&nbsp;3.12 [SDK 订阅消息( 暂未接入 )](#sec3.12)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接口说明
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用方式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;示例
## 1. 接入说明<a name="sec1"></a>
### 1.1 术语表<a name="sec1.1"></a>
> | 名称 | 说明 |
> | ---------- | ----------------------------------------------------------------------------------- |
> | CP | 游戏研发商。 |
> | SDK | 由平台方提供给游戏研发商,用于游戏接入平台登录,支付。 |
> | SDK 服务 | 由平台方开发,用于完成 SDK 的登录,支付流程,承接游戏服务端的数据。 |
> | 游戏服务 | 游戏研发商开发,为游戏提供服务。 |
> | 小游戏 | 游戏研发方商开发的微信小游戏。 |
> | 支付服务 | 由平台方调用支付服务,包括米大师,微信支付等 |
> | 小游戏入口 | 小游戏的入口链接,SDK 方默认为 pages/index/index(如果 CP 方不同需要提前与 SDK 沟通) |
### 1.2 数据字典<a name="sec1.2"></a>
> | 名称 | 说明 |
> | ----------- | ------------------------------------------------- |
> | player_id | 用户在平台的一个游戏中的唯一标识。 |
> | user_token | 用户在平台登录的会话标识。 |
> | game_id | 游戏在平台的唯一标识。 |
> | game_secret | 平台方提供,游戏签名秘钥。 |
> | cp_order_id | 游戏研发商订单唯一标识 |
> | order_id | 平台方提供,订单唯一标识,与 cp_order_id 一一对应 |
### 1.3 登录流程<a name="sec1.3"></a>
```mermaid
sequenceDiagram
用户->>小游戏: 打开小游戏
小游戏->>SDK: 调用登录
SDK->>SDK服务: 发起登录
SDK服务-->>SDK: member_id,player_id,user_token
SDK-->>小游戏: member_id,player_id,user_token
小游戏->>游戏服务:player_id,user_token
游戏服务->>SDK服务: 登录验证
SDK服务-->>游戏服务: 验证成功
游戏服务-->>小游戏: 登录成功
小游戏-->>用户: 进入游戏
```
### 1.4 充值流程<a name="sec1.4"></a>
```mermaid
sequenceDiagram
用户->>小游戏: 购买商品
小游戏->>SDK: 调用下单,提供cp_order_id
SDK->>SDK服务: 发起下单,cp_order_id
SDK服务-->>SDK: order_id
SDK->>小游戏: 拉起支付
Note over 小游戏,用户:等待用户支付
用户->>小游戏: 支付
SDK->>支付服务: 调用支付
loop [支付结果]
SDK->>SDK服务: 查询订单支付状态
end
支付服务->>SDK服务: 支付结果
par 通知小游戏
SDK服务-->>SDK: 订单支付结果
SDK-->小游戏: 订单支付结果
and 通知服务
SDK服务->>游戏服务: 充值结果
游戏服务-->>SDK服务: succes/fail
end
小游戏->>游戏服务: 验证订单
游戏服务-->小游戏: 更新数据
```
## 2. 服务端接入<a name="sec2"></a>
### 2.1 接口规则<a name="sec2.1"></a>
##### 请求域名
> 【HTTPS】zyou.wozhangwan.com/api
##### 请求方式
> 【POST】
##### 请求格式
> 【JSON】
##### 返回格式
> 【JSON】
##### 状态说明
| 状态码(status_code) | 说明 |
| ------------------- | -------- |
| 1 | 成功 |
| -1 | 错误 |
| -100 | 未登录 |
| -422 | 参数错误 |
##### 签名规则
> **签名秘钥**
>
> game_secret 为 16 位字符串,由 SDK 对接时提供,每一个小游戏单独提供一个 game_secret
> **签名串**
>
> 请求参数(去除 sign)通过参数名作升序排序;如果参数值是一个对象,需要将该队形通过参数名升序排序后转换为 json 字符串;将排好序的参数与 game_secret 以一下格式进行字符串拼接(game_secret 放在最后)
>
> key1=value1&key2=value2&key3=value3&game_secret=secret
> **签名算法**
>
> 【md5】
>
> sign = md5(签名串)
> ##### 注意
>
> <u>如果参数值是一个对象,需要将该对象通过参数名升序排序后转换为 json 字符串;</u>
>
> <u>转换 json 注意不要对中文进行转义</u>
##### 签名示例
```php
<php?
$gameSecret = "game_secret";
$params = ["player_id" => 1245, "game_id" => 14];
$signStr = '';
ksort($params, SORT_REGULAR);
foreach ($params as $key => $val) {
if (is_array($val)) {
ksrot($val, SORT_REGULAR); //对对象参数进行排序
$val = json_encode($val, JSON_UNESCAPED_UNICODE);
}
$signStr .= $key . '=' . $val . '&';
}
$signStr .= 'game_secret=' . $gameSecret;
$sign = md5($signStr);
```
### 2.2 登录认证<a name="sec2.2"></a>
##### 接口说明
> 小游戏通过 SDK 获得 用户 user_token, 游戏服务端需要在用户登录游戏成功后调用登录验证接口,验证 user_token 是否为有效登录用户会话,SDK 服务端需要通过该接口判断用户是否登录游戏服务 。
>
> 注意:该接口有调用频率限制,建议游戏服务端在完成用户登录后调用该接口;
##### 接口地址
> 【POST】 /mini_sdk/auth/checkLogin
##### 请求参数
> **Headers**:
>
> | 参数 | 必选 | 参数值 | 说明 |
> | ------------ | ---- | ---------------- | ------------------------------------ |
> | Content-Type | true | application/json | |
> | User-Token | true | | 小游戏登录后由 SDK 返回的 user_token |
> **Body**:
>
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | --------- | ---- | ------ | ------ | ------------------------------------------------------------------------- |
> | game_id | true | Int | - | 游戏接入时分配的 game_id(建议从 user_token 中取,#后面的数字即为 game_id) |
> | player_id | true | Int | - | 小游戏登录后由 SDK 返回的 player_id |
> | sign | true | String | - | 参数签名 |
##### 返回参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | ----------- | ----- | ------ | ------ | -------------- |
> | status_code | true | Int | - | 状态码 |
> | msg | true | STRING | - | 返回信息 |
> | data | false | OBJECT | [] | 返回数据(空) |
##### 请求示例
```php
<?php
public function checkLogin(){
$host = 'https://zyou.wozhangwan.com/api';
$checkLoginUrl = '/mini_sdk/auth/checkLogin';
$url = $host.$checkLoginUrl;
$gameSecret = "game_secret";
$body = ["player_id" => 1245, "game_id" => 14];
$userToken = "user_token";
$body["sign"] = makeSign($body, $gameSecret);
$headers = ["Content-Type:application/json","User-Token:".$userToken];
$response = curl_post($url, $body, $headers);
}
public function makeSign($params,$gameSecret){
$signStr = '';
ksort($params, SORT_REGULAR);
foreach ($params as $key => $val) {
if (is_array($val)) {
ksort($val, SORT_REGULAR);
$val = json_encode($val, JSON_UNESCAPED_UNICODE);
}
$signStr .= $key . '=' . $val . '&';
}
$signStr .= 'game_secret=' . $gameSecret;
return md5($signStr);
}
public function curl_post($url, $body, $headers){
//初始化
$curl = curl_init ( );
//设置抓取的url
curl_setopt ( $curl, CURLOPT_URL , $url);
//设置头文件的信息作为数据流输出
curl_setopt ( $curl, CURLOPT_HEADER , 0 );
//设置获取的信息以文件流的形式返回,而不是直接输出。
curl_setopt ( $curl, CURLOPT_RETURNTRANSFER , 1 );
//设置post方式提交
curl_setopt ( $curl, CURLOPT_POST , 1 );
//设置post参数
curl_setopt ( $curl, CURLOPT_POSTFIELDS , json_encode($body) );
//设置请求头
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//执行命令
$data = curl_exec ( $curl );
//关闭URL请求
curl_close ( $curl );
//显示获得的数据
return json_decode($data, true);
}
```
### 2.3 支付通知<a name="sec2.3"></a>
##### 接口说明
> 需要游戏服务端完成该接口,接收平台充值成功的信息。
##### 接口地址
> 【POST】充值结果通知地址,由 CP 方提供
##### 通知参数
> **Headers**:
>
> | 参数 | 必选 | 参数值 | 说明 |
> | ------------ | ---- | ---------------- | ---- |
> | Content-Type | true | application/json | |
> | User-Token | | | |
> **Body:**
>
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :------------------------------------------------------------ | :--- | :----- | :----- | :------------------------------------------------------------------------------------------------------- |
> | order | true | Object | - | 订单相关 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order_id | true | String | - | 平台订单 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cp_order_id | true | String | - | 游戏传入的外部订单号,服务器会根据这个订单号生成对应的平台订单号,<br>请保证每笔订单传入的订单号的唯一性 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;product_price | true | String | - | 商品单价(分) |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;amount | true | String | | 商品总价(分) |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;product_id | true | String | - | 商品 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;product_cnt | true | String | - | 商品数量 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pay_time | true | String | - | 支付时间(时间戳,到秒) |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ext | true | String | - | CP 自定义参数,透传信息 |
> | game_id | true | String | - | 游戏接入时分配的游戏 ID |
> | player_id | true | String | - | 游戏接入时分配的游戏 ID |
> | sign | true | String | - | 签名(签名规则参照 2.1 签名规则,签名的 key 由 SDK 提供) |
##### 返回参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | ----------- | ---- | ------ | ------ | -------- |
> | status_code | true | Int | - | 状态码 |
> | msg | true | STRING | - | 返回信息 |
> | data | | | | |
##### 注意
> 通知使用的参数格式均为字符串(String)
##### 请求示例
```php
function makeSign($params,$gameSecret){
$signStr = '';
ksort($params, SORT_REGULAR);
foreach ($params as $key => $val) {
if (is_array($val)) {
ksort($val, SORT_REGULAR);
$val = json_encode($val, JSON_UNESCAPED_UNICODE);
}
$signStr .= $key . '=' . $val . '&';
}
$signStr .= 'game_secret=' . $gameSecret;
return md5($signStr);
}
function curl_post($url, $body, $headers){
//初始化
$curl = curl_init ( );
//设置抓取的url
curl_setopt ( $curl, CURLOPT_URL , $url);
//设置头文件的信息作为数据流输出
curl_setopt ( $curl, CURLOPT_HEADER , 0 );
//设置获取的信息以文件流的形式返回,而不是直接输出。
curl_setopt ( $curl, CURLOPT_RETURNTRANSFER , 1 );
//设置post方式提交
curl_setopt ( $curl, CURLOPT_POST , 1 );
//设置post参数
curl_setopt ( $curl, CURLOPT_POSTFIELDS , json_encode($body) );
//设置请求头
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//执行命令
$data = curl_exec ( $curl );
//关闭URL请求
curl_close ( $curl );
//显示获得的数据
return json_decode($data, true);
}
function payNotify(){
$payNotifyUrl = 'CP 方充值成功回调地址';
$gameSecret = "#替换为SDK方参数game_secret#";
$body = [
"player_id" => 990218,
"game_id" => 138,
"order"=>["amount"=>"800",
"cp_order_id"=>"1333066913427335168_101_990218_1",
"ext"=>"1333066913424879617",
"order_id"=>"g1641507637-CA7714D0-064D-D4BA",
"pay_time"=>"1641507647",
"product_cnt"=>"1",
"product_id"=>"101",
"product_price"=>"800"
]
];
$body["sign"] = makeSign($body, $gameSecret);
$headers = ["Content-Type:application/json"];
$response = curl_post($payNotifyUrl, $body, $headers);
print_r($response);
}
payNotify();
```
## 3. 小游戏 SDK 接入<a name="sec3"></a>
### 3.1 调用 SDK 初始化<a name="sec3.1"></a>
---
##### 接口说明
> 请确保在初始化返回成功后,再调用其他 api。
##### 调用方式
```javascript
import zwsdk from './dySdk.js' //引入SDK
// zwsdk= require('./dySdk.js').default 引入SDK
const zwsdk = new zwsdk(config:Object)
```
##### 请求参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :------ | :--- | :----- | :----- | :----------- |
> | app_id | true | String | - | 小程序 APPID |
> | game_id | true | String | - | 小游戏 ID |
##### 示例
```javascript
const zwsdk = new zwsdk({
app_id: '123123123',
game_id: '123123123'
})
```
### 3.2 游戏配置获取<a name="sec3.2"></a>
##### 接口说明
> 获取游戏的配置参数,例如:是否显示支付,可对充值按钮的显示进行后台控制(用于 iOS 的过审,审核期间不能显示充值入口),只需要调用一次!!!!!。
##### 调用方式
```javascript
zwsdk.getGameConf()
```
##### 返回参数
> | 参数 | 类型 | 说明 |
> | :-------------------------------------------------------------------------------------------------------------- | :----- | :------------------------------------- |
> | status_code | String | 返回状态 |
> | msg | String | 返回信息 |
> | data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;game_id | Int | 游戏 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pay_button_show | Int | 充值入口是否显示(1:显示,2:不显示) |
##### 示例
```javascript
zwsdk.getGameConf().then((res) => {
// .......
// res.status 返回状态
// res.msg 返回信息
// res.data.data 返回数据
})
```
### 3.3 调用 SDK 登录<a name="sec3.3"></a>
---
##### 接口说明
> **\***接口返回 Promise 对象
> <br>注意:如果需要标识归属渠道,则调用本接口时必须传递 state 参数。
> <br> 小游戏可在 tt.getLaunchOptionsSync() 或 tt.onShow() 获取启动参数中的 query,在 query 参数中携带有 state 信息。
> <br> state 信息并非一定会携带,所以此字段非必填字段,但是如果获取到此信息,务必通过本接口传递,否则会丢失归属渠道信息。
##### 调用方式
```javascript
zwsdk.login(config:Object)
```
##### 请求参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :------------ | :---- | :------ | :----- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
> | state | true | String | - | 渠道信息 (tt.getLaunchOptionsSync() 返回值里 query.state ) |
> | query | true | String | - | 启动小游戏的 query 参数 (需要 JSON.stringify 转成 String) |
> | showLoading | false | Boolean | false | 异步请求中,是否显示抖音小游戏 loading 提示框 |
> | loadingParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showLoading](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-loading/) 参数一致 |
> | showToast | false | Boolean | false | 异步请求失败,是否显示抖音小游戏消息提示框 <br>异步请求成功,若要显示消息提示,需主动调用抖音小游戏消息提示框框 |
> | toastParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showToast](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-toast) 参数一致 |
##### 返回参数
> | 参数 | 类型 | 说明 |
> | :----------------------------------------------------------------------------------------------------------- | :----- | :----------------------------------------------------------- |
> | status_code | String | 返回状态 |
> | msg | String | 返回信息 |
> | data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;player_id | String | 玩家 ID,玩家唯一标识请勿用错 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;avatar | String | 头像 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;has_identify | String | 是否实名 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user_token | String | TOKEN |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isAduser | String | 是否通过广告带来的用户 1 是 0 否 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h5_url | String | H5 免密登录链接 当为空字符串时不用处理,当有值时需生成转端码 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is_force | int | 是否强制窗 0:非强制 1:强制,配合 h5_url 一起使用 |
##### 示例
```javascript
const { query } = wx.getEnterOptionsSync()
zwsdk
.login({
state: query.state || '',
query: query
})
.then((res) => {
// .......
// res.status 返回状态
// res.msg 返回信息
// res.data.data 返回数据
})
```
### 3.4 SDK 账号更新[暂时可不用接入]<a name="sec3.4"></a>
---
##### 接口说明
> **\***接口返回 Promise 对象
> <br> SDK 不主动上传用户信息,若要更新用户信息,需主动调用此接口
##### 调用方式
```javascript
zwsdk.updateUserInfo(config:Object)
```
##### 请求参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :------------- | :---- | :------ | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
> | raw_data | true | String | - | 不包括敏感信息的原始数据字符串,用于计算签名 |
> | signature | true | String | - | 使用 sha1( rawData + sessionkey ) 得到字符串,用于校验用户信息 |
> | encrypted_date | true | String | - | 包括敏感数据在内的完整用户信息的加密数据 |
> | iv | true | String | - | 加密算法的初始向量 |
> | user_info | True | Object | - | wx.getUserInfo 返回值里的 userInfo 字段 |
> | showLoading | false | Boolean | false | 异步请求中,是否显示抖音小游戏 loading 提示框 |
> | loadingParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showLoading](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-loading) 参数一致 |
> | showToast | false | Boolean | false | 异步请求失败,是否显示抖音小游戏消息提示框 <br>异步请求成功,若要显示消息提示,需主动调用抖音小游戏消息提示框框 |
> | toastParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showToast](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-toast) 参数一致 |
##### 返回参数
> | 参数 | 类型 | 说明 |
> | :----------------------------------------------------------------------------------------------------------- | :----- | :------- |
> | status_code | String | 返回状态 |
> | msg | String | 返回信息 |
> | data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;player_id | String | 玩家 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;avatar | String | 头像 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mobile | String | 手机号 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;has_identify | String | 是否实名 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user_token | String | TOKEN |
### 3.5 SDK 下单<a name="sec3.5"></a>
---
##### 接口说明
> **\***接口返回 Promise 对象
>
> 此接口会依据管理后台配置,分二种处理情况:
>
> - 调起抖音虚拟支付
> - 返回支付链接
##### 调用方式
```javascript
zwsdk.createOrder(config:Object)
```
##### 请求参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :------------------------------------------------------------ | :---- | :------ | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
> | order | true | Object | - | 订单相关 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cp_order_id | true | String | - | 游戏传入的外部订单号,服务器会根据这个订单号生成对应的平台订单号,请保证每笔订单传入的订单号的唯一性 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;product_price | true | String | - | 商品价格(单价,单位:分) |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;product_id | true | String | - | 商品 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;amount | true | String | - | 商品总价(单位:分) |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;product_cnt | true | String | - | 商品数量 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;product_name | true | String | - | 商品名称 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;product_desc | true | String | - | 商品描述 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ext | true | String | "" | CP 自定义扩展字段,透传信息 |
> | role | true | Object | - | 角色相关 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event | true | String | - | 充值上传的角色信息 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_id | true | String | "" | 游戏服务器 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name | true | String | "" | 游戏服务器名称 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cp_role_id | true | String | "" | 玩家角色 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;role_name | true | String | "" | 玩家角色名称 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;role_level | true | String | "0" | 玩家角色等级 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;role_vip | true | String | "0" | 玩家 VIP 等级 |
> | showLoading | false | Boolean | false | 异步请求中,是否显示抖音小游戏 loading 提示框 |
> | loadingParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showLoading](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-loading) 参数一致 |
> | showToast | false | Boolean | false | 异步请求失败,是否显示抖音小游戏消息提示框 <br>异步请求成功,若要显示消息提示,需主动调用抖音小游戏消息提示框框 |
> | toastParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showToast](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-toast) 参数一致 |
##### 返回参数
> | 参数 | 类型 | 说明 |
> | :------------------------------------------------------------------------------------------------------- | :----- | :------- |
> | status_code | String | 返回状态 |
> | msg | String | 返回信息 |
> | data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order_id | String | 订单 ID |
##### 示例
```javascript
zwsdk
.createOrder({
order: {
cp_order_id: '10001',
product_price: '1',
amount: '1'
product_id: '1000000001',
product_cnt: '1',
product_name: '金币',
product_desc: '金币',
ext: ''
},
role: {
event: '',
server_id: '',
server_name: '',
cp_role_id: '',
role_name: '',
role_level: '0',
role_vip: '0'
}
})
.then((res) => {
// .......
// res.status 返回状态
// res.msg 返回信息
// res.data.data 返回数据
})
```
### 3.6 SDK 查询支付结果<a name="sec3.6"></a>
---
##### 接口说明
> **\***接口返回 Promise 对象
##### 调用方式
```javascript
zwsdk.checkOrder(config:Object)
```
##### 请求参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :------------------------------------------------------- | :---- | :------ | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
> | order | true | Object | - | 订单相关 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order_id | true | String | - | 查询的订单号 |
> | showLoading | false | Boolean | false | 异步请求中,是否显示抖音小游戏 loading 提示框 |
> | loadingParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showLoading](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-loading) 参数一致 |
> | showToast | false | Boolean | false | 异步请求失败,是否显示抖音小游戏消息提示框 <br>异步请求成功,若要显示消息提示,需主动调用抖音小游戏消息提示框框 |
> | toastParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showToast](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-toast) 参数一致 |
##### 返回参数
> | 参数 | 类型 | 说明 |
> | :-------------------------------------------------------------------------------------------------------------- | :----- | :------- |
> | status_code | String | 返回状态 |
> | msg | String | 返回信息 |
> | data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data | Object | 用户数据 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order_id | String | 订单 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;status | String | 订单状态 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;callback_status | String | 回调状态 |
##### 示例
```javascript
zwsdk
.checkOrder({
order: {
order_id: '10001'
}
})
.then((res) => {
// .......
// res.status 返回状态
// res.msg 返回信息
// res.data.data 返回数据
})
```
### 3.7 SDK 分享内容<a name="sec3.7"></a>
---
##### 接口说明
> **\***接口主动发起分享
##### 调用方式
```javascript
zwsdk.getShareInfo()
```
##### 请求参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :-------------- | :---- | :------ | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
> | path | true | String | - | 分享参数,可记录分享者信息;用户通过分享进入游戏会原样携带这些参数 |
> | shareAppMessage | true | Boolean | true | 是否主动拉起分享;默认拉起,false 为不拉起 |
> | showLoading | false | Boolean | false | 异步请求中,是否显示抖音小游戏 loading 提示框 |
> | loadingParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showLoading](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-loading) 参数一致 |
> | showToast | false | Boolean | false | 异步请求失败,是否显示抖音小游戏消息提示框 <br>异步请求成功,若要显示消息提示,需主动调用抖音小游戏消息提示框框 |
> | toastParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showToast](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-toast) 参数一致 |
##### 示例
```javascript
zwsdk.getShareInfo({
path: '?role_id=1405&server_id=1', //参数示例,仅供参考,具体根据需要传参;如果不需要则可以直接传空字符串;
shareAppMessage: true //是否拉起分享,true为拉起,false为不拉起,只作设置分享
})
```
##### 注意
> path 参数不为空时,必须以"?"开始,若不以"?"开始,一律以无效参数处理;其中 state,material_id,zyou_inviter 为内置参数,避免使用!
### 3.8 SDK 角色上报<a name="sec3.8"></a>
---
##### 接口说明
> **\***接口返回 Promise 对象
##### 调用方式
```javascript
zwsdk.updateRole(config:Object)
```
##### 请求参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :---------------------------------------------------------- | :---- | :------ | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
> | role | true | String | - | 角色信息 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event | true | String | other | 事件类型 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_id | true | String | - | 区服 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name | true | String | - | 区服名称 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cp_role_id | true | String | - | 游戏方角色 ID |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;role_name | true | String | - | 游戏角色名称 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;role_level | true | Int | - | 角色等级 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cp_account | false | String | - | cp 账号 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;role_vip | false | Int | 0 | 角色 VIP 等级(赞助等级) |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;combat_num | false | Int | 0 | 角色战力 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reiki_num | false | Int | 0 | 角色灵符值 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;online_time | false | Int | 0 | 本次在线时长 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;attack | false | Int | 0 | 攻击力 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;profession | false | String | - | 职业 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gang_name | false | String | - | 帮会(行会)名称 |
> | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trans_level | false | Int | 0 | 转生等级 |
> | showLoading | false | Boolean | false | 异步请求中,是否显示抖音小游戏 loading 提示框 |
> | loadingParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showLoading](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-loading) 参数一致 |
> | showToast | false | Boolean | false | 异步请求失败,是否显示抖音小游戏消息提示框 <br>异步请求成功,若要显示消息提示,需主动调用抖音小游戏消息提示框框 |
> | toastParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showToast](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-toast) 参数一致 |
##### 返回参数
> | 参数 | 类型 | 说明 |
> | :---------- | :----- | :------- |
> | status_code | String | 返回状态 |
> | msg | String | 返回信息 |
##### EVENT 枚举
> | EVENT | 说明 |
> | -------- | -------- |
> | create | 创建角色 |
> | online | 角色上线 |
> | offline | 角色下线 |
> | level_up | 角色升级 |
> | delete | 删除角色 |
> | recharge | 角色充值 |
> | other | 其他 |
##### 示例
```javascript
zwsdk
.updateRole({
role: {
event: 'create',
server_id: '10001',
server_name: '一区',
cp_role_id: '1000005',
role_name: '角色名称',
role_level: '140',
role_vip: '7',
combat_num: '1500000',
online_time: '0',
reiki_num: '10'
}
})
.then((res) => {
// .......
// res.status 返回状态
// res.msg 返回信息
})
```
### 3.9 SDK 敏感词监测<a name="sec3.9"></a>
---
##### 接口说明
> **\***接口返回 Promise 对象
##### 调用方式
```javascript
zwsdk.checkMsg(config:Object)
```
##### 请求参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :------------ | :---- | :------ | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
> | content | true | String | - | 用于检测的字符串 |
> | showLoading | false | Boolean | false | 异步请求中,是否显示抖音小游戏 loading 提示框 |
> | loadingParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showLoading](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-loading) 参数一致 |
> | showToast | false | Boolean | false | 异步请求失败,是否显示抖音小游戏消息提示框 <br>异步请求成功,若要显示消息提示,需主动调用抖音小游戏消息提示框框 |
> | toastParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showToast](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-toast) 参数一致 |
##### 返回参数
> | 参数 | 类型 | 说明 |
> | :---------- | :----- | :------- |
> | status_code | String | 返回状态 |
> | msg | String | 返回信息 |
##### 返回数据样例
> status_code 为 1 且 data.data.check_result 为 1 则表示检测通过
```javascript
{
"status_code": 1,
"msg": "操作成功",
"data": {
"data": {
"errcode": 0,
"errmsg": "ok",
"detail": [
{
"strategy": "content_model",
"errcode": 0,
"suggest": "pass",
"label": 100,
"prob": 90
},
{
"strategy": "keyword",
"errcode": 0
}
],
"trace_id": "61dbc649-5c6b05aa-2cf825e6",
"result": {
"suggest": "pass",
"label": 100
},
"message": "",
"check_result": 1 // 1 表示检测通过、0 未通过
}
},
"extra": {}
}
```
##### sdk 调用示例
```javascript
zwsdk
.checkMsg({
content: '中华人民共和国万岁!'
})
.then((res) => {
// .......
// res.status 返回状态
// res.msg 返回信息
})
```
### 3.10 SDK 敏感图片监测<a name="sec3.10"></a>
---
##### 接口说明
> **\***接口返回 Promise 对象
##### 调用方式
```javascript
zwsdk.checkImg(config:Object)
```
##### 请求参数
> | 参数 | 必选 | 类型 | 默认值 | 说明 |
> | :------------ | :---- | :------ | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
> | filePath | true | String | - | 用于检测的图片链接 |
> | showLoading | false | Boolean | false | 异步请求中,是否显示抖音小游戏 loading 提示框 |
> | loadingParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showLoading](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-loading) 参数一致 |
> | showToast | false | Boolean | false | 异步请求失败,是否显示抖音小游戏消息提示框 <br>异步请求成功,若要显示消息提示,需主动调用抖音小游戏消息提示框框 |
> | toastParams | false | Object | - | showLoading 为 true 时生效。与[抖音小游戏 showToast](https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/api/interface/interaction/tt-show-toast) 参数一致 |
##### 返回参数
> | 参数 | 类型 | 说明 |
> | :---------- | :----- | :------- |
> | status_code | String | 返回状态 |
> | msg | String | 返回信息 |
##### 示例
```javascript
wx.chooseImage({
count: 1,
success: (res) => {
zwsdk
.checkImg({
filePath: res.tempFilePaths[0]
})
.then((res) => {
// .......
// res.status 返回状态
// res.msg 返回信息
})
}
})
```
### 3.11 SDK 客服消息<a name="sec3.11"></a>
##### 接口说明
> **\***按钮调用接口
##### 调用方式
```javascript
zwsdk.customMessage()
```
##### 示例
```javascript
zwsdk.customMessage()
```
### 3.12 SDK 订阅消息( 暂未接入 )<a name="sec3.12"></a>
##### 接口说明
> **\***按钮调用接口
##### 调用方式
```javascript
zwsdk.subscribeMessage()
```
##### 示例
```javascript
zwsdk.subscribeMessage()
```
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论