addressBook.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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'}]"> <!-- :style="[{top:CustomBar + 'px'}]" -->
  15. <view class="search-form round" @touchstart="accordingTo">
  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" @click="accordingOut">取消</button>
  21. </view>
  22. </view>
  23. <!-- 搜索列表 -->
  24. <view class="search-content " ref="search" >
  25. <block>
  26. <view class="cu-list menu-avatar no-padding mar_t" >
  27. <!-- <view class="cu-avatar">{{item.name}}</view> 字母开头显示 -->
  28. <!-- 将汉字以当前字母开头的遍历 -->
  29. <view class="cu-item " v-for="item in userListData" >
  30. <view v-if="item.remak1==1">
  31. <view class="content" @click="go(userid,lastUserName,items.nickname,items.id,1)">
  32. <view class="text-grey">{{item.username}}({{item.remak2}})<!-- <text class="text-abc">{{items.name}}</text>君 --></view>
  33. <view class="text-gray text-sm">
  34. 有条消息
  35. </view>
  36. </view>
  37. <!-- 在线离线标识 -->
  38. <text class="cuIcon-radioboxfill text-green" style="margin-right: 3px;">在线</text>
  39. </view>
  40. <view v-if="item.remak1==0">
  41. <view class="content" @click="go(userid,lastUserName,item.nickname,item.id,0)">
  42. <view class="text-grey">{{item.username}}({{item.remak2}})<!-- <text class="text-abc">{{items.name}}</text>君 --></view>
  43. <view class="text-gray text-sm">
  44. 有条消息
  45. </view>
  46. </view>
  47. <text class="cuIcon-radioboxfill text-gray" style="margin-right: 3px;">离线</text>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- <view :class="'indexItem-' + item.name" :id="'indexes-' + item.name" :data-index="item.name">
  52. <view class="padding"></view>
  53. <view class="cu-list menu-avatar no-padding" >
  54. <view class="cu-item" @tap="common.navTo('/components/mine/addressBook/chat?name='+item+'&send='+send+'&receive='+receive+'&sendname='+sendname+'&receivename='+receivename)">
  55. <view class="cu-avatar round lg"></view>
  56. <view class="content" >
  57. <view class="text-grey">{{item.name}}</view>
  58. </view>
  59. </view>
  60. </view>
  61. </view> -->
  62. </block>
  63. </view>
  64. <!-- 通讯列表 -->
  65. <scroll-view scroll-y class="indexes" :scroll-into-view="'indexes-'+ listCurID" :style="[{height:'calc(100vh - '+ CustomBar + 'px - 50px)'}]"
  66. :scroll-with-animation="true" :enable-back-to-top="true" v-if="play">
  67. <!-- <block v-for="(item,index) in list" :key="index"> -->
  68. <!-- 控制侧导航栏 -->
  69. <!-- <view :class="'indexItem-' + item.name" :id="'indexes-' + item.name" :data-index="item.name"> -->
  70. <!-- <view class="padding">{{item.name}}</view> -->
  71. <view class="cu-list menu-avatar no-padding" >
  72. <!-- <view class="cu-avatar">{{item.name}}</view> 字母开头显示 -->
  73. <!-- 将汉字以当前字母开头的遍历 -->
  74. <view class="cu-item" v-for="(items,sub) in userList" :key="sub" >
  75. <view v-if="items.remak1==1">
  76. <view class="content" @click="go(userid,lastUserName,items.nickname,items.id,1)">
  77. <view class="text-grey">{{items.username}}({{items.remak2}})<!-- <text class="text-abc">{{items.name}}</text>君 --></view>
  78. <view class="text-gray text-sm">
  79. 有{{items.remak1}}条消息
  80. </view>
  81. </view>
  82. <!-- 在线标识 -->
  83. <text class="cuIcon-radioboxfill text-green" style="margin-right: 3px;">在线</text>
  84. </view>
  85. <view v-if="items.remak1==0">
  86. <view class="content" @click="go(userid,lastUserName,items.nickname,items.id,0)">
  87. <view class="text-grey">{{items.username}}({{items.remak2}})<!-- <text class="text-abc">{{items.name}}</text>君 --></view>
  88. <view class="text-gray text-sm">
  89. 有{{items.remak1}}条消息
  90. </view>
  91. </view>
  92. <!-- 离线标识 -->
  93. <text class="cuIcon-radioboxfill text-gray" style="margin-right: 3px;">离线</text>
  94. </view>
  95. </view>
  96. </view>
  97. <!-- </view>
  98. </block> -->
  99. </scroll-view>
  100. <!-- 侧导航栏 -->
  101. <!-- <view class="indexBar" :style="[{height:'calc(100vh - ' + CustomBar + 'px - 50px)'}]">
  102. <view class="indexBar-box" @touchstart="tStart" @touchend="tEnd" @touchmove.stop="tMove">
  103. <view class="indexBar-item" v-for="(item,index) in list" :key="index" :id="index" @touchstart="getCur" @touchend="setCur"> {{item.name}}</view>
  104. </view>
  105. </view> -->
  106. <!--选择显示 keyword-->
  107. <view v-show="!hidden" class="indexToast">
  108. <!-- {{listCur}} -->
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. import pinyin from './index.js';
  114. export default {
  115. data() {
  116. return {
  117. userid:'',
  118. lastUserName:'',
  119. StatusBar: this.StatusBar,
  120. CustomBar: this.CustomBar,
  121. listCurID: '',
  122. list: [],
  123. listCur: '',
  124. send:'1',
  125. receive:'2',
  126. hidden: true,
  127. play:true,
  128. sendname:'ming',
  129. receivename:'fang',
  130. search:'',
  131. timer: null,
  132. userList:{
  133. id:'',
  134. nickname:'',
  135. password:'',
  136. remak1:'',
  137. username:'',
  138. remak2:'',
  139. },
  140. biaos:2,
  141. socketTask_getUserList:'',
  142. };
  143. },
  144. created: function() {
  145. this.getUserList();
  146. /* this.pinyin(); */
  147. },
  148. onLoad() {
  149. this.getUserList();
  150. let list = [{}];
  151. for (let i = 0; i < 26; i++) {
  152. list[i] = {};
  153. list[i].name = String.fromCharCode(65 + i);
  154. }
  155. this.list = list;
  156. this.listCur = list[0];
  157. },
  158. onReady() {
  159. let that = this;
  160. /* uni.createSelectorQuery().select('.indexBar-box').boundingClientRect(function(res) {
  161. that.boxTop = res.top
  162. }).exec();
  163. uni.createSelectorQuery().select('.indexes').boundingClientRect(function(res) {
  164. that.barTop = res.top
  165. }).exec(); */
  166. /*
  167. this.pinyin(); */
  168. },
  169. computed: {
  170. backStageIp: function() {
  171. return this.$store.state.wholeSituationBackStageIp;
  172. },
  173. backStagePort: function() {
  174. return this.$store.state.wholeSituationBackStagePort;
  175. },
  176. windpowerstationNameToId: function() {
  177. return this.$store.state.windpowerstationNameToId;
  178. },
  179. userListData: function() {
  180. var search = this.search;
  181. if(!this.search){
  182. return [];
  183. }
  184. else if (search) {
  185. return this.userList.filter(function(userList) {
  186. return Object.keys(userList).some(function(key) {
  187. return String(userList[key]).toLowerCase().indexOf(search) > -1
  188. })
  189. })
  190. }
  191. return this.products;
  192. },
  193. hasNoData () {
  194. return !this.list.length
  195. }
  196. },
  197. methods: {
  198. go(userid,lastUserName,nickname,id,bool){
  199. if(bool==0){
  200. /* console.log("https://192.168.1.102:4397/websocket/usercontroller/viewoffline?send="+userid+"&receive="+id+"&sendname="+lastUserName+"&receivename="+nickname); */
  201. window.location.href="https://192.168.1.102:4397/websocket/usercontroller/viewoffline?send="+userid+"&receive="+id+"&sendname="+lastUserName+"&receivename="+nickname;
  202. }
  203. if(bool==1){
  204. window.location.href="https://192.168.1.102:4397/websocket/usercontroller/view?send="+userid+"&receive="+id+"&sendname="+lastUserName+"&receivename="+nickname;
  205. }
  206. /* */
  207. },
  208. accordingOut(){
  209. this.play=true;
  210. this.search='';
  211. },
  212. accordingTo(){
  213. this.play=false;
  214. },
  215. pinyin(str){
  216. var l = pinyin.getSpell(str).substring(0,1);
  217. console.log(l);
  218. },
  219. /* handleCityClick (city) {
  220. this.changeCity(city)
  221. this.$router.push('/')
  222. }, */
  223. closeFrame: function() {
  224. this.count = this.count + 1;
  225. if (this.isFrameShow) {
  226. this.isFrameShow = false;
  227. this.sanJiao = 'sanJiaoDown';
  228. }
  229. },
  230. async getUserList() {
  231. let _this = this;
  232. // 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
  233. this.socketTask_getUserList = uni.connectSocket({
  234. // 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
  235. url: 'ws://117.78.18.24:9988/websocket/pageNumber_4/functionNumber_3/all',
  236. success(data) {
  237. console.log(data);
  238. }
  239. });
  240. /* let windpowerstationid = uni.getStorageSync('windpowerstationName'); */
  241. // 消息的发送和接收必须在正常连接打开中,才能发送或接收【否则会失败】
  242. this.socketTask_getUserList.onOpen(res => {
  243. console.log('WebSocket连接正常打开中...!');
  244. this.is_open_socket = true;
  245. // 注:只有连接正常打开中 ,才能正常收到消息
  246. this.socketTask_getUserList.onMessage(res => {
  247. console.log("收到服务器内容:" + res.data);
  248. /* _this.windpowerstationdetail.getUserList = JSON.parse(res.data); */
  249. _this.userList = JSON.parse(res.data);
  250. _this.lastUserName = uni.getStorageSync('gyeeusername');
  251. _this.userid = uni.getStorageSync('userid');
  252. });
  253. });
  254. },
  255. //获取文字信息
  256. getCur(e) {
  257. this.hidden = false;
  258. this.listCur = this.list[e.target.id].name;
  259. },
  260. setCur(e) {
  261. this.hidden = true;
  262. this.listCur = this.listCur
  263. },
  264. //滑动选择Item
  265. tMove(e) {
  266. let y = e.touches[0].clientY,
  267. offsettop = this.boxTop,
  268. that = this;
  269. //判断选择区域,只有在选择区才会生效
  270. if (y > offsettop) {
  271. let num = parseInt((y - offsettop) / 20);
  272. this.listCur = that.list[num].name
  273. };
  274. },
  275. //触发全部开始选择
  276. tStart() {
  277. this.hidden = false
  278. },
  279. //触发结束选择
  280. tEnd() {
  281. this.hidden = true;
  282. this.listCurID = this.listCur
  283. },
  284. indexSelect(e) {
  285. let that = this;
  286. let barHeight = this.barHeight;
  287. let list = this.list;
  288. let scrollY = Math.ceil(list.length * e.detail.y / barHeight);
  289. for (let i = 0; i < list.length; i++) {
  290. if (scrollY < i + 1) {
  291. that.listCur = list[i].name;
  292. that.movableY = i * 20
  293. return false
  294. }
  295. }
  296. }
  297. },
  298. }
  299. </script>
  300. <style>
  301. body {
  302. font-family: '方正兰亭细黑_GBK';
  303. font-size: 20px;
  304. color: silver;
  305. background: #000;
  306. }
  307. @font-face {
  308. font-family: '方正兰亭细黑_GBK';
  309. src: url(../../../static/fzltxh.TTF);
  310. }
  311. page {
  312. background-color: #1f1f1f;
  313. font-family: '方正兰亭细黑_GBK';
  314. overflow-x: hidden;
  315. }
  316. .indexes {
  317. position: relative;
  318. }
  319. .indexBar {
  320. position: fixed;
  321. right: 0px;
  322. bottom: 0px;
  323. padding: 20upx 20upx 20upx 60upx;
  324. display: flex;
  325. align-items: center;
  326. }
  327. .indexBar .indexBar-box {
  328. width: 40upx;
  329. height: auto;
  330. background: #fff;
  331. display: flex;
  332. flex-direction: column;
  333. box-shadow: 0 0 20upx rgba(0, 0, 0, 0.1);
  334. border-radius: 10upx;
  335. }
  336. .indexBar-item {
  337. flex: 1;
  338. width: 40upx;
  339. height: 40upx;
  340. display: flex;
  341. align-items: center;
  342. justify-content: center;
  343. font-size: 24upx;
  344. color: #888;
  345. }
  346. movable-view.indexBar-item {
  347. width: 40upx;
  348. height: 40upx;
  349. z-index: 9;
  350. position: relative;
  351. }
  352. movable-view.indexBar-item::before {
  353. content: "";
  354. display: block;
  355. position: absolute;
  356. left: 0;
  357. top: 10upx;
  358. height: 20upx;
  359. width: 4upx;
  360. background-color: #f37b1d;
  361. }
  362. .indexToast {
  363. position: fixed;
  364. top: 0;
  365. right: 80upx;
  366. bottom: 0;
  367. background: rgba(0, 0, 0, 0.5);
  368. width: 100upx;
  369. height: 100upx;
  370. border-radius: 10upx;
  371. margin: auto;
  372. color: #fff;
  373. line-height: 100upx;
  374. text-align: center;
  375. font-size: 48upx;
  376. }
  377. .bg-white{
  378. background-color: #242424;
  379. }
  380. .cu-list,.menu-avatar>.cu-item {
  381. background-color: #242424;
  382. }
  383. .cu-avatar{
  384. height: 20px;
  385. width: 20px;
  386. }
  387. .mar_t{
  388. margin-top: 50px;
  389. }
  390. .text-grey{
  391. margin-top: -10px;
  392. }
  393. </style>