uni-suspension.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view>
  3. <view class="suspension">
  4. <tm-badges v-if="num>0" :offset="[5,0]" :label="num" :dot="false"></tm-badges>
  5. <tm-button @click="change" :width="80" :height="80" fab :icon-size="40"
  6. icon="icon-aliwangwang"></tm-button>
  7. <!-- <view v-else>
  8. <tm-button v-if="user.nickname=='游客'" :open-type="user.nickname=='游客'?'getUserInfo':''"
  9. @getUserInfo='getUserInfo' :width="90" :height="90" fab :icon-size="50" icon="icon-aliwangwang" theme="blue"></tm-button>
  10. <tm-button v-else @click="goChat" :width="90" :height="90" fab :icon-size="50" icon="icon-aliwangwang" theme="blue"></tm-button>
  11. </view> -->
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {}
  19. },
  20. computed: {
  21. user() {
  22. return this.$tm.vx.state().user.userInfo || {}
  23. },
  24. num() {
  25. return this.$tm.vx.state().num.num
  26. }
  27. },
  28. methods: {
  29. change() {
  30. uni.navigateTo({
  31. url: "/pages/room/index"
  32. })
  33. },
  34. upData(name, avatar) {
  35. this.$tm.request.post('user/update', {
  36. nickname: name,
  37. avatar: avatar
  38. }).then(res => {
  39. this.$tm.vx.commit('user/setUserInfo', res.data)
  40. this.$tm.request.post('card/viewread', {
  41. card_id: this.$tm.vx.state().card.cardId
  42. }).then(res => {
  43. let {
  44. id,
  45. name,
  46. uid
  47. } = res.data.card
  48. this.chatClick(uid, name, id)
  49. })
  50. })
  51. },
  52. getUserInfo(e) {
  53. if (e) {
  54. this.upData(e.userInfo.nickName, e.userInfo.avatarUrl)
  55. }
  56. },
  57. goChat(){
  58. this.$tm.request.post('card/viewread', {
  59. card_id: this.$tm.vx.state().card.cardId
  60. }).then(res => {
  61. let {
  62. id,
  63. name,
  64. uid
  65. } = res.data.card
  66. this.chatClick(uid, name, id)
  67. })
  68. },
  69. chatClick(id, name, card_id) {
  70. uni.navigateTo({
  71. url: "/subpages/pages/card/cardChat?t_uid=" + id + '&name=' + name + '&card_id=' + card_id
  72. })
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. .suspension {
  79. position: fixed;
  80. bottom: 200rpx;
  81. right: 50rpx;
  82. }
  83. </style>