addressbook.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="main">
  3. <!-- #ifdef APP-PLUS -->
  4. <cu-custom bgColor="bg-blue_default">
  5. <block slot="content">通讯录</block>
  6. </cu-custom>
  7. <!-- #endif -->
  8. <view class=" text-center flex tab-custom" style="height: 45px;line-height: 45px;">
  9. <u-tabs :list="list" @click="changeParent" lineWidth="30" lineHeight="1" lineColor="#ffffff" :activeStyle="{
  10. color: '#ffffff',
  11. fontWeight: 'bold',
  12. transform: 'scale(1.05)'
  13. }" :inactiveStyle="{
  14. color: '#fff',
  15. transform: 'scale(1)'
  16. }" itemStyle=" height: 34px;"></u-tabs>
  17. </view>
  18. <!-- <view class="tree">
  19. <ly-tree :tree-data="officeList" :props="props" node-key="id" :checkOnClickNode="true" :showRadio="false"
  20. :show-checkbox="false" :checkOnlyLeaf="false" ref="officeTree" />
  21. </view> -->
  22. <view>
  23. <u-cell-group class="cell_group__title" v-for="(item, index) in indexList" :key="index"
  24. :title="indexList[index].name">
  25. <u-cell class="book_info" v-for="user in getUser(indexList[index].id)">
  26. <view class="book_info_title" slot="title">
  27. {{user.name}}
  28. </view>
  29. <u-avatar v-if="user.photo!=''" slot="icon" shape="circle" size="40" :src="BASE_URL + user.photo"
  30. customStyle="margin: -3px 5px -3px 0"></u-avatar>
  31. <u-avatar v-else slot="icon" shape="circle" size="35" src="../../static/img/avatar.png"
  32. customStyle="margin: -3px 5px -3px 0"></u-avatar>
  33. <view v-if="user.mobile || user.phone" class="ellipsis-description text-gray" slot="label">
  34. {{user.mobile + ' ' + user.phone}}
  35. </view>
  36. <view v-if="user.mobile || user.phone" class="flex" slot="value">
  37. <u-icon @click="toPhone(user)" size="30" style="margin-right: 10px;" name="../../static/img/icon_dh.png"></u-icon>
  38. <u-icon @click="copyPhone(user)" v-if="user.mobile || user.phone" size="30"
  39. name="../../static/img/icon_fz.png"></u-icon>
  40. </view>
  41. </u-cell>
  42. </u-cell-group>
  43. </view>
  44. <u-modal :show="show" title="选择号码" :showConfirmButton="false" :showCancelButton="true" @cancel="show = false">
  45. <view class="slot-content">
  46. <view v-for="(item,index) in phones" :key="index">
  47. <view @click="toPhone(item)" class="modal_content">{{item}}</view>
  48. </view>
  49. </view>
  50. </u-modal>
  51. <u-overlay :show="loading">
  52. <view class="warp">
  53. <view class="rect"><u-button plain loading loadingText="加载中"></u-button></view>
  54. </view>
  55. </u-overlay>
  56. </view>
  57. </template>
  58. <script>
  59. import userService from '@/api/sys/userService'
  60. import officeService from "@/api/sys/officeService"
  61. import BASE_URL from '@/config.js'
  62. export default {
  63. data() {
  64. return {
  65. loading: true,
  66. show: false,
  67. indexList: [],
  68. officeList: [],
  69. userList: [],
  70. total: 0,
  71. searchUserName: '',
  72. list: [],
  73. phones: [],
  74. }
  75. },
  76. props: {
  77. props: {
  78. type: Object,
  79. default: () => {
  80. return {
  81. children: 'children',
  82. label: 'name'
  83. }
  84. }
  85. }
  86. },
  87. created() {
  88. officeService.treeData().then(data => {
  89. this.officeList = data
  90. this.list = this.officeList.filter((item) => {
  91. if (item.type == "1") {
  92. return true
  93. }
  94. })
  95. this.list.sort((a, b) => b.name.localeCompare(a.name) || b.name.localeCompare(a
  96. .name));
  97. userService.list({
  98. current: 1,
  99. size: 10000
  100. }).then((res) => {
  101. this.userList = res.records
  102. this.indexList = this.list[0].children
  103. this.total = res.total
  104. this.loading = false
  105. }).catch((e) => {
  106. throw e
  107. })
  108. })
  109. },
  110. methods: {
  111. // 切换部门
  112. changeParent(e) {
  113. this.indexList = e.children
  114. },
  115. // 获取用户
  116. getUser(id) {
  117. let b = this.userList.filter(item => item.officeDTO && item.officeDTO.id == id)
  118. return b
  119. },
  120. // 打电话
  121. toPhone(user) {
  122. if (user.mobile || user.phone) {
  123. if (user.mobile != '' && user.phone == '') {
  124. uni.makePhoneCall({
  125. phoneNumber: user.mobile //仅为示例
  126. });
  127. } else if (user.mobile == '' && user.phone != '') {
  128. uni.makePhoneCall({
  129. phoneNumber: user.phone //仅为示例
  130. });
  131. } else if (user.mobile != '' && user.phone != '') {
  132. this.phones = []
  133. this.phones.push(user.mobile)
  134. this.phones.push(user.phone)
  135. this.show = true
  136. }
  137. } else {
  138. this.show = false
  139. uni.makePhoneCall({
  140. phoneNumber: user //仅为示例
  141. });
  142. }
  143. },
  144. // 复制号码
  145. copyPhone(user) {
  146. uni.setClipboardData({
  147. data: user.phone + " " + user.mobile,
  148. success: function() {
  149. uni.showToast({
  150. title: '复制成功',
  151. icon: 'success'
  152. });
  153. }
  154. });
  155. },
  156. }
  157. }
  158. </script>
  159. <style lang="scss">
  160. .warp {
  161. display: flex;
  162. align-items: center;
  163. justify-content: center;
  164. height: 100%;
  165. }
  166. .book_info {
  167. background-color: #fefefe;
  168. }
  169. .book_info .cell_group__title span {
  170. // background-color: #ededed;
  171. font-size: 18px !important;
  172. }
  173. .book_info .ellipsis-description {
  174. font-size: 12px !important;
  175. margin-top: 10px;
  176. }
  177. .main .tab-custom {
  178. justify-content: center;
  179. align-items: center;
  180. background-color: #36a7f3;
  181. }
  182. .main .modal_content {
  183. height: 40px;
  184. line-height: 40px;
  185. border-bottom: 1px solid #ededed;
  186. z-index: 10;
  187. }
  188. .book_info_title {
  189. color: #21b7fc;
  190. }
  191. .list {
  192. &__item {
  193. @include flex;
  194. padding: 6px 12px;
  195. align-items: center;
  196. &__avatar {
  197. height: 35px;
  198. width: 35px;
  199. border-radius: 3px;
  200. }
  201. &__user-name {
  202. font-size: 16px;
  203. margin-left: 10px;
  204. color: $u-main-color;
  205. }
  206. }
  207. &__footer {
  208. color: $u-tips-color;
  209. font-size: 14px;
  210. text-align: center;
  211. margin: 15px 0;
  212. }
  213. }
  214. </style>