addressBook.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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" v-model="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. <!-- 搜索列表 -->
  24. <view class="search-content" ref="search" v-for="item in userListData">
  25. <block>
  26. <view :class="'indexItem-' + item.name" :id="'indexes-' + item.name" :data-index="item.name">
  27. <view class="padding"></view>
  28. <view class="cu-list menu-avatar no-padding" >
  29. <view class="cu-item" @tap="common.navTo('/components/mine/addressBook/chat?name='+item+'&send='+send+'&receive='+receive+'&sendname='+sendname+'&receivename='+receivename)">
  30. <view class="cu-avatar round lg"></view>
  31. <view class="content" >
  32. <view class="text-grey">{{item.name}}</view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </block>
  38. </view>
  39. <!-- 通讯列表 -->
  40. <scroll-view scroll-y class="indexes" :scroll-into-view="'indexes-'+ listCurID" :style="[{height:'calc(100vh - '+ CustomBar + 'px - 50px)'}]"
  41. :scroll-with-animation="true" :enable-back-to-top="true" >
  42. <block v-for="(item,index) in list" :key="index">
  43. <!-- 控制侧导航栏 -->
  44. <view :class="'indexItem-' + item.name" :id="'indexes-' + item.name" :data-index="item.name">
  45. <!-- <view class="padding">{{item.name}}</view> -->
  46. <view class="cu-list menu-avatar no-padding" >
  47. <view class="cu-avatar">{{item.name}}</view>
  48. <view class="cu-item" v-for="(items,sub) in 2" :key="sub" @tap="common.navTo('/components/mine/addressBook/chat?name='+list[index].name+'&send='+send+'&receive='+receive+'&sendname='+sendname+'&receivename='+receivename)">
  49. <view class="content" >
  50. <view class="text-grey">{{item.name}}yy<text class="text-abc">{{list[sub].name}}ll</text>君</view>
  51. <view class="text-gray text-sm">
  52. 有{{sub}}条消息
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </block>
  59. </scroll-view>
  60. <!-- 侧导航栏 -->
  61. <view class="indexBar" :style="[{height:'calc(100vh - ' + CustomBar + 'px - 50px)'}]">
  62. <view class="indexBar-box" @touchstart="tStart" @touchend="tEnd" @touchmove.stop="tMove">
  63. <view class="indexBar-item" v-for="(item,index) in list" :key="index" :id="index" @touchstart="getCur" @touchend="setCur"> {{item.name}}</view>
  64. </view>
  65. </view>
  66. <!--选择显示 keyword-->
  67. <view v-show="!hidden" class="indexToast">
  68. {{listCur}}
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. StatusBar: this.StatusBar,
  77. CustomBar: this.CustomBar,
  78. listCurID: '',
  79. list: [],
  80. listCur: '',
  81. send:'1',
  82. receive:'2',
  83. hidden: true,
  84. sendname:'ming',
  85. receivename:'fang',
  86. search:'',
  87. timer: null,
  88. userList:[],
  89. products:[
  90. //假数据
  91. {name:"数据1",date:'2018-01-04',depart:'泸化工1'},
  92. {name:"数据2",date:'2018-01-25',depart:'泸化工2'},
  93. {name:"数据3",date:'2018-02-10',depart:'泸化工3'},
  94. {name:"数据4",date:'2018-03-04',depart:'泸化工4'},
  95. {name:"数据5",date:'2018-05-24',depart:'泸化工5'},
  96. {name:"数据6",date:'2018-10-29',depart:'泸化工6'}
  97. ]
  98. };
  99. },
  100. created: function() {
  101. /* this.getUserList(); */
  102. },
  103. onLoad() {
  104. let list = [{}];
  105. for (let i = 0; i < 26; i++) {
  106. list[i] = {};
  107. list[i].name = String.fromCharCode(65 + i);
  108. }
  109. this.list = list;
  110. this.listCur = list[0];
  111. },
  112. onReady() {
  113. let that = this;
  114. uni.createSelectorQuery().select('.indexBar-box').boundingClientRect(function(res) {
  115. that.boxTop = res.top
  116. }).exec();
  117. uni.createSelectorQuery().select('.indexes').boundingClientRect(function(res) {
  118. that.barTop = res.top
  119. }).exec();
  120. /* this.getUserList(); */
  121. },
  122. computed: {
  123. userListData: function() {
  124. var search = this.search;
  125. if(!this.search){
  126. return [];
  127. }
  128. else if (search) {
  129. return this.products.filter(function(product) {
  130. return Object.keys(product).some(function(key) {
  131. return String(product[key]).toLowerCase().indexOf(search) > -1
  132. })
  133. })
  134. }
  135. return this.products;
  136. },
  137. hasNoData () {
  138. return !this.list.length
  139. }
  140. },
  141. methods: {
  142. handleCityClick (city) {
  143. this.changeCity(city)
  144. this.$router.push('/')
  145. },
  146. closeFrame: function() {
  147. this.count = this.count + 1;
  148. if (this.isFrameShow) {
  149. this.isFrameShow = false;
  150. this.sanJiao = 'sanJiaoDown';
  151. }
  152. },
  153. getUserList: function() {
  154. let _this = this;
  155. uni.request({
  156. /* url: 'http://' + this.backStageIp + ':' + this.backStagePort + '/GyeeMatrixController/GyeeMatrixList?keyid=' +
  157. this.FDC, */
  158. url:'https://192.168.1.102:4397/websocket/usercontroller/selectUserList',
  159. data: {},
  160. method: 'GET',
  161. success: function(res) {
  162. _this.userList = res.data.data
  163. console.log(_this.userList);
  164. },
  165. fail: () => {
  166. _this.tips = '网络错误,小程序端请检查合法域名';
  167. },
  168. });
  169. },
  170. //获取文字信息
  171. getCur(e) {
  172. this.hidden = false;
  173. this.listCur = this.list[e.target.id].name;
  174. },
  175. setCur(e) {
  176. this.hidden = true;
  177. this.listCur = this.listCur
  178. },
  179. //滑动选择Item
  180. tMove(e) {
  181. let y = e.touches[0].clientY,
  182. offsettop = this.boxTop,
  183. that = this;
  184. //判断选择区域,只有在选择区才会生效
  185. if (y > offsettop) {
  186. let num = parseInt((y - offsettop) / 20);
  187. this.listCur = that.list[num].name
  188. };
  189. },
  190. //触发全部开始选择
  191. tStart() {
  192. this.hidden = false
  193. },
  194. //触发结束选择
  195. tEnd() {
  196. this.hidden = true;
  197. this.listCurID = this.listCur
  198. },
  199. indexSelect(e) {
  200. let that = this;
  201. let barHeight = this.barHeight;
  202. let list = this.list;
  203. let scrollY = Math.ceil(list.length * e.detail.y / barHeight);
  204. for (let i = 0; i < list.length; i++) {
  205. if (scrollY < i + 1) {
  206. that.listCur = list[i].name;
  207. that.movableY = i * 20
  208. return false
  209. }
  210. }
  211. }
  212. },
  213. }
  214. </script>
  215. <style>
  216. body {
  217. font-family: '方正兰亭细黑_GBK';
  218. font-size: 20px;
  219. color: silver;
  220. background: #000;
  221. }
  222. @font-face {
  223. font-family: '方正兰亭细黑_GBK';
  224. src: url(../../../static/fzltxh.TTF);
  225. }
  226. page {
  227. background-color: #1f1f1f;
  228. font-family: '方正兰亭细黑_GBK';
  229. overflow-x: hidden;
  230. }
  231. .indexes {
  232. position: relative;
  233. }
  234. .indexBar {
  235. position: fixed;
  236. right: 0px;
  237. bottom: 0px;
  238. padding: 20upx 20upx 20upx 60upx;
  239. display: flex;
  240. align-items: center;
  241. }
  242. .indexBar .indexBar-box {
  243. width: 40upx;
  244. height: auto;
  245. background: #fff;
  246. display: flex;
  247. flex-direction: column;
  248. box-shadow: 0 0 20upx rgba(0, 0, 0, 0.1);
  249. border-radius: 10upx;
  250. }
  251. .indexBar-item {
  252. flex: 1;
  253. width: 40upx;
  254. height: 40upx;
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. font-size: 24upx;
  259. color: #888;
  260. }
  261. movable-view.indexBar-item {
  262. width: 40upx;
  263. height: 40upx;
  264. z-index: 9;
  265. position: relative;
  266. }
  267. movable-view.indexBar-item::before {
  268. content: "";
  269. display: block;
  270. position: absolute;
  271. left: 0;
  272. top: 10upx;
  273. height: 20upx;
  274. width: 4upx;
  275. background-color: #f37b1d;
  276. }
  277. .indexToast {
  278. position: fixed;
  279. top: 0;
  280. right: 80upx;
  281. bottom: 0;
  282. background: rgba(0, 0, 0, 0.5);
  283. width: 100upx;
  284. height: 100upx;
  285. border-radius: 10upx;
  286. margin: auto;
  287. color: #fff;
  288. line-height: 100upx;
  289. text-align: center;
  290. font-size: 48upx;
  291. }
  292. .bg-white{
  293. background-color: #242424;
  294. }
  295. .cu-list,.menu-avatar>.cu-item {
  296. background-color: #242424;
  297. }
  298. .cu-avatar{
  299. height: 20px;
  300. width: 20px;
  301. }
  302. .indexes{
  303. margin-top: 50px;
  304. }
  305. </style>