12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import { _decorator, Component, Label, Node, Sprite } from 'cc';
- import { base_ui } from '../../fw/base_ui';
- import { sign_reward_data } from '../../data';
- import { tools } from '../../tools';
- import { http } from '../../http';
- import { config } from '../../config';
- import { GameManager } from '../../GameManager';
- const { ccclass, property } = _decorator;
- @ccclass('sign_receive_reward')
- export class sign_receive_reward extends base_ui {
- @property(Node) public_bg:Node = null
- @property(Node) img_icon:Node = null
- @property(Node) lab_name:Node = null
- @property(Node) lab_count:Node = null
- @property(Node) btn_receive:Node = null
- @property(Node) btn_double:Node = null
- private m_data:sign_reward_data = null
- private m_cb = null
- start() {
- this.onButtonListen(this.public_bg, ()=>{
- this.node.active = false
- })
- this.onButtonListen(this.btn_receive, ()=>{
- this.requestUserSign(false)
- })
- this.onButtonListen(this.btn_double, ()=>{
- GameManager.showVideoAd(config.ADS_TYPE.GAME_SIGN_DOUBLE, (res)=>{
- this.requestUserSign(true)
- })
- })
- }
- initView(data:sign_reward_data, cb) {
- this.m_data = data
- this.m_cb = cb
- tools.loadRemoteImg(data.icon, (d)=>{
- this.img_icon.getComponent(Sprite).spriteFrame = d.sf
- })
- this.lab_name.getComponent(Label).string = data.name
- this.lab_count.getComponent(Label).string = `x${data.quantity}`
- }
- private requestUserSign(is_double:boolean) {
- let stype = 1
- if(is_double) {
- stype = 2
- }
- let opt = {'index':this.m_data.index, 'stype': stype}
- http.post(config.API.user_sign, opt, (err,d)=>{
- if(!err){
- let nd = JSON.parse(d)
- if(nd.code === config.status.SUCCESS){
- // console.log("user_sign", nd.content)
- this.m_cb()
- }
- }
- })
- }
- }
|