wechatList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="popupBox ">
  3. <view class="es-bc-white popupBox-content" v-if="userList.length>0">
  4. <view class="u-f es-mt-20 popupBox-content-list" v-for="(item,index) in userList" :key="index"
  5. @tap="loginByUserIdFun(item)">
  6. <view class="es-mr-20">
  7. <image class="es-icon-90 es-br-ban" :src="item.avatar" mode=""></image>
  8. </view>
  9. <view class="es-fs-40 es-fw x-c">
  10. {{item.nickName}}
  11. </view>
  12. </view>
  13. </view>
  14. <view v-else>
  15. <u-empty></u-empty>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. loginByUserId
  22. } from '@/api/user'
  23. export default {
  24. data() {
  25. return {
  26. userList: []
  27. }
  28. },
  29. mounted() {
  30. this.getRegistrationID()
  31. const wechatList = uni.getStorageSync('wechatList')
  32. if (wechatList) {
  33. this.userList = wechatList
  34. uni.removeStorageSync('wechatList')
  35. }
  36. },
  37. methods: {
  38. getRegistrationID() {
  39. let registrationID = uni.getStorageSync("registrationID");
  40. if (!registrationID) {
  41. uni.getPushClientId({
  42. success: res => {
  43. uni.setStorageSync("registrationID", res.cid);
  44. }
  45. });
  46. }
  47. },
  48. async loginByUserIdFun(e) {
  49. const requestParam = uni.getStorageSync('requestParam')
  50. uni.removeStorageSync('requestParam')
  51. let params = {
  52. ...requestParam,
  53. userId: e.userId,
  54. jpushId: uni.getStorageSync("registrationID")
  55. }
  56. const res = await loginByUserId(params)
  57. if (res.code == 200) {
  58. uni.setStorageSync('AppToken', res.token);
  59. uni.setStorageSync('userInfo', JSON.stringify(res.user));
  60. uni.$emit('refreshIM');
  61. uni.$emit('showHealthButler');
  62. this.goPage();
  63. } else {
  64. uni.showToast({
  65. title: res.msg,
  66. icon: 'none'
  67. });
  68. }
  69. },
  70. goPage() {
  71. let pages = getCurrentPages();
  72. let url = pages[pages.length - 1];
  73. let openUrl = uni.getStorageSync("openUrl");
  74. if (openUrl) {
  75. uni.navigateTo({
  76. url: openUrl,
  77. success: function(res) {
  78. uni.removeStorageSync("openUrl")
  79. }
  80. })
  81. } else {
  82. this.$updateMsgDot();
  83. this.$setSource();
  84. uni.reLaunch({
  85. // url: '../course/index',
  86. url: '/pages_im/pages/conversation/conversationList/index',
  87. animationType: 'none',
  88. animationDuration: 2000
  89. });
  90. return;
  91. if (pages.length == 1) {
  92. uni.reLaunch({
  93. // url: '../course/index',
  94. url: '/pages_im/pages/conversation/conversationList/index',
  95. //url: '../course/video/living-app',
  96. animationType: 'none',
  97. animationDuration: 2000
  98. });
  99. } else {
  100. //this.$navBack();
  101. }
  102. }
  103. },
  104. },
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .popupBox {
  109. padding: 48rpx 24rpx;
  110. padding-top: 0rpx;
  111. margin-top: 24rpx;
  112. width: 100vw;
  113. box-sizing: border-box;
  114. flex-direction: column;
  115. .popupBox-content {
  116. padding: 24rpx;
  117. padding-bottom: 0;
  118. border-radius: 16rpx;
  119. .popupBox-content-list {
  120. padding-bottom: 24rpx;
  121. border-bottom: 1rpx solid #F7F8FA;
  122. &:last-child {
  123. border-bottom: none;
  124. }
  125. }
  126. }
  127. }
  128. </style>