<template>
  <div>
    <input v-model='content' placeholder='请输入短信内容'/>
    <input v-model='phone' placeholder='请输入联系人手机号'/>
    <button @click='sendSMS'>发送短信</button>
  </div>
</template>
<script>
export default {
  data() {
    return {
      content: '',
      phone: ''
    }
  },
  methods: {
    sendSMS() {
      uni.showModal({
        title: '提示',
        content: '确定发送短信吗?',
        success: (res) => {
          if (res.confirm) {
            uni.request({
              url: 'https://sms-api.com/send',
              method: 'POST',
              data: {
                content: this.content,
                phone: this.phone
              },
              success: (res) => {
                uni.showToast({
                  title: '短信发送成功',
                  icon: 'success'
                })
              },
              fail: (err) => {
                uni.showToast({
                  title: '短信发送失败',
                  icon: 'none'
                })
              }
            })
          }
        }
      })
    }
  }
}
</script>

原文地址: https://www.cveoy.top/t/topic/g5sR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录