diff --git a/project.private.config.json b/project.private.config.json index b7ae25a..15688d0 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -9,6 +9,13 @@ "miniprogram": { "list": [ { + "name": "个人信息", + "pathName": "pages/userInfo/index", + "query": "", + "launchMode": "default", + "scene": null + }, + { "name": "隐私协议", "pathName": "pages/protocol/index", "query": "", diff --git a/src/app.json b/src/app.json index e06653b..044f216 100644 --- a/src/app.json +++ b/src/app.json @@ -10,7 +10,8 @@ "pages/classify/index", "pages/article/index", "pages/search/index", - "pages/protocol/index" + "pages/protocol/index", + "pages/userInfo/index" ], "preloadRule": {}, "window": { diff --git a/src/components/global-toast/index.wxml b/src/components/global-toast/index.wxml index e091afc..8411d9b 100644 --- a/src/components/global-toast/index.wxml +++ b/src/components/global-toast/index.wxml @@ -1,7 +1,33 @@ - + 关注适中健康微信公众号 - + + 长按识别二维码关注 + + + + + + 添加我的企业微信 + 长按识别二维码关注 diff --git a/src/components/uploadFile/index.ts b/src/components/uploadFile/index.ts index b38e768..3efb12f 100644 --- a/src/components/uploadFile/index.ts +++ b/src/components/uploadFile/index.ts @@ -16,15 +16,7 @@ Component({ }, accept: { type: String, - value: "image", - }, - obscure: { - type: Boolean, - value: false, - }, - edit: { - type: Boolean, - value: false, + value: 'image', }, }, @@ -32,15 +24,6 @@ Component({ * 组件的初始数据 */ data: { - show1: false, - fileTypeList: { - doc: 5, - docx: 5, - pdf: 4, - xls: 6, - xlsx: 6, - ppt: 7, - }, cacheEditParams: {}, }, @@ -50,63 +33,29 @@ Component({ methods: { GetExtensionFileName(pathfilename) { const reg = /(\\+)/g; - const pString = pathfilename.replace(reg, "#"); //用正则表达式来将\或\\替换成# - const arr = pString.split("#"); // 以“#”为分隔符,将字符分解为数组 例如 D Program Files bg.png + const pString = pathfilename.replace(reg, '#'); //用正则表达式来将\或\\替换成# + const arr = pString.split('#'); // 以“#”为分隔符,将字符分解为数组 例如 D Program Files bg.png const lastString = arr[arr.length - 1]; //取最后一个字符 - const arr2 = lastString.split("."); // 再以"."作为分隔符 + const arr2 = lastString.split('.'); // 再以"."作为分隔符 return arr2[arr2.length - 1]; //将后缀名返回出来 }, - handleAfterRead(e, editEnd = false) { - if (this.data.edit && !editEnd) { - this.setData({ - show1: true, - cacheEditParams: e, - }); - return; - } - if (this.data.obscure) { - wx.editImage({ - src: e.detail.file.url || e.detail.file.tempFilePath, - success: (res: any) => { - this.uploadFile({ - ...e.detail.file, - tempFilePath: res.tempFilePath, - }).then((res) => { - this.triggerEvent("file", res as object); - }); - }, - fail: (err) => { - if (err.errMsg.includes("开发者工具")) { - this.uploadFile(e.detail.file).then((res) => { - this.triggerEvent("file", res as object); - }); - } - }, - }); - } else { - this.uploadFile(e.detail.file).then((res) => { - this.triggerEvent("file", res as object); - }); - } - }, - handleEditEnd() { - this.setData({ - show1: false, + handleAfterRead(e) { + this.uploadFile(e.detail.file).then((res) => { + this.triggerEvent('file', res as object); }); - this.handleAfterRead(this.data.cacheEditParams, true); }, handleChooseAvatar(e) { this.uploadFile({ - fileType: "image", + fileType: 'image', tempFilePath: e.detail.avatarUrl, size: 0, }).then((res) => { - this.triggerEvent("file", res as object); + this.triggerEvent('file', res as object); }); }, handleChooseFile() { wx.chooseMessageFile({ - type: "file", + type: 'file', count: 1, success: (res) => { this.uploadFile({ @@ -114,66 +63,65 @@ Component({ fileType: res.tempFiles[0].type, tempFilePath: res.tempFiles[0].path, }).then((res) => { - this.triggerEvent("file", res as object); + this.triggerEvent('file', res as object); }); }, fail() { wx.showToast({ - icon: "none", - title: "取消选择", + icon: 'none', + title: '取消选择', }); }, }); }, uploadFile(item) { wx.showLoading({ - title: "正在上传", + title: '正在上传', }); return new Promise((resolve, reject) => { let url = `${app.globalData.upFileUrl}?r=file-service/upload-`; - if (item.fileType === "image") { - url += "img"; - } else if (item.fileType === "video" || item.type === "video") { - url += "video"; + if (item.fileType === 'image') { + url += 'img'; + } else if (item.fileType === 'video' || item.type === 'video') { + url += 'video'; item.tempFilePath = item.url; - } else if (item.fileType === "audio") { - url += "audio"; + } else if (item.fileType === 'audio') { + url += 'audio'; } else { - url += "doc"; + url += 'doc'; } wx.uploadFile({ filePath: item.tempFilePath, - name: "file", + name: 'file', url, success: (res) => { wx.hideLoading(); const data = JSON.parse(res.data); const suffix = this.GetExtensionFileName(data.data.Url); const expandJson = { - fileId: "", + fileId: '', name: item.name || `病历相关文件.${suffix}`, size: (item.size / 1024).toFixed(2), fileUrl: data.data.Url, suffix, type: item.fileType, - imgUrl: "", + imgUrl: '', duration: 0, - fileType: this.data.fileTypeList[suffix] || 99, - videoUrl: "", - hash: "", + videoUrl: '', + hash: '', }; - if (item.fileType === "image") { + if (item.fileType === 'image') { expandJson.imgUrl = data.data.Url; - } else if (item.fileType === "video" || item.type === "video") { + } else if (item.fileType === 'video' || item.type === 'video') { expandJson.imgUrl = data.data.SnapshotUrl; - } else if (item.fileType === "audio") { + } else if (item.fileType === 'audio') { expandJson.duration = Number.parseInt(String(item.duration / 1000)); } resolve(expandJson); }, fail() { wx.hideLoading(); - reject(new Error("上传失败")); + reject(new Error('上传失败')); }, }); }); diff --git a/src/components/uploadFile/index.wxml b/src/components/uploadFile/index.wxml index 2ed103b..4fcc942 100644 --- a/src/components/uploadFile/index.wxml +++ b/src/components/uploadFile/index.wxml @@ -7,13 +7,3 @@ - - - - - - 我知道了 去涂抹 - - - - diff --git a/src/images/copnay-code.png b/src/images/copnay-code.png new file mode 100644 index 0000000..5c08e8f Binary files /dev/null and b/src/images/copnay-code.png differ diff --git a/src/images/icon-edit.png b/src/images/icon-edit.png new file mode 100644 index 0000000..a5b54cc Binary files /dev/null and b/src/images/icon-edit.png differ diff --git a/src/images/icon-pic.png b/src/images/icon-pic.png new file mode 100644 index 0000000..a9752d9 Binary files /dev/null and b/src/images/icon-pic.png differ diff --git a/src/images/my-list-icon3.png b/src/images/my-list-icon3.png new file mode 100644 index 0000000..13a3b39 Binary files /dev/null and b/src/images/my-list-icon3.png differ diff --git a/src/pages/my/index.scss b/src/pages/my/index.scss index b2f7aac..26ac902 100644 --- a/src/pages/my/index.scss +++ b/src/pages/my/index.scss @@ -37,6 +37,10 @@ page { color: #141515; font-weight: bold; line-height: 1; + .icon { + width: 36rpx; + height: 36rpx; + } } .tel { margin-top: 8rpx; diff --git a/src/pages/my/index.ts b/src/pages/my/index.ts index d21c468..5456e73 100644 --- a/src/pages/my/index.ts +++ b/src/pages/my/index.ts @@ -5,7 +5,7 @@ Page({ toastShow: false, toastType: 1, - userInfo: {}, + userInfo: {} as any, }, onLoad() { app.waitLogin(true).then(() => { @@ -40,12 +40,36 @@ Page({ }, }); }, + handleEditUser() { + wx.navigateTo({ + url: '/pages/userInfo/index', + }); + }, + handleAvatar(e) { + const avatar = e.detail.fileUrl; + wx.ajax({ + method: 'POST', + url: '?r=shizhong/account/update-info', + data: { + userName: this.data.userInfo.username, + avatar, + }, + }).then(() => { + app.getUserInfo(this); + }); + }, handleOffice() { this.setData({ toastShow: true, toastType: 1, }); }, + handleCompanyOffice() { + this.setData({ + toastShow: true, + toastType: 2, + }); + }, handleToastClose() { this.setData({ toastShow: false, diff --git a/src/pages/my/index.wxml b/src/pages/my/index.wxml index 83d8154..614737b 100644 --- a/src/pages/my/index.wxml +++ b/src/pages/my/index.wxml @@ -5,6 +5,7 @@ chooseAvatar bind:file="handleFile" data-key="Img" + bind:file="handleAvatar" > - - {{userInfo.username}} + {{userInfo.username || '---'}} + + {{userInfo.telephone}} {{userInfo.isMember===1?'会员':'非会员'}} @@ -44,6 +50,10 @@ 关注公众号 + + + 联系我们 + diff --git a/src/pages/userInfo/index.json b/src/pages/userInfo/index.json new file mode 100644 index 0000000..fb43e76 --- /dev/null +++ b/src/pages/userInfo/index.json @@ -0,0 +1,7 @@ +{ + "navigationStyle": "default", + "navigationBarTitleText": "个人信息", + "usingComponents": { + "uploadFile": "/components/uploadFile/index" + } +} diff --git a/src/pages/userInfo/index.scss b/src/pages/userInfo/index.scss new file mode 100644 index 0000000..f0171e1 --- /dev/null +++ b/src/pages/userInfo/index.scss @@ -0,0 +1,56 @@ +page { + background-color: #f3f4f5; +} +.page { + padding: 32rpx; + .container { + border-radius: 16rpx; + background-color: #fff; + .row { + padding: 36rpx 32rpx; + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1px solid #f0f0f0; + &:last-of-type { + border: none; + } + &.small { + padding: 24rpx 32rpx; + } + .label { + font-size: 36rpx; + color: #222222; + } + .wrap { + flex: 1; + display: flex; + justify-content: flex-end; + .avatar { + position: relative; + width: 100rpx; + height: 100rpx; + .a-img { + width: 100rpx; + height: 100rpx; + border-radius: 50%; + } + .icon { + position: absolute; + bottom: 0; + right: 0; + width: 32rpx; + height: 32rpx; + } + } + .input { + text-align: right; + font-size: 36rpx; + } + .place-input { + color: #babdc1; + } + } + } + } +} diff --git a/src/pages/userInfo/index.ts b/src/pages/userInfo/index.ts new file mode 100644 index 0000000..72445b9 --- /dev/null +++ b/src/pages/userInfo/index.ts @@ -0,0 +1,48 @@ +const app = getApp(); + +Page({ + data: { + userInfo: {} as any, + }, + onLoad() { + app.waitLogin().then(() => { + app.getUserInfo(this); + }); + }, + handleFile(e) { + const avatar = e.detail.fileUrl; + this.setData({ + 'userInfo.avatar': avatar, + }); + this.updateUserInfo(); + }, + handleInputBlur(e) { + const { key } = e.currentTarget.dataset; + this.setData({ + [`userInfo.${key}`]: e.detail.value, + }); + this.updateUserInfo(); + }, + updateUserInfo() { + const { avatar, username } = this.data.userInfo; + if (!username) { + wx.showToast({ + title: '请输入用户名', + icon: 'none', + }); + return; + } + wx.ajax({ + method: 'POST', + url: '?r=shizhong/account/update-info', + data: { + userName: username, + avatar, + }, + }).then(() => { + app.getUserInfo(this); + }); + }, +}); + +export {}; diff --git a/src/pages/userInfo/index.wxml b/src/pages/userInfo/index.wxml new file mode 100644 index 0000000..ed3ae78 --- /dev/null +++ b/src/pages/userInfo/index.wxml @@ -0,0 +1,43 @@ + + + + 头像 + + + + + + + + + + + 昵称 + + + + + +