phone-directory.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="phone-main" :style="{height: winHeight + 'px'}">
  3. <view class="phone-main-search">
  4. <navigator :url="'phone-search?phones=' + phonesEscape" hover-class="none">
  5. <input disabled="false" class="phone-main-input" type="text" placeholder="请输入要搜索的联系人"/>
  6. </navigator>
  7. </view>
  8. <view class="phoneDirectory">
  9. <phone-list
  10. :phones="phones"
  11. :letter="letter"
  12. :scrollAnimationOFF="scrollAnimationOFF"
  13. @change="handlePhoneListIndex"
  14. @reset="handleReset"
  15. @handleClick="handleClick"
  16. >
  17. </phone-list>
  18. <phone-alphabet
  19. :phones="phones"
  20. :phoneListIndex="phoneListIndex"
  21. @change="handleDatasetKey"
  22. @scrollAnimationOFF="handleScrollAnimationOFF"
  23. @reset="handleReset"
  24. >
  25. </phone-alphabet>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import phoneList from './phone-list.vue'
  31. import phoneAlphabet from './phone-alphabet.vue'
  32. export default {
  33. name:"phone-directory",
  34. components:{
  35. phoneList,
  36. phoneAlphabet
  37. },
  38. props:{
  39. phones:Object,
  40. default:false
  41. },
  42. data () {
  43. return {
  44. winHeight:0,
  45. letter : 'A',
  46. scrollAnimationOFF:true,
  47. phoneListIndex:'A',
  48. reset:true
  49. }
  50. },
  51. computed:{
  52. phonesEscape () {
  53. return escape(JSON.stringify(this.phones))
  54. }
  55. },
  56. mounted () {
  57. let windowHeight = uni.getSystemInfoSync().windowHeight
  58. // #ifndef APP-PLUS
  59. this.winHeight = windowHeight
  60. //#endif
  61. //#ifdef APP-PLUS
  62. this.winHeight = windowHeight - 56
  63. //#endif
  64. if(!this.phones){
  65. uni.showToast({
  66. title: '没有数据',
  67. icon:"none",
  68. mask: false,
  69. duration: 1500
  70. })
  71. }
  72. },
  73. methods:{
  74. handleClick (e) {
  75. this.$emit('paramClick',e)
  76. },
  77. handleDatasetKey (val) {
  78. this.letter = val
  79. },
  80. handleScrollAnimationOFF (val) {
  81. this.scrollAnimationOFF = val
  82. },
  83. handlePhoneListIndex(val){
  84. if(this.reset){
  85. this.phoneListIndex = val
  86. }
  87. },
  88. handleReset (val){
  89. if(val){
  90. this.letter = ''
  91. }
  92. this.reset = val
  93. }
  94. }
  95. }
  96. </script>
  97. <style>
  98. .phone-main{
  99. display: flex;
  100. flex-direction: column;
  101. overflow: hidden;
  102. }
  103. .phoneDirectory{
  104. display: flex;
  105. flex-direction: row;
  106. }
  107. .phone-main-search{
  108. background-color: #fff;
  109. padding: 10upx 20upx;
  110. border-bottom: 1px solid #e5e5e5;
  111. }
  112. .phone-main-input{
  113. font-size:28upx;
  114. border: 1px solid #e5e5e5;
  115. border-radius: 3px;
  116. padding: 10upx 20upx 10upx 20upx;
  117. }
  118. </style>