diff --git a/src/api/request.ts b/src/api/request.ts index aa310a1..05aaff2 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -1,6 +1,6 @@ interface IGlobalParams { - gUrl: string; - version: string; + gUrl: string + version: string } export const request = function ( @@ -10,9 +10,9 @@ export const request = function ( return new Promise((resolve, reject) => { if (loading) { wx.showLoading({ - title: "加载中...", + title: '加载中...', mask: true, - }); + }) } wx.request({ header: { @@ -20,53 +20,53 @@ export const request = function ( ...header, }, url: gUrl + url, - method: method, + method, data: { loginState: getApp().globalData.loginState, ...(data as object), }, ...options, success(res: any) { - const { code, data } = res.data; + const { code, data } = res.data if (isJSON) { - resolve(res.data); + resolve(res.data) } else if (code === 0) { - resolve(data); + resolve(data) } else if (showMsg) { - const msg = errPicker(res.data); + const msg = errPicker(res.data) if (loading) { setTimeout(() => { wx.showToast({ title: msg, - icon: "none", - }); - }, 30); + icon: 'none', + }) + }, 30) } else { wx.showToast({ title: msg, - icon: "none", - }); - reject(res); + icon: 'none', + }) + reject(res) } } else { - reject(res); + reject(res) } }, fail(err) { - reject(err); + reject(err) }, complete() { if (loading) { - wx.hideLoading(); + wx.hideLoading() } }, - }); - }); -}; + }) + }) +} function errPicker(err) { - if (typeof err === "string") { - return err; + if (typeof err === 'string') { + return err } - return err.data || err.msg || err.errMsg || (err.detail && err.detail.errMsg) || "未知错误"; + return err.data || err.msg || err.errMsg || (err.detail && err.detail.errMsg) || '未知错误' } diff --git a/src/app.ts b/src/app.ts index 34b0ce7..bdbf286 100644 --- a/src/app.ts +++ b/src/app.ts @@ -17,349 +17,82 @@ App({ globalData: { // dev // appid:wxa4ece062e60e93a5 - url: 'https://m.zd.hbraas.com', - upFileUrl: 'https://m.zd.hbraas.com/', - imageUrl: "https://m.wtx.hbraas.com/GeneB/", + url: 'https://m.wtx.hbraas.com', + upFileUrl: 'https://m.wtx.hbraas.com/', + imageUrl: 'https://m.wtx.hbraas.com/GeneB/', // pro // appid:wx96f45ca4f1fa36ec - // url: 'https://m.zd.hbsaas.com', - // upFileUrl: 'https://m.zd.hbsaas.com/', - // imageUrl: 'https://m.zd.hbsaas.com/zd/', - // - //login - registrationSource: 0, - registChannel: 0, - regBusinessId: '', - IsAliQiWei: 0, + // url: 'https://m.wtx.hbsaas.com', + // upFileUrl: 'https://m.wtx.hbsaas.com/', + // imageUrl: 'https://m.wtx.hbsaas.com/GeneB/', + Timestamp: new Date().getTime(), scene: {}, - listeners: [], - Timestamp: new Date().getTime(), loginState: '', isLogin: 0, // 0 未登录 1 已登录 - isReg: '0', - WorkerId: '', - loginType: '', // 1:患者 2:医生 + isReg: 0, + userId: '', + guestPrivacyAgree: false, - first: true, // anyWhere: true, anyWhere: false, userInfo: {}, }, onLaunch() { - // if (options.path) { - // this.globalData.anyWhere = true; - // } + this.autoUpdate() + Page = page as WechatMiniprogram.Page.Constructor wx.ajax = licia.curry(request)({ gUrl: this.globalData.url }) - this.autoUpdate() - wx.setInnerAudioOption({ obeyMuteSwitch: false, mixWithOther: false, }) - wx.login({ - success: (res) => { - console.log('code',res) - }, - }) }, onShow(options) { if (options.query.scene) { - this.globalData.anyWhere = false this.globalData.scene = parseScene(options.query.scene) as { workerId: string } } - // this.startLogin() + this.startLogin() }, startLogin() { - const that = this wx.login({ - success(res) { + success: (res) => { wx.ajax({ method: 'GET', - url: '?r=zd/user/init-login', + url: '?r=wtx/user/init-login', data: { code: res.code, }, }).then((res) => { - that.globalData.loginState = res.loginState - that.globalData.isReg = res.isReg - that.globalData.isLogin = res.isLogin - that.globalData.loginType = res.loginType - if (!Object.keys(that.globalData.scene)?.length) { - that.globalData.anyWhere = res.anyWhere - } - if (wx.getLaunchOptionsSync()?.query?.activity === 'NRDL') { - that.clickPush() - } - that.getUserInfo() + this.globalData.loginState = res.loginState + this.globalData.isReg = res.isReg + this.globalData.isLogin = res.isLogin + this.globalData.userId = res.userId + this.globalData.guestPrivacyAgree = res.guestPrivacyAgree }) }, }) }, - waitLogin({ isReg = true, loginPage = false } = { isReg: true, loginPage: false }) { + waitLogin() { let time: number - const regFun = (resolve) => { - if (this.verifySys()) { - if (this.globalData.loginType === 1) { - this.registrationVerification(() => resolve(), loginPage) - } else { - resolve() - } - } - } - const unRegFun = (resolve) => { - if (!this.verifySys(isReg)) return - resolve() - } return new Promise((resolve: (value?) => void) => { - if (isReg) { - if (Object.keys(this.globalData.userInfo).length) { - regFun(resolve) - return - } - time = setInterval(() => { - if (Object.keys(this.globalData.userInfo).length) { - clearInterval(time) - regFun(resolve) - } - }, 500) - return - } - this.globalData.anyWhere = true if (this.globalData.loginState) { - unRegFun(resolve) + resolve() return } time = setInterval(() => { if (this.globalData.loginState) { clearInterval(time) - unRegFun(resolve) + resolve() } }, 500) }) }, - registrationVerification(callback: () => void, loginPage = false) { - // 1-空白用户,2-注册用户,3-疾病患者,4-用药患者 - const { PatientId, AuditStatus, isFollow, UserType } = this.globalData.userInfo - const { anyWhere, first } = this.globalData - - if (loginPage || (anyWhere && first)) { - callback() - return - } - - if (UserType == 4) { - this.globalData.first = false - callback() - return - } - - if (UserType == 1) { - this.globalData.registChannel = 0 - this.globalData.first = false - wx.reLaunch({ - url: '/pages/login/index', - }) - return - } - - let urlKey = '' - if (!PatientId) { - urlKey = 'enterInfo' - } else if (AuditStatus == 0) { - urlKey = 'noCert' - } else if (AuditStatus == 1) { - urlKey = isFollow ? 'nopending' : 'pending' - } else if (AuditStatus == 2) { - urlKey = 'reject' - } - let navUrl = { - enterInfo: '/pages/enterInfo/index', - noCert: '/pages/enterInfo/index', - reject: '/pages/enterInfo/index', - pending: '/pages/enterInfo/index', - nopending: '/pages/enterInfo/index', - }[urlKey] - - if (navUrl && first) { - this.globalData.registChannel = 0 - this.globalData.first = false - wx.reLaunch({ - url: navUrl, - }) - this.globalData.first = false - return - } - - this.globalData.first = false - callback() - }, - verifySys() { - // 1:患者 2:医生 - const { loginType, isLogin, anyWhere } = this.globalData - const pages = getCurrentPages() - const currentPage = pages[pages.length - 1] - const url = currentPage.route - const options = currentPage.options - const ignorePath = ['pages/start/index'] - - // 未登录用户 - if (!isLogin) { - // 医生端页面重定向到医生端登录页 - if (url.includes('doctor/pages')) { - wx.reLaunch({ - url: '/doctor/pages/d_login/index', - }) - return false - } - // 患者端随便看看 - if (anyWhere) { - return true - } - wx.reLaunch({ - url: '/pages/login/index', - }) - return false - } - if (ignorePath.includes(url)) return true - - if (loginType === 1) { - if (url.includes('doctor/pages')) { - wx.reLaunch({ - url: '/pages/index/index', - }) - return false - } else { - return true - } - } - if (loginType === 2) { - if (url.includes('doctor/pages')) { - return true - } else { - const params = Object.entries(options) - .map(([key, value]) => `${key}=${value}`) - .join('&') - wx.reLaunch({ - url: '/doctor/pages/d_trans/index?path=' + encodeURIComponent(`/${url}?${params}`), - }) - return false - } - } - return true - }, - permissionVerification(grade = 1, registChannel = 0, backPage = null, regBusinessId = '') { - // 1-空白用户,2-注册用户,3-疾病患者,4-用药患者 - const { PatientId, AuditStatus, isFollow, UserType } = this.globalData.userInfo - const that = this - this.globalData.registChannel = registChannel - this.globalData.regBusinessId = regBusinessId - let isReject = false - return new Promise((resolve, reject) => { - if (grade == 2 && Number(UserType) < 2) { - wx.reLaunch({ - url: '/pages/login/index', - }) - isReject = true - } - if (grade == 3 && Number(UserType) < 3) { - if (UserType == 1) { - wx.reLaunch({ - url: '/pages/login/index', - }) - isReject = true - } - if (UserType == 2) { - let urlKey = '' - if (!PatientId) { - urlKey = 'enterInfo' - } else if (AuditStatus == 0) { - urlKey = 'noCert' - } else if (AuditStatus == 1) { - if (backPage && (backPage as string).includes('liveResult')) { - urlKey = 'liveResult' - } else { - urlKey = isFollow ? 'nopending' : 'pending' - } - } else if (AuditStatus == 2) { - urlKey = 'reject' - } - let navUrl = { - enterInfo: '/pages/enterInfo/index', - noCert: '/pages/enterInfo/index', - reject: '/pages/enterInfo/index', - pending: '/pages/enterInfo/index', - nopending: '/pages/enterInfo/index', - liveResult: backPage, - }[urlKey] - if (urlKey == 'liveResult') { - wx.navigateTo({ - url: navUrl as string, - }) - } else { - wx.reLaunch({ - url: navUrl as string, - }) - } - isReject = true - } - } - if (grade == 4 && Number(UserType) < 4) { - wx.reLaunch({ - url: '/pages/vipLogin/index', - }) - isReject = true - } - if (isReject) { - that.globalData.backPage = backPage - reject(null) - return - } - resolve(null) - }) - }, - getUserInfo(self, update = false, callback = (_userInfo) => {}) { - if (this.globalData.userInfo?.UserId && !update) { - self?.setData({ - userInfo: this.globalData.userInfo, - }) - callback(this.globalData.userInfo) - return - } - wx.ajax({ - method: 'GET', - url: '?r=zd/account/info', - showMsg: false, - }).then((res) => { - res.UserType = res.UserType || 1 - if (res.UserType > 2) { - this.globalData.anyWhere = false - } - this.globalData.userInfo = res - this.triggerListeners() - self?.setData({ - userInfo: res, - }) - const { doctorId, inviteChan } = this.globalData.scene - if (doctorId && res.InviteDoctorId != doctorId && this.globalData.isLogin && res.PatientId) { - wx.ajax({ - method: 'POST', - url: '?r=zd/account/update-doctor', - data: { - inviteDoctorId: doctorId, - inviteChannel: inviteChan, - }, - }) - } - callback(res) - }) - }, mpBehavior(data: { PageName: string; doctor?: boolean }) { let url = '?r=zd/mp-behavior/add' if (data.doctor) { @@ -377,117 +110,12 @@ App({ }) }, - // 更新用户信息 - async updateUserInfo(encryptedData, iv) { - let loginState = this.globalData.loginState - const encodeEncryptedData = encodeURIComponent(encryptedData) - const encodeIv = encodeURIComponent(iv) - const { - data: { code, msg }, - } = await wx.ajax({ - method: 'POST', - url: '?r=eyecare/user/update-wx-user-info', - data: { - loginState, - encryptedData: encodeEncryptedData, - iv: encodeIv, - }, - }) - if (code !== 0) { - wx.showToast({ - duration: 1500, - title: msg, - icon: 'none', - }) - } - return code - }, - getCode() { - return new Promise((resolve) => { - wx.login({ - success: (res) => { - resolve(res.code) - }, - fail: () => { - wx.showToast({ - duration: 10000, - title: '发生错误请重试', - icon: 'none', - }) - }, - }) - }) - }, - // 微信登录 - doLogin() { - return new Promise((resolve) => { - wx.showLoading({ - title: '加载中...', - mask: true, - }) - this.getCode().then((code) => { - wx.ajax({ - url: '?r=eyecare/user/init-login', - data: { - code, - }, - }).then((res) => { - if (res.data.code === 0) { - resolve(res) - } - }) - }) - }) - }, - clickPush() { - wx.ajax({ - method: 'POST', - url: '?r=zd/nrdl/add-push-click-record', - }) - }, - watch: function (key, method) { - var obj = this.globalData - //加个前缀生成隐藏变量,防止死循环发生 - let ori = obj[key] //obj[key]这个不能放在Object.defineProperty里 - if (ori) { - //处理已经声明的变量,绑定处理 - method(ori) - } - Object.defineProperty(obj, key, { - configurable: true, - enumerable: true, - set: function (value) { - this['_' + key] = value - console.log('是否会被执行2') - method(value) - }, - get: function () { - // 在其它界面调用key值的时候,这里就会执行。 - if (typeof this['_' + key] == 'undefined') { - if (ori) { - //这里读取数据的时候隐藏变量和 globalData设置不一样,所以要做同步处理 - this['_' + key] = ori - return ori - } else { - return undefined - } - } else { - return this['_' + key] - } - }, + getUserInfo() { + return wx.ajax({ + method: 'GET', + url: '?r=wtx/user/userinfo', }) }, - // 注册监听器函数的方法 - registerListener: function (listener: () => {}) { - this.globalData.listeners.push(listener) - }, - // 触发监听器函数的方法 - triggerListeners: function () { - var listeners = this.globalData.listeners - for (var i = 0; i < listeners.length; i++) { - listeners[i]() - } - }, autoUpdate: function () { var self = this // 获取小程序更新机制兼容 @@ -547,25 +175,4 @@ App({ }) }) }, - getTheme() { - return new Promise((resolve) => { - const checkUserType = () => { - const userInfo = this.globalData.userInfo - if (userInfo.UserType) { - // resolve(userInfo.UserType >= 4 ? 'DRUG' : 'PATIENT') - resolve('PATIENT') - return true - } - return false - } - - const tryResolve = () => { - if (!checkUserType()) { - setTimeout(tryResolve, 30) - } - } - - tryResolve() - }) - }, }) diff --git a/src/components/pickerArea/index.json b/src/components/pickerArea/index.json new file mode 100644 index 0000000..9a0f641 --- /dev/null +++ b/src/components/pickerArea/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-popup": "@vant/weapp/popup/index", + "van-cascader": "@vant/weapp/cascader/index" + } +} diff --git a/src/components/pickerArea/index.scss b/src/components/pickerArea/index.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/components/pickerArea/index.ts b/src/components/pickerArea/index.ts new file mode 100644 index 0000000..e08fb38 --- /dev/null +++ b/src/components/pickerArea/index.ts @@ -0,0 +1,73 @@ +const _app = getApp() + +Component({ + properties: { + level: { + type: Number, + value: 3, + }, + value: { + type: String, + value: '', + }, + }, + + data: { + show: false, + options: [], + fieldNames: { + text: 'label', + value: 'value', + children: 'children', + }, + }, + lifetimes: { + attached() { + this.getArea() + }, + }, + methods: { + handleShow() { + this.setData({ + show: true, + }) + }, + getArea() { + const { level } = this.data + wx.ajax({ + method: 'GET', + url: '/js/area.json', + data: {}, + isJSON: true, + }).then((res) => { + if (level === 1) { + res.forEach((item: any) => { + delete item.children + }) + } + if (level === 2) { + res.forEach((item: any) => { + item.children.forEach((child: any) => { + delete child.children + }) + }) + } + this.setData({ + options: res, + }) + }) + }, + onFinish(e) { + this.triggerEvent('change', e.detail.selectedOptions) + this.setData({ + show: false, + }) + }, + onClose() { + this.setData({ + show: false, + }) + this.triggerEvent('cancel') + }, + }, +}) diff --git a/src/components/pickerArea/index.wxml b/src/components/pickerArea/index.wxml new file mode 100644 index 0000000..1f92857 --- /dev/null +++ b/src/components/pickerArea/index.wxml @@ -0,0 +1,13 @@ + + + + + diff --git a/src/components/popup/index.scss b/src/components/popup/index.scss index 2e8fc70..699b742 100644 --- a/src/components/popup/index.scss +++ b/src/components/popup/index.scss @@ -12,8 +12,9 @@ font-size: 48rpx; color: #f23a2f; font-weight: bold; + text-align: center; } - .conent { + .content { margin-top: 30rpx; font-size: 32rpx; color: #010105; diff --git a/src/components/popup/index.ts b/src/components/popup/index.ts index efcc9f3..9ebc74c 100644 --- a/src/components/popup/index.ts +++ b/src/components/popup/index.ts @@ -15,18 +15,22 @@ Component({ }, }, - data: {}, + data: { + popup1Check1: false, + }, methods: { handleOk() { - this.setData({ - show: false, - }) + const { type } = this.data + if (type === 'argument' && !this.data.popup1Check1) { + wx.showToast({ + title: '请同意隐私政策', + icon: 'none', + }) + return + } this.triggerEvent('ok') }, handleCancel() { - this.setData({ - show: false, - }) this.triggerEvent('cancel') }, }, diff --git a/src/components/popup/index.wxml b/src/components/popup/index.wxml index 7c8a874..f566298 100644 --- a/src/components/popup/index.wxml +++ b/src/components/popup/index.wxml @@ -15,12 +15,12 @@ ,请您仔细阅读。一旦您开始使用,即表示您已充分理解并同意协议内容。 - + 我已阅读并同意 《个人信息及隐私政策》 - 同意并继续 - 不同意 + 同意并继续 + 不同意 diff --git a/src/images/index-apply-end.png b/src/images/index-apply-end.png new file mode 100644 index 0000000..846822e Binary files /dev/null and b/src/images/index-apply-end.png differ diff --git a/src/pages/applyFrom/index.json b/src/pages/applyFrom/index.json index ad4d4ef..b8c2d80 100644 --- a/src/pages/applyFrom/index.json +++ b/src/pages/applyFrom/index.json @@ -1,6 +1,7 @@ { "navigationStyle": "custom", "usingComponents": { - "navbar": "/components/navbar/index" + "navbar": "/components/navbar/index", + "pickerArea": "/components/pickerArea/index" } } diff --git a/src/pages/applyFrom/index.scss b/src/pages/applyFrom/index.scss index 598c070..27d5ad9 100644 --- a/src/pages/applyFrom/index.scss +++ b/src/pages/applyFrom/index.scss @@ -9,7 +9,7 @@ page { background: #ffffff; border-radius: 32rpx 32rpx 32rpx 32rpx; .from-item { - padding: 20rpx 0; + padding: 32rpx 0; display: flex; border-bottom: 1px solid #ededf7; &:last-of-type { @@ -39,6 +39,7 @@ page { justify-content: center; background: #f6f6f9; border-radius: 46rpx 46rpx 46rpx 46rpx; + border: 1px solid #f6f6f9; &.active { color: #f23a2f; background: rgba(242, 58, 47, 0.13); @@ -74,6 +75,21 @@ page { .place-textarea { color: rgba(0, 0, 0, 0.3); } + .tel { + margin: 0; + width: 218rpx; + height: 64rpx; + font-size: 32rpx; + color: rgba(255, 255, 255, 1); + display: flex; + align-items: center; + justify-content: center; + background: linear-gradient(356deg, #f23a2f 0%, #fc684f 100%); + border-radius: 126rpx 126rpx 126rpx 126rpx; + &::after { + border: none; + } + } } } } @@ -107,6 +123,11 @@ page { .share { flex-shrink: 0; text-align: center; + margin: 0; + padding: 0; + &::after { + border: none; + } .icon { display: block; width: 48rpx; diff --git a/src/pages/applyFrom/index.ts b/src/pages/applyFrom/index.ts index 0a8a241..958dcbb 100644 --- a/src/pages/applyFrom/index.ts +++ b/src/pages/applyFrom/index.ts @@ -1,15 +1,135 @@ -const _app = getApp() +const app = getApp() Page({ data: { pageTop: 0, background: 'transparent', + + Id: '', + UserName: '', + Relation: '', + BirthMonth: '', + ProvinceId: '', + CityId: '', + Telephone: '', + Remark: '', + + ProvinceName: '', + CityName: '', + + Argument: false, }, onLoad() { + app.waitLogin().then(() => { + app.getUserInfo().then((userInfo) => { + if (userInfo.ApplyIntentionId) { + this.getDetail(userInfo.ApplyIntentionId) + this.setData({ + Argument: true, + }) + } + }) + }) + }, + getDetail(Id: string) { + wx.ajax({ + method: 'GET', + url: '?r=wtx/user-apply-intention/view', + data: { + Id, + }, + }).then((res) => { + this.setData({ + Id: res.Id, + UserName: res.UserName, + Relation: res.Relation, + BirthMonth: res.BirthMonth, + ProvinceId: res.ProvinceId, + CityId: res.CityId, + Telephone: res.Telephone, + Remark: res.Remark, + + ProvinceName: res.ProvinceName, + CityName: res.CityName, + }) + }) + }, + handleRelation(e) { + const { value } = e.currentTarget.dataset + this.setData({ + Relation: value, + }) + }, + handleAreaChange(e) { + const value = e.detail + this.setData({ + ProvinceId: value[0].value, + CityId: value[1] ? value[1].value : '', + ProvinceName: value[0].label, + CityName: value[1] ? value[1].label : '', + }) + }, + handlePhoneNumber(e) { + wx.ajax({ + method: 'POST', + url: '?r=wtx/user/wx-telephone', + data: { + iv: e.detail.iv, + encryptedData: e.detail.encryptedData, + }, + }).then((res) => { + this.setData({ + Telephone: res.Telehpone, + }) + }) }, handleSubmit() { - wx.navigateTo({ - url: '/pages/applyFromResult/index', + const { Id, UserName, Relation, BirthMonth, ProvinceId, CityId, Telephone, Remark, Argument } = this.data + let toast = '' + if (!Telephone) { + toast = '请先获取手机号' + } + if (!ProvinceId) { + toast = '请选择所在地区' + } + if (!BirthMonth) { + toast = '请选择您的出生月份' + } + if (!UserName) { + toast = '请输入您的姓名' + } + if (!Relation) { + toast = '请选择您的身份' + } + if (!Argument) { + toast = '请先阅读并同意《服务隐私政策》' + } + if (toast) { + wx.showToast({ + title: toast, + icon: 'none', + }) + return + } + + const url = Id ? '?r=wtx/user-apply-intention/edit' : '?r=wtx/user-apply-intention/add' + wx.ajax({ + method: 'POST', + url, + data: { + Id, + UserName, + Relation, + BirthMonth, + ProvinceId, + CityId, + Telephone, + Remark, + }, + }).then(() => { + wx.navigateTo({ + url: '/pages/applyFromResult/index', + }) }) }, }) diff --git a/src/pages/applyFrom/index.wxml b/src/pages/applyFrom/index.wxml index 92b4610..f9b326a 100644 --- a/src/pages/applyFrom/index.wxml +++ b/src/pages/applyFrom/index.wxml @@ -1,5 +1,5 @@ - + 您的身份 - 本人 - 亲友 + 本人 + 亲友 您的姓名 - + 您的出生年月 - + - + {{BirthMonth}} @@ -38,41 +44,48 @@ 所在地区 - + - + + {{ProvinceName ? ProvinceName+ '/' : ProvinceName }}{{CityName}} - + 如何联系您 - + {{Telephone}} + 其他说明 - + - + 我已阅读并同意 《服务隐私政策》 - diff --git a/src/pages/applyFromResult/index.ts b/src/pages/applyFromResult/index.ts index 18adc37..56a0e63 100644 --- a/src/pages/applyFromResult/index.ts +++ b/src/pages/applyFromResult/index.ts @@ -1,11 +1,26 @@ -const _app = getApp() +const app = getApp() Page({ data: { pageTop: 0, background: 'transparent', }, - onLoad() {}, + onLoad() { + app.waitLogin().then(() => { + this.getCodeImg() + }) + }, + getCodeImg() { + wx.ajax({ + method: 'GET', + url: '?r=wtx/common/get-channel-wx-code', + data: {}, + }).then((res) => { + this.setData({ + codeImg: res, + }) + }) + }, }) export {} diff --git a/src/pages/applyFromResult/index.wxml b/src/pages/applyFromResult/index.wxml index bc62a8e..945ceff 100644 --- a/src/pages/applyFromResult/index.wxml +++ b/src/pages/applyFromResult/index.wxml @@ -10,7 +10,7 @@ 48 小时内与您联系 - + 关注公众号,接收您的服务提醒 diff --git a/src/pages/index/index.ts b/src/pages/index/index.ts index 8d21c1a..6ceb6ac 100644 --- a/src/pages/index/index.ts +++ b/src/pages/index/index.ts @@ -1,4 +1,4 @@ -const _app = getApp() +const app = getApp() Page({ data: { @@ -8,13 +8,40 @@ Page({ position: 'bottom', }, + userInfo: {}, + bannerList: [], + pageTop: '', background: 'transparent', }, onLoad() { - const menuInfo = wx.getMenuButtonBoundingClientRect() - this.setData({ - pageTop: menuInfo.bottom, + app.waitLogin().then(() => { + this.setData({ + popupShow: !app.globalData.guestPrivacyAgree, + }) + app.getUserInfo().then((userInfo) => { + this.setData({ + userInfo, + }) + }) + this.getBanner() + }) + }, + getBanner() { + wx.ajax({ + method: 'GET', + url: '?r=wtx/common/banner-config', + data: {}, + }).then((res) => { + this.setData({ + bannerList: res, + }) + }) + }, + onBannerItemTap(e) { + const { path } = e.currentTarget.dataset + wx.navigateTo({ + url: path, }) }, routerTo(e) { @@ -23,6 +50,28 @@ Page({ url, }) }, + handlePopupOk() { + const { popupType } = this.data + if (popupType === 'argument') { + wx.ajax({ + method: 'POST', + url: '?r=wtx/user/agree-guest-privacy', + data: { + // TODO: 待补充 + WorkerId: '', + }, + }).then(() => { + this.setData({ + popupShow: false, + }) + }) + } + }, + handlePopupCancel() { + if (this.data.popupType === 'argument') { + wx.exitMiniProgram() + } + }, }) export {} diff --git a/src/pages/index/index.wxml b/src/pages/index/index.wxml index abe131a..ef2f510 100644 --- a/src/pages/index/index.wxml +++ b/src/pages/index/index.wxml @@ -3,14 +3,21 @@ - - + + + @@ -71,5 +78,12 @@ - - + + + diff --git a/src/pages/my/index.scss b/src/pages/my/index.scss index d6d5f33..8e07ebf 100644 --- a/src/pages/my/index.scss +++ b/src/pages/my/index.scss @@ -6,11 +6,21 @@ page { .user { display: flex; align-items: center; - .avatar { + .avatar-wrapper { flex-shrink: 0; + padding: 0; + margin: 0; width: 128rpx; height: 128rpx; - border-radius: 50%; + outline: none; + &::after { + border: none; + } + .avatar { + width: 128rpx; + height: 128rpx; + border-radius: 50%; + } } .wrap { padding-left: 24rpx; @@ -116,6 +126,6 @@ page { align-items: center; justify-content: center; font-size: 32rpx; - color: rgba(1, 1, 5, 0.40); + color: rgba(1, 1, 5, 0.4); } } diff --git a/src/pages/my/index.ts b/src/pages/my/index.ts index 75573fe..fb8ddb5 100644 --- a/src/pages/my/index.ts +++ b/src/pages/my/index.ts @@ -1,12 +1,59 @@ -const _app = getApp() +const app = getApp() Page({ data: { - popupShow: true, + popupShow: false, popupType: 'stayTuned', popupParams: {}, }, - onLoad() {}, + onLoad() { + app.waitLogin().then(() => { + app.getUserInfo().then((userInfo) => { + this.setData({ + userInfo, + }) + }) + }) + }, + onChooseAvatar(e) { + const { avatarUrl } = e.detail + const url = `${app.globalData.upFileUrl}?r=file-service/upload-img` + wx.showLoading({ + title: '上传中', + }) + wx.uploadFile({ + url, + filePath: avatarUrl, + name: 'file', + success: (res) => { + const data = JSON.parse(res.data) + const avatarUrl = data.data.Url + wx.ajax({ + method: 'POST', + url: '?r=wtx/user/update-avatar', + data: { + Avatar: avatarUrl, + }, + }) + .then(() => { + wx.hideLoading() + wx.showToast({ + title: '头像更新成功!', + icon: 'none', + }) + this.setData({ + 'userInfo.Avatar': avatarUrl, + }) + }) + .catch(() => { + wx.hideLoading() + }) + }, + fail() { + wx.hideLoading() + }, + }) + }, handlePopupCancel() { this.setData({ popupShow: false, diff --git a/src/pages/my/index.wxml b/src/pages/my/index.wxml index e82a866..5d12d5f 100644 --- a/src/pages/my/index.wxml +++ b/src/pages/my/index.wxml @@ -3,25 +3,24 @@ style="background: url('/images/bg1.png') no-repeat top center/100% 602rpx;padding-top:{{pageTop+21}}px;" > - + - 小明 + ??? 今天是陪伴您的第 - 32 - 天 + {{userInfo.Days}} - - + + + diff --git a/src/utils/page.ts b/src/utils/page.ts index bba8fcb..0a2bef9 100644 --- a/src/utils/page.ts +++ b/src/utils/page.ts @@ -52,8 +52,8 @@ function page(config: WechatMiniprogram.Page.Instance Promise - getCode: () => Promise - doLogin: () => Promise - waitLogin: (obj?: { isReg?: boolean; loginPage?: boolean }) => Promise + getUserInfo: () => Promise startLogin: () => void - getUserInfo: (self?, update?: boolean, callback?: (userinfo) => void) => void + waitLogin: () => Promise mpBehavior: (data: { PageName: string; doctor?: boolean }) => void globalSystemInfo?: globalSystemInfo [propName: string]: any