Przeglądaj źródła

my-profile page

邹能昇 6 dni temu
rodzic
commit
f07934fccf

+ 2 - 1
app.json

@@ -18,7 +18,8 @@
                 "pages/home/sport/sport-home/index",
                 "pages/home/sport/sport-start/index",
                 "pages/home/statistics/index",
-                "pages/home/integral/index"
+                "pages/home/integral/index",
+                "pages/my/my-profile/index"
             ]
         },
         {

+ 25 - 3
nova-werun/components/my/index.js

@@ -21,7 +21,8 @@ Component({
         contentHeight: 0, // 可用内容高度
         contentpadding: 0, //顶部padding高度
 
-        circlecount: 0
+        circlecount: 0,
+        User1List:[]
     },
     lifetimes: {
 
@@ -49,6 +50,7 @@ Component({
                 contentpadding
             });
             this.getcircle()
+            this.getname()
         },
     },
 
@@ -90,7 +92,27 @@ Component({
         },
         //查看积分
         async getpoint(){
-            
-        }
+
+        },
+        //获取头像名称
+        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
+            })
+            console.log(this.data.User1List);
+        },
+        gourl(e) {
+            const url = e.currentTarget.dataset.url
+            wx.navigateTo({
+                url: `${url}`// 目标页面的路径
+            });
+        },
     }
 })

+ 3 - 3
nova-werun/components/my/index.less

@@ -6,15 +6,15 @@
         width: 100%;
         height: 270rpx;
         background-color: #87ceeb;
-        padding: 20rpx;
+        padding-top: 20rpx;
         display: flex;
         position: relative;
         margin-bottom: 80rpx;
+        padding-left: 5%;
         .avatar{
             width: 130rpx;
             height: 130rpx;
-            border-radius: 15rpx;
-            background-color: red;
+            border-radius: 20rpx;
         }
         .namebox{
             width: 200rpx;

+ 3 - 3
nova-werun/components/my/index.wxml

@@ -2,10 +2,10 @@
 <nav type="title"  background-color="{{'#87ceeb'}}" front-color="{{'#ffffff'}}"></nav>
 <view class="all" style="height: {{contentHeight}}rpx;">
     <view class="perxonalbox">
-        <image class="avatar" src="https://file-cloud.fmode.cn/qpFbRRSZrO/20241111/je1q5i052857833.png?imageView2/1/w/200/h/200" mode="scaleToFill"></image>
+        <image class="avatar" src="{{User1List[0].avatar||'https://file-cloud.fmode.cn/qpFbRRSZrO/20241120/63c55i022235020.png?imageView2/1/w/200/h/200'}}" mode="scaleToFill"></image>
         <view class="namebox">
-            <view class="name">微信用户</view>
-            <view class="databox">
+            <view class="name">{{User1List[0].nickname}}</view>
+            <view class="databox" data-url="../../pages/my/my-profile/index" bindtap="gourl">
                 <view class="data">完善资料</view>
                 <image src="https://file-cloud.fmode.cn/qpFbRRSZrO/20241120/1ssc1a102512989.png?imageView2/1/w/200/h/200"></image>
             </view>

+ 1 - 1
nova-werun/components/my/index.wxss

@@ -1 +1 @@
-.all{width:100vw;background-color:#e6e6e6}.all .perxonalbox{width:100%;height:270rpx;background-color:#87ceeb;padding:20rpx;display:flex;position:relative;margin-bottom:80rpx}.all .perxonalbox .avatar{width:130rpx;height:130rpx;border-radius:15rpx;background-color:red}.all .perxonalbox .namebox{width:200rpx;height:130rpx;display:flex;justify-content:center;flex-direction:column;margin-left:20rpx}.all .perxonalbox .namebox .name{font-size:34rpx}.all .perxonalbox .namebox .databox{width:100%;height:40rpx;display:flex;color:#d81e06;margin-top:10rpx;align-items:center}.all .perxonalbox .namebox .databox .data{font-size:28rpx}.all .perxonalbox .namebox .databox image{width:30rpx;height:30rpx;margin-left:10rpx}.all .perxonalbox .infobox{width:90%;height:130rpx;display:flex;justify-content:center;align-items:center;background-color:white;position:absolute;left:5%;bottom:-66rpx;border-radius:20rpx}.all .perxonalbox .infobox .info{width:120rpx;height:100rpx;display:flex;justify-content:center;align-items:center;flex-direction:column;margin-left:10rpx;margin-right:10rpx}.all .perxonalbox .infobox .info .info-num{font-size:30rpx}.all .perxonalbox .infobox .info .info-tex{font-size:28rpx;color:gray;margin-top:10rpx}
+.all{width:100vw;background-color:#e6e6e6}.all .perxonalbox{width:100%;height:270rpx;background-color:#87ceeb;padding-top:20rpx;display:flex;position:relative;margin-bottom:80rpx;padding-left:5%}.all .perxonalbox .avatar{width:130rpx;height:130rpx;border-radius:20rpx}.all .perxonalbox .namebox{width:200rpx;height:130rpx;display:flex;justify-content:center;flex-direction:column;margin-left:20rpx}.all .perxonalbox .namebox .name{font-size:34rpx}.all .perxonalbox .namebox .databox{width:100%;height:40rpx;display:flex;color:#d81e06;margin-top:10rpx;align-items:center}.all .perxonalbox .namebox .databox .data{font-size:28rpx}.all .perxonalbox .namebox .databox image{width:30rpx;height:30rpx;margin-left:10rpx}.all .perxonalbox .infobox{width:90%;height:130rpx;display:flex;justify-content:center;align-items:center;background-color:white;position:absolute;left:5%;bottom:-66rpx;border-radius:20rpx}.all .perxonalbox .infobox .info{width:120rpx;height:100rpx;display:flex;justify-content:center;align-items:center;flex-direction:column;margin-left:10rpx;margin-right:10rpx}.all .perxonalbox .infobox .info .info-num{font-size:30rpx}.all .perxonalbox .infobox .info .info-tex{font-size:28rpx;color:gray;margin-top:10rpx}

+ 157 - 0
nova-werun/pages/my/my-profile/index.js

@@ -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
+        })
+    },
+
+})

+ 6 - 0
nova-werun/pages/my/my-profile/index.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "van-field": "@vant/weapp/field/index",
+    "van-action-sheet": "@vant/weapp/action-sheet/index"
+  }
+}

+ 48 - 0
nova-werun/pages/my/my-profile/index.less

@@ -0,0 +1,48 @@
+/* nova-werun/pages/my/my-profile/index.wxss */
+.all{
+    width: 100vw;
+    .avatarbox{
+        width: 100%;
+        height: 270rpx;
+        background-color: #87ceeb;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        .avatar-box{
+            width: 150rpx;
+            height: 150rpx;
+            position: relative;
+            .avatar{
+                width: 150rpx;
+                height: 150rpx;
+                border-radius: 50%;
+            }
+            .photo{
+                width: 60rpx;
+                height: 60rpx;
+                position: absolute;
+                right: -15rpx;
+                bottom: -18rpx;
+            }
+        }
+    }
+    .submitbox{
+        width: 100%;
+        height: 80rpx;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        margin-top: 40rpx;
+        .submit{
+            width: 200rpx;
+            height: 80rpx;
+            font-size: 30rpx;
+            color: white;
+            background-color: #87ceeb;
+            display: flex;
+            justify-content: center;
+            align-items: center;
+            border-radius: 40rpx;
+        }
+    }
+}

+ 19 - 0
nova-werun/pages/my/my-profile/index.wxml

@@ -0,0 +1,19 @@
+<!--nova-werun/pages/my/my-profile/index.wxml-->
+<nav type="back" title="完善资料" background-color="{{'#87ceeb'}}" front-color="{{'#ffffff'}}"></nav>
+<view class="all" style="height: {{contentHeight}}rpx;">
+    <view class="avatarbox">
+        <view class="avatar-box">
+            <image class="avatar" src="{{avatar||'https://file-cloud.fmode.cn/qpFbRRSZrO/20241120/63c55i022235020.png?imageView2/1/w/200/h/200'}}" mode="scaleToFill"></image>
+            <image class="photo" src="https://file-cloud.fmode.cn/qpFbRRSZrO/20241120/95uip6030022742.png?imageView2/1/w/200/h/200"></image>
+        </view>
+
+    </view>
+    <van-field value="{{ nickname }}" required clearable label="昵称"  placeholder="请输入昵称" bind:click-icon="onClickIcon" />
+    <van-field class="field" required model:value="{{ sex }}" readonly maxlength="1" label="性别"  bind:tap="showSelect" />
+    <van-field value="{{ height }}" required  clearable  label="身高" type="number"   placeholder="请输入身高" bind:blur="getHeight" />
+    <van-action-sheet show="{{ show2 }}"  actions="{{ actions }}" bind:select="onSelect" />
+
+    <view class="submitbox">
+        <view class="submit">提交</view>
+    </view>
+</view>

+ 1 - 0
nova-werun/pages/my/my-profile/index.wxss

@@ -0,0 +1 @@
+.all{width:100vw}.all .avatarbox{width:100%;height:270rpx;background-color:#87ceeb;display:flex;justify-content:center;align-items:center}.all .avatarbox .avatar-box{width:150rpx;height:150rpx;position:relative}.all .avatarbox .avatar-box .avatar{width:150rpx;height:150rpx;border-radius:50%}.all .avatarbox .avatar-box .photo{width:60rpx;height:60rpx;position:absolute;right:-15rpx;bottom:-18rpx}.all .submitbox{width:100%;height:80rpx;display:flex;justify-content:center;align-items:center;margin-top:40rpx}.all .submitbox .submit{width:200rpx;height:80rpx;font-size:30rpx;color:white;background-color:#87ceeb;display:flex;justify-content:center;align-items:center;border-radius:40rpx}

+ 6 - 0
project.private.config.json

@@ -75,6 +75,12 @@
                     "pathName": "nova-werun/pages/home/statistics/index",
                     "query": "",
                     "scene": null
+                },
+                {
+                    "name": "完善资料",
+                    "pathName": "nova-werun/pages/my/my-profile/index",
+                    "query": "",
+                    "scene": null
                 }
             ]
         }