forked from gzzfw/frontEnd/gzDyh

zhangyongtian
2024-09-13 cf88306b1f6aade9f0c6c4fa5859872d3f177c4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-06-06 15:33:48
 * @LastEditTime: 2022-06-15 17:10:03
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description:
 */
// pages/me/index.js
const $$ = require('../../utils/util');
 
// 获取用户信息
function getUserInfoApi() {
    return $$.request({ url: 'paUser/personal', type: 'get', service: 'cust' });
}
 
Page({
    /**
     * 页面的初始数据
     */
    data: {
        imgUrl: $$.url.img, // icon图片地址
        userInfo: {}, // 用户信息
    },
 
    // 点击完善资料
    handleGo() {
        let visible = this.data.userInfo.realStatus === '1';
        wx.navigateTo({ url: visible ? '../../pages/perfectInformation/index?type=improvedata' : '../../pages/perfectInformation/index' });
    },
 
    // 退出登录
    handleLoginOut() {
        $$.showModal({
            content: '是否确认退出登录?',
            success: (res) => {
                if (res.confirm) {
                    $$.loginOutClearData();
                    $$.showToast('已退出登录');
                    wx.reLaunch({
                        url: '../../pages/homePage/index',
                    });
                }
            },
        });
    },
 
    // 获取用户信息
    async getUserInfo() {
        $$.showLoading();
        const res = await getUserInfoApi();
        $$.hideLoading();
        if (res.type) {
            this.setData({ userInfo: res.data });
        }
    },
 
    onLoad: function () {
        this.getUserInfo();
    },
});