im.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="im">
  3. <commons-header></commons-header>
  4. <view style="margin-top:128rpx" @click="bindConfirmInvite">
  5. <view class="company-list">
  6. <view class="company-title"><span>新美特</span></view>
  7. <view class="list-box">
  8. <view class="user-img">
  9. </view>
  10. <view class="user-text">
  11. <p>张三</p>
  12. <span>总经理</span>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import commonsHeader from '../../components/commons-header/index.vue'
  21. import { setTokenStorage } from '../../utils/token';
  22. import logger from '../../utils/logger';
  23. import { genTestUserSig } from '../../debug/GenerateTestUserSig.js';
  24. const { getTokenStorage } = require('../../utils/token.js');
  25. const app = getApp();
  26. export default {
  27. components:{
  28. commonsHeader
  29. },
  30. data() {
  31. return {
  32. userID: '',
  33. hidden: false,
  34. btnValue: '获取验证码',
  35. btnDisabled: false,
  36. privateAgree: false,
  37. phone: '',
  38. code: '',
  39. sessionID: '',
  40. second: 60,
  41. path: '',
  42. lastTime: 0,
  43. countryIndicatorStatus: false,
  44. country: '86',
  45. indicatorValue: 46,
  46. headerHeight: app.globalData.headerHeight,
  47. statusBarHeight: app.globalData.statusBarHeight,
  48. showlogin: false
  49. }
  50. },
  51. onLoad(option) {
  52. const v = this
  53. this.setData({
  54. path: option.path
  55. });
  56. uni.getStorage({
  57. // 获取本地缓存
  58. key: 'sessionID',
  59. success(res) {
  60. that.setData({
  61. sessionID: res.data
  62. });
  63. }
  64. });
  65. uni.setStorage({
  66. key: 'path',
  67. data: option.path
  68. });
  69. setTimeout(()=>{
  70. v.imInit()
  71. },5000)
  72. },
  73. methods: {
  74. bindConfirmInvite() {
  75. uni.$TUIKit
  76. .getUserProfile({
  77. userIDList: ['111']
  78. })
  79. .then(imRes => {
  80. if (imRes.data.length > 0) {
  81. console.log(imRes.data[0].userID)
  82. uni.navigateTo({
  83. url: `../TUI-Chat/chat?conversationID=C2C${imRes.data[0].userID}`
  84. });
  85. } else {
  86. uni.showToast({
  87. title: '用户不存在',
  88. icon: 'error'
  89. });
  90. this.setData({
  91. userID: ''
  92. });
  93. }
  94. });
  95. },
  96. imInit(){
  97. const userID = '111';
  98. const userSig = genTestUserSig(userID).userSig;
  99. const SDKAppID = app.globalData.SDKAppID;
  100. app.globalData.userInfo = {
  101. userSig,
  102. userID
  103. };
  104. setTokenStorage({
  105. userInfo: app.globalData.userInfo
  106. });
  107. wx.setStorageSync(`TIM_${getApp().SDKAppID}_isTUIKit`, true);
  108. uni.$TUIKit.login({
  109. userID: userID,
  110. userSig: userSig
  111. }).then(() => {
  112. }).catch((error) => {
  113. })
  114. console.log(SDKAppID,userID,userSig)
  115. uni.$TUICalling.login(
  116. {
  117. sdkAppID: SDKAppID,
  118. userID: userID,
  119. userSig: userSig
  120. },
  121. res => {
  122. console.log(JSON.stringify(res.msg));
  123. // uni.showToast({
  124. // title: 'login',
  125. // icon: 'none'
  126. // });
  127. // uni.navigateTo({
  128. // url: '../TUI-Index/index'
  129. // });
  130. }
  131. );
  132. // 登录原生插件
  133. // #ifdef APP-PLUS
  134. // if(typeof(uni.$TUICalling) == 'undefined') {
  135. // uni.showToast({
  136. // title: '如果需要音视频功能,请集成插件使用真机运行并且自定义基座调试哦~',
  137. // icon: 'none',
  138. // duration: 3000
  139. // });
  140. // logger.error('请使用真机运行并且自定义基座调试,否则影响音视频功能~ 插件地址:https://ext.dcloud.net.cn/plugin?id=7097 , 调试地址:https://nativesupport.dcloud.net.cn/NativePlugin/use/use');
  141. // } else {
  142. // }
  143. // #endif
  144. if (this.path && this.path !== 'undefined') {
  145. uni.redirectTo({
  146. url: this.path
  147. });
  148. } else {
  149. }
  150. },
  151. },
  152. }
  153. </script>
  154. <style lang="less">
  155. .im{
  156. background-color: #f1f1f1;
  157. min-height: calc(100vh - 128rpx);
  158. .company-title{
  159. height: 100rpx;
  160. line-height: 100rpx;
  161. color: #333;
  162. font-size: 28rpx;
  163. position: relative;
  164. padding: 0 47rpx;
  165. background-color: #fff;
  166. border-bottom: 1rpx solid #ddd;
  167. }
  168. .company-title::before{
  169. content:' ';
  170. position: absolute;
  171. width: 8rpx;
  172. height: 32rpx;
  173. top: 35rpx;
  174. left: 24rpx;
  175. background-color: #3370FF;
  176. }
  177. .list-box{
  178. background-color: #fff;
  179. height: 160rpx;
  180. padding: 40rpx 24rpx;
  181. display: flex;
  182. box-sizing: border-box;
  183. .user-img{
  184. height: 80rpx;
  185. width: 80rpx;
  186. background-color: #3370FF;
  187. border-radius: 10rpx;
  188. color: #fff;
  189. text-align: center;
  190. line-height: 80rpx;
  191. }
  192. .user-text{
  193. margin-left: 24rpx;
  194. line-height: 40rpx;
  195. p{
  196. color: #333;
  197. font-size: 28rpx;
  198. }
  199. span{
  200. color: #999;
  201. font-size: 24rpx;
  202. }
  203. }
  204. }
  205. }
  206. </style>