qrcode-old.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view class="page">
  3. <uni-nav-bar leftText="" :statusBar="true" backgroundColor="#11d7a8" :border="false">
  4. <template v-slot:left>
  5. <view class="icon-center" @click="backUser">
  6. <image class="back-icon" src="/static/share/nav_icon_back_black.png" mode="widthFix"></image>
  7. </view>
  8. </template>
  9. <template v-slot:default>
  10. <view class="nav-bar">
  11. <text class="title">我的二维码</text>
  12. </view>
  13. </template>
  14. <template class="" v-slot:right>
  15. <view class="icon-center" @click="refreshData">
  16. <image class="refresh-icon" :class="{refresh:loading}" src="/static/share/refresh.png"
  17. mode="widthFix"></image>
  18. </view>
  19. </template>
  20. </uni-nav-bar>
  21. <view class="qr-box">
  22. <view class="qr-box-title">
  23. <image class="qr-box-avatar" :lazy-load="true" :src="myPhoto" mode="widthFix"></image>
  24. <view class="qr-box-tip">
  25. <text class="black">{{my_data.nickname}}</text>
  26. <text class="gray">{{my_data.doodling}}</text>
  27. </view>
  28. </view>
  29. <view class="qrimg">
  30. <tki-qrcode ref="qrcode" :val="qrData" :onval="true" :size="300" unit="upx" background="#ffffff"
  31. foreground="#000000" pdground="#000000" :loadMake="true" :showLoading="true" loadingText="加载中..."
  32. @result="qrR" />
  33. </view>
  34. <text class="text_font">使用默往APP扫描二维码,加我为好友</text>
  35. <view class="btn-group">
  36. <view class="btn" @click="saveImage">
  37. <image src="/static/share/album_down_save.webp" mode="widthFix"></image>
  38. <text>保存</text>
  39. </view>
  40. <view class="btn" @click="shareImage">
  41. <image src="/static/share/album_share_friend.webp" mode="widthFix"></image>
  42. <text>分享</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import uniList from '../../components/uni-list/uni-list.vue';
  50. import uniListItem from '../../components/uni-list-item/uni-list-item.vue';
  51. import _page from '../../common/common';
  52. import _hook from '../../common/_hook';
  53. import _data from '../../common/_data';
  54. import tkiQrcode from "../../components/tki-qrcode/tki-qrcode";
  55. import uniNavBar from '@/components/uni-ui/uni-nav-bar/uni-nav-bar.vue'
  56. export default {
  57. components: {
  58. uniList,
  59. uniListItem,
  60. tkiQrcode,
  61. uniNavBar
  62. },
  63. data() {
  64. return {
  65. my_data: {
  66. id: 0
  67. },
  68. img_path: '',
  69. loading: false,
  70. }
  71. },
  72. onShow() {
  73. this.initData();
  74. },
  75. onLoad() {
  76. },
  77. onUnload() {
  78. uni.$off('data_user_info');
  79. },
  80. computed: {
  81. qrPhoto() {
  82. return _data.data('cache').local_photo;
  83. },
  84. myPhoto() {
  85. return _data.staticPhoto() + this.my_data.photo;
  86. },
  87. qrData() {
  88. let qr = _page.qrAction.chatAdd({
  89. user_id: this.my_data.id
  90. });
  91. console.log("qr", qr);
  92. return qr;
  93. },
  94. },
  95. methods: {
  96. shareImage() {
  97. // #ifdef H5
  98. uni.showToast({
  99. icon: 'none',
  100. title: '请截图保存'
  101. })
  102. // #endif
  103. // console.log("this.$refs.qrcode", this.$refs.qrcode.result);
  104. uni.saveImageToPhotosAlbum({
  105. filePath: this.$refs.qrcode.result,
  106. success: function(res) {
  107. console.log('save success', res);
  108. uni.shareWithSystem({
  109. type: 'image',
  110. imageUrl: res.path,
  111. })
  112. }
  113. });
  114. },
  115. saveImage() {
  116. // #ifdef APP-PLUS
  117. this.$refs.qrcode._saveCode();
  118. // #endif
  119. // #ifdef H5
  120. uni.showToast({
  121. icon: 'none',
  122. title: '请截图保存'
  123. })
  124. // #endif
  125. },
  126. initData() {
  127. _hook.routeTabBarHook();
  128. let _this = this;
  129. /** 监听新的个人数据 */
  130. uni.$on('data_user_info', function(data) {
  131. _this.my_data = data;
  132. });
  133. _this.my_data = _data.data('user_info');
  134. setTimeout(() => {
  135. this.loading = false;
  136. }, 1000)
  137. },
  138. refreshData() {
  139. this.loading = true;
  140. this.initData();
  141. },
  142. backUser() {
  143. uni.switchTab({
  144. url: '/pages/my/index'
  145. })
  146. },
  147. qrR(ref) {
  148. this.img_path = ref;
  149. },
  150. },
  151. watch: {
  152. },
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .btn-group {
  157. width: 400rpx;
  158. height: 120rpx;
  159. display: flex;
  160. justify-content: space-between;
  161. align-items: center;
  162. margin: 20rpx auto;
  163. .btn {
  164. display: flex;
  165. flex-direction: column;
  166. align-items: center;
  167. justify-content: center;
  168. image {
  169. width: 58rpx;
  170. height: 58rpx;
  171. }
  172. text {
  173. color: #0e131c;
  174. font-size: 32rpx;
  175. font-weight: bold;
  176. }
  177. }
  178. }
  179. .qr-box {
  180. width: 650rpx;
  181. margin: 160rpx auto 0;
  182. border-radius: 50rpx;
  183. height: 1040rpx;
  184. overflow: hidden;
  185. box-shadow: 0 0 10rpx 0rpx rgba(0, 0, 0, .1);
  186. background: #fff;
  187. .qr-box-title {
  188. display: flex;
  189. flex-direction: column;
  190. align-items: center;
  191. margin-bottom: 60rpx;
  192. .qr-box-avatar {
  193. width: 160rpx;
  194. height: 160rpx;
  195. border-radius: 50%;
  196. box-shadow: 0 10px 30rpx 6rpx rgba(0, 0, 0, .1);
  197. margin-bottom: 30rpx;
  198. margin-top: 100rpx;
  199. }
  200. .qr-box-tip {
  201. display: flex;
  202. flex-direction: column;
  203. align-items: center;
  204. text {
  205. font-size: 30rpx;
  206. }
  207. .gray {
  208. color: #d2d3d6;
  209. }
  210. .black {
  211. color: #353941;
  212. }
  213. }
  214. }
  215. }
  216. .page {
  217. background: url('@/static/share/im_group_qr_bg_big.png') no-repeat;
  218. background-size: 100% auto;
  219. }
  220. .icon-center {
  221. width: 100%;
  222. height: 100%;
  223. display: flex;
  224. justify-content: center;
  225. align-items: center;
  226. }
  227. .back-icon {
  228. width: 44rpx;
  229. height: 44rpx;
  230. flex-shrink: 0;
  231. }
  232. .refresh-icon {
  233. width: 50rpx;
  234. height: 50rpx;
  235. flex-shrink: 0;
  236. }
  237. @keyframes round {
  238. 0% {
  239. transform: rotate(0);
  240. }
  241. 0% {
  242. transform: rotate(-360deg);
  243. }
  244. }
  245. .refresh {
  246. animation: round 1s linear infinite;
  247. }
  248. .nav-bar {
  249. display: flex;
  250. justify-content: center;
  251. align-items: center;
  252. height: 100%;
  253. margin-left: -30rpx;
  254. .title {
  255. font-weight: bold;
  256. font-size: 30rpx;
  257. }
  258. }
  259. .qrimg {
  260. text-align: center;
  261. background: #FFFFFF;
  262. padding-bottom: 40upx;
  263. }
  264. .bode_main {
  265. margin: 150upx 35upx 0 35upx;
  266. width: 680upx;
  267. height: 900upx;
  268. border-radius: 50upx;
  269. overflow: hidden;
  270. }
  271. .photo {
  272. width: 110upx;
  273. height: 110upx;
  274. margin-left: 30upx;
  275. margin-right: 30upx;
  276. }
  277. .my_padding {
  278. padding-bottom: 20px;
  279. }
  280. .my_padding:before {
  281. background-color: white;
  282. }
  283. .my_padding:before {
  284. background-color: white;
  285. }
  286. .my_padding:after {
  287. background-color: white;
  288. }
  289. .text_font {
  290. color: #8f8f94;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. }
  295. </style>