邃芒智像相册
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

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