12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- // Learn TypeScript:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
- import LocalData from "../manager/LocalData";
- import Plat from "../utils/Palt";
- import UIbase from "../utils/UIbase";
- import PrefabUtil from "../utils/manager/PrefabUtil";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class rankUI extends UIbase {
- private static _inst: rankUI;
- public static get inst() {
- if (this._inst == null) {
- let v = cc.instantiate(PrefabUtil.get("rankUI"));
- this._inst = v.getComponent(rankUI);
- }
- return this._inst;
- }
- @property(cc.SubContextView)
- view: cc.SubContextView = null;
- public showUI(data?: any): void {
- super.showUI(data)
- Plat.setRank(LocalData.lv)
- Plat.updateRank()
- }
- // update (dt) {}
- protected onShow(): void {
- wx.getSetting({
- success(res) {
- if (!res.authSetting['scope.userInfo']) {
- wx.authorize({
- scope: 'scope.userInfo',
- success() {
- console.error('用户已经同意授权,可以调用 getUserCloudStorage 方法');
- // // 用户已经同意授权,可以调用 getUserCloudStorage 方法
- // wx.getUserCloudStorage({
- // keyList: ['score'],
- // success: (kvData) => {
- // if (kvData.KVDataList && kvData.KVDataList.length > 0) {
- // let level = Number(kvData.KVDataList[0].value)
- // if (level < data.level) {
- // wx.setUserCloudStorage({
- // KVDataList: [{
- // key: 'score',
- // value: String(data.level)
- // }],
- // success: () => {
- // console.log('设置分数完成' + data.level)
- // }
- // })
- // } else {
- // console.log('设置的分数比最高分数低', level, data.level)
- // }
- // } else {
- // // 处理没有找到 score 数据的情况
- // }
- // }
- // })
- },
- fail() {
- // 用户拒绝授权,你可以提示用户授权的重要性或提供其他操作选项
- console.error('用户拒绝授权');
- }
- })
- } else {
- // 用户已经授权,可以直接调用 getUserCloudStorage 方法
- console.error('222用户已经授权,可以调用 getUserCloudStorage 方法');
- }
- }
- })
- }
- }
|