import Vue from 'vue'
import lib from 'lib'

let uid = lib.getParam("uid"),token = lib.getParam("token")

export default {
    data() {
        return {
            timeline : 0,
            isloading : false,
            nextFlag : 1,
            records : [],
            isloading : false,
            nextFlag : 1
        };
    },
    mounted () {
        lib.setTitle("获奖记录");

        this.getBonusList()
    },
    methods: {
        //获奖记录
        getBonusList(){
            let self = this
            let url = `${lib.apiUrl}/share/bonusList.do`
            
            let param = {
                count : 20,
                timeline : self.timeline,
                channel : "LuciferChannel",
                ver : 1,
                os : 1,
                uid : uid || 1,
                token : token || "lucifer_test_token"
            }

            self.isloading = true
            $.ajax({
                type: "get",
                url: url,
                data: param,
                dataType: "jsonp",

                success: function(ret) {
                    ret = lib.formatHttpProtocol(ret);

                    self.isloading = false
                    if(ret.code == 0) {
                        let data = ret.data

                        self.nextFlag = data.next
                        self.timeline = data.timeline
                        if(data.records) self.records = self.records.concat(data.records)
                    } else {
                        self.nextFlag = 0
                        lib.showDialog(ret.msg)
                    }
                }
            })
        }
    },
    filters : {
        parseReleaseDate(value){
            return lib.handleTime(value,2)
        }
    }
};