// Learn cc.Class: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html // Learn Attribute: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { // foo: { // // ATTRIBUTES: // default: null, // The default value will be used only when the component attaching // // to a node for the first time // type: cc.SpriteFrame, // optional, default is typeof default // serializable: true, // optional, default is true // }, // bar: { // get () { // return this._bar; // }, // set (value) { // this._bar = value; // } // }, scoreLabel:cc.Label, content:cc.Node, products:null, selectedPosition:0, }, // LIFE-CYCLE CALLBACKS: onEnable () { this.getArrows(Global.user); this.scoreLabel.string = Global.user.score; }, getArrows(userInfo){ wx.request({ url:Global.storeUrl, data:{ token:userInfo.token, uid:userInfo.uid, channel:Global.channel, os:Global.os, ver:Global.ver, type:2 }, success:(response)=>{ if(response.data.code==-5){ wx.showToast({ title:'登录过期' }) Global.showLoginPage = true; cc.director.loadScene('MainMenu'); } this.products = response.data.data.products; let user = response.data.data.user; Global.user.score = user.score; this.scoreLabel.string = user.score; if(this.products!=undefined){ for(let i =0;i{ if(res.confirm){ wx.showLoading(); this.buySkin(product,position); } } }) }else{ wx.showToast({ title:'分数不够,继续努力吧!', icon:null }) } } }, selectItem(position){ let product = this.products[position]; Global.arrowSkinId = product.id; Global.arrowSkinIndex = position; wx.setStorage({ key:"skinId", data:{ bottleSkinId:Global.bottleSkinId, arrowSkinId:Global.arrowSkinId, bottleSkinIndex:Global.bottleSkinIndex, arrowSkinIndex:Global.arrowSkinIndex } }) for(let i =0;i{ if(response.data.code==-5){ wx.showToast({ title:'登录过期' }) Global.showLoginPage = true; cc.director.loadScene('MainMenu'); } if(response.data.code==0||response.data.code==-5101){ let data = response.data.data; skinItem.setUnLock(); this.selectItem(position); wx.showToast({ title:'解锁成功', icon:null }) }else{ console.log(response.data.msg); } }, complete:()=>{ wx.hideLoading(); } }) } // update (dt) {}, });