<template>
    <view class="random_practice">
        <nav-bar title="随机练习"></nav-bar>
        <view class="contents">
            <view>试卷情况</view>
            <view>本题库共{{ questionNum.totalNum || 0 }}道题，剩余800题，你已做{{ questionNum.doNum || 0}}</view>
            <view class="number_crad">
                <view>选择做题数量</view>
                <view v-for="(item, index) in numberLists" :key="index" class="items" @click="changeNum(item)">
                    {{item}}
                </view>
                <view class="starts" @click="startPractice()">
                    开始做题
                </view>
            </view>
            
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            goodsId: '',
            orderGoodsId: '',
            numberLists: [5, 10, 15, 20, 50, 100],
            number: 5,
            questionNum: {}
        }
    },
    onLoad(option) {
        this.goodsId = option.goodsId
        this.orderGoodsId = option.orderGoodsId
    },
    onShow() {
        this.getQuestionTempNum()
    },
    methods: {
        changeNum(item) {
            console.log(item);
            this.number = item
        },
        getQuestionTempNum() {
            this.$http({
                url: `/goods/bank/questionTempNum/${this.orderGoodsId}`,
                method: 'get',
            }).then((res) => {
                if (res.data.code == 200) {
                    this.questionNum = res.data.data || {}
                }
            })
        },
        startPractice() {
            uni.navigateTo({
                url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=""' + '&goodsid=' + this.goodsId 
                +'&moduleId=0' + '&chapterId=0' + '&entryType=random' + '&bankNum=' + this.number
            })
        }
    },
}
</script>

<style lang="scss">
.number_crad {
    .items {
        margin-bottom: 28rpx;
    }
    .starts {
        width: 646rpx;
        height: 96rpx;
        line-height: 96rpx;
        text-align: center;
        color: #fff;
        font-size: 32rpx;
        font-weight: bold;
        background: #3577E8;
        border-radius: 24rpx;
    }
}
</style>