index.js 449 B

123456789101112131415161718192021222324
  1. import ad from '../index/ad'
  2. ad({
  3. data: {
  4. current: 1,
  5. },
  6. onLoad() {
  7. this.key = Math.floor(Math.random() * 3)
  8. },
  9. onChange(e) {
  10. console.log(e)
  11. if (e.detail.key === this.key) {
  12. return wx.showModal({
  13. title: 'No switching is allowed',
  14. showCancel: !1,
  15. })
  16. }
  17. this.setData({
  18. current: e.detail.key,
  19. })
  20. },
  21. })