Shenlong/library/imports/3c/3c9692f1-fd69-4a82-bd5c-ce5...

1 line
6.7 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"sources":["assets/scripts/WechatManager.ts"],"names":[],"mappings":";;;;;;;AAAA,4DAA4D;AAC5D,0CAA0C;AACpC,IAAA,KAAwB,EAAE,CAAC,UAAU,EAAnC,OAAO,aAAA,EAAE,QAAQ,cAAkB,CAAC;AAE5C;IAAA;QAIE,OAAO;QACC,oBAAe,GAAG,IAAI,CAAC;IAyHjC,CAAC;IAvHC,sBAAW,yBAAQ;aAAnB;YACE,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,OAAO,IAAI,CAAC,SAAS,CAAC;aACvB;YACD,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;;;OAAA;IAED,SAAS;IACF,uCAAe,GAAtB,UAAuB,QAAQ;QAA/B,iBA4BC;QA3BC,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC;QAChC,WAAW;QACX,2BAA2B;QAC3B,aAAa;QACb,IAAI,MAAM,GAAQ;YAChB,gBAAgB;YAChB,OAAO,EAAE,UAAC,GAAG;gBACX,WAAW;gBACX,IAAM,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;gBACpC,IAAI,WAAW,CAAC,gBAAgB,CAAC,EAAE;oBACjC,MAAM;oBACN,KAAI,CAAC,WAAW,EAAE,CAAC;iBACpB;qBAAM;oBACL,MAAM;oBACN,KAAI,CAAC,mBAAmB,EAAE,CAAC;iBAC5B;YACH,CAAC;YACD,OAAO;YACP,IAAI;gBACF,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YACvC,CAAC;YACD,oBAAoB;YACpB,QAAQ;gBACN,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CA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S,GAAG,GAAG,CAAC,QAAQ,CAAC;gBAC9B,IAAI,KAAI,CAAC,eAAe,EAAE;oBACxB,KAAI,CAAC,eAAe,CAAC,KAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;iBAChD;gBACD,cAAc;gBACd,MAAM,CAAC,OAAO,EAAE,CAAC;aAClB;iBAAM;gBACL,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,mDAAmD;IAC5C,mCAAW,GAAlB;QAAA,iBAkBC;QAjBC,IAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,MAAM,GAAQ;YAChB,OAAO,EAAE,UAAC,GAAG;gBACX,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;gBAC1C,IAAI,GAAG,EAAE;oBACP,KAAI,CAAC,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC;oBAC9B,IAAI,KAAI,CAAC,eAAe,EAAE;wBACxB,KAAI,CAAC,eAAe,CAAC,KAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;qBAChD;iBACF;YACH,CAAC;YACD,IAAI,EAAE;gBACJ,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;YACnC,CAAC;YACD,QAAQ,EAAE,cAAO,CAAC;SACnB,CAAC;QACF,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IA5Hc,uBAAS,GAAkB,IAAI,CAAC;IA6HjD,oBAAC;CA9HD,AA8HC,IAAA;AA9HY,sCAAa","file":"","sourceRoot":"/","sourcesContent":["// wxAPI: https://developers.weixin.qq.com/minigame/dev/api/\n// import { _decorator, screen} from 'cc';\nconst { ccclass, property } = cc._decorator;\n\nexport class WechatManager {\n private static _instance: WechatManager = null; \n // 用户信息: 昵称,头像,语言等\n private _userInfo;\n // 头像回调\n private _avatarCallBack = null;\n\n static get instance() {\n if (this._instance) {\n return this._instance;\n }\n this._instance = new WechatManager();\n return this._instance;\n }\n\n // 获取标记权限\n public initAutoSetting(callBack) {\n this._avatarCallBack = callBack;\n // 避开ts语法检测\n // const wx = window['wx'];\n // 获取请求过的权限标记\n let object: any = {\n // 成功回调 \n success: (res) => {\n // 是否授权用户信息\n const autoSetting = res.authSetting;\n if (autoSetting[\"scope.userInfo\"]) {\n // 已授权\n this.getUserInfo();\n } else {\n // 未授权\n this.creatUserInfoButton();\n }\n },\n // 失败回调\n fail() {\n console.log(\"wx.getSetting获取用户配置失败\");\n },\n // 结束回调(调用成功,失败都会执行)\n complete() {\n console.log(\"wx.getSetting获取用户配置结束\");\n }\n }\n wx.getSetting(object);\n }\n\n // 创建用户授权按钮(仅用于登录页面, 如果用户拒绝授权,则一直显示)\n private creatUserInfoButton(isFull: boolean = false) {\n let sysInfo = wx.getSystemInfoSync();\n let width = sysInfo.screenWidth;\n let height = sysInfo.screenHeight;\n // const wx = window['wx'];\n let object: any = {\n type: 'text',\n text: '',\n style: {\n left: 0,\n top: 0,\n width: width,\n height: height,\n backgroundColor: '#00000000',\n color: '#ffffff',\n fontSize: 20,\n textAlign: \"center\",\n lineHeight: height,\n }\n };\n // 创建用户授权按钮(仅用于登录页面, 如果用户拒绝授权,则一直显示)\n// private creatUserInfoButton(isFull: boolean = false) {\n// // const wx = window['wx'];\n// let object: any = {\n// // 按钮类型: text可设置背景色和文本 image仅能设置背景贴图\n// type: \"text\",\n// // 按钮文本仅对type为text有效\n// text: \"授权\",\n// // 按钮样式\n// style: {\n// left: 70, \n// top: 60,\n// width: 100,\n// height: 40,\n// backgroundColor: \"#66CC00\",\n// color: \"#FFFFFF\",\n// textAlign: 'center',\n// lineHeight: 40,\n// fontSize: 20,\n// },\n// };\n\n const button = wx.createUserInfoButton(object);\n // 监听用户信息按钮点击事件\n button.onTap((res) => {\n if (res && res.userInfo) {\n console.log(\"用户同意授权\");\n this._userInfo = res.userInfo; \n if (this._avatarCallBack) {\n this._avatarCallBack(this._userInfo.avatarUrl);\n }\n // 授权成功后,才销毁按钮\n button.destroy();\n } else {\n console.log(\"用户拒绝授权\");\n }\n });\n }\n\n // 获取用户信息需要获取scope.userInfo的授权也就是getSettings的接口调用\n public getUserInfo() {\n const wx = window['wx'];\n let object: any = {\n success: (res) => {\n console.log(\"通过 getUserInfo 获取的数据:\", res);\n if (res) {\n this._userInfo = res.userInfo;\n if (this._avatarCallBack) {\n this._avatarCallBack(this._userInfo.avatarUrl);\n }\n } \n },\n fail: () => {\n console.log(\"getUserInfo获取信息失败\");\n },\n complete: () => {},\n };\n wx.getUserInfo(object);\n }\n}\n"]}