hh-doctor-sdk 0.9.1 → 0.9.2
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.
|
@@ -9,6 +9,7 @@ const doctorLoader = require('../../public/doctor-loader')
|
|
|
9
9
|
const permission = require('../../utils/permission-utils')
|
|
10
10
|
const imManager = require('../../public/im-manager')
|
|
11
11
|
const cache = require('../../public/cache-data')
|
|
12
|
+
const loginGuard = require('../../public/login-guard')
|
|
12
13
|
const { urlEndsWith } = require('../../utils/common-utils')
|
|
13
14
|
|
|
14
15
|
Page({
|
|
@@ -66,10 +67,14 @@ Page({
|
|
|
66
67
|
this.setData({
|
|
67
68
|
showPreview: false,
|
|
68
69
|
})
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
// 未登录时 onLoad 已经去登录页,这里再刷新会失败并 navigateBack,把登录页弹掉
|
|
73
|
+
if (!loginGuard.isLoggedIn()) {
|
|
74
|
+
wx.stopPullDownRefresh()
|
|
75
|
+
return
|
|
72
76
|
}
|
|
77
|
+
wx.startPullDownRefresh()
|
|
73
78
|
},
|
|
74
79
|
|
|
75
80
|
/**
|
|
@@ -110,6 +115,10 @@ Page({
|
|
|
110
115
|
},
|
|
111
116
|
|
|
112
117
|
_refreshOrder() {
|
|
118
|
+
if (!loginGuard.isLoggedIn()) {
|
|
119
|
+
wx.stopPullDownRefresh()
|
|
120
|
+
return
|
|
121
|
+
}
|
|
113
122
|
if (this.data.orderId === null || this.data.orderId === '') {
|
|
114
123
|
return
|
|
115
124
|
}
|
|
@@ -20,9 +20,10 @@ Page({
|
|
|
20
20
|
* 生命周期函数--监听页面加载
|
|
21
21
|
*/
|
|
22
22
|
onLoad(options) {
|
|
23
|
-
// 短链直达列表页时,链接里的 doctorId / userToken 要落下来,否则 onShow 只读 storage
|
|
23
|
+
// 短链直达列表页时,链接里的 doctorId / userToken 要落下来,否则 onShow 只读 storage 会取空。
|
|
24
|
+
// doctorId 先校验格式再写,避免转发来的链接把本地医生身份覆盖成脏值
|
|
24
25
|
const doctorId = options && options.doctorId ? String(options.doctorId).trim() : ''
|
|
25
|
-
if (doctorId) {
|
|
26
|
+
if (/^[DE]\d{19}$/.test(doctorId)) {
|
|
26
27
|
wx.setStorageSync('doctorId', doctorId)
|
|
27
28
|
}
|
|
28
29
|
hhDoctor.absorbEntryOptions(options)
|
|
@@ -92,6 +93,11 @@ Page({
|
|
|
92
93
|
init: true
|
|
93
94
|
})
|
|
94
95
|
}
|
|
96
|
+
} else {
|
|
97
|
+
// 未登录被引导去登录、或拉医生信息失败:复位 loading,避免停在加载态
|
|
98
|
+
this.setData({
|
|
99
|
+
isLoading: false
|
|
100
|
+
})
|
|
95
101
|
}
|
|
96
102
|
})
|
|
97
103
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const api = require('../../apis/order-app-api')
|
|
2
2
|
const cache = require('../../public/cache-data')
|
|
3
|
+
const loginGuard = require('../../public/login-guard')
|
|
3
4
|
|
|
4
5
|
module.exports = Behavior({
|
|
5
6
|
|
|
@@ -20,10 +21,12 @@ module.exports = Behavior({
|
|
|
20
21
|
* @param options keepPage 为 true 时失败只留日志,不提示也不退出页面
|
|
21
22
|
*/
|
|
22
23
|
loadOrder(callback, options) {
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
// 未登录时详情页 onShow 仍会进来。请求必定失败,随后 navigateBack 会把刚打开的登录页退掉。
|
|
25
|
+
if (!loginGuard.isLoggedIn()) {
|
|
26
|
+
wx.hideNavigationBarLoading()
|
|
27
|
+
wx.stopPullDownRefresh()
|
|
28
|
+
return
|
|
29
|
+
}
|
|
27
30
|
const requestToken = (this._orderLoadToken || 0) + 1
|
|
28
31
|
this._orderLoadToken = requestToken
|
|
29
32
|
const orderId = this.data.orderId
|
|
@@ -61,7 +64,10 @@ module.exports = Behavior({
|
|
|
61
64
|
}
|
|
62
65
|
wx.statLog.sendStatLog(orderId, `获取订单数据出错${JSON.stringify(e)}`)
|
|
63
66
|
wx.hideLoading()
|
|
64
|
-
|
|
67
|
+
wx.hideNavigationBarLoading()
|
|
68
|
+
wx.stopPullDownRefresh()
|
|
69
|
+
// 请求发出后登录态没了:同样不能退栈,否则登录页会被弹掉
|
|
70
|
+
if ((options && options.keepPage) || !loginGuard.isLoggedIn()) {
|
|
65
71
|
return
|
|
66
72
|
}
|
|
67
73
|
wx.showToast({
|
|
@@ -84,9 +84,17 @@ function uuid() {
|
|
|
84
84
|
return null
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/** 链接参数里的 token 只采纳一次,避免退出登录后又被取回 */
|
|
88
|
+
let linkTokenConsumed = false
|
|
89
|
+
|
|
87
90
|
function setUserToken(token) {
|
|
91
|
+
const value = token || ''
|
|
92
|
+
if (value) {
|
|
93
|
+
// 任何来源写过非空 token 后,本次启动内不再回退到链接参数
|
|
94
|
+
linkTokenConsumed = true
|
|
95
|
+
}
|
|
88
96
|
cache({
|
|
89
|
-
userToken:
|
|
97
|
+
userToken: value
|
|
90
98
|
})
|
|
91
99
|
}
|
|
92
100
|
|
|
@@ -117,16 +125,26 @@ function storedUserToken() {
|
|
|
117
125
|
}
|
|
118
126
|
|
|
119
127
|
function linkUserToken() {
|
|
128
|
+
if (linkTokenConsumed) {
|
|
129
|
+
return ''
|
|
130
|
+
}
|
|
120
131
|
const pick = (options) => {
|
|
121
132
|
const query = (options && options.query) || {}
|
|
122
133
|
return query.userToken || query.hhusertoken || ''
|
|
123
134
|
}
|
|
135
|
+
let token = ''
|
|
124
136
|
try {
|
|
125
137
|
const enter = wx.getEnterOptionsSync && wx.getEnterOptionsSync()
|
|
126
|
-
|
|
138
|
+
token = pick(enter) || pick(wx.getLaunchOptionsSync && wx.getLaunchOptionsSync())
|
|
127
139
|
} catch (e) {
|
|
140
|
+
token = ''
|
|
141
|
+
}
|
|
142
|
+
if (!token) {
|
|
128
143
|
return ''
|
|
129
144
|
}
|
|
145
|
+
// 采纳一次即落库,之后都走内存/storage;退出登录清空后不会再从链接取回
|
|
146
|
+
setUserToken(token)
|
|
147
|
+
return token
|
|
130
148
|
}
|
|
131
149
|
|
|
132
150
|
function videoToken() {
|