card.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. <mt-cell-swipe
  13. v-for="(item, index) in userList" :key="'userList' + index"
  14. :right="[
  15. {
  16. content: '删除',
  17. style: { background: 'red', color: '#fff', display:'table-cell',verticalAlign:'middle'},
  18. handler: () => deleteItem(item)
  19. }
  20. ]">
  21. <div slot="title" class="cell"
  22. @click="openDialog(item)">
  23. <div class="userImg" :class="calcUserVip(item)">
  24. <img :src="item.iconUrl" alt="">
  25. </div>
  26. <div class="right">
  27. <div class="userInfo">
  28. <p class="name">{{item.nickname || ''}}</p>
  29. <p class="tips">{{item.company || ''}} {{item.title}}</p>
  30. </div>
  31. <div class="addTime">
  32. <p>{{item.processTimeName || ''}}</p>
  33. </div>
  34. </div>
  35. </div>
  36. </mt-cell-swipe>
  37. </div>
  38. <div v-else-if="!loadingPage" class="noneList">
  39. <p>暂无名片</p>
  40. </div>
  41. <div v-else class="pageLoading">
  42. <mt-spinner type="fading-circle"></mt-spinner>
  43. </div>
  44. </mt-loadmore>
  45. <no-ssr>
  46. <p v-show="loading" class="page-infinite-loading">
  47. <mt-spinner type="fading-circle"></mt-spinner>
  48. 加载中...
  49. </p>
  50. </no-ssr>
  51. <div class="popUp" v-if="showToast">
  52. <div class="toastBox">
  53. <div class="content">
  54. <div class="userImg" :class="calcUserVip(selectedItem)">
  55. <img :src="selectedItem.iconUrl" alt="">
  56. </div>
  57. <p class="name">{{selectedItem.nickname}}</p>
  58. <div class="userInfo">
  59. <div class="cell" v-for="(item, index) in userData" :key="'uT'+index">
  60. <p class="cname">{{item.title}}</p>
  61. <p class="cvalue">{{item.value}}</p>
  62. <p class="cbutton" @click="copyItem(item)">复制</p>
  63. </div>
  64. </div>
  65. <div class="button" @click="jumpUserPage">
  66. <p>个人主页</p>
  67. </div>
  68. </div>
  69. <div class="closeIcon" @click="showToast=false"></div>
  70. </div>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. /**
  76. * 名片夹
  77. */
  78. import Vue from 'vue'
  79. import { InfiniteScroll, Loadmore, CellSwipe, MessageBox } from 'mint-ui';
  80. import MintUI from 'mint-ui';
  81. import "mint-ui/lib/style.css";
  82. const mix = {
  83. data() {
  84. return {
  85. // 详情id
  86. detailID: this.$route.params.detail,
  87. }
  88. },
  89. methods: {
  90. testMy() {
  91. console.log(22222)
  92. }
  93. }
  94. }
  95. Vue.use(InfiniteScroll);
  96. Vue.use(MintUI);
  97. Vue.component(Loadmore.name, Loadmore);
  98. Vue.component(CellSwipe.name, CellSwipe);
  99. export default {
  100. name: 'UserCard',
  101. mixins: [mix],
  102. data() {
  103. return {
  104. userList: [],
  105. userData: [
  106. { title: '邮箱', name: 'email', value: '' },
  107. { title: '电话', name: 'mobile', value: '' },
  108. { title: '微信', name: 'weixin', value: '' },
  109. { title: 'QQ', name: 'qq', value: '' },
  110. ],
  111. selectedItem: {},
  112. showToast: false,
  113. loading: false,
  114. loadingPage: true, //页面加载
  115. page: {
  116. page: 1,
  117. size: 10,
  118. total: 0
  119. }
  120. }
  121. },
  122. async created() {
  123. },
  124. async mounted() {
  125. this.loadingPage = true
  126. this.page = {
  127. page: 1,
  128. size: 10,
  129. total: 0
  130. }
  131. await this.needLogin()
  132. this.getList()
  133. this.testMy()
  134. },
  135. methods: {
  136. /** 获取 */
  137. getList() {
  138. const { page = 1, pageSize = 10 } = this.page || {}
  139. let p = { page, pageSize }
  140. this.$axios.post('/api/nameCard/list', p).then(res => {
  141. if (res.data.status === 1) {
  142. this.userList = [ ...(res.data.data && res.data.data.list || []) ]
  143. this.page.total = Number(res.data.data && res.data.data.total || 0)
  144. } else {
  145. this.$message.error('查询失败:' + res.info)
  146. }
  147. }).finally(() => {
  148. this.loadingPage = false
  149. this.loading = false
  150. })
  151. },
  152. /** 打开弹出层 **/
  153. openDialog(selectedItem) {
  154. this.showToast = true
  155. this.selectedItem = selectedItem
  156. this.userData.forEach(item => {
  157. item.value = ''
  158. item.value = selectedItem[ item.name ] || ''
  159. })
  160. this.userData = [ ...this.userData ]
  161. },
  162. refresh() {
  163. this.page = {
  164. page: 1,
  165. size: 10,
  166. total: 0
  167. }
  168. this.getList()
  169. },
  170. loadMore() {
  171. this.loading = true;
  172. this.page.page = this.page.page + 1
  173. this.getList()
  174. },
  175. jumpUserPage() {
  176. const { id } = this.selectedItem
  177. let url = `/wo/${id}`
  178. if (this.$deviceType.app) {
  179. location.href = `proginn://jump?path=${url}`
  180. } else {
  181. location.href = url
  182. }
  183. },
  184. /** 复制到剪切板 */
  185. copyItem(item) {
  186. const { value } = item
  187. const input = document.createElement('input')
  188. input.readOnly = 'readonly'
  189. input.value = value
  190. document.body.appendChild(input)
  191. input.select()
  192. input.setSelectionRange(0, input.value.length)
  193. document.execCommand('Copy')
  194. document.body.removeChild(input)
  195. },
  196. calcUserVip(item) {
  197. const { isVip, vipTypeID } = item
  198. return { [ 'vip' + vipTypeID ]: isVip }
  199. },
  200. deleteItem(item) {
  201. console.log(item)
  202. const { nameCardId=0, nickname} = item
  203. MessageBox.confirm(`将从您的名片夹中移除 ${nickname} 的名片`).then(action => {
  204. let loading = this.$loading({
  205. title: "删除中..."
  206. })
  207. this.$axios.post('/api/nameCard/delete', {
  208. nameCardId
  209. }).then(res => {
  210. if (Number(res.data.status) === 1) {
  211. loading && loading.close()
  212. this.$toast('删除成功!')
  213. this.refresh()
  214. } else {
  215. loading && loading.close()
  216. }
  217. }).catch((e) => {
  218. loading && loading.close()
  219. })
  220. }).catch(e=>{
  221. });
  222. },
  223. testMy() {
  224. console.log('111111')
  225. }
  226. },
  227. }
  228. </script>
  229. <style lang="scss">
  230. .mint-cell-swipe-buttongroup {
  231. display: table;
  232. }
  233. </style>
  234. <style lang="scss" scoped>
  235. @import '../../../assets/css/otherpage/user/userCard.scss';
  236. </style>