addressBook.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view>
  3. <view @tap="closeFrame">
  4. <cu-custom bgColor="bg-gradual-sisBlack" :isBack="true">
  5. <block slot="backText">
  6. <view style="height: 80rpx;line-height: 80rpx;color: silver;">返回</view>
  7. </block>
  8. <block slot="content">
  9. <view style="color: silver;">聊天通讯</view>
  10. </block>
  11. </cu-custom>
  12. </view>
  13. <!-- 搜索标签 -->
  14. <view class="cu-bar bg-white search fixed" :style="[{top:CustomBar + 'px'}]">
  15. <view class="search-form round">
  16. <text class="cuIcon-search"></text>
  17. <input type="text" placeholder="输入搜索的关键词" confirm-type="search"></input>
  18. </view>
  19. <view class="action">
  20. <button class="cu-btn bg-gradual-sisBlack shadow-blur round">搜索</button>
  21. </view>
  22. </view>
  23. <scroll-view scroll-y class="indexes" :scroll-into-view="'indexes-'+ listCurID" :style="[{height:'calc(100vh - '+ CustomBar + 'px - 50px)'}]"
  24. :scroll-with-animation="true" :enable-back-to-top="true" >
  25. <block v-for="(item,index) in list" :key="index">
  26. <view :class="'indexItem-' + item.name" :id="'indexes-' + item.name" :data-index="item.name">
  27. <view class="padding">{{item.name}}</view>
  28. <view class="cu-list menu-avatar no-padding">
  29. <view class="cu-item" v-for="(items,sub) in 2" :key="sub" @tap="common.navTo('/components/mine/addressBook/chat?name='+list[index].name)">
  30. <view class="cu-avatar round lg">{{item.name}}</view>
  31. <view class="content">
  32. <view class="text-grey">{{item.name}}<text class="text-abc">{{list[sub].name}}</text>君</view>
  33. <view class="text-gray text-sm">
  34. 有{{sub+2}}条消息
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </block>
  41. </scroll-view>
  42. <view class="indexBar" :style="[{height:'calc(100vh - ' + CustomBar + 'px - 50px)'}]">
  43. <view class="indexBar-box" @touchstart="tStart" @touchend="tEnd" @touchmove.stop="tMove">
  44. <view class="indexBar-item" v-for="(item,index) in list" :key="index" :id="index" @touchstart="getCur" @touchend="setCur"> {{item.name}}</view>
  45. </view>
  46. </view>
  47. <!--选择显示-->
  48. <view v-show="!hidden" class="indexToast">
  49. {{listCur}}
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. StatusBar: this.StatusBar,
  58. CustomBar: this.CustomBar,
  59. hidden: true,
  60. listCurID: '',
  61. list: [],
  62. listCur: '',
  63. };
  64. },
  65. onLoad() {
  66. let list = [{}];
  67. for (let i = 0; i < 26; i++) {
  68. list[i] = {};
  69. list[i].name = String.fromCharCode(65 + i);
  70. }
  71. this.list = list;
  72. this.listCur = list[0];
  73. },
  74. onReady() {
  75. let that = this;
  76. uni.createSelectorQuery().select('.indexBar-box').boundingClientRect(function(res) {
  77. that.boxTop = res.top
  78. }).exec();
  79. uni.createSelectorQuery().select('.indexes').boundingClientRect(function(res) {
  80. that.barTop = res.top
  81. }).exec()
  82. },
  83. methods: {
  84. closeFrame: function() {
  85. this.count = this.count + 1;
  86. if (this.isFrameShow) {
  87. this.isFrameShow = false;
  88. this.sanJiao = 'sanJiaoDown';
  89. }
  90. },
  91. //获取文字信息
  92. getCur(e) {
  93. this.hidden = false;
  94. this.listCur = this.list[e.target.id].name;
  95. },
  96. setCur(e) {
  97. this.hidden = true;
  98. this.listCur = this.listCur
  99. },
  100. //滑动选择Item
  101. tMove(e) {
  102. let y = e.touches[0].clientY,
  103. offsettop = this.boxTop,
  104. that = this;
  105. //判断选择区域,只有在选择区才会生效
  106. if (y > offsettop) {
  107. let num = parseInt((y - offsettop) / 20);
  108. this.listCur = that.list[num].name
  109. };
  110. },
  111. //触发全部开始选择
  112. tStart() {
  113. this.hidden = false
  114. },
  115. //触发结束选择
  116. tEnd() {
  117. this.hidden = true;
  118. this.listCurID = this.listCur
  119. },
  120. indexSelect(e) {
  121. let that = this;
  122. let barHeight = this.barHeight;
  123. let list = this.list;
  124. let scrollY = Math.ceil(list.length * e.detail.y / barHeight);
  125. for (let i = 0; i < list.length; i++) {
  126. if (scrollY < i + 1) {
  127. that.listCur = list[i].name;
  128. that.movableY = i * 20
  129. return false
  130. }
  131. }
  132. }
  133. }
  134. }
  135. </script>
  136. <style>
  137. body {
  138. font-family: '方正兰亭细黑_GBK';
  139. font-size: 20px;
  140. color: silver;
  141. background: #000;
  142. }
  143. @font-face {
  144. font-family: '方正兰亭细黑_GBK';
  145. src: url(../../../static/fzltxh.TTF);
  146. }
  147. page {
  148. background-color: #1f1f1f;
  149. font-family: '方正兰亭细黑_GBK';
  150. overflow-x: hidden;
  151. }
  152. .indexes {
  153. position: relative;
  154. }
  155. .indexBar {
  156. position: fixed;
  157. right: 0px;
  158. bottom: 0px;
  159. padding: 20upx 20upx 20upx 60upx;
  160. display: flex;
  161. align-items: center;
  162. }
  163. .indexBar .indexBar-box {
  164. width: 40upx;
  165. height: auto;
  166. background: #fff;
  167. display: flex;
  168. flex-direction: column;
  169. box-shadow: 0 0 20upx rgba(0, 0, 0, 0.1);
  170. border-radius: 10upx;
  171. }
  172. .indexBar-item {
  173. flex: 1;
  174. width: 40upx;
  175. height: 40upx;
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. font-size: 24upx;
  180. color: #888;
  181. }
  182. movable-view.indexBar-item {
  183. width: 40upx;
  184. height: 40upx;
  185. z-index: 9;
  186. position: relative;
  187. }
  188. movable-view.indexBar-item::before {
  189. content: "";
  190. display: block;
  191. position: absolute;
  192. left: 0;
  193. top: 10upx;
  194. height: 20upx;
  195. width: 4upx;
  196. background-color: #f37b1d;
  197. }
  198. .indexToast {
  199. position: fixed;
  200. top: 0;
  201. right: 80upx;
  202. bottom: 0;
  203. background: rgba(0, 0, 0, 0.5);
  204. width: 100upx;
  205. height: 100upx;
  206. border-radius: 10upx;
  207. margin: auto;
  208. color: #fff;
  209. line-height: 100upx;
  210. text-align: center;
  211. font-size: 48upx;
  212. }
  213. .bg-white{
  214. background-color: #242424;
  215. }
  216. .cu-list,.menu-avatar>.cu-item {
  217. background-color: #242424;
  218. }
  219. </style>