group_qrcode.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <template>
  2. <share-poster ref="poster">
  3. <view class="page">
  4. <uni-nav-bar leftText="" :statusBar="true" backgroundColor="transparent" :border="false">
  5. <!-- <template v-slot:left v-if="!load_image">
  6. <view class="icon-center" @click="backUser">
  7. <image class="back-icon" src="/static/share/nav_icon_back_black.png" mode="widthFix"></image>
  8. </view>
  9. </template>
  10. <template v-slot:default v-if="!load_image">
  11. <view class="nav-bar">
  12. <text class="title">分享群</text>
  13. </view>
  14. </template> -->
  15. </uni-nav-bar>
  16. <view class="qr-box">
  17. <view class="qr-box-title">
  18. <!-- <view class="chatgroup-avatar-group">
  19. <image :class="'chatgroup-avatar-item-' + member.length" v-for="(item,index) in member"
  20. :key="index" :src="photo(item.photo)" :lazy-load="true">
  21. </image>
  22. </view>
  23. <view class="chatgroup-title">
  24. <text v-for="(item,index) in member" :key="index">{{item.show_name}}
  25. <block v-if="index < member.length - 1">、</block>
  26. </text>
  27. </view> -->
  28. <image class="qr-box-avatar" :lazy-load="true" :src="group_photo" mode="widthFix"></image>
  29. <view class="chatgroup-title">
  30. {{group_data.name}}
  31. </view>
  32. </view>
  33. <view class="qrimg">
  34. <tki-qrcode ref="qrcode" :val="qrData" :onval="true" :size="300" unit="upx" background="#ffffff"
  35. foreground="#000000" pdground="#000000" :loadMake="true" :showLoading="true"
  36. loadingText="加载中..." @result="qrR" />
  37. </view>
  38. <text class="text_font">使用易趣APP扫描二维码,加入群聊</text>
  39. <view class="btn-group" v-if="!load_image">
  40. <view class="btn" @click="savePoster">
  41. <image src="/static/share/album_down_save.webp" mode="widthFix"></image>
  42. <text>保存</text>
  43. </view>
  44. <view class="btn" @click="createPoster">
  45. <image src="/static/share/album_share_friend.webp" mode="widthFix"></image>
  46. <text>分享</text>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="qr-box-small" @click="groupCopy" v-if="!load_image">
  51. <view class="kouling">
  52. <image src="/static/group/kouling.png" mode=""></image>
  53. <text>生成群口令</text>
  54. </view>
  55. <view class="kouling-tips">
  56. 点击生成群口令
  57. </view>
  58. </view>
  59. <view class="share" v-if="load_image">
  60. <image class="share_icon" src="@/static/share_icon.png" mode="widthFix"></image>
  61. </view>
  62. </view>
  63. </share-poster>
  64. </template>
  65. <script>
  66. import tkiQrcode from '../../../components/tki-qrcode/tki-qrcode.vue';
  67. import _data from '../../../common/_data';
  68. import _hook from '../../../common/_hook';
  69. import _page from '../../../common/common';
  70. import uniNavBar from '@/components/uni-ui/uni-nav-bar/uni-nav-bar.vue'
  71. export default {
  72. components: {
  73. tkiQrcode,
  74. uniNavBar,
  75. },
  76. data() {
  77. return {
  78. list_id: '',
  79. my_data: {
  80. id: 0
  81. },
  82. group_photo: '',
  83. load_image: false,
  84. group_data: {}, //群数据
  85. member: [], //成员
  86. }
  87. },
  88. onShow() {
  89. _hook.routeTabBarHook();
  90. let _this = this;
  91. /** 监听新的个人数据 */
  92. uni.$on('data_user_info', function(data) {
  93. _this.my_data = data;
  94. });
  95. _this.my_data = _data.data('user_info');
  96. // this.group_photo = _data.data('cache')['group_photo_' + _this.list_id];
  97. },
  98. onLoad(option) {
  99. this.list_id = option.list_id;
  100. this.getData();
  101. },
  102. onUnload() {
  103. uni.$off('data_user_info');
  104. },
  105. computed: {
  106. qrData() {
  107. return _page.qrAction.addGroup({
  108. user_id: this.my_data.id,
  109. list_id: this.list_id
  110. });
  111. },
  112. staticPhoto() {
  113. return _data.staticPhoto();
  114. },
  115. },
  116. methods: {
  117. photo(path) {
  118. return this.staticPhoto + path + '?_=' + Math.random();
  119. },
  120. getData() {
  121. let _this = this;
  122. _this.$httpSend({
  123. path: '/im/message/getChatDetails',
  124. data: {
  125. list_id: _this.list_id,
  126. },
  127. success(data) {
  128. console.log("群数据", data);
  129. _this.group_data = data.group;
  130. // todo
  131. _this.member = data.member;
  132. // _this.member = [..._this.member, ..._this.member, ..._this.member];
  133. if (_this.member.length >= 6) {
  134. _this.member = _this.member.splice(0, 6);
  135. }
  136. _this.group_photo = _this.photo(data.group.is_photo);
  137. }
  138. });
  139. },
  140. backUser() {
  141. uni.navigateBack({
  142. })
  143. },
  144. qrR(ref) {
  145. this.img_path = ref;
  146. },
  147. saveQrcode() {
  148. _page.saveImgToPhotos(this.img_path);
  149. },
  150. // app截图保存、分享
  151. capture(type) {
  152. const _this = this;
  153. var pages = getCurrentPages();
  154. var page = pages[pages.length - 1];
  155. var bitmap = null;
  156. var currentWebview = page.$getAppWebview();
  157. bitmap = new plus.nativeObj.Bitmap('amway_img');
  158. currentWebview.draw(bitmap, function() {
  159. console.log("绘制截图成功");
  160. bitmap.save("_doc/b.jpg", {}, function(i) {
  161. console.log("保存图片成功", JSON.stringify(i));
  162. uni.saveImageToPhotosAlbum({
  163. filePath: i.target,
  164. success: function() {
  165. bitmap.clear(); //销毁缓存图片
  166. if (type == 'save') {
  167. uni.showToast({
  168. icon: 'none',
  169. title: '保存成功',
  170. })
  171. }
  172. if (type == "share") {
  173. uni.shareWithSystem({
  174. type: 'image',
  175. imageUrl: i.target,
  176. })
  177. }
  178. _this.load_image = false;
  179. uni.hideLoading();
  180. }
  181. })
  182. }, function(err) {
  183. _this.load_image = false;
  184. uni.hideLoading();
  185. console.log("保存失败", JSON.stringify(err))
  186. })
  187. }, function(err) {
  188. _this.load_image = false;
  189. uni.hideLoading();
  190. console.log("绘制截图失败", JSON.stringify(err))
  191. }, {
  192. check: true, // 设置为检测白屏
  193. clip: {
  194. top: '100px',
  195. left: '0px',
  196. height: '100%',
  197. width: '100%'
  198. } // 设置截屏区域
  199. })
  200. },
  201. // 生成海报
  202. createPoster() {
  203. // #ifdef H5
  204. uni.showToast({
  205. icon: 'none',
  206. title: '请截图分享'
  207. })
  208. // #endif
  209. // #ifdef APP-PLUS
  210. this.createImage('share');
  211. // #endif
  212. },
  213. // 生成海报
  214. createImage(type) {
  215. this.load_image = true;
  216. uni.showLoading({
  217. title: '正在生成...'
  218. });
  219. setTimeout(() => {
  220. this.capture(type);
  221. }, 300)
  222. },
  223. // 保存海报
  224. savePoster() {
  225. // #ifdef H5
  226. uni.showToast({
  227. icon: 'none',
  228. title: '请截图保存'
  229. })
  230. // #endif
  231. // #ifdef APP-PLUS
  232. this.createImage('save');
  233. // #endif
  234. },
  235. groupCopy() {
  236. _page.uniCopy({
  237. content: this.group_data.id,
  238. success: function() {
  239. uni.showToast({
  240. 'title': '复制成功',
  241. duration: 2000
  242. })
  243. }
  244. })
  245. },
  246. },
  247. watch: {
  248. },
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. .chatgroup-avatar-group {
  253. display: flex;
  254. flex-wrap: wrap;
  255. width: 200rpx;
  256. height: 200rpx;
  257. border-radius: 50%;
  258. overflow: hidden;
  259. margin-right: 20rpx;
  260. box-sizing: border-box;
  261. padding: 20rpx 10rpx;
  262. justify-content: center;
  263. align-items: center;
  264. .chatgroup-avatar-item-0 {
  265. width: 100rpx;
  266. height: 100rpx;
  267. border-radius: 50%;
  268. }
  269. .chatgroup-avatar-item-1 {
  270. width: 100rpx;
  271. height: 100rpx;
  272. border-radius: 50%;
  273. }
  274. .chatgroup-avatar-item-2 {
  275. width: 90rpx;
  276. height: 90rpx;
  277. border-radius: 50%;
  278. }
  279. .chatgroup-avatar-item-3 {
  280. width: 90rpx;
  281. height: 90rpx;
  282. border-radius: 50%;
  283. }
  284. .chatgroup-avatar-item-4 {
  285. width: 80rpx;
  286. height: 80rpx;
  287. border-radius: 50%;
  288. }
  289. .chatgroup-avatar-item-5 {
  290. width: 60rpx;
  291. height: 60rpx;
  292. border-radius: 50%;
  293. }
  294. .chatgroup-avatar-item-6 {
  295. width: 60rpx;
  296. height: 60rpx;
  297. border-radius: 50%;
  298. }
  299. }
  300. .chatgroup-avatar {
  301. width: 150rpx;
  302. height: 150rpx;
  303. border-radius: 50%;
  304. margin-right: 20rpx;
  305. }
  306. .chatgroup-title {
  307. font-size: 30rpx;
  308. font-weight: bold;
  309. width: 500rpx; //固定宽度
  310. display: -webkit-box;
  311. -webkit-box-orient: vertical;
  312. -webkit-line-clamp: 2;
  313. overflow: hidden;
  314. word-break: break-all;
  315. text-align: center;
  316. margin: 6rpx auto;
  317. }
  318. .share {
  319. display: flex;
  320. justify-content: center;
  321. align-items: center;
  322. height: 80rpx;
  323. margin: 30rpx;
  324. .share_icon {
  325. width: 200rpx;
  326. }
  327. }
  328. .btn-group {
  329. width: 400rpx;
  330. height: 120rpx;
  331. display: flex;
  332. justify-content: space-between;
  333. align-items: center;
  334. margin: 20rpx auto;
  335. .btn {
  336. display: flex;
  337. flex-direction: column;
  338. align-items: center;
  339. justify-content: center;
  340. image {
  341. width: 58rpx;
  342. height: 58rpx;
  343. }
  344. text {
  345. color: #0e131c;
  346. font-size: 32rpx;
  347. font-weight: bold;
  348. }
  349. }
  350. }
  351. .qr-box-small {
  352. width: 630rpx;
  353. margin: 20rpx auto;
  354. border-radius: 40rpx;
  355. // height: 100rpx;
  356. overflow: hidden;
  357. box-shadow: 0 0 10rpx 2rpx rgba(0, 0, 0, .2);
  358. background: #fff;
  359. box-sizing: border-box;
  360. padding: 20rpx 30rpx;
  361. display: flex;
  362. flex-direction: column;
  363. .kouling {
  364. display: flex;
  365. justify-content: center;
  366. align-items: center;
  367. image {
  368. width: 40rpx;
  369. height: 40rpx;
  370. }
  371. text {
  372. font-size: 30rpx;
  373. }
  374. }
  375. .kouling-tips {
  376. font-size: 24rpx;
  377. color: #d2d3d6;
  378. display: flex;
  379. justify-content: center;
  380. align-items: center;
  381. }
  382. }
  383. .qr-box {
  384. width: 650rpx;
  385. margin: 10rpx auto 0;
  386. // border-radius: 50rpx;
  387. // height: 1040rpx;
  388. // overflow: hidden;
  389. // box-shadow: 0 0 10rpx 0rpx rgba(0, 0, 0, .1);
  390. // background: #fff;
  391. background: url('@/static/bg.png') no-repeat;
  392. background-size: 100% 100%;
  393. box-sizing: border-box;
  394. padding: 30rpx;
  395. .qr-box-title {
  396. display: flex;
  397. flex-direction: column;
  398. align-items: center;
  399. margin-bottom: 20rpx;
  400. .qr-box-avatar {
  401. width: 160rpx;
  402. height: 160rpx;
  403. border-radius: 10rpx;
  404. // box-shadow: 0 10px 30rpx 6rpx rgba(0, 0, 0, .1);
  405. margin-bottom: 30rpx;
  406. margin-top: 30rpx;
  407. }
  408. .qr-box-tip {
  409. display: flex;
  410. flex-direction: column;
  411. align-items: center;
  412. text {
  413. font-size: 30rpx;
  414. }
  415. .gray {
  416. color: #d2d3d6;
  417. }
  418. .black {
  419. color: #353941;
  420. }
  421. }
  422. }
  423. }
  424. .page {
  425. background: url('@/static/share/im_group_qr_bg_big.png') no-repeat;
  426. background-size: 100% auto;
  427. }
  428. // page {
  429. // height: 100vh;
  430. // background: url('@/static/share/im_group_qr_bg_big.png') no-repeat;
  431. // background-size: 100% auto;
  432. // }
  433. .icon-center {
  434. width: 100%;
  435. height: 100%;
  436. display: flex;
  437. justify-content: center;
  438. align-items: center;
  439. }
  440. .back-icon {
  441. width: 44rpx;
  442. height: 44rpx;
  443. flex-shrink: 0;
  444. }
  445. .refresh-icon {
  446. width: 50rpx;
  447. height: 50rpx;
  448. flex-shrink: 0;
  449. }
  450. @keyframes round {
  451. 0% {
  452. transform: rotate(0);
  453. }
  454. 0% {
  455. transform: rotate(-360deg);
  456. }
  457. }
  458. .refresh {
  459. animation: round 1s linear infinite;
  460. }
  461. .nav-bar {
  462. display: flex;
  463. justify-content: center;
  464. align-items: center;
  465. height: 100%;
  466. margin-left: -30rpx;
  467. .title {
  468. font-weight: bold;
  469. font-size: 30rpx;
  470. }
  471. }
  472. .qrimg {
  473. text-align: center;
  474. background: #FFFFFF;
  475. padding-bottom: 10upx;
  476. }
  477. .bode_main {
  478. margin: 150upx 35upx 0 35upx;
  479. width: 680upx;
  480. height: 900upx;
  481. border-radius: 50upx;
  482. overflow: hidden;
  483. }
  484. .photo {
  485. width: 110upx;
  486. height: 110upx;
  487. margin-left: 30upx;
  488. margin-right: 30upx;
  489. }
  490. .my_padding {
  491. padding-bottom: 20px;
  492. }
  493. .my_padding:before {
  494. background-color: white;
  495. }
  496. .my_padding:before {
  497. background-color: white;
  498. }
  499. .my_padding:after {
  500. background-color: white;
  501. }
  502. .text_font {
  503. color: #8f8f94;
  504. display: flex;
  505. justify-content: center;
  506. align-items: center;
  507. }
  508. </style>