|
|
// index.js
|
|
|
// 获取应用实例
|
|
|
const app = getApp()
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
pages:[
|
|
|
{
|
|
|
type:'视图容器',
|
|
|
pages:[
|
|
|
{title:'view组件',url: "../test/view"},
|
|
|
{title:'scroll-view组件',url: "../test/scrollview"},
|
|
|
{title:'swiper组件',url: "../test/swiper"},
|
|
|
{title:'movable-view组件',url: "../test/moveable-view"},
|
|
|
{title:'cover-view组件',url: "../test/cover-view"}
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
type:'基础内容',
|
|
|
pages:[
|
|
|
{title:'text组件',url: "../test/text"},
|
|
|
{title:'rich-text组件',url: "../test/rich-text"},
|
|
|
{title:'icon组件',url: "../test/icon"},
|
|
|
{title:'progress组件',url: "../test/progress"}
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
type:'表单',
|
|
|
pages:[
|
|
|
{title:'button组件',url: "../test/button"},
|
|
|
{title:'checkbox组件',url: "../test/checkbox"},
|
|
|
{title:'input组件',url: "../test/input"},
|
|
|
{title:'form组件',url: "../test/form"},
|
|
|
{title:'picker组件',url: "../test/picker"},
|
|
|
{title:'picker-view组件',url: "../test/picker-view"},
|
|
|
{title:'radio组件',url: "../test/radio"},
|
|
|
{title:'slider组件',url: "../test/slider"},
|
|
|
{title:'switch组件',url: "../test/switch"},
|
|
|
{title:'textarea组件',url: "../test/textarea"}
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
type:'媒体组件',
|
|
|
pages:[
|
|
|
{title:'audio组件',url: "../test/audio"},
|
|
|
{title:'image组件',url: "../test/image"},
|
|
|
{title:'vedio组件',url: "../test/vedio"},
|
|
|
{title:'camera组件',url: "../test/camera"}
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
motto: 'Hello World',
|
|
|
userInfo: {},
|
|
|
hasUserInfo: false,
|
|
|
canIUse: wx.canIUse('button.open-type.getUserInfo'),
|
|
|
canIUseGetUserProfile: false,
|
|
|
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
|
|
|
},
|
|
|
// 事件处理函数
|
|
|
bindViewTap() {
|
|
|
wx.navigateTo({
|
|
|
url: '../logs/logs'
|
|
|
})
|
|
|
},
|
|
|
onLoad() {
|
|
|
if (wx.getUserProfile) {
|
|
|
this.setData({
|
|
|
canIUseGetUserProfile: true
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
getUserProfile(e) {
|
|
|
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
|
|
|
wx.getUserProfile({
|
|
|
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
|
|
success: (res) => {
|
|
|
console.log(res)
|
|
|
this.setData({
|
|
|
userInfo: res.userInfo,
|
|
|
hasUserInfo: true
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
getUserInfo(e) {
|
|
|
// 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
|
|
|
console.log(e)
|
|
|
this.setData({
|
|
|
userInfo: e.detail.userInfo,
|
|
|
hasUserInfo: true
|
|
|
})
|
|
|
}
|
|
|
})
|