Files
wx-h5-demo/miniapp/scenario2-host-page.wxml

20 lines
1.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- 场景2(也是场景1授权后的落地页):web-view 承载 H5 + postMessage 授权 + 回传
用法:本页 <web-view src="{{url}}"> 加载 wx-h5-demo/index.html。
- 场景2:H5 请求授权 → bindmessage 收到 → 弹原生面板 → 授权 → 更新 web-view src(带结果)。
- 场景1:auth-bridge 授权后 redirectTo 本页,本页 onLoad 从 globalData 读结果拼进 H5 url。 -->
<!-- wxml -->
<web-view wx:if="{{url}}" src="{{url}}" bindmessage="onMessage"></web-view>
<view wx:if="{{showAuth}}" class="auth-mask" bindtap="closeAuth">
<view class="auth-panel" catchtap="noop">
<view class="auth-title">授权获取资料</view>
<view class="auth-sub">用于在 wx-h5-demo 中展示昵称/头像/手机号</view>
<button class="auth-btn" open-type="getPhoneNumber" bindgetphonenumber="onPhone">获取手机号</button>
<input class="auth-input" type="nickname" bindblur="onNick" bindchange="onNick" placeholder="输入昵称" />
<button class="auth-btn avatar" open-type="chooseAvatar" bindchooseavatar="onAvatar">
<image wx:if="{{avatar}}" class="auth-avatar" src="{{avatar}}" mode="aspectFill" /><text wx:else>选择头像</text>
</button>
<view class="auth-cancel" bindtap="closeAuth">取消</view>
</view>
</view>