businessCard.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view>
  3. <view class="userinfo">
  4. <u-avatar :src="userInfo.avatar" mode="square" size="110" @tap="previewImg(url)"></u-avatar>
  5. <view class="userinfo-desc">
  6. <view class="userinfo-desc-name">{{userInfo.nickName||userInfo.realname }}</view>
  7. <view class="userinfo-desc-gray">积分:{{userInfo.money}}</view>
  8. </view>
  9. </view>
  10. <view class="perch"></view>
  11. <u-cell-group v-if="1 == source">
  12. <u-cell-item title="粮友圈" label="暂不支持查看粮友圈" hover-class="none" :title-style="{ marginLeft: '10rpx' }"></u-cell-item>
  13. <u-cell-item title="更多信息" :title-style="{ marginLeft: '10rpx' }" @click="linkToMoreInfoMation"></u-cell-item>
  14. </u-cell-group>
  15. <view class="" v-if="!isItMe">
  16. <view class="perch"></view>
  17. <u-cell-group v-if="0 == source || 2 == source">
  18. <u-cell-item title=" " @click="toAddUser" :arrow="false" :center="true" :title-style="{ marginLeft: '10rpx' }">
  19. <view style="text-align: center;">添加到通讯录</view>
  20. </u-cell-item>
  21. </u-cell-group>
  22. <u-cell-group v-else-if="1 == source">
  23. <u-cell-item title="发消息" :arrow="false" :center="true" :title-style="{ marginLeft: '10rpx' }" @click="linkToChat">
  24. <u-icon slot="icon" name="chat" color="#36648B" size="34"></u-icon>
  25. </u-cell-item>
  26. </u-cell-group>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. userInfo:{
  35. },
  36. isItMe:false,
  37. source:'',
  38. $url:''
  39. }
  40. },
  41. methods: {
  42. linkToChat(){
  43. let chat = {
  44. chatId: this.userInfo.id,
  45. chatType:0,
  46. chatName:this.userInfo.nickName
  47. }
  48. this.$u.vuex('chatObj',chat);
  49. this.$u.route({
  50. url:"pageC/chat/chat"
  51. });
  52. },
  53. previewImg(urls){
  54. uni.previewImage({urls:[urls]})
  55. },
  56. linkToMoreInfoMation(){
  57. this.$u.route({
  58. url:"pageD/moreInforMation/moreInforMation",
  59. params:{ signature:this.userInfo.signature }
  60. })
  61. },
  62. toAddUser(){
  63. this.$socket.insertFriend(this.userData.user.operId, this.userInfo.id, res => {
  64. if (res.success) {
  65. uni.showModal({
  66. title: '请求已发送',
  67. showCancel: false
  68. });
  69. }
  70. });
  71. },
  72. },
  73. onLoad({ id, nickName, source }) {
  74. this.source = source
  75. if(0 == source){
  76. let _this = this
  77. this.$socket.findFriendRequestList(nickName, res => {
  78. if (res.success) {
  79. res.userList.forEach(function(element) {
  80. if(element.id == id){
  81. _this.userInfo = element
  82. }
  83. });
  84. }
  85. });
  86. }else if(2 == source){
  87. this.$socket.getUserById(id, res=>{
  88. this.userInfo = res.user
  89. })
  90. } else {
  91. if(id == this.userData.user.operId){
  92. this.userInfo = this.userData.user;
  93. this.isItMe = true;
  94. return;
  95. }
  96. for(let i in this.firendItem){
  97. let members = this.firendItem[i].members
  98. for(let j in members){
  99. if (members[j].id==id){
  100. this.userInfo = members[j]
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .perch{
  110. height: 10rpx;
  111. }
  112. .userinfo{
  113. display: flex;
  114. justify-content: flex-start;
  115. align-items: flex-start;
  116. padding: 20rpx 30rpx 40rpx 40rpx;
  117. background-color: #FFFFFF;
  118. .img{
  119. display: block;
  120. width: 110rpx;
  121. height: 110rpx;
  122. border-radius: 10rpx;
  123. }
  124. &-desc{
  125. padding-left: 30rpx;
  126. &-name{
  127. font-weight: bold;
  128. font-size: 36rpx;
  129. transform: translateY(-10rpx);
  130. }
  131. &-gray{
  132. color: $u-tips-color;
  133. font-size: 29rpx;
  134. }
  135. }
  136. }
  137. </style>