|
@@ -0,0 +1,157 @@
|
|
|
+// 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
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+})
|