Browse Source

1期接口联调

master
kola-web 1 week ago
parent
commit
199f84dad2
  1. 48
      src/api/request.ts
  2. 447
      src/app.ts
  3. 7
      src/components/pickerArea/index.json
  4. 0
      src/components/pickerArea/index.scss
  5. 73
      src/components/pickerArea/index.ts
  6. 13
      src/components/pickerArea/index.wxml
  7. 3
      src/components/popup/index.scss
  8. 18
      src/components/popup/index.ts
  9. 6
      src/components/popup/index.wxml
  10. BIN
      src/images/index-apply-end.png
  11. 3
      src/pages/applyFrom/index.json
  12. 23
      src/pages/applyFrom/index.scss
  13. 126
      src/pages/applyFrom/index.ts
  14. 41
      src/pages/applyFrom/index.wxml
  15. 19
      src/pages/applyFromResult/index.ts
  16. 2
      src/pages/applyFromResult/index.wxml
  17. 57
      src/pages/index/index.ts
  18. 26
      src/pages/index/index.wxml
  19. 16
      src/pages/my/index.scss
  20. 53
      src/pages/my/index.ts
  21. 17
      src/pages/my/index.wxml
  22. 4
      src/utils/page.ts
  23. 43
      typings/index.d.ts

48
src/api/request.ts

@ -1,6 +1,6 @@
interface IGlobalParams { interface IGlobalParams {
gUrl: string; gUrl: string
version: string; version: string
} }
export const request = function ( export const request = function (
@ -10,9 +10,9 @@ export const request = function (
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (loading) { if (loading) {
wx.showLoading({ wx.showLoading({
title: "加载中...", title: '加载中...',
mask: true, mask: true,
}); })
} }
wx.request({ wx.request({
header: { header: {
@ -20,53 +20,53 @@ export const request = function (
...header, ...header,
}, },
url: gUrl + url, url: gUrl + url,
method: method, method,
data: { data: {
loginState: getApp().globalData.loginState, loginState: getApp().globalData.loginState,
...(data as object), ...(data as object),
}, },
...options, ...options,
success(res: any) { success(res: any) {
const { code, data } = res.data; const { code, data } = res.data
if (isJSON) { if (isJSON) {
resolve(res.data); resolve(res.data)
} else if (code === 0) { } else if (code === 0) {
resolve(data); resolve(data)
} else if (showMsg) { } else if (showMsg) {
const msg = errPicker(res.data); const msg = errPicker(res.data)
if (loading) { if (loading) {
setTimeout(() => { setTimeout(() => {
wx.showToast({ wx.showToast({
title: msg, title: msg,
icon: "none", icon: 'none',
}); })
}, 30); }, 30)
} else { } else {
wx.showToast({ wx.showToast({
title: msg, title: msg,
icon: "none", icon: 'none',
}); })
reject(res); reject(res)
} }
} else { } else {
reject(res); reject(res)
} }
}, },
fail(err) { fail(err) {
reject(err); reject(err)
}, },
complete() { complete() {
if (loading) { if (loading) {
wx.hideLoading(); wx.hideLoading()
} }
}, },
}); })
}); })
}; }
function errPicker(err) { function errPicker(err) {
if (typeof err === "string") { if (typeof err === 'string') {
return err; 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) || '未知错误'
} }

447
src/app.ts

@ -17,349 +17,82 @@ App<IAppOption>({
globalData: { globalData: {
// dev // dev
// appid:wxa4ece062e60e93a5 // appid:wxa4ece062e60e93a5
url: 'https://m.zd.hbraas.com', url: 'https://m.wtx.hbraas.com',
upFileUrl: 'https://m.zd.hbraas.com/', upFileUrl: 'https://m.wtx.hbraas.com/',
imageUrl: "https://m.wtx.hbraas.com/GeneB/", imageUrl: 'https://m.wtx.hbraas.com/GeneB/',
// pro // pro
// appid:wx96f45ca4f1fa36ec // appid:wx96f45ca4f1fa36ec
// url: 'https://m.zd.hbsaas.com', // url: 'https://m.wtx.hbsaas.com',
// upFileUrl: 'https://m.zd.hbsaas.com/', // upFileUrl: 'https://m.wtx.hbsaas.com/',
// imageUrl: 'https://m.zd.hbsaas.com/zd/', // imageUrl: 'https://m.wtx.hbsaas.com/GeneB/',
// Timestamp: new Date().getTime(),
//login
registrationSource: 0,
registChannel: 0,
regBusinessId: '',
IsAliQiWei: 0,
scene: {}, scene: {},
listeners: [],
Timestamp: new Date().getTime(),
loginState: '', loginState: '',
isLogin: 0, // 0 未登录 1 已登录 isLogin: 0, // 0 未登录 1 已登录
isReg: '0', isReg: 0,
WorkerId: '', userId: '',
loginType: '', // 1:患者 2:医生 guestPrivacyAgree: false,
first: true,
// anyWhere: true, // anyWhere: true,
anyWhere: false, anyWhere: false,
userInfo: {}, userInfo: {},
}, },
onLaunch() { onLaunch() {
// if (options.path) { this.autoUpdate()
// this.globalData.anyWhere = true;
// }
Page = page as WechatMiniprogram.Page.Constructor Page = page as WechatMiniprogram.Page.Constructor
wx.ajax = licia.curry(request)({ gUrl: this.globalData.url }) wx.ajax = licia.curry(request)({ gUrl: this.globalData.url })
this.autoUpdate()
wx.setInnerAudioOption({ wx.setInnerAudioOption({
obeyMuteSwitch: false, obeyMuteSwitch: false,
mixWithOther: false, mixWithOther: false,
}) })
wx.login({
success: (res) => {
console.log('code',res)
},
})
}, },
onShow(options) { onShow(options) {
if (options.query.scene) { if (options.query.scene) {
this.globalData.anyWhere = false
this.globalData.scene = parseScene(options.query.scene) as { workerId: string } this.globalData.scene = parseScene(options.query.scene) as { workerId: string }
} }
// this.startLogin() this.startLogin()
}, },
startLogin() { startLogin() {
const that = this
wx.login({ wx.login({
success(res) { success: (res) => {
wx.ajax({ wx.ajax({
method: 'GET', method: 'GET',
url: '?r=zd/user/init-login', url: '?r=wtx/user/init-login',
data: { data: {
code: res.code, code: res.code,
}, },
}).then((res) => { }).then((res) => {
that.globalData.loginState = res.loginState this.globalData.loginState = res.loginState
that.globalData.isReg = res.isReg this.globalData.isReg = res.isReg
that.globalData.isLogin = res.isLogin this.globalData.isLogin = res.isLogin
that.globalData.loginType = res.loginType this.globalData.userId = res.userId
if (!Object.keys(that.globalData.scene)?.length) { this.globalData.guestPrivacyAgree = res.guestPrivacyAgree
that.globalData.anyWhere = res.anyWhere
}
if (wx.getLaunchOptionsSync()?.query?.activity === 'NRDL') {
that.clickPush()
}
that.getUserInfo()
}) })
}, },
}) })
}, },
waitLogin({ isReg = true, loginPage = false } = { isReg: true, loginPage: false }) { waitLogin() {
let time: number 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) => { 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) { if (this.globalData.loginState) {
unRegFun(resolve) resolve()
return return
} }
time = setInterval(() => { time = setInterval(() => {
if (this.globalData.loginState) { if (this.globalData.loginState) {
clearInterval(time) clearInterval(time)
unRegFun(resolve) resolve()
} }
}, 500) }, 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 }) { mpBehavior(data: { PageName: string; doctor?: boolean }) {
let url = '?r=zd/mp-behavior/add' let url = '?r=zd/mp-behavior/add'
if (data.doctor) { if (data.doctor) {
@ -377,117 +110,12 @@ App<IAppOption>({
}) })
}, },
// 更新用户信息 getUserInfo() {
async updateUserInfo(encryptedData, iv) { return wx.ajax({
let loginState = this.globalData.loginState method: 'GET',
const encodeEncryptedData = encodeURIComponent(encryptedData) url: '?r=wtx/user/userinfo',
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]
}
},
}) })
}, },
// 注册监听器函数的方法
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 () { autoUpdate: function () {
var self = this var self = this
// 获取小程序更新机制兼容 // 获取小程序更新机制兼容
@ -547,25 +175,4 @@ App<IAppOption>({
}) })
}) })
}, },
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()
})
},
}) })

7
src/components/pickerArea/index.json

@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"van-popup": "@vant/weapp/popup/index",
"van-cascader": "@vant/weapp/cascader/index"
}
}

0
src/components/pickerArea/index.scss

73
src/components/pickerArea/index.ts

@ -0,0 +1,73 @@
const _app = getApp<IAppOption>()
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')
},
},
})

13
src/components/pickerArea/index.wxml

@ -0,0 +1,13 @@
<van-popup show="{{ show }}" round position="bottom">
<van-cascader
wx:if="{{ show }}"
value="{{ value }}"
title="请选择所在地区"
fieldNames="{{fieldNames}}"
options="{{ options }}"
bind:close="onClose"
bind:finish="onFinish"
/>
</van-popup>
<slot bind:tap="handleShow"></slot>

3
src/components/popup/index.scss

@ -12,8 +12,9 @@
font-size: 48rpx; font-size: 48rpx;
color: #f23a2f; color: #f23a2f;
font-weight: bold; font-weight: bold;
text-align: center;
} }
.conent { .content {
margin-top: 30rpx; margin-top: 30rpx;
font-size: 32rpx; font-size: 32rpx;
color: #010105; color: #010105;

18
src/components/popup/index.ts

@ -15,18 +15,22 @@ Component({
}, },
}, },
data: {}, data: {
popup1Check1: false,
},
methods: { methods: {
handleOk() { handleOk() {
this.setData({ const { type } = this.data
show: false, if (type === 'argument' && !this.data.popup1Check1) {
}) wx.showToast({
title: '请同意隐私政策',
icon: 'none',
})
return
}
this.triggerEvent('ok') this.triggerEvent('ok')
}, },
handleCancel() { handleCancel() {
this.setData({
show: false,
})
this.triggerEvent('cancel') this.triggerEvent('cancel')
}, },
}, },

6
src/components/popup/index.wxml

@ -15,12 +15,12 @@
,请您仔细阅读。一旦您开始使用,即表示您已充分理解并同意协议内容。 ,请您仔细阅读。一旦您开始使用,即表示您已充分理解并同意协议内容。
</view> </view>
<view class="check"> <view class="check">
<checkbox class="checkbox"></checkbox> <checkbox class="checkbox" model:checked="{{popup1Check1}}" color="#f23a2f"></checkbox>
我已阅读并同意 我已阅读并同意
<text class="link">《个人信息及隐私政策》</text> <text class="link">《个人信息及隐私政策》</text>
</view> </view>
<view class="btn1">同意并继续</view> <view class="btn1" bind:tap="handleOk">同意并继续</view>
<view class="btn2">不同意</view> <view class="btn2" bind:tap="handleCancel">不同意</view>
</view> </view>
<view class="popup2" wx:if="{{type==='stayTuned'}}"> <view class="popup2" wx:if="{{type==='stayTuned'}}">

BIN
src/images/index-apply-end.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

3
src/pages/applyFrom/index.json

@ -1,6 +1,7 @@
{ {
"navigationStyle": "custom", "navigationStyle": "custom",
"usingComponents": { "usingComponents": {
"navbar": "/components/navbar/index" "navbar": "/components/navbar/index",
"pickerArea": "/components/pickerArea/index"
} }
} }

23
src/pages/applyFrom/index.scss

@ -9,7 +9,7 @@ page {
background: #ffffff; background: #ffffff;
border-radius: 32rpx 32rpx 32rpx 32rpx; border-radius: 32rpx 32rpx 32rpx 32rpx;
.from-item { .from-item {
padding: 20rpx 0; padding: 32rpx 0;
display: flex; display: flex;
border-bottom: 1px solid #ededf7; border-bottom: 1px solid #ededf7;
&:last-of-type { &:last-of-type {
@ -39,6 +39,7 @@ page {
justify-content: center; justify-content: center;
background: #f6f6f9; background: #f6f6f9;
border-radius: 46rpx 46rpx 46rpx 46rpx; border-radius: 46rpx 46rpx 46rpx 46rpx;
border: 1px solid #f6f6f9;
&.active { &.active {
color: #f23a2f; color: #f23a2f;
background: rgba(242, 58, 47, 0.13); background: rgba(242, 58, 47, 0.13);
@ -74,6 +75,21 @@ page {
.place-textarea { .place-textarea {
color: rgba(0, 0, 0, 0.3); 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 { .share {
flex-shrink: 0; flex-shrink: 0;
text-align: center; text-align: center;
margin: 0;
padding: 0;
&::after {
border: none;
}
.icon { .icon {
display: block; display: block;
width: 48rpx; width: 48rpx;

126
src/pages/applyFrom/index.ts

@ -1,15 +1,135 @@
const _app = getApp<IAppOption>() const app = getApp<IAppOption>()
Page({ Page({
data: { data: {
pageTop: 0, pageTop: 0,
background: 'transparent', background: 'transparent',
Id: '',
UserName: '',
Relation: '',
BirthMonth: '',
ProvinceId: '',
CityId: '',
Telephone: '',
Remark: '',
ProvinceName: '',
CityName: '',
Argument: false,
}, },
onLoad() { 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() { handleSubmit() {
wx.navigateTo({ const { Id, UserName, Relation, BirthMonth, ProvinceId, CityId, Telephone, Remark, Argument } = this.data
url: '/pages/applyFromResult/index', 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',
})
}) })
}, },
}) })

41
src/pages/applyFrom/index.wxml

@ -1,5 +1,5 @@
<navbar title="基因疗法筛查申请" fixed custom-style="background:{{background}}"> <navbar title="基因疗法筛查申请" fixed custom-style="background:{{background}}">
<van-icon name="arrow-left" slot="left" size="18px" color="#000" /> <van-icon name="arrow-left" slot="left" size="18px" color="#000" />
</navbar> </navbar>
<view <view
@ -11,24 +11,30 @@
<view class="label required">您的身份</view> <view class="label required">您的身份</view>
<view class="content"> <view class="content">
<view class="select"> <view class="select">
<view class="s-btn active">本人</view> <view class="s-btn {{Relation == 1 && 'active'}}" bind:tap="handleRelation" data-value="1">本人</view>
<view class="s-btn">亲友</view> <view class="s-btn {{Relation == 2 && 'active'}}" bind:tap="handleRelation" data-value="2">亲友</view>
</view> </view>
</view> </view>
</view> </view>
<view class="from-item"> <view class="from-item">
<view class="label required">您的姓名</view> <view class="label required">您的姓名</view>
<view class="content"> <view class="content">
<input class="input" placeholder-class="place-input" type="text" placeholder="如何称呼您" /> <input
model:value="{{UserName}}"
class="input"
placeholder-class="place-input"
type="text"
placeholder="如何称呼您"
/>
</view> </view>
</view> </view>
<view class="from-item"> <view class="from-item">
<view class="label required">您的出生年月</view> <view class="label required">您的出生年月</view>
<view class="content"> <view class="content">
<picker mode="date"> <picker mode="date" model:value="{{BirthMonth}}" fields="month">
<view class="picker"> <view class="picker">
<view class="picker-content"> <view class="picker-content">
<view class="picker-text" data-place="请选择您的出生月"></view> <view class="picker-text" data-place="请选择您的出生月">{{BirthMonth}}</view>
<van-icon name="arrow-down" color="rgba(51,51,51,0.73)" /> <van-icon name="arrow-down" color="rgba(51,51,51,0.73)" />
</view> </view>
</view> </view>
@ -38,41 +44,48 @@
<view class="from-item"> <view class="from-item">
<view class="label required">所在地区</view> <view class="label required">所在地区</view>
<view class="content"> <view class="content">
<picker mode="region" level="city"> <pickerArea mode="region" value="{{CityId}}" level="city" level="{{2}}" bind:change="handleAreaChange">
<view class="picker"> <view class="picker">
<view class="picker-content"> <view class="picker-content">
<view class="picker-text" data-place="请选择您的所在地区"></view> <!-- prettier-ignore -->
<view class="picker-text" data-place="请选择您的所在地区">{{ProvinceName ? ProvinceName+ '/' : ProvinceName }}{{CityName}}</view>
<van-icon name="arrow-down" color="rgba(51,51,51,0.73)" /> <van-icon name="arrow-down" color="rgba(51,51,51,0.73)" />
</view> </view>
</view> </view>
</picker> </pickerArea>
</view> </view>
</view> </view>
<view class="from-item"> <view class="from-item">
<view class="label required">如何联系您</view> <view class="label required">如何联系您</view>
<view class="content"> <view class="content">
<button class="tel" open-type="getPhoneNumber" bindgetphonenumber="handlePhoneNumber"></button> <view wx:if="{{Telephone}}">{{Telephone}}</view>
<button wx:else class="tel" open-type="getPhoneNumber" bindgetphonenumber="handlePhoneNumber">一键获取</button>
</view> </view>
</view> </view>
<view class="from-item"> <view class="from-item">
<view class="label">其他说明</view> <view class="label">其他说明</view>
<view class="content"> <view class="content">
<textarea class="textarea" placeholder-class="place-textarea" placeholder="输入说明"></textarea> <textarea
model:value="{{Remark}}"
class="textarea"
placeholder-class="place-textarea"
placeholder="输入说明"
></textarea>
</view> </view>
</view> </view>
</view> </view>
<view class="argument"> <view class="argument">
<radio class="radio" color="#e73e37"></radio> <radio class="radio" model:checked="{{Argument}}" color="#e73e37"></radio>
<view class="content"> <view class="content">
我已阅读并同意 我已阅读并同意
<text class="link">《服务隐私政策》</text> <text class="link">《服务隐私政策》</text>
</view> </view>
</view> </view>
<view class="footer"> <view class="footer">
<view class="share"> <button open-type="share" class="share">
<image class="icon" src="/images/icon4.png"></image> <image class="icon" src="/images/icon4.png"></image>
<view class="name">分享</view> <view class="name">分享</view>
</view> </button>
<view class="submit" bind:tap="handleSubmit">提交报名信息</view> <view class="submit" bind:tap="handleSubmit">提交报名信息</view>
</view> </view>
</view> </view>

19
src/pages/applyFromResult/index.ts

@ -1,11 +1,26 @@
const _app = getApp<IAppOption>() const app = getApp<IAppOption>()
Page({ Page({
data: { data: {
pageTop: 0, pageTop: 0,
background: 'transparent', 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 {} export {}

2
src/pages/applyFromResult/index.wxml

@ -10,7 +10,7 @@
<text class="time">48</text> <text class="time">48</text>
小时内与您联系 小时内与您联系
</view> </view>
<image class="code" show-menu-by-longpress src="/images/icon5.png"></image> <image class="code" show-menu-by-longpress src="{{codeImg}}"></image>
<view class="tip">关注公众号,接收您的服务提醒</view> <view class="tip">关注公众号,接收您的服务提醒</view>
</view> </view>
</view> </view>

57
src/pages/index/index.ts

@ -1,4 +1,4 @@
const _app = getApp<IAppOption>() const app = getApp<IAppOption>()
Page({ Page({
data: { data: {
@ -8,13 +8,40 @@ Page({
position: 'bottom', position: 'bottom',
}, },
userInfo: {},
bannerList: [],
pageTop: '', pageTop: '',
background: 'transparent', background: 'transparent',
}, },
onLoad() { onLoad() {
const menuInfo = wx.getMenuButtonBoundingClientRect() app.waitLogin().then(() => {
this.setData({ this.setData({
pageTop: menuInfo.bottom, 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) { routerTo(e) {
@ -23,6 +50,28 @@ Page({
url, 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 {} export {}

26
src/pages/index/index.wxml

@ -3,14 +3,21 @@
</navbar> </navbar>
<view class="page"> <view class="page">
<swiper class="banner" indicator-dots indicator-active-color="#fff" indicator-color="rgba(255 255 255,0.3)"> <swiper class="banner" indicator-dots indicator-active-color="#fff" indicator-color="rgba(255 255 255,0.3)">
<swiper-item class="banner-item"> <swiper-item
<image class="banner-item-img" src="/images/index-banner1.png"></image> class="banner-item"
wx:for="{{bannerList}}"
wx:key="index"
bindtap="onBannerItemTap"
data-path="{{item.path}}"
>
<image class="banner-item-img" src="{{item.imgUrl}}"></image>
</swiper-item> </swiper-item>
</swiper> </swiper>
<view class="page-containr"> <view class="page-containr">
<view class="apply" bind:tap="routerTo" data-url="/pages/applyFrom/index"> <view class="apply" bind:tap="routerTo" data-url="/pages/applyFrom/index">
<image class="a-img" src="/images/index-apply.png"></image> <image wx:if="{{userInfo.ApplyIntentionId}}" class="a-img" src="/images/index-apply-end.png"></image>
<image class="a-label" src="/images/index-apply-label.png"></image> <image wx:else class="a-img" src="/images/index-apply.png"></image>
<image wx:if="{{userInfo.ApplyIntentionId}}" class="a-label" src="/images/index-apply-label.png"></image>
</view> </view>
<view class="module1"> <view class="module1">
<view class="module-header"> <view class="module-header">
@ -71,5 +78,12 @@
</view> </view>
</view> </view>
<popup model:show="{{popupShow}}" type="{{popupType}}" params="{{popupParams}}"></popup> <popup
<login show="{{true}}"></login> show="{{popupShow}}"
type="{{popupType}}"
params="{{popupParams}}"
bind:ok="handlePopupOk"
bind:cancel="handlePopupCancel"
></popup>
<login show="{{false}}"></login>

16
src/pages/my/index.scss

@ -6,11 +6,21 @@ page {
.user { .user {
display: flex; display: flex;
align-items: center; align-items: center;
.avatar { .avatar-wrapper {
flex-shrink: 0; flex-shrink: 0;
padding: 0;
margin: 0;
width: 128rpx; width: 128rpx;
height: 128rpx; height: 128rpx;
border-radius: 50%; outline: none;
&::after {
border: none;
}
.avatar {
width: 128rpx;
height: 128rpx;
border-radius: 50%;
}
} }
.wrap { .wrap {
padding-left: 24rpx; padding-left: 24rpx;
@ -116,6 +126,6 @@ page {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-size: 32rpx; font-size: 32rpx;
color: rgba(1, 1, 5, 0.40); color: rgba(1, 1, 5, 0.4);
} }
} }

53
src/pages/my/index.ts

@ -1,12 +1,59 @@
const _app = getApp<IAppOption>() const app = getApp<IAppOption>()
Page({ Page({
data: { data: {
popupShow: true, popupShow: false,
popupType: 'stayTuned', popupType: 'stayTuned',
popupParams: {}, 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() { handlePopupCancel() {
this.setData({ this.setData({
popupShow: false, popupShow: false,

17
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;" style="background: url('/images/bg1.png') no-repeat top center/100% 602rpx;padding-top:{{pageTop+21}}px;"
> >
<view class="user"> <view class="user">
<image <button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
class="avatar" <image class="avatar" src="{{userInfo.Avatar}}"></image>
src="https://pic1.zhimg.com/50/v2-8cfef5f9ea7d15963af2277c6814f152_720w.jpg?source=2c26e567" </button>
></image>
<view class="wrap"> <view class="wrap">
<view class="name"> <view class="name">
<text class="nickname">小明</text> <text class="nickname">???</text>
<image class="icon" src="/images/icon12.png"></image> <image class="icon" src="/images/icon12.png"></image>
</view> </view>
<view class="day"> <view class="day">
今天是陪伴您的第 今天是陪伴您的第
<text class="num">32</text> <text class="num">{{userInfo.Days}}</text>
</view> </view>
</view> </view>
</view> </view>
<view class="apply" bind:tap="routerTo" data-url="/pages/applyFrom/index"> <view class="apply" bind:tap="routerTo" data-url="/pages/applyFrom/index">
<image class="a-img" src="/images/index-apply.png"></image> <image wx:if="{{userInfo.ApplyIntentionId}}" class="a-img" src="/images/index-apply-end.png"></image>
<image class="a-label" src="/images/index-apply-label.png"></image> <image wx:else class="a-img" src="/images/index-apply.png"></image>
<image wx:if="{{userInfo.ApplyIntentionId}}" class="a-label" src="/images/index-apply-label.png"></image>
</view> </view>
<view class="list"> <view class="list">
<view class="list-header"> <view class="list-header">

4
src/utils/page.ts

@ -52,8 +52,8 @@ function page(config: WechatMiniprogram.Page.Instance<WechatMiniprogram.IAnyObje
urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1) urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1)
return { return {
title: '分享标题', title: '血友病B 基因疗法数字化平台',
path: '/pages/index/index', path: url,
// imageUrl: `${getApp().globalData.imageUrl}1/1.png?t=${Timestamp}`, // imageUrl: `${getApp().globalData.imageUrl}1/1.png?t=${Timestamp}`,
} }
} }

43
typings/index.d.ts vendored

@ -27,50 +27,23 @@ type pickerList = pickerItem[]
interface IAppOption { interface IAppOption {
globalData: { globalData: {
userInfo: {
UserId?: string
PatientId?: number
PatientName?: string
AuditStatus?: number
UserType?: number
RelationType?: number
isFollow?: number
UserRegTime?: string
IsRootUser?: number
AgeYear?: number
AgeMonth?: number
Birth?: string
DiagnosisTime?: string
DiagnoseType?: number
DiagnoseImg?: string
CommitTime?: string
IsSick?: number
IsUseDrugs?: number
IsAliQiWei?: 0 | 1
}
url?: string url?: string
upFileUrl: string upFileUrl: string
imageUrl: string imageUrl: string
/**
* token
*/
Timestamp: number Timestamp: number
loginState: string
isReg: string
registrationSource: number loginState: string
registChannel: number isLogin: 0 | 1
regBusinessId: string isReg: 0 | 1
userId: string
guestPrivacyAgree: boolean
[propName: string]: any [propName: string]: any
} }
updateUserInfo: (encryptedData: string, iv: string) => Promise<any> getUserInfo: () => Promise<any>
getCode: () => Promise<any>
doLogin: () => Promise<any>
waitLogin: (obj?: { isReg?: boolean; loginPage?: boolean }) => Promise<any>
startLogin: () => void startLogin: () => void
getUserInfo: (self?, update?: boolean, callback?: (userinfo) => void) => void waitLogin: () => Promise<void>
mpBehavior: (data: { PageName: string; doctor?: boolean }) => void mpBehavior: (data: { PageName: string; doctor?: boolean }) => void
globalSystemInfo?: globalSystemInfo globalSystemInfo?: globalSystemInfo
[propName: string]: any [propName: string]: any

Loading…
Cancel
Save