邃芒智像相册
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

184 rindas
4.2 KiB

  1. const app = getApp()
  2. import request from '../../utils/request'
  3. import { timestampToTime } from '../../utils/util'
  4. import Dialog from '@vant/weapp/dialog/dialog';
  5. Page({
  6. data: {
  7. isLogin: false,
  8. itemList: [1, 1, 1, 1, 1, 1],
  9. showPrivacy: false
  10. },
  11. // 事件处理函数
  12. clickPrivacy(e) {
  13. },
  14. closePrivacy() {
  15. wx.exitMiniProgram()
  16. },
  17. getPrivacySetting() {
  18. const canIUsePrivacy = wx.canIUse('getPrivacySetting')
  19. console.log(canIUsePrivacy, 'canIUse getPrivacySetting')
  20. if (canIUsePrivacy) {
  21. wx.getPrivacySetting({
  22. success: res => {
  23. console.log(res, 'getPrivacySetting') // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
  24. if (res.needAuthorization) {
  25. // 需要弹出隐私协议
  26. this.setData({
  27. showPrivacy: true
  28. })
  29. } else {
  30. // this.setData({
  31. // showPrivacy: true
  32. // })
  33. // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用已声明过的隐私接口
  34. // wx.getUserProfile()
  35. // wx.chooseMedia()
  36. // wx.getClipboardData()
  37. // wx.startRecord()
  38. // this.setData({
  39. // showPrivacy: true
  40. // })
  41. }
  42. },
  43. fail: () => { },
  44. complete: () => { }
  45. })
  46. }
  47. },
  48. handleAgreePrivacyAuthorization() {
  49. console.log('Privacy Agreed!');
  50. this.setData({
  51. showPrivacy: false
  52. })
  53. // 用户同意隐私协议事件回调
  54. // 用户点击了同意,之后所有已声明过的隐私接口和组件都可以调用了
  55. // wx.getUserProfile()
  56. // wx.chooseMedia()
  57. // wx.getClipboardData()
  58. // wx.startRecord()
  59. },
  60. handleOpenPrivacyContract() {
  61. // 打开隐私协议页面
  62. wx.openPrivacyContract({
  63. success: () => {
  64. // this.setData({
  65. // showPrivacy: false
  66. // })
  67. }, // 打开成功
  68. fail: () => { }, // 打开失败
  69. complete: () => { }
  70. })
  71. },
  72. onLoad(option) {
  73. wx.hideHomeButton()
  74. this.getPrivacySetting()
  75. },
  76. onShow() {
  77. const isLogin = wx.getStorageSync('token')
  78. this.setData({
  79. isLogin
  80. })
  81. app.tokenCallBack = res => {
  82. this.setData({
  83. isLogin: res
  84. })
  85. }
  86. },
  87. getUserProfile() {
  88. // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  89. wx.getUserProfile({
  90. desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  91. success: (res) => {
  92. console.log(res, 'getUserProfile')
  93. }
  94. })
  95. },
  96. getUserPhone(e) {
  97. const sessionKey = wx.getStorageSync('sessionKey')
  98. this.doGetUserPhone(e.detail.encryptedData, e.detail.iv, sessionKey, request.appId)
  99. },
  100. /** 获取手机号授权 */
  101. doGetUserPhone(encryptedData, iv, sessionKey, appId) {
  102. request.post({
  103. url: '/api/user/getUserPhone',
  104. data: {
  105. encryptedData,
  106. iv,
  107. sessionKey,
  108. appId
  109. }
  110. }).then(res => {
  111. console.log(res, 'getUserPhone');
  112. wx.showToast({
  113. title: '申请成功!',
  114. icon: 'success'
  115. })
  116. this.checkUserInfo()
  117. }).catch(err => {
  118. console.log(err, 'err');
  119. })
  120. },
  121. showMore() {
  122. Dialog.confirm({
  123. title: '删除作品',
  124. message: '确定要删除这个作品吗?',
  125. })
  126. .then(() => {
  127. // on confirm
  128. })
  129. .catch(() => {
  130. // on cancel
  131. });
  132. },
  133. goLogin() {
  134. wx.redirectTo({
  135. url: '/pages/login/login',
  136. })
  137. },
  138. goCheckImage(){
  139. },
  140. onShareAppMessage() {
  141. const promise = new Promise(resolve => {
  142. setTimeout(() => {
  143. resolve({
  144. title: '智像小相册'
  145. })
  146. }, 500)
  147. })
  148. return {
  149. title: '智像小相册',
  150. promise
  151. }
  152. },
  153. onShareTimeline() {
  154. const promise = new Promise(resolve => {
  155. setTimeout(() => {
  156. resolve({
  157. title: '智像小相册'
  158. })
  159. }, 500)
  160. })
  161. return {
  162. title: '智像小相册',
  163. promise
  164. }
  165. }
  166. })