add.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div style="padding-top: 20px">
  3. <u--input
  4. placeholder="请输入"
  5. prefixIcon="search"
  6. prefixIconStyle="font-size: 22px;color: #909399"
  7. border="surround"
  8. v-model="phone"
  9. >
  10. <template slot="suffix">
  11. <u-button
  12. @click="query"
  13. text="搜索"
  14. style="
  15. height: 30px;
  16. border-radius: 20px;
  17. background: linear-gradient(87deg, #28d141 0%, #28ef8c 100%);
  18. color: white;
  19. "
  20. ></u-button>
  21. </template>
  22. </u--input>
  23. <div v-if="userInfo">
  24. <view class="main">
  25. <view class="item">
  26. <view class="left">
  27. <img :src="userInfo.headUrl" alt="" class="img" />
  28. </view>
  29. <view class="right">
  30. <view class="right_contont">
  31. <view style="width: 80%">
  32. <view class="title">{{ userInfo.nick }}</view>
  33. </view>
  34. <view @click="addUser(userInfo)">
  35. <u-button
  36. type="primary"
  37. text="添加"
  38. color="linear-gradient( 275deg, #01CF6C 0%, #07E278 100%)"
  39. shape="circle"
  40. style="height: 30px"
  41. ></u-button>
  42. </view>
  43. </view>
  44. <view class="remake"> {{ userInfo.introduction }} </view>
  45. </view>
  46. </view>
  47. </view>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import TUIChatEngine, {
  53. TUIFriendService,
  54. TUIConversationService,
  55. TUIGroupService,
  56. TUIUserService,
  57. TUITranslateService,
  58. AddFriendParams,
  59. JoinGroupParams,
  60. } from "@tencentcloud/chat-uikit-engine";
  61. import { Toast, TOAST_TYPE } from "../../TUIKit/components/common/Toast/index";
  62. export default {
  63. data() {
  64. return {
  65. phone: "",
  66. userInfo: "",
  67. };
  68. },
  69. methods: {
  70. query() {
  71. this.api.getUserInfoByPhone(this.phone).then((res) => {
  72. if (res.code === 200) {
  73. console.log(res);
  74. this.userInfo = res.data;
  75. }
  76. });
  77. },
  78. addUser(record) {
  79. let params = {
  80. remark: "",
  81. source: "AddSource_Type_Web",
  82. to: JSON.stringify(record.id),
  83. wording: "",
  84. };
  85. TUIFriendService.addFriend(params)
  86. .then(() => {
  87. Toast({
  88. message: TUITranslateService.t("TUIContact.申请已发送"),
  89. type: TOAST_TYPE.SUCCESS,
  90. });
  91. })
  92. .catch((error) => {
  93. console.log(error);
  94. Toast({
  95. message: TUITranslateService.t("TUIContact.申请发送失败"),
  96. type: TOAST_TYPE.ERROR,
  97. });
  98. });
  99. },
  100. },
  101. };
  102. </script>
  103. <style lang="scss" scope>
  104. ::v-deep .u-input {
  105. border: 1px solid #00d36e;
  106. border-radius: 20px;
  107. }
  108. .main {
  109. .item {
  110. display: flex;
  111. flex-direction: row;
  112. align-items: center;
  113. padding: 10px 20px;
  114. background: white;
  115. .left {
  116. width: 20%;
  117. margin-right: 10px;
  118. .img {
  119. width: 110rpx;
  120. height: 110rpx;
  121. border-radius: 50%;
  122. }
  123. }
  124. .right {
  125. width: 80%;
  126. line-height: 25px;
  127. .remake {
  128. font-weight: 400;
  129. font-size: 28rpx;
  130. color: #999999;
  131. }
  132. .right_contont {
  133. display: flex;
  134. flex-direction: row;
  135. align-items: center;
  136. .gys {
  137. width: 168rpx;
  138. height: 28rpx;
  139. font-weight: 500;
  140. font-size: 24rpx;
  141. color: #ff8b2f;
  142. line-height: 28rpx;
  143. font-style: normal;
  144. }
  145. .cgs {
  146. width: 168rpx;
  147. height: 28rpx;
  148. font-weight: 500;
  149. font-size: 24rpx;
  150. color: #00d36d;
  151. line-height: 28rpx;
  152. font-style: normal;
  153. }
  154. }
  155. .value {
  156. display: flex;
  157. flex-direction: row;
  158. align-items: center;
  159. height: 60rpx;
  160. }
  161. .title {
  162. font-weight: 600;
  163. font-size: 32rpx;
  164. color: #333333;
  165. }
  166. }
  167. }
  168. }
  169. </style>