123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- const app = getApp()
- const formLayout = {
- fieldId: '101',
- fieldName: '基本信息',
- formInfo: [
- {
- label: '名字',
- type: 'text',
- id: 'input-name-form',
- placeholder: '输入您的姓名',
- data: [],
- role: {
- type: 'reg',
- value: '',
- },
- force: true,
- },
- {
- label: '手机号',
- type: 'text',
- id: 'input-id-form',
- placeholder: '输入您的手机号',
- data: [],
- role: {
- type: 'reg',
- formatter:(v)=>{
- let reg = /^1[3-9]\d{9}$/
- if (!reg.test(v)) return '手机号输入有误'
- return ''
- }
- },
- force: true,
- },
- {
- label: '性别',
- type: 'picker',
- id: 'input-sex-form',
- inputValue:'男',
- placeholder: '输入您的姓名',
- data: [
- { value: 1, label: '男' },
- { value: 2, label: '女' },
- ],
- role: {
- type: 'reg',
- value: '',
- },
- force: false,
- },
- {
- label: '上传',
- type: 'upload',
- id: 'input-sex-form',
- inputValue:'男',
- placeholder: '输入您的姓名',
- data: [
- { value: 1, label: '男' },
- { value: 2, label: '女' },
- ],
- role: {
- type: 'reg',
- value: '',
- },
- force: false,
- },
- {
- label: '选择日期',
- type: 'datepicker',
- id: 'input-sex-form',
- inputValue:(new Date()).toISOString().split('T')[0],
- placeholder: '选择日期',
- role: {
- type: 'reg',
- value: '',
- },
- force: false,
- },
- ]
- }
- Page({
- data: {
- 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'),
- formLayout
- },
-
- bindViewTap() {
- wx.navigateTo({
- url: '../logs/logs'
- })
- },
- onLoad() {
- if (wx.getUserProfile) {
- this.setData({
- canIUseGetUserProfile: true
- })
- }
- },
- getUserProfile(e) {
-
- wx.getUserProfile({
- desc: '展示用户信息',
- success: (res) => {
- console.log(res)
- this.setData({
- userInfo: res.userInfo,
- hasUserInfo: true
- })
- }
- })
- },
- getUserInfo(e) {
-
- console.log(e)
- this.setData({
- userInfo: e.detail.userInfo,
- hasUserInfo: true
- })
- }
- })
|