index.js
5.2 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
"use strict";
var common_vendor = require("../../common/vendor.js");
var pages_api_my = require("../api/my.js");
var utils_index = require("../../utils/index.js");
require("../../utils/request.js");
require("../../utils/env.js");
require("../api/login.js");
const _sfc_main = {
__name: "index",
setup(__props) {
const token = common_vendor.ref();
const sexList = common_vendor.reactive(["\u5973", "\u7537"]);
let nickName = common_vendor.ref("");
let avatarUrl = common_vendor.ref("");
let startDate = common_vendor.ref();
let endDate = common_vendor.ref();
let idCard = common_vendor.ref("");
let name = common_vendor.ref("");
let sex = common_vendor.ref(1);
let birthday = common_vendor.ref("1995-09-01");
const isRealNameAuth = common_vendor.ref(false);
common_vendor.onShow(() => {
startDate.value = getDate("start");
endDate.value = getDate("end");
nickName.value = common_vendor.index.getStorageSync("nickName") || "\u795E\u9886\u7528\u6237";
avatarUrl.value = common_vendor.index.getStorageSync("avatarUrl") || "../../static/defaultHeadImg.png";
token.value = common_vendor.index.getStorageSync("token");
baseUserInfo();
});
const handleLogout = () => {
common_vendor.index.removeStorageSync("token");
common_vendor.index.removeStorageSync("nickName");
common_vendor.index.removeStorageSync("avatarUrl");
common_vendor.index.switchTab({
url: "/pages/index/index"
});
};
const baseUserInfo = () => {
pages_api_my.getUserInfo().then((res) => {
if (res) {
isRealNameAuth.value = Boolean(res.data.idCardNoVerify);
idCard.value = res.data.idCardNo || "";
name.value = res.data.name;
sex.value = res.data.sex;
birthday.value = res.data.birthday;
nickName.value = res.data.phone;
common_vendor.index.setStorageSync("nickName", res.data.phone);
}
});
};
const getDate = (type) => {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === "start") {
year = year - 60;
} else {
year = year + 2;
}
month = month > 9 ? month : "0" + month;
day = day > 9 ? day : "0" + day;
return `${year}-${month}-${day}`;
};
const toLogin = () => {
if (common_vendor.index.getStorageSync("token")) {
getUserInfoFunc();
} else {
common_vendor.index.navigateTo({
url: "/pages/login/index"
});
}
};
const handleToAddress = () => {
common_vendor.index.navigateTo({
url: common_vendor.index.getStorageSync("token") ? "/pages/address/index?type=address&isFromAddress=true" : "/pages/login/index"
});
};
const handleTorealName = () => {
if (!common_vendor.index.getStorageSync("token")) {
return common_vendor.index.navigateTo({
url: "/pages/login/index"
});
}
if (isRealNameAuth.value) {
common_vendor.index.navigateTo({
url: "/subPages/authentication-success/index?name=" + name.value + "&idCard=" + idCard.value
});
} else {
common_vendor.index.navigateTo({
url: "/subPages/realName-authentication/index"
});
}
};
const getDateChange = (e) => {
pages_api_my.updateUserInfo({
birthday: e.detail.value
}).then((res) => {
baseUserInfo();
}).catch((err) => {
common_vendor.index.showToast({
title: "\u7F51\u7EDC\u5F02\u5E38",
duration: 2e3,
icon: "none"
});
});
};
const changeSex = (e) => {
pages_api_my.updateUserInfo({
sex: Number(e.detail.value)
}).then((res) => {
baseUserInfo();
}).catch((err) => {
common_vendor.index.showToast({
title: "\u7F51\u7EDC\u5F02\u5E38",
duration: 2e3,
icon: "none"
});
});
};
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.unref(avatarUrl),
b: common_vendor.t(common_vendor.unref(nickName)),
c: common_vendor.o(toLogin),
d: common_vendor.o(handleToAddress),
e: common_vendor.o(handleTorealName),
f: common_vendor.o((...args) => common_vendor.unref(utils_index.handleSecondQi) && common_vendor.unref(utils_index.handleSecondQi)(...args)),
g: token.value
}, token.value ? {
h: common_vendor.t(common_vendor.unref(sex) ? "\u7537" : "\u5973"),
i: common_vendor.o(changeSex),
j: common_vendor.unref(sex),
k: sexList,
l: common_vendor.t(common_vendor.unref(birthday)),
m: common_vendor.unref(birthday),
n: common_vendor.unref(startDate),
o: common_vendor.unref(endDate),
p: common_vendor.o(getDateChange)
} : {}, {
q: token.value
}, token.value ? {
r: common_vendor.o(handleLogout)
} : {});
};
}
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4dcceeb0"], ["__file", "E:/project/project-wl-yonghuduan-uniapp-vue3/pages/my/index.vue"]]);
wx.createPage(MiniProgramPage);