sharePage.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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;">&#xe754;</text>
  39. <text class="share-text">复制链接</text>
  40. </view>
  41. <view class="share-icons">
  42. <text class="share-icon iconfont" style="color: #029a73;">&#xe654;</text>
  43. <text class="share-text">微信</text>
  44. </view>
  45. <view class="share-icons">
  46. <text class="share-icon iconfont" style="color: #02d9a2;">&#xe602;</text>
  47. <text class="share-text">朋友圈</text>
  48. </view>
  49. <view class="share-icons">
  50. <text class="share-icon iconfont" style="color: #1890ff;">&#xe887;</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">&#xe6b4;</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.$refs.popupRef.open()
  88. },
  89. methods: {
  90. openShare() {
  91. this.$nextTick(() => {
  92. this.showTabBar(false)
  93. this.$refs.popupRef.open()
  94. })
  95. },
  96. cancelShare() {
  97. this.$refs.popupRef.close()
  98. this.showTabBar()
  99. },
  100. showTabBar(type = true) {
  101. if (this.tabBar) {
  102. try {
  103. if (type) {
  104. uni.showTabBar();
  105. } else {
  106. uni.hideTabBar();
  107. }
  108. } catch {}
  109. }
  110. },
  111. saveBase64(imageStr) {
  112. uni.showLoading({
  113. title: "保存中"
  114. })
  115. try{
  116. let bitmap = new plus.nativeObj.Bitmap();
  117. bitmap.loadBase64Data(imageStr, function() {
  118. console.log('加载base64图片数据成功');
  119. //图片名称命名
  120. bitmap.save('_doc/' + new Date().getTime() + '.png', {
  121. quality: 100
  122. }, function(i) {
  123. // 将图片保存到相册
  124. uni.saveImageToPhotosAlbum({
  125. filePath: i.target,
  126. success: function() {
  127. bitmap.clear(); //销毁Bitmap图片
  128. // uni.$u.toast('保存图片成功')
  129. uni.showToast({
  130. title: '保存图片成功',
  131. duration: 2000
  132. });
  133. // that.noPhoto = true;
  134. }
  135. });
  136. }, function(e) {
  137. console.log('保存图片失败:' + JSON.stringify(e));
  138. });
  139. }, function(e) {
  140. console.log('截屏绘制图片失败:' + JSON.stringify(e));
  141. });
  142. }catch{
  143. uni.hideLoading()
  144. }
  145. },
  146. }
  147. }
  148. </script>
  149. <script module="my_js" lang="renderjs">
  150. import html2canvas from 'html2canvas';
  151. export default {
  152. data() {
  153. return {}
  154. },
  155. methods: {
  156. onclicks(event, ownerInstance) {
  157. html2canvas(document.getElementById('share-content'), {
  158. backgroundColor: '#fff',
  159. useCORS: true,
  160. taintTest: true,
  161. timeout: 2000
  162. }).then(canvas => {
  163. let imgurl = canvas.toDataURL('image/jpg');
  164. ownerInstance.callMethod('saveBase64', imgurl)
  165. })
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .share-box {
  172. width: 750rpx;
  173. height: 100vh;
  174. display: flex;
  175. flex-direction: column;
  176. .share-status-bar {
  177. flex-shrink: 0;
  178. width: 100%;
  179. background-color: rgba(255, 255, 255, 0.5);
  180. }
  181. .share-content {
  182. flex: 1;
  183. padding: 30rpx 40rpx;
  184. .content {
  185. flex-shrink: 0;
  186. width: 100%;
  187. height: 100%;
  188. background: url("@/static/share/img_01.png") no-repeat center center;
  189. background-size: 100% 100%;
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: space-between;
  193. padding: 30rpx 30rpx 20rpx;
  194. .share-top {
  195. display: flex;
  196. flex-direction: column;
  197. align-items: flex-start;
  198. .share-logo {
  199. display: inline-block;
  200. width: 322rpx;
  201. height: 80rpx;
  202. // margin-bottom: 14rpx;
  203. }
  204. .share-title {
  205. font-size: 56rpx;
  206. font-family: PingFang SC, PingFang SC-Bold;
  207. font-weight: 700;
  208. color: #ffffff;
  209. line-height: 1.1;
  210. letter-spacing: 1.2px;
  211. }
  212. .share-list {
  213. width: 100%;
  214. padding-top: 20rpx;
  215. display: flex;
  216. flex-direction: column;
  217. .share-list-item {
  218. font-size: 20rpx;
  219. font-family: PingFang SC, PingFang SC-Regular;
  220. font-weight: 400;
  221. color: #ffffff;
  222. line-height: 1.5;
  223. // transform: scale(0.8);
  224. display: flex;
  225. align-items: center;
  226. justify-content: flex-start;
  227. .item-icon {
  228. display: inline-block;
  229. width: 14rpx;
  230. height: 14rpx;
  231. border-radius: 50%;
  232. background-color: #fff;
  233. }
  234. .item-text {
  235. padding-left: 3px;
  236. }
  237. }
  238. }
  239. }
  240. .footer {
  241. width: 100%;
  242. display: flex;
  243. align-items: center;
  244. padding: 0 20rpx;
  245. .share-code {
  246. width: 130rpx;
  247. height: 130rpx;
  248. }
  249. .share-btns {
  250. width: calc(100% - 130rpx);
  251. padding-left: 45rpx;
  252. color: #fff;
  253. .share-btn {
  254. width: 100%;
  255. height: 50rpx;
  256. background: linear-gradient(180deg, #faae3d, #f9d159);
  257. border-radius: 29rpx;
  258. text-align: center;
  259. line-height: 50rpx;
  260. font-size: 24rpx;
  261. font-family: PingFang SC, PingFang SC-Regular;
  262. font-weight: 400;
  263. }
  264. .share-btn-hint {
  265. padding-top: 22rpx;
  266. font-size: 24rpx;
  267. font-family: PingFang SC, PingFang SC-Regular;
  268. font-weight: 400;
  269. color: #ffffff;
  270. letter-spacing: 0.56rpx;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. .share-footer {
  277. flex-shrink: 0;
  278. .share-list {
  279. border-radius: 40rpx 40rpx 0 0;
  280. width: 100%;
  281. padding: 30rpx 30rpx;
  282. display: flex;
  283. justify-content: space-between;
  284. align-items: stretch;
  285. background-color: #f6f7fc;
  286. }
  287. .share-icons {
  288. display: flex;
  289. flex-direction: column;
  290. justify-content: center;
  291. align-items: center;
  292. .share-icon {
  293. font-size: 100rpx;
  294. color: red;
  295. }
  296. .share-text {
  297. font-size: 24rpx;
  298. padding-top: 10rpx;
  299. }
  300. }
  301. .share-cancel {
  302. width: 100%;
  303. height: 100rpx;
  304. line-height: 100rpx;
  305. background-color: #fff;
  306. text-align: center;
  307. font-size: 34rpx;
  308. color: #c0c0c0;
  309. }
  310. }
  311. // <view class="share-content"></view>
  312. // <view class="share-share"></view>
  313. }
  314. </style>