小程序模板网

小程序-记牌器

发布时间:2018-09-08 09:41 所属栏目:小程序开发教程

这个想法来自看直播时看主播斗地主时经常由于没有记牌器,判断失误导致输豆,所以做了这个记牌器。估计不会有人用 :laughing:,就当作练手,熟悉小程序的整个开发流程哈哈。 没想到提交第二天就审核通过了

截图

 

思路比较简单只有一个页面

1.可选一副牌或两副牌

2.点击相应牌减少对应牌的数量, 数量为0时该图标变灰

3.可撤销,撤销操作仅保留最近100个点击操作

4.重置操作会清空所有操作记录

开发上选择的是 mpvuempvue.com/

然后直接使用grid布局对卡牌进行排列

<div class="gird-container">
  <div class="gird-item" v-for="(poker, index) in pokers" :key="index">
    <card :poker="poker" :index="index" @handleHuase="handleHuase" @handleWang="handleWang">
    </card>
  </div>
</div>
复制代码

操作方法

// 点击操作
handleHuase (obj) {
// 这里用来记录操作历史
this.updateHistory.push(JSON.parse(JSON.stringify(this.pokers)))
  if (this.pokers[obj.index][obj.huase] > 0) {
    this.pokers[obj.index][obj.huase] -= 1
    this.pokers[obj.index].count -= 1
  } else {
    this.pokers[obj.index][obj.huase] = this.defaultCount
    this.pokers[obj.index].count += 1
  }
}
复制代码
// 撤销操作
rollback () {
  let pokers = this.updateHistory[this.updateHistory.length - 1]
  this.pokers = pokers
  this.updateHistory.pop(this.updateHistory.length - 1)
}
复制代码


易优小程序(企业版)+灵活api+前后代码开源 码云仓库:starfork
本文地址:https://www.eyoucms.com/wxmini/doc/course/24788.html 复制链接 如需定制请联系易优客服咨询:800182392 点击咨询
QQ在线咨询