share_img.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="page">
  3. <view class="topBody">
  4. <view class="header">
  5. </view>
  6. <view class="myinfo">
  7. <image class="img" :src="myinfo.share_img0" mode="widthFix"></image>
  8. <view style="margin-top: 24rpx;" class="numlist">
  9. <view class="num" @click="shareImg">
  10. <view class="img2">
  11. <image src="../../static/icon/share_wx.png" mode="widthFix"></image>
  12. </view>
  13. <view class="name">分享</view>
  14. </view>
  15. <view class="num" @click="saveImg">
  16. <view class="img2">
  17. <image src="../../static/icon/share_down.png" mode="widthFix"></image>
  18. </view>
  19. <view class="name">保存</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="blankHeight"></view>
  24. </view>
  25. <DialogBox ref="DialogBox"></DialogBox>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. components: {},
  31. data() {
  32. return {
  33. title: '',
  34. sel: 1,
  35. nodata: true,
  36. myinfo: {},
  37. list: [],
  38. }
  39. },
  40. onLoad() {
  41. // setTimeout(function() {
  42. // uni.setNavigationBarColor({
  43. // frontColor: '#ffffff',
  44. // backgroundColor: '#00000000',
  45. // animation: {
  46. // duration: 400,
  47. // timingFunc: 'easeIn'
  48. // }
  49. // })
  50. // }, 200);
  51. this.loadInfo();
  52. },
  53. onShow() {},
  54. methods: {
  55. onBack() {},
  56. chkSel() {
  57. if (this.sel == 1) {
  58. this.sel = 0;
  59. } else {
  60. this.sel = 1;
  61. }
  62. },
  63. loadInfo() {
  64. console.log({
  65. uuid: getApp().globalData.uuid,
  66. skey: getApp().globalData.skey
  67. });
  68. uni.request({
  69. url: this.$apiHost + '/Web/getinfo',
  70. data: {
  71. uuid: getApp().globalData.uuid,
  72. type: 'tuan'
  73. },
  74. header: {
  75. "content-type": "application/json",
  76. 'sign': getApp().globalData.headerSign
  77. },
  78. success: (res) => {
  79. console.log("----:", res.data);
  80. this.myinfo = res.data;
  81. },
  82. complete: (com) => {
  83. // uni.hideLoading();
  84. },
  85. fail: (e) => {
  86. console.log("----e:", e);
  87. }
  88. });
  89. },
  90. shareImg() {
  91. let that = this;
  92. uni.share({
  93. provider: "weixin",
  94. scene: "WXSceneSession",
  95. type: 2,
  96. imageUrl: that.myinfo.share_img0,
  97. success: function(res) {
  98. console.log("success:" + JSON.stringify(res));
  99. },
  100. fail: function(err) {
  101. console.log("fail:" + JSON.stringify(err));
  102. }
  103. });
  104. },
  105. saveImg() {
  106. // #ifdef APP-PLUS
  107. let that = this;
  108. uni.showLoading({
  109. title: '正在保存...',
  110. })
  111. uni.downloadFile({
  112. url: that.myinfo.share_img0,
  113. success: (res) => {
  114. if (res.statusCode === 200) {
  115. uni.saveImageToPhotosAlbum({
  116. filePath: res.tempFilePath,
  117. success: function() {
  118. uni.showToast({
  119. title: '已保存到相册'
  120. });
  121. },
  122. fail: function(e) {
  123. uni.showToast({
  124. icon: 'none',
  125. title: '保存到相册失败'
  126. });
  127. },
  128. complete: function() {
  129. uni.hideLoading()
  130. }
  131. });
  132. } else {
  133. uni.showToast({
  134. icon: 'none',
  135. title: '邀请码下载失败'
  136. })
  137. uni.hideLoading()
  138. }
  139. },
  140. fail: function() {
  141. uni.showToast({
  142. icon: 'none',
  143. title: '邀请码下载错误'
  144. })
  145. },
  146. complete() {
  147. uni.hideLoading()
  148. }
  149. })
  150. // #endif
  151. }
  152. }
  153. }
  154. </script>
  155. <style scoped lang="scss">
  156. @import 'share_img.scss';
  157. </style>