card.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div class="userCard">
  3. <mt-loadmore :top-method="refresh">
  4. <div
  5. class="userList"
  6. v-infinite-scroll="loadMore"
  7. infinite-scroll-disabled="loading"
  8. infinite-scroll-distance="10"
  9. infinite-scroll-immediate-check="true"
  10. v-if="userList.length > 0"
  11. >
  12. <div class="cell" v-for="(item, index) in userList" :key="'userList' + index" @click="openDialog(item)">
  13. <div class="userImg">
  14. <img src="" alt="">
  15. </div>
  16. <div class="right">
  17. <div class="userInfo">
  18. <p class="name">{{item.nickname || ''}}</p>
  19. <p class="tips">{{item.company || ''}} {{item.title}}</p>
  20. </div>
  21. <div class="addTime">
  22. <p>{{item.processTimeName || ''}}</p>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. <div v-else-if="!loadingPage" class="noneList">
  28. <p>暂无名片</p>
  29. </div>
  30. <div v-else class="pageLoading">
  31. <mt-spinner type="fading-circle"></mt-spinner>
  32. </div>
  33. </mt-loadmore>
  34. <no-ssr>
  35. <p v-show="loading" class="page-infinite-loading">
  36. <mt-spinner type="fading-circle"></mt-spinner>
  37. 加载中...
  38. </p>
  39. </no-ssr>
  40. <div class="popUp" v-if="showToast">
  41. <div class="toastBox">
  42. <div class="content">
  43. <div class="userImg">
  44. <img :src="selectedItem.iconUrl" alt="">
  45. </div>
  46. <p class="name">{{selectedItem.nickname}}</p>
  47. <div class="userInfo">
  48. <div class="cell" v-for="(item, index) in userData" :key="'uT'+index">
  49. <p class="cname">{{item.title}}</p>
  50. <p class="cvalue">{{item.value}}</p>
  51. <p class="cbutton" @click="copyItem(item)">复制</p>
  52. </div>
  53. </div>
  54. <div class="button" @click="jumpUserPage">
  55. <p>个人主页</p>
  56. </div>
  57. </div>
  58. <div class="closeIcon" @click="showToast=false"></div>
  59. </div>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. /**
  65. * 名片夹
  66. */
  67. import Vue from 'vue'
  68. import { InfiniteScroll, Loadmore } from 'mint-ui';
  69. import MintUI from 'mint-ui';
  70. import "mint-ui/lib/style.css";
  71. Vue.use(InfiniteScroll);
  72. Vue.use(MintUI);
  73. Vue.component(Loadmore.name, Loadmore);
  74. export default {
  75. name: 'UserCard',
  76. data() {
  77. return {
  78. userList: [],
  79. userData: [
  80. { title: '邮箱', name: 'email', value: '' },
  81. { title: '电话', name: 'mobile', value: '' },
  82. { title: '微信', name: 'weixin', value: '' },
  83. { title: 'QQ', name: 'qq', value: '' },
  84. ],
  85. selectedItem: {},
  86. showToast: false,
  87. loading: false,
  88. loadingPage: true, //页面加载
  89. page: {
  90. page: 1,
  91. size: 10,
  92. total: 0
  93. }
  94. }
  95. },
  96. async created() {
  97. },
  98. async mounted() {
  99. this.loadingPage = true
  100. this.page = {
  101. page: 1,
  102. size: 10,
  103. total: 0
  104. }
  105. await this.needLogin()
  106. this.getList()
  107. },
  108. methods: {
  109. /** 获取 */
  110. getList() {
  111. const { page = 1, pageSize = 10 } = this.page || {}
  112. let p = { page, pageSize }
  113. this.$axios.post('/api/nameCard/list', p).then(res => {
  114. if (res.data.status === 1) {
  115. this.userList = [ ...(res.data.data && res.data.data.list || []) ]
  116. this.userList = [{id:1, name:2, email: 3}]
  117. this.page.total = Number(res.data.data && res.data.data.total || 0)
  118. } else {
  119. this.$message.error('查询失败:' + res.info)
  120. }
  121. }).finally(() => {
  122. this.loadingPage = false
  123. })
  124. },
  125. /** 打开弹出层 **/
  126. openDialog(selectedItem) {
  127. this.showToast = true
  128. this.selectedItem = selectedItem
  129. this.userData.forEach(item=>{
  130. item.value = ''
  131. item.value = selectedItem[item.name] || ''
  132. })
  133. this.userData = [ ...this.userData ]
  134. },
  135. refresh() {
  136. this.page = {
  137. page: 1,
  138. size: 10,
  139. total: 0
  140. }
  141. this.getList()
  142. },
  143. loadMore() {
  144. this.loading = true;
  145. setTimeout(() => {
  146. this.userList = [ ...this.userList, ...this.userList ]
  147. this.loading = false;
  148. }, 5000)
  149. },
  150. jumpUserPage() {
  151. const { id } = this.selectedItem
  152. let url = `/wo/${id}`
  153. if (this.$deviceType.app) {
  154. location.href = `proginn://jump?path=${url}`
  155. } else {
  156. location.href = url
  157. }
  158. },
  159. /** 复制到剪切板 */
  160. copyItem(item) {
  161. const { value } = item
  162. const input = document.createElement('input')
  163. input.readOnly = 'readonly'
  164. input.value = value
  165. document.body.appendChild(input)
  166. input.select()
  167. input.setSelectionRange(0, input.value.length)
  168. document.execCommand('Copy')
  169. document.body.removeChild(input)
  170. }
  171. },
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. @import '../../../assets/css/otherpage/user/userCard.scss';
  176. </style>