EnableWallet.js 1.37 KB
// pages/Login/components/EnableWallet/EnableWallet.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean
    },
    walletObj: {
      type: Object,
      value: {}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    stepDataArr: [{
      icon: 'wallet-icon-1',
      label: '开通钱包',
      tips: '一站式积分管理体验'
    }, {
      icon: 'wallet-icon-2',
      label: '查询积分',
      tips: '您的第一笔可用积分',
      pointsFlag: true
    }, {
      icon: 'wallet-icon-3',
      label: '积分随心用',
      tips: '兑换商品/分享亲友/话费充值, 想怎么用就怎么用!'
    }]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 关闭弹窗
    closeWallet() {
      this.triggerEvent('close')
    },
    input(e) {
      let { target } = e.currentTarget.dataset
      let { value } = e.detail
      value = target == 'phone' ? value.replace(/[^0-9]/g, '') : value
      this.setData({
        [`walletObj.${target}`]: value
      })
    },
    // 开通
    confirm() {
      let { walletObj } = this.data
      if (!walletObj?.name) return wx.p.wxApi.showToast('姓名不能为空')
      if (!walletObj?.phone || !/^[1]([3-9])[0-9]{9}$/.test(walletObj?.phone)) return wx.p.wxApi.showToast('请输入正确手机号')
      this.triggerEvent('confirm', {walletObj})
    }
  }
})