lock.ts:
[JavaScript] 纯文本查看 复制代码 Page({
data:{
shareLocation: false,
avatarURL: '',
},
async onLoad() {
const userInfo = await getApp<IAppOption>().globalData.userInfo
this.setData({
avatarURL: userInfo.avatarUrl,
})
},
onGetUserInfo(e: any) {
const userInfo: WechatMiniprogram.UserInfo = e.detail.userInfo
getApp<IAppOption>().resolveUserInfo(userInfo)
},
})
lock.wxml:
[HTML] 纯文本查看 复制代码 <view class="container">
<view class="static">
<image class="sedan" src="/resources/sedan.png" />
<view class="margin-top">
<view>驾驶安全是用户的责任</view>
<view>请将车辆停放在停车位内</view>
</view>
</view>
<view class="avatar-container">
<button wx:if="{{!avatarURL}}" class="cu-avatar round lg bg-grey margin-xs"
open-type="getUserInfo" bindgetuserinfo="onGetUserInfo">
<text class="cuIcon-people"></text>
</button>
<view wx:if="{{avatarURL}}" class="switch-container">
<image class="cu-avatar round lg bg-grey margin-xs"
src="{{avatarURL}}"/>
<switch bindchange="onShareLocation" checked="{{shareLocation}}" />
</view>
<view class="margin-top">实时展示我的头像</view>
</view>
<button style="width:80%" class="bg-grey lg" bindtap="onUnlockTap">立即开锁</button>
</view>
贴一下代码 大佬帮我改改吧 |