xyvcard-wechat-auth 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,6 +50,8 @@ export interface UpdateUserReq {
50
50
  nickName?: string;
51
51
  avatar?: string;
52
52
  realName?: string;
53
+ gender?: string;
54
+ birthDate?: string;
53
55
  }
54
56
  export interface UserInfoReq {
55
57
  tenant?: string;
@@ -0,0 +1,108 @@
1
+ import { authApi } from "../../../api/auth/index.js";
2
+ import { fileApi } from "../../../api/files/index.js";
3
+ import { config } from "../../../utils/config.js";
4
+ import { db } from "../../../utils/db.js";
5
+ Component({
6
+ /**
7
+ * 组件的属性列表
8
+ */
9
+ properties: {
10
+ // 定义一个对象类型的属性
11
+ isUserAvatar: {
12
+ type: Boolean,
13
+ value: true
14
+ },
15
+ isUserNickName: {
16
+ type: Boolean,
17
+ value: true
18
+ },
19
+ isUserRealName: {
20
+ type: Boolean,
21
+ value: true
22
+ },
23
+ isUserMobilePhone: {
24
+ type: Boolean,
25
+ value: true
26
+ }
27
+ },
28
+ /**
29
+ * 组件的初始数据
30
+ */
31
+ data: {
32
+ userInfo: {
33
+ // 获取缓存中的用户信息
34
+ ...wx.getStorageSync("userInfo"),
35
+ updateMask: "nickName,avatar,realName"
36
+ }
37
+ },
38
+ lifetimes: {
39
+ ready() {
40
+ this.setData({
41
+ userInfo: {
42
+ ...this.data.userInfo,
43
+ // 获取缓存中的用户信息
44
+ ...wx.getStorageSync("userInfo"),
45
+ requestId: Math.random() * 10 + ""
46
+ }
47
+ });
48
+ }
49
+ },
50
+ /**
51
+ * 组件的方法列表
52
+ */
53
+ methods: {
54
+ // 获取微信昵称
55
+ getNicknameValue(e) {
56
+ this.setData({
57
+ "userInfo.nickName": e.detail.value
58
+ });
59
+ },
60
+ // 设置姓名
61
+ setrealNameValue(e) {
62
+ this.setData({
63
+ "userInfo.realName": e.detail.value
64
+ });
65
+ },
66
+ // 获取微信头像
67
+ onChooseAvatar(e) {
68
+ const { avatarUrl } = e.detail;
69
+ fileApi.uploadFile(avatarUrl).then((res) => {
70
+ this.setData({
71
+ "userInfo.avatar": res.data.fileSrc
72
+ });
73
+ });
74
+ },
75
+ // 更换手机号
76
+ getPhoneNumber(e) {
77
+ if (e.detail.errMsg === "getPhoneNumber:ok") {
78
+ authApi.replaceBindphone({
79
+ appId: config.appId,
80
+ phoneCode: e.detail.code,
81
+ componentAppid: config.componentAppid
82
+ }).then((res) => {
83
+ if (res.data) {
84
+ authApi.findUserInfo({}).then((res2) => {
85
+ if (res2.code == 200) {
86
+ db.userInfoStorage(res2.data);
87
+ this.setData({
88
+ userInfo: {
89
+ ...this.data.userInfo,
90
+ ...wx.getStorageSync("userInfo")
91
+ }
92
+ });
93
+ }
94
+ });
95
+ }
96
+ });
97
+ }
98
+ },
99
+ // 更新用户信息
100
+ updateUserInfo() {
101
+ authApi.updateUserInfo(this.data.userInfo).then((res) => {
102
+ if (res.code == 200) {
103
+ db.userInfoStorage(res.data);
104
+ }
105
+ });
106
+ }
107
+ }
108
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,35 @@
1
+ <!-- 我的页面 中个人信息编辑页面 -->
2
+ <view class="my-information">
3
+ <view class="main">
4
+ <view class="main-profile" wx:if="{{ userInfoShow.avatar }}">
5
+ <view class="profile-left">头像</view>
6
+ <view class="profile-right">
7
+ <button class="image-box-bgc" open-type="chooseAvatar" plain="true" bind:chooseavatar="onChooseAvatar">
8
+ <image class="profile-image" src="{{ resourceUrl + '/components/gray_head2x.png' }}" mode="" wx:if="{{ !userInfo.avatar }}" />
9
+ <image class="profile-image" src="{{ imageUrl + userInfo.avatar }}" mode="" wx:else />
10
+ </button>
11
+ </view>
12
+ </view>
13
+ <view class="main-nickname" wx:if="{{ userInfoShow.nickName }}">
14
+ <view class="nickname-left">昵称</view>
15
+ <view class="nickname-right">
16
+ <input value="{{ userInfo.nickName }}" type="nickname" bindinput="getNicknameValue" class="nickname-input" />
17
+ </view>
18
+ </view>
19
+ <view class="main-nickname" wx:if="{{ userInfoShow.realName }}">
20
+ <view class="nickname-left">姓名</view>
21
+ <view class="nickname-right">
22
+ <input value="{{ userInfo.realName }}" type="realName" bindinput="setrealNameValue" class="nickname-input" />
23
+ </view>
24
+ </view>
25
+
26
+ <view class="main-phone" wx:if="{{ userInfoShow.mobilePhone }}">
27
+ <view class="phone-left">手机号</view>
28
+ <view class="phone-right">
29
+ <view>{{ userInfo.mobilePhone }}</view>
30
+ <button open-type="getPhoneNumber" class="phone-right-btn" bindgetphonenumber="getPhoneNumber" plain="true">更换手机号</button>
31
+ </view>
32
+ </view>
33
+ </view>
34
+
35
+ </view>
@@ -0,0 +1 @@
1
+ .my-information{background-color:#f6f6f6;width:100%;height:100vh;position:relative}.my-information .main{background-color:#fff;padding:0 15px}.my-information .main .main-profile,.my-information .main .main-nickname,.my-information .main .main-phone{display:flex;justify-content:space-between;align-items:center;height:55px;border-bottom:1px solid #f5f5f5}.my-information .main .main-profile .profile-left,.my-information .main .main-profile .nickname-left,.my-information .main .main-profile .nickname-right,.my-information .main .main-profile .phone-left,.my-information .main .main-nickname .profile-left,.my-information .main .main-nickname .nickname-left,.my-information .main .main-nickname .nickname-right,.my-information .main .main-nickname .phone-left,.my-information .main .main-phone .profile-left,.my-information .main .main-phone .nickname-left,.my-information .main .main-phone .nickname-right,.my-information .main .main-phone .phone-left{font-size:15px;color:#333}.my-information .main .main-profile .profile-right .profile-image,.my-information .main .main-nickname .profile-right .profile-image,.my-information .main .main-phone .profile-right .profile-image{width:35px;height:35px}.my-information .main .main-profile .phone-right,.my-information .main .main-nickname .phone-right,.my-information .main .main-phone .phone-right{display:flex;justify-content:space-between;align-items:center;font-size:15px;color:#333}.my-information .main .main-profile .phone-right .phone-right-btn,.my-information .main .main-nickname .phone-right .phone-right-btn,.my-information .main .main-phone .phone-right .phone-right-btn{background-color:#e6edff;border-radius:12px;margin-left:10px;border:none;font-size:12px;color:#0551ff}.my-information .main .image-box-bgc{background-color:rgba(0,0,0,0);border-radius:0;line-height:0;border:0;padding:0}.my-information .main .nickname-input{text-align:right}.my-information .main .main-phone{border:none}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import { config } from "../../../utils/config.js";
2
+ Component({
3
+ /**
4
+ * 组件的属性列表
5
+ */
6
+ properties: {
7
+ userInfo: {
8
+ type: Object,
9
+ value: {}
10
+ },
11
+ token: {
12
+ type: String,
13
+ value: ""
14
+ }
15
+ },
16
+ /**
17
+ * 组件的初始数据
18
+ */
19
+ data: {
20
+ BASE_URL: config.baseUrl + "/v1/file/image/clip/200/200/",
21
+ resourceUrl: config.resourceUrl + "/images/mall"
22
+ },
23
+ /**
24
+ * 组件的方法列表
25
+ */
26
+ methods: {
27
+ handleLogin() {
28
+ this.triggerEvent("login");
29
+ },
30
+ handleUpdateUser() {
31
+ this.triggerEvent("updateUser");
32
+ }
33
+ }
34
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,19 @@
1
+ <view class="auth-user-box">
2
+ <block wx:if="{{ token }}">
3
+ <view class="auth-user-l">
4
+ <image src="{{ BASE_URL + userInfo.avatar }}" class="avatar-img" wx:if="{{ userInfo.avatar }}"></image>
5
+ <image src="{{ resourceUrl }}/tswk.png" class="avatar-img" wx:else></image>
6
+ <view class="auth-user-r">
7
+ <view class="user-edit">{{ userInfo.realName }}
8
+ <image src="{{ resourceUrl }}/book/user_edit_icon.png" class="edit_icon" bind:tap="handleUpdateUser"></image>
9
+ </view>
10
+ <text class="user-mobile">{{ userInfo.mobilePhoneIns }}</text>
11
+ </view>
12
+ </view>
13
+ </block>
14
+ <view class="auth-user-l" wx:else>
15
+ <image src="{{ resourceUrl }}/tswk.png" class="avatar-img"></image>
16
+ <text bind:tap="handleLogin">登录</text>
17
+ </view>
18
+
19
+ </view>
@@ -0,0 +1 @@
1
+ .auth-user-box{display:flex;align-items:center;padding:15px 0 15px 3%}.auth-user-box .auth-user-l{display:flex;align-items:center;font-size:15px;font-weight:bold}.auth-user-box .auth-user-l .avatar-img{width:60px;height:60px;border-radius:25px;margin-right:10px}.auth-user-box .auth-user-r .user-edit{display:flex;align-items:center}.auth-user-box .auth-user-r .user-edit .edit_icon{width:30px;height:30px;margin-left:10px}.auth-user-box .auth-user-r .user-mobile{font-size:14px;color:#666;font-weight:500}
@@ -24,9 +24,4 @@ $border-line: #EBEBEB;
24
24
  // 背景色
25
25
  $background-color: #f6f6f6;
26
26
  // 白色背景
27
- $background-white-color: #fff;
28
- // 灰色字体
29
- $grey-color: #999;
30
- $grey-dark-color: #666;
31
- // 字体大小
32
- $font-mini-size: 12px;
27
+ $background-white-color: #fff;
@@ -3,7 +3,7 @@ const host = "gh.sooyie.cn";
3
3
  const agentUrl = "/v1/file/path/wxapp";
4
4
  const config = {
5
5
  dev: true,
6
- testNewUser: true,
6
+ testNewUser: false,
7
7
  name: "Jmash框架",
8
8
  baseUrl: https + host,
9
9
  // 接口域名
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xyvcard-wechat-auth",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",