大数据平台的小程序版本

mine.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // pages/mine/mine.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. isIpx: app.data.systemInfo.isIpx ? true : false, //底部按钮适配Iphone X
  9. safeAreaTop: '',
  10. userInfo: {},
  11. writePhotosFlag:-1,
  12. qunFlag:false
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. this.init()
  19. this.setData({
  20. safeAreaTop:30+app.data.safeAreaTop,
  21. userInfo: wx.getStorageSync('userInfo')
  22. })
  23. },
  24. onShow: function(){
  25. this.init()
  26. },
  27. init(){
  28. var _this = this;
  29. wx.getSetting({
  30. success(res) {
  31. if(res.authSetting['scope.writePhotosAlbum'] == false){
  32. _this.setData({writePhotosFlag:false})
  33. }
  34. if(res.authSetting['scope.writePhotosAlbum'] == true){
  35. _this.setData({writePhotosFlag:true})
  36. }
  37. }
  38. })
  39. },
  40. /**
  41. * 生命周期函数--监听页面初次渲染完成
  42. */
  43. onReady: function () {
  44. },
  45. cancelTask(){
  46. this.setData({qunFlag:false})
  47. },
  48. copyEvent(){
  49. wx.setClipboardData({
  50. data: 'https://sph.wenxingshuju.com',
  51. success: function (res) {
  52. wx.getClipboardData({
  53. success: function (res) {
  54. wx.showToast({
  55. title: '复制成功'
  56. })
  57. }
  58. })
  59. }
  60. })
  61. },
  62. toUrl(e) {
  63. if(e.currentTarget.dataset.path.indexOf('allNotice')!=-1) {
  64. wx.navigateTo({
  65. url: '/pages/newNotice/allNotice/allNotice'
  66. })
  67. }else {
  68. wx.navigateTo({
  69. url: e.currentTarget.dataset.path
  70. })
  71. }
  72. },
  73. goPageClaim(){
  74. wx.navigateTo({
  75. url: '/pages/claim/index/index',
  76. })
  77. },
  78. qunEvent(){
  79. this.setData({qunFlag:true})
  80. },
  81. downLoadImgEvent(){
  82. if(!this.data.writePhotosFlag){
  83. wx.openSetting()
  84. return
  85. }
  86. var _this = this;
  87. wx.getSetting({
  88. success(res) {
  89. if (!res.authSetting['scope.writePhotosAlbum']) {
  90. wx.authorize({
  91. scope:'scope.writePhotosAlbum',
  92. success() {//授权成功
  93. _this.setData({writePhotosFlag:true})
  94. _this.downloadImg()
  95. },
  96. fail:function(err){
  97. _this.setData({writePhotosFlag:false})
  98. },
  99. })
  100. }else{//已经授权
  101. _this.setData({writePhotosFlag:true})
  102. _this.downloadImg()
  103. }
  104. }
  105. })
  106. },
  107. downloadImg(){
  108. var imgSrc = "https://www.wenxingshuju.com/kol_wx_qun_evm.jpg"
  109. wx.downloadFile({
  110. url: imgSrc,
  111. success: function (res) {
  112. wx.saveImageToPhotosAlbum({
  113. filePath: res.tempFilePath,
  114. success: function (data) {
  115. wx.showToast({
  116. title: '保存成功',
  117. icon: 'success',
  118. duration: 2000
  119. })
  120. },
  121. fail: function (err) {
  122. },
  123. complete(res){
  124. }
  125. })
  126. }
  127. })
  128. },
  129. goExtension(){
  130. wx.navigateTo({
  131. url: "/pages/extension/list/index",
  132. })
  133. },
  134. goWebView(){
  135. wx.navigateTo({
  136. url: '/pages/webView/index',
  137. })
  138. },
  139. onShareAppMessage(res){
  140. return app.shareEvent(res)
  141. }
  142. })