hh-doctor-sdk 0.8.7 → 0.9.0

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.
@@ -8,20 +8,12 @@ const doctorLoader = require('../../public/doctor-loader')
8
8
  const permission = require('../../utils/permission-utils')
9
9
  const imManager = require('../../public/im-manager')
10
10
  const cache = require('../../public/cache-data')
11
- const appConfig = require('../../public/app-config')
12
11
  const { urlEndsWith } = require('../../utils/common-utils')
13
12
 
14
13
  Page({
15
14
 
16
15
  behaviors: [require('./behaviors/consultation-behaviors'), require('./behaviors/consultation-reply-behaviors')],
17
16
 
18
- /**
19
- * 页面的初始数据
20
- */
21
- data: {
22
- sdkVersion: appConfig.sdkVersion,
23
- },
24
-
25
17
  /**
26
18
  * 生命周期函数--监听页面加载
27
19
  */
@@ -1,6 +1,5 @@
1
1
  <import src="../detail/widget/chat-cell-template/chat-cell-template" />
2
- <view class="sdk-version-mark">hh-doctor-sdk {{sdkVersion}}(IM 刷新版)</view>
3
- <view class="match-parent body-display sdk-detail-body">
2
+ <view class="match-parent body-display">
4
3
  <view
5
4
  id="scroll-body"
6
5
  class="body-display"
@@ -6,27 +6,6 @@ page {
6
6
  height: 100%;
7
7
  }
8
8
 
9
- .sdk-version-mark {
10
- position: fixed;
11
- top: 0;
12
- left: 0;
13
- right: 0;
14
- z-index: 9999;
15
- background-color: #ff4d4f;
16
- color: #ffffff;
17
- font-size: 28rpx;
18
- font-weight: bold;
19
- text-align: center;
20
- line-height: 1.4;
21
- padding: 16rpx 24rpx;
22
- padding-top: calc(16rpx + env(safe-area-inset-top));
23
- box-shadow: 0 4rpx 12rpx rgba(255, 77, 79, 0.45);
24
- }
25
-
26
- .sdk-detail-body {
27
- padding-top: calc(72rpx + env(safe-area-inset-top));
28
- }
29
-
30
9
  .body-display {
31
10
  position: absolute;
32
11
  width: 100%;
@@ -51,9 +51,10 @@ Page({
51
51
  if (judgeLogin) {
52
52
  wx.statLog.sendStatLog(null, '打开咨询单列表界面')
53
53
  const doctorId = wx.getStorageSync('doctorId') || ''
54
- // console.error(`doctorId => ${doctorId}`)
54
+ const userToken = wx.getStorageSync('userToken') || ''
55
55
  cache.cache({
56
- doctorId: doctorId
56
+ doctorId: doctorId,
57
+ userToken: userToken
57
58
  })
58
59
  if (!doctorId) {
59
60
  this.setData({
@@ -1,5 +1,5 @@
1
1
  const api = require('./apis/order-app-api')
2
- const { doctor } = require('./public/cache-data')
2
+ const cache = require('./public/cache-data')
3
3
 
4
4
  function initEventBus() {
5
5
  if (wx.eventBus) {
@@ -37,6 +37,17 @@ function setLoginCheck(judgeLogin, directLogin) {
37
37
  wx.loginConfig.directLogin = directLogin
38
38
  }
39
39
 
40
+ /** 宿主在拉医生信息前写入 userToken,order 请求和换 session 都读这份 */
41
+ function setUserToken(userToken) {
42
+ const token = (userToken || '').trim()
43
+ cache.setUserToken(token)
44
+ if (token) {
45
+ wx.setStorageSync('userToken', token)
46
+ } else {
47
+ wx.removeStorageSync('userToken')
48
+ }
49
+ }
50
+
40
51
  /**
41
52
  * 检测医生信息是否认证完成
42
53
  * @param {*} doctorId 医生Id
@@ -86,6 +97,7 @@ module.exports = {
86
97
  initTim,
87
98
  initStatLog,
88
99
  setLoginCheck,
100
+ setUserToken,
89
101
  enterForground,
90
102
  enterBackground,
91
103
  isDoctorAuth
@@ -1,12 +1,10 @@
1
1
  /** 发版 npm 时与 package.json version 保持一致 */
2
- const sdkVersion = '0.8.7'
2
+ const sdkVersion = '0.8.8'
3
3
 
4
4
  const appVersion = '7.1.6'
5
5
  const appID = '10423'
6
6
  const appKey = ''
7
7
  const appSecret = 'N0e7293NSF8nBZjO'
8
- const sessionId = '1776843236242882600'
9
- const sessionIdProd = '1792831747042312418'
10
8
 
11
9
  module.exports = {
12
10
  sdkVersion,
@@ -14,6 +12,4 @@ module.exports = {
14
12
  appID,
15
13
  appKey,
16
14
  appSecret,
17
- sessionId,
18
- sessionIdProd,
19
15
  }
@@ -84,7 +84,18 @@ function uuid() {
84
84
  return null
85
85
  }
86
86
 
87
+ function setUserToken(token) {
88
+ cache({
89
+ userToken: token || ''
90
+ })
91
+ }
92
+
93
+ /** 外部预先写入的 userToken 优先;医生信息回来后仍可回退到 doctor.userToken */
87
94
  function userToken() {
95
+ const preset = getValue('userToken')
96
+ if (preset) {
97
+ return preset
98
+ }
88
99
  const doctorInfo = doctor()
89
100
  if (doctorInfo) {
90
101
  return doctorInfo.userToken
@@ -134,5 +145,6 @@ module.exports = {
134
145
  getLogId,
135
146
  clearLogId,
136
147
  isRequest,
148
+ setUserToken,
137
149
  userToken,
138
150
  }
@@ -7,6 +7,12 @@ const cache = require('./cache-data')
7
7
  */
8
8
  function loadDoctor(options, callback) {
9
9
  const doctorId = options.doctorId
10
+ if (!cache.userToken()) {
11
+ const storedToken = wx.getStorageSync('userToken') || ''
12
+ if (storedToken) {
13
+ cache.setUserToken(storedToken)
14
+ }
15
+ }
10
16
  if (!doctorId) {
11
17
  wx.statLog.sendStatLog(null, `场景:${options.scence || '未知'} 未传必要的参数`)
12
18
  wx.showToast({