addressbook.vue 5.4 KB

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