addressbook.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <view>
  3. <u-navbar title="通讯录"></u-navbar>
  4. <view class="navbartitle" v-if="0" >
  5. <view class="navbartitle-left" >
  6. <u-icon name="arrow-left" v-if="historyIndex!=0" color="#FFF"></u-icon>
  7. </view>
  8. <view class="navbartitle-name">
  9. {{title}}
  10. <span v-show="getCompanyListReady">
  11. {{!list.length?' ('+userList.length+'人)':''}}
  12. </span>
  13. </view>
  14. </view>
  15. <view class="main" v-show="getCompanyListReady">
  16. <scroll-view scroll-y="true" v-show="list.length" :scroll-top="scrollTop1"
  17. :style="('width: 45%;')+'height:'+ screenHeight+'px;'"
  18. class="scroll-Y1">
  19. <view class="news">
  20. <view class="news-item" :class="{
  21. 'news-item-index':key=='置顶'
  22. }"
  23. @click="userList=toplist,key='置顶'" >
  24. <view class="content1">
  25. <view class="news-title">
  26. 置顶
  27. </view>
  28. <view>
  29. <!-- {{item.userList.length}}人 -->
  30. <u-icon name="arrow-right" color="#B3B3B3"></u-icon>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="news-item" v-for="(item,i) in list"
  35. @click="ckInfo(item)" :class="{
  36. 'news-item-index':key==item.label
  37. }"
  38. v-show="item.label.indexOf('测试')==-1" :key="i">
  39. <view class="content1">
  40. <view class="news-title">
  41. {{item.label}}
  42. </view>
  43. <view>
  44. <!-- {{item.userList.length}}人 -->
  45. <u-icon name="arrow-right" color="#B3B3B3"></u-icon>
  46. </view>
  47. </view>
  48. </view>
  49. <u-divider
  50. border-color="#CFD2D5">已经到底了</u-divider>
  51. </view>
  52. </scroll-view>
  53. <u-modal v-model="show" @confirm="confirmPhone" confirm-text="拨打电话" confirm-color="#606266" :show-cancel-button="true" ref="uModal"
  54. :asyncClose="true" :title="phoneInfo.name" :content="phoneInfo.phone" :content-style="{fontSize: '24px',color: '#101010'}"></u-modal>
  55. <scroll-view scroll-y="true" v-if="userList.length" :scroll-top="scrollTop2"
  56. :style="('width: 55%;')+'height:'+ screenHeight+'px'"
  57. class="scroll-Y2"
  58. >
  59. <view class="userList" >
  60. <u-divider margin-top="10"
  61. border-color="#CFD2D5">点击可拨打电话 </u-divider>
  62. <view class="news-item" v-for="(item,i) in userList"
  63. :key="i">
  64. <view class="content2" @click="phoneInfoCk(item)">
  65. <view class="news-title1">
  66. {{item.name}}
  67. </view>
  68. <view class="news-title2">
  69. <!-- <u-icon name="phone"></u-icon> -->
  70. {{item.phone?item.phone:'无'}}
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <u-divider
  76. border-color="#CFD2D5">已经到底了 </u-divider>
  77. </scroll-view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import * as API from '@/apis/pagejs/addressbook.js'
  83. export default {
  84. data() {
  85. return {
  86. title:"列表",
  87. list:[],
  88. userList:[],
  89. listForm:{
  90. pageIndex:1,
  91. typeId:"",
  92. title:"",
  93. pageSize:20,
  94. },
  95. recordsTotal:0,
  96. imgurl:'',
  97. parentId:"",
  98. oldparentId:"",
  99. historyList:[],
  100. historyIndex:0,
  101. phoneInfo:{},
  102. toplist:[],
  103. show:false,
  104. screenHeight:0,
  105. scrollTop1: 0 ,
  106. scrollTop2: 0 ,
  107. getCompanyListReady:false,
  108. key:"置顶"
  109. }
  110. },
  111. onLoad(op){
  112. if(op.title){
  113. this.title=op.title
  114. }
  115. this.listForm.typeId=op.id
  116. var _this=this
  117. uni.getSystemInfo({
  118. success: function (res) {
  119. var k=uni.upx2px((44+42+10)*2)
  120. _this.screenHeight=res.windowHeight-k
  121. console.log(res.windowHeight,k,_this.screenHeight)
  122. }
  123. });
  124. this.getCompanyList()
  125. this.dataList()
  126. //this.getList()
  127. },
  128. onReachBottom() {
  129. if (this.list.length < this.recordsTotal) {
  130. this.myLoadmore();
  131. }
  132. },
  133. methods: {
  134. dataList(){
  135. API.dataList("通讯录置顶人员").then((res) => {
  136. this.toplist=res.data.map(item=>{
  137. return {
  138. phone:item.value,
  139. name:item.name,
  140. }
  141. })
  142. this.userList=this.toplist
  143. })
  144. },
  145. phoneInfoCk(item){
  146. if(item.phone){
  147. this.phoneInfo=item
  148. this.show=true
  149. }else{
  150. uni.showToast({
  151. title: "当前人员未录入电话号码",
  152. icon: "none"
  153. })
  154. }
  155. },
  156. confirmPhone(){
  157. this.show = false;
  158. uni.makePhoneCall({
  159. phoneNumber:this.content //仅为示例
  160. });
  161. },
  162. ckInfo(item){
  163. // this.scrollTop1=0
  164. // this.scrollTop2=0
  165. this.key=item.label
  166. this.query(item)
  167. },
  168. query(item){
  169. this.userList =[]
  170. uni.showLoading({
  171. title: "加载中",
  172. mask: true,
  173. })
  174. API.userList({
  175. orgId:item.value
  176. }).then((res) => {
  177. uni.hideLoading();
  178. this.userList = res.data;
  179. }).catch(error => {
  180. uni.showToast({
  181. title: error,
  182. icon: "none"
  183. })
  184. })
  185. },
  186. myLoadmore(){
  187. this.listForm.pageIndex += 1;
  188. this.getList();
  189. },
  190. getCompanyList(){
  191. this.getCompanyListReady=false
  192. uni.showLoading({
  193. title: "加载中",
  194. mask: true,
  195. })
  196. API.bookList({
  197. parentId:this.parentId
  198. }).then((res) => {
  199. uni.hideLoading();
  200. this.getCompanyListReady=true
  201. //this.oldparentId=this.parentId;
  202. // if(this.parentId==''){
  203. // this.parentId=res.data[0].value
  204. // this.title = res.data[0].label;
  205. // this.historyList.push(res.data[0])
  206. // this.getCompanyList()
  207. // }else{
  208. // }
  209. this.list = res.data;
  210. }).catch(error => {
  211. uni.showToast({
  212. title: error,
  213. icon: "none"
  214. })
  215. })
  216. },
  217. }
  218. }
  219. </script>
  220. <style lang="scss" scoped>
  221. .main{
  222. display: flex;
  223. }
  224. .navbartitle{
  225. margin-top: 40rpx;
  226. background-color: #3179f6;
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. .navbartitle-left{
  231. padding:20rpx;
  232. width: 10%;
  233. }
  234. .navbartitle-name{
  235. padding:20rpx;
  236. width: 90%;
  237. color: #fff;
  238. font-size: 32rpx;
  239. }
  240. }
  241. .scroll-Y1{
  242. border-right: 1px dashed #B3B3B3;
  243. }
  244. .news,.userList{
  245. .news-item{
  246. padding:25rpx 20rpx 25rpx 25rpx;
  247. margin: 20rpx 15rpx 20rpx 20rpx;
  248. background: #fff;
  249. border-radius: 10px;
  250. font-size:32rpx ;
  251. .content1{
  252. display: flex;
  253. justify-content: space-between;
  254. }
  255. .content2{
  256. padding: 4rpx;
  257. .news-title1{
  258. font-size: 36rpx;
  259. font-weight: bold;
  260. }
  261. }
  262. }
  263. .news-item-index{
  264. color: #3179f6;
  265. font-weight: bold;
  266. }
  267. }
  268. </style>