邃芒智像相册
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

165 строки
3.9 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: true,
  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. this.getPrivacySetting()
  74. },
  75. onShow() {
  76. },
  77. getUserProfile() {
  78. // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  79. wx.getUserProfile({
  80. desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  81. success: (res) => {
  82. console.log(res, 'getUserProfile')
  83. }
  84. })
  85. },
  86. getUserPhone(e) {
  87. const sessionKey = wx.getStorageSync('sessionKey')
  88. this.doGetUserPhone(e.detail.encryptedData, e.detail.iv, sessionKey, request.appId)
  89. },
  90. /** 获取手机号授权 */
  91. doGetUserPhone(encryptedData, iv, sessionKey, appId) {
  92. request.post({
  93. url: '/api/user/getUserPhone',
  94. data: {
  95. encryptedData,
  96. iv,
  97. sessionKey,
  98. appId
  99. }
  100. }).then(res => {
  101. console.log(res, 'getUserPhone');
  102. wx.showToast({
  103. title: '申请成功!',
  104. icon: 'success'
  105. })
  106. this.checkUserInfo()
  107. }).catch(err => {
  108. console.log(err, 'err');
  109. })
  110. },
  111. showMore() {
  112. Dialog.confirm({
  113. title: '删除作品',
  114. message: '确定要删除这个作品吗?',
  115. })
  116. .then(() => {
  117. // on confirm
  118. })
  119. .catch(() => {
  120. // on cancel
  121. });
  122. },
  123. onShareAppMessage() {
  124. const promise = new Promise(resolve => {
  125. setTimeout(() => {
  126. resolve({
  127. title: '智像小相册'
  128. })
  129. }, 500)
  130. })
  131. return {
  132. title: '智像小相册',
  133. promise
  134. }
  135. },
  136. onShareTimeline() {
  137. const promise = new Promise(resolve => {
  138. setTimeout(() => {
  139. resolve({
  140. title: '智像小相册'
  141. })
  142. }, 500)
  143. })
  144. return {
  145. title: '智像小相册',
  146. promise
  147. }
  148. }
  149. })