最近在买双色球,据说流言头奖中奖号码是这一期所有号码组合中注数起码的一个,基于大部分人都是机选买彩票,所以写了代码如下模仿彩票抽奖后果。
图个乐子,早上下班跑起来,上班看下后果再去买,哈哈
代码如下

<template>  <div class="detail-page-box">    <span> {{ count }} </span>    <button @click="alertResult">点我进行,并计算</button>  </div></template><script lang="ts">import { Component, Vue, Watch, Prop } from "vue-property-decorator";import { Search, Toast } from "vant";let timer: any;@Component({  components: {    "van-search": Search,  },})export default class CardItem extends Vue {  @Prop() boxWidth: any;  @Prop({ default: false }) ifShowCancel!: boolean;  count: number = 0;  allList: any = {};  guess() {    this.count++;    let str = "";    let numEdList: any = [];    for (let i = 0; i < 7; i++) {      if (i < 6) {        let randomNum:any = Math.floor(Math.random() * 35 + 1);        while (numEdList.includes(randomNum)) {          randomNum = Math.floor(Math.random() * 35 + 1);        }        if (randomNum < 10) {          str +=" "+ "0" + randomNum;        } else {          str +=" "+ randomNum;        }        numEdList.push(randomNum);      } else {        let randomNum = Math.floor(Math.random() * 15 + 1);        if (randomNum < 10) {          str +=" "+ "0" + randomNum;        } else {          str +=" "+ randomNum;        }      }    }    if (!this.allList[str]) {      this.allList[str] = 1;    } else {      this.allList[str]++;    }  }  alertResult() {    let minCombination: any = "";    let minNum: number = 0;    clearInterval(timer);    Object.keys(this.allList).forEach((item, index) => {      if (index === 0) {        minNum = this.allList[item];        minCombination = item;      } else {        if (minNum > this.allList[item]) {          minNum = this.allList[item];          minCombination = item;        }      }    });    alert(`最小注数为:` + minNum + `号码组合为:` + minCombination);  }  created() {    timer = setInterval(this.guess, 500);  }}</script><style lang="less" scoped>.detail-page-box {  text-align: center;  line-height: 100px;}</style>

效果图比拟简陋如下

以及点击后果后图片如下,最初一个号码为蓝球,前六个为红球