diff --git a/app.js b/app.js
index 8878ee8..3f7c794 100644
--- a/app.js
+++ b/app.js
@@ -1,16 +1,15 @@
// app.js
App({
onLaunch() {
-
// 登录
xhs.login({
- success: res => {
+ success: (res) => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
- console.log('login', res)
- }
+ console.log("login, code", res.code);
+ },
});
},
globalData: {
- userInfo: null
- }
-});
\ No newline at end of file
+ userInfo: null,
+ },
+});
diff --git a/pages/index/index.js b/pages/index/index.js
index 1a8db03..0cc1641 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -1,23 +1,23 @@
// index.js
-const defaultAvatarUrl =
- "https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
+import { getPhone } from '../../utils/get-phone.js';
+const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0';
Page({
data: {
- motto: "Hello World",
+ motto: 'Hello World',
userInfo: {
avatarUrl: defaultAvatarUrl,
- nickName: "",
+ nickName: '',
},
hasUserInfo: false,
- canIUseGetUserProfile: xhs.canIUse("getUserProfile"),
- canIUseNicknameComp: xhs.canIUse("input.type.nickname"),
+ canIUseGetUserProfile: xhs.canIUse('getUserProfile'),
+ canIUseNicknameComp: xhs.canIUse('input.type.nickname'),
},
bindViewTap() {},
onChooseAvatar(e) {
const { avatarUrl } = e.detail;
const { nickName } = this.data.userInfo;
this.setData({
- "userInfo.avatarUrl": avatarUrl,
+ 'userInfo.avatarUrl': avatarUrl,
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
});
},
@@ -25,12 +25,12 @@ Page({
const nickName = e.detail.value;
const { avatarUrl } = this.data.userInfo;
this.setData({
- "userInfo.nickName": nickName,
+ 'userInfo.nickName': nickName,
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
});
},
getUserProfile(e) {
- console.log("user -profile", e);
+ console.log('user -profile', e);
// 推荐使用xhs.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
const userInfo = e.detail.userInfo;
this.setData({
@@ -38,4 +38,9 @@ Page({
hasUserInfo: true,
});
},
+ getPhoneNumber(e) {
+ const { detail } = e;
+ // console.log('e', detail);
+ getPhone(detail);
+ },
});
diff --git a/pages/index/index.xhsml b/pages/index/index.xhsml
index 819ce72..1a308b8 100644
--- a/pages/index/index.xhsml
+++ b/pages/index/index.xhsml
@@ -23,5 +23,8 @@
{{motto}}
+
+
+
diff --git a/utils/get-phone.js b/utils/get-phone.js
new file mode 100644
index 0000000..e98ad5b
--- /dev/null
+++ b/utils/get-phone.js
@@ -0,0 +1,4 @@
+export const getPhone = (data) => {
+ console.log("getPhone", data);
+ return data;
+}
\ No newline at end of file