MrShi
2025-04-11 3a45da15c947c2d478a44a51bd0f926647b1b841
company/src/components/business/operaverifyPhoneNumberWindew.vue
@@ -22,80 +22,80 @@
</template>
<script>
    import BaseOpera from '@/components/base/BaseOpera'
    import GlobalWindow from '@/components/common/GlobalWindow'
    import { sendSms, validateCode } from '@/api/business/smsEmail'
    import { mapState } from 'vuex'
    export default {
        name: 'operaverifyPhoneNumberWindew',
        extends: BaseOpera,
        components: { GlobalWindow },
        data () {
            return {
                form: {
                    phone: this.$store.state.userInfo.company.phone,
                    code: ''
                },
                rules: {
                    code: [
                        { required: true, message: '请输入验证码' }
                    ]
                },
                num: 0,
                timer: null
            }
        },
        computed: {
            ...mapState(['userInfo'])
        },
        methods: {
            open (title) {
                this.title = title
                this.num = 0
                clearInterval(this.timer)
                this.timer = null
                this.visible = true
                this.$nextTick(() => {
                    this.$refs.form.resetFields()
                })
            },
            send () {
                sendSms({
                    phone: this.form.phone
                }).then(res => {
                    this.num = 60
                    this.setTime()
                })
            },
            setTime () {
                this.timer = setInterval(() => {
                    if (this.num === 0) {
                        clearInterval(this.timer)
                        this.timer = null
                        return
                    }
                    this.num = this.num - 1
                }, 1000)
            },
            confirm () {
                this.$refs.form.validate((valid) => {
                    if (!valid) {
                        return
                    }
                    this.isWorking = true
                    validateCode({
                        code: this.form.code
                    }).then(res => {
                        this.visible = false
                        this.$tip.apiSuccess('操作成功')
                        this.$emit('success')
                    }).catch(e => {
                        this.$tip.apiFailed(e)
                    }).finally(() => {
                        this.isWorking = false
                    })
                })
            }
        }
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { sendSms, validateCode } from '@/api/business/smsEmail'
import { mapState } from 'vuex'
export default {
  name: 'operaverifyPhoneNumberWindew',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    return {
      form: {
        phone: this.$store.state.userInfo.company? this.$store.state.userInfo.company.phone:null,
        code: ''
      },
      rules: {
        code: [
          { required: true, message: '请输入验证码' }
        ]
      },
      num: 0,
      timer: null
    }
  },
  computed: {
    ...mapState(['userInfo'])
  },
  methods: {
    open (title) {
      this.title = title
      this.num = 0
      clearInterval(this.timer)
      this.timer = null
      this.visible = true
      this.$nextTick(() => {
        this.$refs.form.resetFields()
      })
    },
    send () {
      sendSms({
        phone: this.form.phone
      }).then(res => {
        this.num = 60
        this.setTime()
      })
    },
    setTime () {
      this.timer = setInterval(() => {
        if (this.num === 0) {
          clearInterval(this.timer)
          this.timer = null
          return
        }
        this.num = this.num - 1
      }, 1000)
    },
    confirm () {
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        this.isWorking = true
        validateCode({
          code: this.form.code
        }).then(res => {
          this.visible = false
          this.$tip.apiSuccess('操作成功')
          this.$emit('success')
        }).catch(e => {
          this.$tip.apiFailed(e)
        }).finally(() => {
          this.isWorking = false
        })
      })
    }
  }
}
</script>