這個(gè)想法來自看直播時(shí)看主播斗地主時(shí)經(jīng)常由于沒有記牌器,判斷失誤導(dǎo)致輸豆,所以做了這個(gè)記牌器。估計(jì)不會有人用 :laughing:,就當(dāng)作練手,熟悉小程序的整個(gè)開發(fā)流程哈哈。 沒想到提交第二天就審核通過了
截圖
思路比較簡單只有一個(gè)頁面
1.可選一副牌或兩副牌
2.點(diǎn)擊相應(yīng)牌減少對應(yīng)牌的數(shù)量, 數(shù)量為0時(shí)該圖標(biāo)變灰
3.可撤銷,撤銷操作僅保留最近100個(gè)點(diǎn)擊操作
4.重置操作會清空所有操作記錄
開發(fā)上選擇的是 mpvuempvue.com/
然后直接使用grid布局對卡牌進(jìn)行排列
<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>
復(fù)制代碼
|
操作方法
// 點(diǎn)擊操作
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
}
}
復(fù)制代碼
|
// 撤銷操作
rollback () {
let pokers = this.updateHistory[this.updateHistory.length - 1]
this.pokers = pokers
this.updateHistory.pop(this.updateHistory.length - 1)
}
復(fù)制代碼
|