share_img.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="page">
  3. <uni-nav-bar rightWidth='136rpx' title="邀请战队成员" fixed :border="false" statusBar backgroundColor="#24234B"
  4. color="#FFFFFF">
  5. <template #left>
  6. <view class="cl-topbar__icon" @click="navigateBack">
  7. <text class="cl-icon-arrow-left"></text>
  8. </view>
  9. </template>
  10. </uni-nav-bar>
  11. <view class="topBody">
  12. <image class="img" :src="myinfo.share_img" mode="aspectFill"></image>
  13. <view class="numlist">
  14. <view class="num" @click="sharePyq">
  15. <image src="http://c.yujianmate.com/images/v1/w3/share_pyq.png" mode="widthFix"></image>
  16. <view class="name">朋友圈</view>
  17. </view>
  18. <view class="num" @click="shareWx">
  19. <image src="http://c.yujianmate.com/images/v1/w3/share_wx.png" mode="widthFix"></image>
  20. <view class="name">微信好友</view>
  21. </view>
  22. <view class="num" @click="saveImg">
  23. <image src="http://c.yujianmate.com/images/v1/w3/share_down.png" mode="widthFix"></image>
  24. <view class="name">下载</view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 提示框 -->
  29. <DialogBox ref="DialogBox"></DialogBox>
  30. </view>
  31. </template>
  32. <script>
  33. import uniNavBar from '../../components/uni-ui/uni-nav-bar/uni-nav-bar.vue'
  34. export default {
  35. components: {
  36. uniNavBar
  37. },
  38. data() {
  39. return {
  40. title: '',
  41. sel: 1,
  42. nodata: true,
  43. myinfo: {},
  44. list: [],
  45. }
  46. },
  47. onLoad() {
  48. // setTimeout(function() {
  49. // uni.setNavigationBarColor({
  50. // frontColor: '#ffffff',
  51. // backgroundColor: '#00000000',
  52. // animation: {
  53. // duration: 400,
  54. // timingFunc: 'easeIn'
  55. // }
  56. // })
  57. // }, 200);
  58. this.loadInfo();
  59. },
  60. onShow() {},
  61. methods: {
  62. navigateBack() {
  63. uni.navigateBack(1)
  64. },
  65. onBack() {},
  66. chkSel() {
  67. if (this.sel == 1) {
  68. this.sel = 0;
  69. } else {
  70. this.sel = 1;
  71. }
  72. },
  73. loadInfo() {
  74. console.log({
  75. uuid: getApp().globalData.uuid,
  76. skey: getApp().globalData.skey
  77. });
  78. uni.request({
  79. url: this.$apiHost + '/Web/getinfo',
  80. data: {
  81. uuid: getApp().globalData.uuid,
  82. type: 'tuan'
  83. },
  84. header: {
  85. "content-type": "application/json",
  86. 'sign': getApp().globalData.headerSign
  87. },
  88. success: (res) => {
  89. console.log("----:", res.data);
  90. this.myinfo = res.data;
  91. },
  92. complete: (com) => {
  93. // uni.hideLoading();
  94. },
  95. fail: (e) => {
  96. console.log("----e:", e);
  97. }
  98. });
  99. },
  100. sharePyq() {
  101. let that = this;
  102. uni.share({
  103. provider: "weixin",
  104. scene: "WXSceneTimeline",
  105. type: 2,
  106. imageUrl: that.myinfo.share_img,
  107. success: function(res) {
  108. console.log("success:" + JSON.stringify(res));
  109. },
  110. fail: function(err) {
  111. console.log("fail:" + JSON.stringify(err));
  112. }
  113. });
  114. },
  115. shareWx() {
  116. let that = this;
  117. uni.share({
  118. provider: "weixin",
  119. scene: "WXSceneSession",
  120. type: 2,
  121. imageUrl: that.myinfo.share_img,
  122. success: function(res) {
  123. console.log("success:" + JSON.stringify(res));
  124. },
  125. fail: function(err) {
  126. console.log("fail:" + JSON.stringify(err));
  127. }
  128. });
  129. },
  130. saveImg() {
  131. // #ifdef APP-PLUS
  132. let that = this;
  133. uni.showLoading({
  134. title: '正在保存...',
  135. })
  136. uni.downloadFile({
  137. url: that.myinfo.share_img,
  138. success: (res) => {
  139. if (res.statusCode === 200) {
  140. uni.saveImageToPhotosAlbum({
  141. filePath: res.tempFilePath,
  142. success: function() {
  143. uni.showToast({
  144. title: '已保存到相册'
  145. });
  146. },
  147. fail: function(e) {
  148. uni.showToast({
  149. icon: 'none',
  150. title: '保存到相册失败'
  151. });
  152. },
  153. complete: function() {
  154. uni.hideLoading()
  155. }
  156. });
  157. } else {
  158. uni.showToast({
  159. icon: 'none',
  160. title: '邀请码下载失败'
  161. })
  162. uni.hideLoading()
  163. }
  164. },
  165. fail: function() {
  166. uni.showToast({
  167. icon: 'none',
  168. title: '邀请码下载错误'
  169. })
  170. },
  171. complete() {
  172. uni.hideLoading()
  173. }
  174. })
  175. // #endif
  176. }
  177. }
  178. }
  179. </script>
  180. <style scoped lang="scss">
  181. @import 'share_img.scss';
  182. </style>