123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- // nova-werun/pages/my/my-profile/index.js
- const Parse = getApp().Parse;
- const company = getApp().globalData.company;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- //屏幕高度
- statusBarHeight: 0, // 状态栏高度
- screenHeight: 0, // 屏幕高度
- customHeight: 0, // 自定义导航栏高度(如小程序右上角胶囊按钮)
- bottomNavHeight: 0, // 底部导航栏高度
- contentHeight: 0, // 可用内容高度
- contentpadding: 0, //顶部padding高度
- User1List: [],
- actions: [{
- name: '男',
- },
- {
- name: '女',
- },
- ],
- avatar:null,
- sex:'男',
- nickname:null,
- height: null,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // 计算
- const systemInfo = wx.getSystemInfoSync();
- const statusBarHeight = systemInfo.statusBarHeight || 0;
- const screenHeight = systemInfo.screenHeight || 0;
- const custom = wx.getMenuButtonBoundingClientRect();
- const customHeight = custom.height + 10 + 2 || 0;
- const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
- const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
- const contentHeight = (screenHeight - bottomNavHeight - 50 - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
- this.setData({
- statusBarHeight,
- screenHeight,
- customHeight,
- bottomNavHeight,
- contentHeight,
- contentpadding
- });
- this.getname()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- //获取身高
- getHeight(e) {
- let height = e.detail.value;
- // 身高范围在 50 到 250 之间的正则表达式,允许浮点数
- let a = /^(?:[5-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|250)(\.\d)?$/;
- if (!height.match(a)) {
- wx.showToast({
- icon: "none",
- title: "请填写正确的身高格式",
- });
- return;
- } else {
- this.setData({
- height: height
- });
- console.log(this.data.height);
- }
- },
- //获取头像名称
- async getname() {
- const currentUser = Parse.User.current();
- let Userquery = new Parse.Query('_User');
- Userquery.equalTo('company', company);
- Userquery.equalTo('objectId', currentUser.id);
- Userquery.notEqualTo('isDeleted', true)
- let P2 = await Userquery.find();
- let User1List = P2.map(item => item.toJSON());
- this.setData({
- User1List
- })
- this.setData({
- avatar:User1List[0].avatar,
- nickname:User1List[0].nickname,
- sex:User1List[0].sex||'男',
- })
- console.log(this.data.User1List);
- },
- onSelect(event) {
- console.log(event.detail);
- let {
- name
- } = event.detail
- this.setData({
- sex : name,
- show2: false
- })
- },
- showSelect() {
- this.setData({
- show2: true
- })
- },
- })
|