在支付宝小程序的各种运营场景中,我们的运营同学会配置多种不同的链接,有发送短信召回用户的、有服务直达的,有跟第三方对接,第三方app引流跳转到我们小程序的等等等等。这篇文章主要内容是跟大家分享下如何生成这类型的链接。
如果你能访问到该小程序具体页面并且能进行分享操作:
- 访问该页面点击右上角分享,可以看到分享面板最后有一个复制链接。复制后可以看到是这样的一个短链接:https://ur.alipay.com/3ufcLe,访问后可以在浏览器地址栏得到这样的地址:
- https://render.alipay.com/p/s/i/?scheme=alipays%3A%2F%2Fplatformapi%2Fstartapp%3FappId%3D2018082861168647%26page%3D%252Fpages%252Fwebview%252Fwebview%253FtargetUrl%253Dhttps%25253A%25252F%25252Fm.qtshe.com%25252Fapp%25252Fdunhuang%2526shareTitle%253D%2525E9%25259D%252592%2525E5%25259B%2525A2%2525E7%2525A4%2525BE%2525E5%252585%2525BC%2525E8%252581%25258C%2526timestamp%253D1615966764158%2526deviceId%253Dundefined%2526_um_ssrc%253D%252BOJJyXK1ieB%252FILhAzUx85wUeM5beiPfL7xY3YhPy2NA%253D%2526_um_sts%253D1615966764174%26enbsv%3D0.2.2103161952.58%26chInfo%3Dch_share__chsub_CopyLink。
- 双重decode后我们可以拿到scheme地址:
decodeURIComponent(decodeURIComponent('https://render.alipay.com/p/s/i/?scheme=alipays%3A%2F%2Fplatformapi%2Fstartapp%3FappId%3D2018082861168647%26page%3D%252Fpages%252Fwebview%252Fwebview%253FtargetUrl%253Dhttps%25253A%25252F%25252Fm.qtshe.com%25252Fapp%25252Fdunhuang%2526shareTitle%253D%2525E9%25259D%252592%2525E5%25259B%2525A2%2525E7%2525A4%2525BE%2525E5%252585%2525BC%2525E8%252581%25258C%2526timestamp%253D1615966764158%2526deviceId%253Dundefined%2526_um_ssrc%253D%252BOJJyXK1ieB%252FILhAzUx85wUeM5beiPfL7xY3YhPy2NA%253D%2526_um_sts%253D1615966764174%26enbsv%3D0.2.2103161952.58%26chInfo%3Dch_share__chsub_CopyLink'))
结果如下:
https://render.alipay.com/p/s/i/?scheme=alipays://platformapi/startapp?appId=2018082861168647&page=/pages/webview/webview?targetUrl=https%3A%2F%2Fm.qtshe.com%2Fapp%2Fdunhuang&shareTitle=%E9%9D%92%E5%9B%A2%E7%A4%BE%E5%85%BC%E8%81%8C×tamp=1615966764158&deviceId=undefined&_um_ssrc=+OJJyXK1ieB/ILhAzUx85wUeM5beiPfL7xY3YhPy2NA=&_um_sts=1615966764174&enbsv=0.2.2103161952.58&chInfo=ch_share__chsub_CopyLink // 拿到有用的信息如下,可以直接访问文章结尾链接进行你的scheme地址拼接: query:'targetUrl=https%3A%2F%2Fm.qtshe.com%2Fapp%2Fdunhuang' path:'/pages/webview/webview' appId:'2018082861168647'
如果你不能访问该小程序具体页面(即您知道该页面参数情况):
- 需要这样进行拼接:
query:'partJobId=123456' path:'pages/partdetails/partdetails' appId:'2018082861168647' scheme:`alipays://platformapi/startapp?appId=${你的appId}&page=${你的path}&query=encodeURIComponent(${你的query参数})` 生成链接:'https://ds.alipay.com/?scheme=${encodeURIComponent(scheme)}'
最后我们拼接后得到以下可以进行外部访问的链接地址:
https://ds.alipay.com/?scheme=alipays%3A%2F%2Fplatformapi%2Fstartapp%3FappId%3D2018082861168647%26page%3Dpages%2Fpartdetails%2Fpartdetails%26query%3DpartJobId%253D123456
不是开发的童鞋可能看不懂哈,没关系,访问下面链接直接找你们的开发童鞋要到链接和参数即可生成。