// componets/loading/index.js.js
let styleList = []
let bg = '#edf0f7'
for (var i = 0; i <= 35; i++) {
    if (i <= 8) {
        bg = '#edf0f7'
    } else if (i > 8 && i <= 16) {
        bg = '#d5dbe9'
    } else if (i > 16 && i <= 24) {
        bg = '#677ab4'
    } else if (i > 24 && i <= 35) {
        bg = '#304999'
    }
    styleList.push({
        'transform': i * 10 + 'deg',
        'bg': bg
    })
}

let timer
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        show: {
            type: Boolean,
            default: false
        },
        msg: {
            type: String,
            default: ''
        },
        speed: {
            type: Number,
            default: 1000
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        styleList: styleList
    },

    created() {
        this.setData({
            styleList: styleList
        })
        this.loading()
    },
    attached() {},


    /**
     * 组件的方法列表
     */
    methods: {
        loading() {
            // console.log(this.properties.speed)
            let index = 0
            timer = setInterval(() => {
                var item = 'styleList[' + index + '].bg'
                if (index <= 36) {
                    this.setData({
                        [item]: 'white'
                    })
                    index += 1
                } else {
                    clearInterval(timer)
                }

            }, 100);

        },
        stop() {
            clearInterval(timer)
        }
    }
})