sharePage.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <uni-popup ref="popupRef">
  3. <view class="share-box">
  4. <view class="share-status-bar" :style="{'height': `${statusBarHeight}px`}"></view>
  5. <!-- statusBarHeight -->
  6. <view class="share-content">
  7. <view class="content" id="share-content">
  8. <view class="share-top">
  9. <image class="share-logo" src="@/static/share/img_02.png" mode="aspectFit"></image>
  10. <text class="share-title">注册会员</text>
  11. <text class="share-title">获取高额奖励</text>
  12. <view class="share-list">
  13. <view class="share-list-item"><text class="item-icon"></text><text
  14. class="item-text">安全的钱包技术</text></view>
  15. <view class="share-list-item"><text class="item-icon"></text><text
  16. class="item-text">交易流畅顶级风控</text></view>
  17. <view class="share-list-item"><text class="item-icon"></text><text
  18. class="item-text">丰富的加密资产业务</text></view>
  19. <view class="share-list-item"><text class="item-icon"></text><text
  20. class="item-text">分布在世界各地的客户</text></view>
  21. </view>
  22. </view>
  23. <view class="footer">
  24. <image class="share-code" src="@/static/share/img_03.png" mode="aspectFit"></image>
  25. <view class="share-btns">
  26. <view class="share-btn">
  27. 邀请您加入[币王]
  28. </view>
  29. <view class="share-btn-hint">
  30. <<<长按识别二维码 </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="share-footer">
  36. <view class="share-list">
  37. <view class="share-icons">
  38. <text class="share-icon iconfont" style="color: #00b1ff;">&#xe65b;</text>
  39. <text class="share-text">复制链接</text>
  40. </view>
  41. <view class="share-icons">
  42. <text class="share-icon iconfont" style="color: #029a73;">&#xe631;</text>
  43. <text class="share-text">微信</text>
  44. </view>
  45. <view class="share-icons">
  46. <text class="share-icon iconfont" style="color: #02d9a2;">&#xe623;</text>
  47. <text class="share-text">朋友圈</text>
  48. </view>
  49. <view class="share-icons">
  50. <text class="share-icon iconfont" style="color: #1890ff;">&#xe66a;</text>
  51. <text class="share-text">QQ</text>
  52. </view>
  53. <view class="share-icons" @click="my_js.onclicks">
  54. <text class="share-icon iconfont" style="color: #83a0e5">&#xe63a;</text>
  55. <text class="share-text">保存图片</text>
  56. </view>
  57. </view>
  58. <view class="share-cancel" @click.stop="cancelShare">
  59. 取消
  60. </view>
  61. </view>
  62. </view>
  63. </uni-popup>
  64. </template>
  65. <script>
  66. import {
  67. mapGetters
  68. } from 'vuex'
  69. export default {
  70. name: "sharePage",
  71. props: {
  72. tabBar: {
  73. type: Boolean,
  74. default: true
  75. }
  76. },
  77. data() {
  78. return {
  79. };
  80. },
  81. computed: {
  82. ...mapGetters([
  83. 'statusBarHeight'
  84. ])
  85. },
  86. mounted() {
  87. // this.openShare()
  88. // this.$refs.popupRef.open()
  89. },
  90. methods: {
  91. openShare() {
  92. this.$nextTick(() => {
  93. this.showTabBar(false)
  94. this.$refs.popupRef.open()
  95. })
  96. },
  97. cancelShare() {
  98. this.$refs.popupRef.close()
  99. this.showTabBar()
  100. },
  101. showTabBar(type = true) {
  102. if (this.tabBar) {
  103. try {
  104. if (type) {
  105. uni.showTabBar();
  106. } else {
  107. uni.hideTabBar();
  108. }
  109. } catch {}
  110. }
  111. },
  112. saveBase64(imageStr) {
  113. uni.showLoading({
  114. title: "保存中",
  115. })
  116. try {
  117. let bitmap = new plus.nativeObj.Bitmap();
  118. bitmap.loadBase64Data(imageStr, function() {
  119. console.log('加载base64图片数据成功');
  120. //图片名称命名
  121. bitmap.save('_doc/' + new Date().getTime() + '.png', {
  122. quality: 100
  123. }, function(i) {
  124. // 将图片保存到相册
  125. uni.saveImageToPhotosAlbum({
  126. filePath: i.target,
  127. success: function() {
  128. bitmap.clear(); //销毁Bitmap图片
  129. // uni.$u.toast('保存图片成功')
  130. uni.showToast({
  131. title: '保存图片成功',
  132. icon:'none',
  133. duration: 2000
  134. });
  135. // that.noPhoto = true;
  136. }
  137. });
  138. }, function(e) {
  139. console.log('保存图片失败:' + JSON.stringify(e));
  140. });
  141. }, function(e) {
  142. console.log('截屏绘制图片失败:' + JSON.stringify(e));
  143. });
  144. } catch {
  145. uni.hideLoading()
  146. }
  147. },
  148. }
  149. }
  150. </script>
  151. <script module="my_js" lang="renderjs">
  152. import html2canvas from 'html2canvas';
  153. export default {
  154. data() {
  155. return {}
  156. },
  157. methods: {
  158. onclicks(event, ownerInstance) {
  159. console.log(99)
  160. html2canvas(document.getElementById('share-content'), {
  161. backgroundColor: '#fff',
  162. useCORS: true,
  163. taintTest: true,
  164. timeout: 2000
  165. }).then(canvas => {
  166. let imgurl = canvas.toDataURL('image/jpg');
  167. ownerInstance.callMethod('saveBase64', imgurl)
  168. })
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. .share-box {
  175. width: 750rpx;
  176. height: 100vh;
  177. display: flex;
  178. flex-direction: column;
  179. .share-status-bar {
  180. flex-shrink: 0;
  181. width: 100%;
  182. background-color: rgba(255, 255, 255, 0.5);
  183. }
  184. .share-content {
  185. flex: 1;
  186. padding: 30rpx 40rpx;
  187. .content {
  188. flex-shrink: 0;
  189. width: 100%;
  190. height: 100%;
  191. background: url("@/static/share/img_01.png") no-repeat center center;
  192. background-size: 100% 100%;
  193. display: flex;
  194. flex-direction: column;
  195. justify-content: space-between;
  196. padding: 30rpx 30rpx 20rpx;
  197. .share-top {
  198. display: flex;
  199. flex-direction: column;
  200. align-items: flex-start;
  201. .share-logo {
  202. display: inline-block;
  203. width: 322rpx;
  204. height: 80rpx;
  205. // margin-bottom: 14rpx;
  206. }
  207. .share-title {
  208. font-size: 56rpx;
  209. font-family: PingFang SC, PingFang SC-Bold;
  210. font-weight: 700;
  211. color: #ffffff;
  212. line-height: 1.1;
  213. letter-spacing: 1.2px;
  214. }
  215. .share-list {
  216. width: 100%;
  217. padding-top: 20rpx;
  218. display: flex;
  219. flex-direction: column;
  220. .share-list-item {
  221. font-size: 20rpx;
  222. font-family: PingFang SC, PingFang SC-Regular;
  223. font-weight: 400;
  224. color: #ffffff;
  225. line-height: 1.5;
  226. // transform: scale(0.8);
  227. display: flex;
  228. align-items: center;
  229. justify-content: flex-start;
  230. .item-icon {
  231. display: inline-block;
  232. width: 14rpx;
  233. height: 14rpx;
  234. border-radius: 50%;
  235. background-color: #fff;
  236. }
  237. .item-text {
  238. padding-left: 3px;
  239. }
  240. }
  241. }
  242. }
  243. .footer {
  244. width: 100%;
  245. display: flex;
  246. align-items: center;
  247. padding: 0 20rpx;
  248. .share-code {
  249. width: 130rpx;
  250. height: 130rpx;
  251. }
  252. .share-btns {
  253. width: calc(100% - 130rpx);
  254. padding-left: 45rpx;
  255. color: #fff;
  256. .share-btn {
  257. width: 100%;
  258. height: 50rpx;
  259. background: linear-gradient(180deg, #faae3d, #f9d159);
  260. border-radius: 29rpx;
  261. text-align: center;
  262. line-height: 50rpx;
  263. font-size: 24rpx;
  264. font-family: PingFang SC, PingFang SC-Regular;
  265. font-weight: 400;
  266. }
  267. .share-btn-hint {
  268. padding-top: 22rpx;
  269. font-size: 24rpx;
  270. font-family: PingFang SC, PingFang SC-Regular;
  271. font-weight: 400;
  272. color: #ffffff;
  273. letter-spacing: 0.56rpx;
  274. }
  275. }
  276. }
  277. }
  278. }
  279. .share-footer {
  280. flex-shrink: 0;
  281. .share-list {
  282. border-radius: 40rpx 40rpx 0 0;
  283. width: 100%;
  284. padding: 30rpx 30rpx;
  285. display: flex;
  286. justify-content: space-between;
  287. align-items: stretch;
  288. background-color: #f6f7fc;
  289. }
  290. .share-icons {
  291. display: flex;
  292. flex-direction: column;
  293. justify-content: center;
  294. align-items: center;
  295. .share-icon {
  296. font-size: 100rpx;
  297. color: red;
  298. }
  299. .share-text {
  300. font-size: 24rpx;
  301. padding-top: 10rpx;
  302. }
  303. }
  304. .share-cancel {
  305. width: 100%;
  306. height: 100rpx;
  307. line-height: 100rpx;
  308. background-color: #fff;
  309. text-align: center;
  310. font-size: 34rpx;
  311. color: #c0c0c0;
  312. }
  313. }
  314. // <view class="share-content"></view>
  315. // <view class="share-share"></view>
  316. }
  317. </style>