
cc.Class({
    extends: cc.Component,
    properties: {
    },
    OnActive(event, customEventData)
    {
        if(cc.sys.platform === cc.sys.WECHAT_GAME) {
            this.onSendScoreToWX();
        }
    },
    onSendScoreToWX(){
        let Riches =  Math.floor(Math.random()*100).toString();
        let LV = Math.floor(Math.random()*20).toString();
        wx.setUserCloudStorage({
            KVDataList: [{ key: 'Riches', value:Riches},{ key: 'LV', value:LV}],
            success: res => {
                // console.log(res);
                // 让子域更新当前用户的最高分，因为主域无法得到getUserCloadStorage;
                let openDataContext = wx.getOpenDataContext();
                openDataContext.postMessage({
                    type: 'updateMaxScore',
                    message: cc.sys.localStorage.getItem('nickName'),
            });
            },
            fail: res => {
                console.log('error=',res);
            }
        });
    }
});
