hh-doctor-sdk 0.0.2 → 0.0.3

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.
@@ -1,5 +1,7 @@
1
1
  const doctorLoader = require('../../public/doctor-loader')
2
-
2
+ const {
3
+ judgeLogin
4
+ } = require('../../utils/uiUtil')
3
5
  Page({
4
6
 
5
7
 
@@ -16,16 +18,7 @@ Page({
16
18
  * 生命周期函数--监听页面加载
17
19
  */
18
20
  onLoad(options) {
19
- wx.statLog.sendStatLog(null, '打开咨询单列表界面')
20
- const doctorId = options.doctorId
21
- doctorLoader.loadDoctor({
22
- doctorId: doctorId,
23
- isTest: options.isTest,
24
- }, (result) => {
25
- if (result) {
26
- this.loadList()
27
- }
28
- })
21
+
29
22
  },
30
23
 
31
24
  /**
@@ -37,11 +30,38 @@ Page({
37
30
  * 生命周期函数--监听页面显示
38
31
  */
39
32
  onShow() {
40
- if (this.data.needRefresh) {
41
- this.setData({
42
- needRefresh: false,
33
+ if (judgeLogin()) {
34
+ wx.statLog.sendStatLog(null, '打开咨询单列表界面')
35
+ const doctorId = wx.getStorageSync('doctorId') || ''
36
+ const isTest = (getApp().globalData.profileName || 'prod') == 'test'
37
+ doctorLoader.loadDoctor({
38
+ doctorId: doctorId,
39
+ isTest: isTest,
40
+ }, (result) => {
41
+ if (result) {
42
+ this.loadList()
43
+ }
44
+ })
45
+ } else {
46
+ wx.showModal({
47
+ showCancel: true,
48
+ cancelText: '取消',
49
+ confirmText: '去登录',
50
+ confirmColor: "#0066ff",
51
+ content: "您还未登录,是否去登录?",
52
+ complete: (res) => {
53
+ if (res.cancel) {
54
+ wx.switchTab({
55
+ url: '/pages/recommend/recommend',
56
+ })
57
+ }
58
+ if (res.confirm) {
59
+ wx.navigateTo({
60
+ url: '/pkgMine/pages/mine/loginpage',
61
+ })
62
+ }
63
+ }
43
64
  })
44
- this.loadList()
45
65
  }
46
66
  },
47
67
 
@@ -10,7 +10,7 @@ function initTim() {
10
10
  return
11
11
  }
12
12
  const imManager = require('./public/im-manager')
13
- imManager.init()
13
+ // imManager.init()
14
14
  wx.hhImManager = imManager
15
15
  }
16
16
 
@@ -3,11 +3,11 @@ function cache(data) {
3
3
  if (data.doctorId && data.doctorId !== null && data.doctorId !== '') {
4
4
  generateSessionId()
5
5
  }
6
- if (data.doctor != null) {
7
- const token = data.doctor.videoToken
8
- const uuid = data.doctor.uuid
9
- wx.hhImManager.loginIm(uuid, token)
10
- }
6
+ // if (data.doctor != null) {
7
+ // const token = data.doctor.videoToken
8
+ // const uuid = data.doctor.uuid
9
+ // wx.hhImManager.loginIm(uuid, token)
10
+ // }
11
11
  const newData = Object.assign(doctorOptions, data)
12
12
  wx.doctorOptions = newData
13
13
  }
@@ -10,9 +10,6 @@ const hhNavigation = require('../hh-navigation')
10
10
  const cache = require('../public/cache-data')
11
11
 
12
12
  var chat
13
- var isLogined = false
14
- var isReady = false
15
- var isInit = false
16
13
 
17
14
  let onMessageReceived = function (event) {
18
15
  const messageList = event.data;
@@ -30,7 +27,6 @@ let onMessageReceived = function (event) {
30
27
  } catch (ex) {
31
28
 
32
29
  }
33
-
34
30
  }
35
31
  });
36
32
  };
@@ -47,29 +43,32 @@ function onMessage(message) {
47
43
 
48
44
  let onSdkReady = function (event) {
49
45
  wx.statLog.sendStatLog(null, `IM SDK Ready`)
50
- isReady = true
51
46
  };
52
47
 
53
48
  let onSdkNotReady = function (event) {
54
49
  wx.statLog.sendStatLog(null, `IM SDK Not Ready ${JSON.stringify(event)}`)
55
- isReady = false
50
+ console.error('销毁腾讯IM实例 onSdkNotReady')
56
51
  };
57
52
 
58
53
  function init() {
59
- if (isInit) {
54
+ if (chat != null) {
60
55
  return
61
56
  }
62
57
  wx.statLog.sendStatLog(null, `初始化 IM 管理类`)
58
+ console.error('初始化 IM 管理类')
63
59
  let options = {
64
60
  SDKAppID: '1400073238'
65
61
  }
66
62
  chat = TencentCloudChat.create(options)
67
63
  chat.setLogLevel(0)
68
-
69
64
  chat.on(TencentCloudChat.EVENT.SDK_READY, onSdkReady);
70
65
  chat.on(TencentCloudChat.EVENT.SDK_NOT_READY, onSdkNotReady);
71
66
  chat.on(TencentCloudChat.EVENT.MESSAGE_RECEIVED, onMessageReceived);
72
- isInit = true
67
+
68
+
69
+ const uuid = cache.uuid()
70
+ const token = cache.videoToken()
71
+ loginIm(uuid, token)
73
72
  }
74
73
 
75
74
  /**
@@ -78,13 +77,13 @@ function init() {
78
77
  * @param {*} userSig 用户UserSign
79
78
  */
80
79
  function loginIm(userID, userSig) {
81
- wx.statLog.sendStatLog(null, `开始登录腾讯IM`)
80
+ wx.statLog.sendStatLog(null, '开始登录腾讯IM')
81
+ console.error('开始登录腾讯IM')
82
82
  if (chat) {
83
83
  chat.login({
84
84
  userID: userID.toString(),
85
85
  userSig
86
86
  }).then((res) => {
87
- isLogined = true
88
87
  wx.eventBus.post({
89
88
  params: {
90
89
  result: true
@@ -97,7 +96,7 @@ function loginIm(userID, userSig) {
97
96
  wx.statLog.sendStatLog(null, `登录腾讯IM完成`)
98
97
  }).catch((error) => {
99
98
  wx.statLog.sendStatLog(null, `登录腾讯IM失败 ${JSON.stringify(error)}`)
100
- isLogined = false
99
+ // isLogined = false
101
100
  wx.eventBus.post({
102
101
  params: {
103
102
  result: false
@@ -109,20 +108,16 @@ function loginIm(userID, userSig) {
109
108
  }
110
109
 
111
110
  function logoutIm() {
112
- if (isLogined) {
113
- if (chat) {
114
- chat.logout().then(() => {
115
- isLogined = false
116
- }).catch(() => {
117
- isLogined = false
118
- })
119
- }
111
+ if (chat) {
112
+ chat.logout().then(() => {}).catch(() => {})
120
113
  }
121
114
  }
122
115
 
123
116
  function destory() {
124
117
  if (chat) {
125
- chat.destory()
118
+ console.error('销毁腾讯IM实例')
119
+ chat.destroy()
120
+ chat = null
126
121
  }
127
122
  }
128
123
 
@@ -0,0 +1,7 @@
1
+ function judgeLogin() {
2
+ return true
3
+ }
4
+
5
+ module.exports = {
6
+ judgeLogin,
7
+ }
@@ -31,6 +31,7 @@ Page({
31
31
  if (!this.checkParams(options)) {
32
32
  return
33
33
  }
34
+ wx.hhImManager.init()
34
35
  this._sendLog('打开呼叫界面')
35
36
  wx.statLog.sendStatLog(this.data.orderId, '打开呼叫界面')
36
37
  this.bindIMMessageEvent()
@@ -64,6 +65,7 @@ Page({
64
65
  */
65
66
  onUnload() {
66
67
  this.unBindIMMessageEvent()
68
+ wx.hhImManager.destroy()
67
69
  },
68
70
 
69
71
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hh-doctor-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "和缓名医小程序SDK",
5
5
  "devDependencies": {},
6
6
  "scripts": {