import C from 'bsl-mp/app/Component'; import { Event } from 'bsl-mp/typings'; import * as Export from './export'; const state = { canIUseGetUserProfile: false }; class Instance extends C { constructor() { super(state, { desc: { type: String, value: '用于完善会员资料' }, type: String }); } public externalClasses = ['wrap-cls']; public options = { styleIsolation: 'apply-shared' }; public ready() { const getUserProfile = wx.getUserProfile as any; if (getUserProfile) { this.setData({ canIUseGetUserProfile: true }); } } public getUserProfile() { // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 wx.getUserProfile({ desc: this.properties.desc, // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 success: (res) => { this.triggerEvent('click', res); }, fail: (err) => { console.error(err); } }); } public getUserInfo(e: Event.Getuserinfo) { // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息 this.triggerEvent('click', e.detail); } } Component(new Instance().init());