App.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <template>
  2. <div id="app">
  3. <lemon-imui
  4. :user="user"
  5. class="imui-center"
  6. ref="IMUI"
  7. @change-menu="handleChangeMenu"
  8. @change-contact="handleChangeContact"
  9. @pull-messages="handlePullMessages"
  10. @send="handleSend"
  11. >
  12. <template #cover>
  13. <h1 style="text-indent:20px">自定义封面内容</h1>
  14. </template>
  15. <!-- <template #contact-info="contact">
  16. <span style="color:blue">contact-info {{ contact }}</span>
  17. </template> -->
  18. <!--
  19. <template #drawer="contact">
  20. <h1>自定义抽屉内容</h1>
  21. <p>{{ contact }}</p>
  22. </template>
  23. -->
  24. <template #contact-title="contact">
  25. <span>{{ contact.displayName }}</span>
  26. <small class="more" @click="changeDrawer(contact)">&#8230;</small>
  27. </template>
  28. </lemon-imui>
  29. </div>
  30. </template>
  31. <script>
  32. export default {
  33. name: "app",
  34. data() {
  35. return {
  36. user: {
  37. id: "superadmin",
  38. displayName: "IMUI super",
  39. avatar:
  40. "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
  41. }
  42. };
  43. },
  44. mounted() {
  45. const contactData1 = {
  46. id: "1",
  47. displayName: "工作协作群",
  48. avatar:
  49. "https://img.ivsky.com/img/tupian/li/201903/24/richu_riluo-015.jpg",
  50. type: "single",
  51. index: "A",
  52. unread: 0,
  53. lastSendTime: 1566047865417,
  54. lastContent: "2"
  55. };
  56. const contactData2 = {
  57. id: "2",
  58. displayName: "马林",
  59. avatar: "https://img.ivsky.com/img/tupian/li/201902/27/yanjing_meinv.jpg",
  60. type: "single",
  61. index: "B",
  62. click(next) {
  63. next();
  64. },
  65. renderContainer: () => {
  66. return <h1 style="text-indent:20px">自定义页面</h1>;
  67. },
  68. lastSendTime: 1345209465000,
  69. lastContent: "12312",
  70. unread: 2
  71. };
  72. const contactData3 = {
  73. id: "3",
  74. displayName: "范君",
  75. avatar:
  76. "https://img.ivsky.com/img/tupian/li/201903/21/huahuan_xiaonvhai.jpg",
  77. type: "many",
  78. index: "C",
  79. lastSendTime: 3
  80. };
  81. const { IMUI } = this.$refs;
  82. setTimeout(() => {
  83. //IMUI.openDrawer();
  84. // IMUI.openDrawer(() => {
  85. // return [
  86. // <h1>123</h1>,
  87. // <h1>123</h1>,
  88. // <h1>123</h1>,
  89. // <h1>123</h1>,
  90. // <h1>123</h1>,
  91. // <h1>123</h1>,
  92. // <h1>123</h1>,
  93. // <h1>123</h1>,
  94. // <h1>123</h1>,
  95. // <h1>123</h1>,
  96. // <h1>123</h1>,
  97. // <h1>123</h1>,
  98. // <h1>123</h1>,
  99. // <h1>123</h1>
  100. // ];
  101. // });
  102. // setTimeout(() => {
  103. // IMUI.openDrawer(() => {
  104. // return <h1>124563</h1>;
  105. // });
  106. // }, 2000);
  107. }, 2000);
  108. //[contactData1, contactData2, contactData3]
  109. let data = [
  110. { ...contactData1 },
  111. { ...contactData2 },
  112. { ...contactData3 }
  113. //...Array(100).fill(contactData1)
  114. ];
  115. IMUI.initContacts(data);
  116. IMUI.initEmoji([
  117. {
  118. label: "表情",
  119. children: [
  120. {
  121. name: "1f600",
  122. title: "微笑",
  123. src: "https://twemoji.maxcdn.com/2/72x72/1f600.png"
  124. },
  125. {
  126. name: "1f62c",
  127. title: "微笑",
  128. src: "https://twemoji.maxcdn.com/2/72x72/1f62c.png"
  129. },
  130. {
  131. name: "1f601",
  132. title: "微笑",
  133. src: "https://twemoji.maxcdn.com/2/72x72/1f601.png"
  134. },
  135. {
  136. name: "1f602",
  137. title: "微笑",
  138. src: "https://twemoji.maxcdn.com/2/72x72/1f602.png"
  139. },
  140. {
  141. name: "1f923",
  142. title: "微笑",
  143. src: "https://twemoji.maxcdn.com/2/72x72/1f923.png"
  144. },
  145. {
  146. name: "1f973",
  147. title: "微笑",
  148. src: "https://twemoji.maxcdn.com/2/72x72/1f973.png"
  149. },
  150. {
  151. name: "1f603",
  152. title: "微笑",
  153. src: "https://twemoji.maxcdn.com/2/72x72/1f603.png"
  154. },
  155. {
  156. name: "1f604",
  157. title: "微笑",
  158. src: "https://twemoji.maxcdn.com/2/72x72/1f604.png"
  159. },
  160. {
  161. name: "1f605",
  162. title: "微笑",
  163. src: "https://twemoji.maxcdn.com/2/72x72/1f605.png"
  164. },
  165. {
  166. name: "1f606",
  167. title: "微笑",
  168. src: "https://twemoji.maxcdn.com/2/72x72/1f606.png"
  169. },
  170. {
  171. name: "1f607",
  172. title: "微笑",
  173. src: "https://twemoji.maxcdn.com/2/72x72/1f607.png"
  174. },
  175. {
  176. name: "1f609",
  177. title: "微笑",
  178. src: "https://twemoji.maxcdn.com/2/72x72/1f609.png"
  179. },
  180. {
  181. name: "1f60a",
  182. title: "微笑",
  183. src: "https://twemoji.maxcdn.com/2/72x72/1f60a.png"
  184. },
  185. {
  186. name: "1f642",
  187. title: "微笑",
  188. src: "https://twemoji.maxcdn.com/2/72x72/1f642.png"
  189. },
  190. {
  191. name: "1f643",
  192. title: "微笑",
  193. src: "https://twemoji.maxcdn.com/2/72x72/1f643.png"
  194. },
  195. {
  196. name: "1263a",
  197. title: "微笑",
  198. src: "https://twemoji.maxcdn.com/2/72x72/263a.png"
  199. },
  200. {
  201. name: "1f60b",
  202. title: "微笑",
  203. src: "https://twemoji.maxcdn.com/2/72x72/1f60b.png"
  204. },
  205. {
  206. name: "1f60c",
  207. title: "微笑",
  208. src: "https://twemoji.maxcdn.com/2/72x72/1f60c.png"
  209. },
  210. {
  211. name: "1f60d",
  212. title: "微笑",
  213. src: "https://twemoji.maxcdn.com/2/72x72/1f60d.png"
  214. },
  215. {
  216. name: "1f970",
  217. title: "微笑",
  218. src: "https://twemoji.maxcdn.com/2/72x72/1f970.png"
  219. },
  220. {
  221. name: "1f618",
  222. title: "微笑",
  223. src: "https://twemoji.maxcdn.com/2/72x72/1f618.png"
  224. },
  225. {
  226. name: "1f617",
  227. title: "微笑",
  228. src: "https://twemoji.maxcdn.com/2/72x72/1f617.png"
  229. },
  230. {
  231. name: "1f619",
  232. title: "微笑",
  233. src: "https://twemoji.maxcdn.com/2/72x72/1f619.png"
  234. },
  235. {
  236. name: "1f61a",
  237. title: "微笑",
  238. src: "https://twemoji.maxcdn.com/2/72x72/1f61a.png"
  239. },
  240. {
  241. name: "1f61c",
  242. title: "微笑",
  243. src: "https://twemoji.maxcdn.com/2/72x72/1f61c.png"
  244. },
  245. {
  246. name: "1f92a",
  247. title: "微笑",
  248. src: "https://twemoji.maxcdn.com/2/72x72/1f92a.png"
  249. },
  250. {
  251. name: "1f928",
  252. title: "微笑",
  253. src: "https://twemoji.maxcdn.com/2/72x72/1f928.png"
  254. },
  255. {
  256. name: "1f9d0",
  257. title: "微笑",
  258. src: "https://twemoji.maxcdn.com/2/72x72/1f9d0.png"
  259. },
  260. {
  261. name: "1f61d",
  262. title: "微笑",
  263. src: "https://twemoji.maxcdn.com/2/72x72/1f61d.png"
  264. },
  265. {
  266. name: "1f61b",
  267. title: "微笑",
  268. src: "https://twemoji.maxcdn.com/2/72x72/1f61b.png"
  269. },
  270. {
  271. name: "1f911",
  272. title: "微笑",
  273. src: "https://twemoji.maxcdn.com/2/72x72/1f911.png"
  274. },
  275. {
  276. name: "1f913",
  277. title: "微笑",
  278. src: "https://twemoji.maxcdn.com/2/72x72/1f913.png"
  279. },
  280. {
  281. name: "1f60e",
  282. title: "微笑",
  283. src: "https://twemoji.maxcdn.com/2/72x72/1f60e.png"
  284. },
  285. {
  286. name: "1f929",
  287. title: "微笑",
  288. src: "https://twemoji.maxcdn.com/2/72x72/1f929.png"
  289. },
  290. {
  291. name: "1f921",
  292. title: "微笑",
  293. src: "https://twemoji.maxcdn.com/2/72x72/1f921.png"
  294. },
  295. {
  296. name: "1f920",
  297. title: "微笑",
  298. src: "https://twemoji.maxcdn.com/2/72x72/1f920.png"
  299. },
  300. {
  301. name: "1f917",
  302. title: "微笑",
  303. src: "https://twemoji.maxcdn.com/2/72x72/1f917.png"
  304. },
  305. {
  306. name: "1f60f",
  307. title: "微笑",
  308. src: "https://twemoji.maxcdn.com/2/72x72/1f60f.png"
  309. },
  310. {
  311. name: "1f636",
  312. title: "微笑",
  313. src: "https://twemoji.maxcdn.com/2/72x72/1f636.png"
  314. },
  315. {
  316. name: "1f610",
  317. title: "微笑",
  318. src: "https://twemoji.maxcdn.com/2/72x72/1f610.png"
  319. },
  320. {
  321. name: "1f611",
  322. title: "微笑",
  323. src: "https://twemoji.maxcdn.com/2/72x72/1f611.png"
  324. },
  325. {
  326. name: "1f612",
  327. title: "微笑",
  328. src: "https://twemoji.maxcdn.com/2/72x72/1f612.png"
  329. },
  330. {
  331. name: "1f644",
  332. title: "微笑",
  333. src: "https://twemoji.maxcdn.com/2/72x72/1f644.png"
  334. },
  335. {
  336. name: "1f914",
  337. title: "微笑",
  338. src: "https://twemoji.maxcdn.com/2/72x72/1f914.png"
  339. },
  340. {
  341. name: "1f925",
  342. title: "微笑",
  343. src: "https://twemoji.maxcdn.com/2/72x72/1f925.png"
  344. },
  345. {
  346. name: "1f92d",
  347. title: "微笑",
  348. src: "https://twemoji.maxcdn.com/2/72x72/1f92d.png"
  349. },
  350. {
  351. name: "1f92b",
  352. title: "微笑",
  353. src: "https://twemoji.maxcdn.com/2/72x72/1f92b.png"
  354. },
  355. {
  356. name: "1f92c",
  357. title: "微笑",
  358. src: "https://twemoji.maxcdn.com/2/72x72/1f92c.png"
  359. },
  360. {
  361. name: "1f92f",
  362. title: "微笑",
  363. src: "https://twemoji.maxcdn.com/2/72x72/1f92f.png"
  364. },
  365. {
  366. name: "1f633",
  367. title: "微笑",
  368. src: "https://twemoji.maxcdn.com/2/72x72/1f633.png"
  369. },
  370. {
  371. name: "1f61e",
  372. title: "微笑",
  373. src: "https://twemoji.maxcdn.com/2/72x72/1f61e.png"
  374. },
  375. {
  376. name: "1f61f",
  377. title: "微笑",
  378. src: "https://twemoji.maxcdn.com/2/72x72/1f61f.png"
  379. },
  380. {
  381. name: "1f620",
  382. title: "微笑",
  383. src: "https://twemoji.maxcdn.com/2/72x72/1f620.png"
  384. },
  385. {
  386. name: "1f621",
  387. title: "微笑",
  388. src: "https://twemoji.maxcdn.com/2/72x72/1f621.png"
  389. }
  390. ]
  391. },
  392. {
  393. label: "武器",
  394. children: [
  395. {
  396. name: "wx",
  397. src: "http://"
  398. }
  399. ]
  400. }
  401. ]);
  402. setTimeout(() => {
  403. IMUI.updateContact("3", {
  404. unread: 100,
  405. //displayName: "123",
  406. lastSendTime: 3,
  407. lastContent: "你好123"
  408. });
  409. }, 2000);
  410. },
  411. methods: {
  412. changeDrawer(contact) {
  413. this.$refs.IMUI.changeDrawer(() => {
  414. return [<h2>自定义抽屉</h2>, contact.displayName];
  415. });
  416. },
  417. handleChangeContact(contact) {
  418. this.$refs.IMUI.updateContact(contact.id, {
  419. //displayName: "123",
  420. unread: 0
  421. });
  422. this.$refs.IMUI.closeDrawer();
  423. },
  424. handleSend(message, next, file) {
  425. setTimeout(() => {
  426. next();
  427. }, 1000);
  428. },
  429. handlePullMessages(contact, next) {
  430. const messages = [
  431. {
  432. id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
  433. type: "text",
  434. status: "succeed",
  435. sendTime: 1564926674646,
  436. fromContactId: "superadmin",
  437. fromUser: {
  438. id: "hehe",
  439. displayName: "I KNOEW",
  440. avatar:
  441. "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
  442. },
  443. content: "测试消息哦..."
  444. },
  445. {
  446. id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
  447. type: "text",
  448. status: "succeed",
  449. sendTime: 1564926674646,
  450. fromContactId: "superadmin",
  451. fromUser: {
  452. id: "superadmin",
  453. displayName: "超级飞机",
  454. avatar:
  455. "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
  456. },
  457. content: "测试消息哦..."
  458. },
  459. {
  460. id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
  461. type: "text",
  462. status: "succeed",
  463. sendTime: 1564926674646,
  464. fromContactId: "superadmin",
  465. fromUser: {
  466. id: "hehe",
  467. displayName: "I KNOEW",
  468. avatar:
  469. "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
  470. },
  471. content: "测试消息哦..."
  472. },
  473. {
  474. id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
  475. type: "text",
  476. status: "succeed",
  477. sendTime: 1564926674646,
  478. fromContactId: "superadmin",
  479. fromUser: {
  480. id: "superadmin",
  481. displayName: "超级飞机",
  482. avatar:
  483. "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
  484. },
  485. content: "测试消息哦..."
  486. },
  487. {
  488. id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
  489. type: "text",
  490. status: "succeed",
  491. sendTime: 1564926674646,
  492. fromContactId: "superadmin",
  493. fromUser: {
  494. id: "hehe",
  495. displayName: "I KNOEW",
  496. avatar:
  497. "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
  498. },
  499. content: "测试消息哦..."
  500. },
  501. {
  502. id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
  503. type: "text",
  504. status: "succeed",
  505. sendTime: 1564926674646,
  506. fromContactId: "superadmin",
  507. fromUser: {
  508. id: "superadmin",
  509. displayName: "超级飞机",
  510. avatar:
  511. "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
  512. },
  513. content: "测试消息哦..."
  514. }
  515. ];
  516. next(messages);
  517. },
  518. handleChangeMenu() {},
  519. openCustomContainer() {}
  520. }
  521. };
  522. </script>
  523. <style lang="stylus">
  524. body
  525. background #384558 !important
  526. .imui-center
  527. position absolute
  528. top 50%
  529. left 50%
  530. transform translate(-50%,-50%)
  531. .more
  532. font-size 32px
  533. line-height 18px
  534. height 32px
  535. position absolute
  536. top 6px
  537. right 14px
  538. cursor pointer
  539. user-select none
  540. color #999
  541. &:active
  542. color #000
  543. </style>