h5页面发送短信并填充带#或者+的链接

h5页面发送短信并填充内容
参考:https://blog.youkuaiyun.com/dhlg123/article/details/126095750

      const visitorPhoneNbr = '159xxxxxx17'
      var u = navigator.userAgent
      var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
      // 安卓写法
      if (isAndroid) {
        // sms:后面跟收件人的手机号,body后接短信内容
        // window.location.href='sms:188XXXXXXXX,134XXXXXXXX?body='+this.msg;
        window.location.href = `sms:${visitorPhoneNbr}?body=${this.link}`
      } else if (isIOS) {
        // ios的写法
        // window.location.href='sms:/open?addresses=134XXXXXXXX,182XXXXXXXX&body='+this.msg;
        window.location.href = `sms:/open?addresses=${visitorPhoneNbr}&body=${this.link}`
      }
 computed: {
    link() {
      return `您好, 来访请点击链接获取通行码 \n${encodeURIComponent(
        window.QR_CODE_LINK_IP
      )}/xxxx/xxxxxxx?key=${encodeURIComponent(
        this.token
      )} \n如果上传人脸,可通过人脸识别进入。\n如果填写车牌,可通过车闸识别进入。`
    }
    }

因为我的填充内容是带链接的,链接会有#和+导致安卓系统短信填充的时候只填充了#前面的内容,加号转成了空格然后链接就不对了,ios系统填充正常;
解决办法将#转为%23,+转为%2B
字符转义https://www.cnblogs.com/eoalfj/p/11607246.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值