index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Page({
  2. data: {
  3. appIcon: 'https://testchu-7gy8occc8dcc14c3-1304825656.tcloudbaseapp.com/platform-console/assets/favicon.svg',
  4. appName: 'Donut 多端应用',
  5. checkedAgree: false,
  6. loginSuccess: false, // 标记是否登录成功
  7. },
  8. /**
  9. * 退出页面时触发基础库回调,由基础库内部处理系统登录态。
  10. */
  11. onUnload() {
  12. const eventChannel = this.getOpenerEventChannel();
  13. if (eventChannel) {
  14. eventChannel.emit('__donutLogin__', { success: this.data.loginSuccess });
  15. }
  16. },
  17. /**
  18. * 触发小程序登录,登录成功后自动退出页面
  19. */
  20. onTapWeixinMiniProgramLogin() {
  21. wx.weixinMiniProgramLogin({
  22. success: () => {
  23. this.setData({ loginSuccess: true });
  24. wx.navigateBack();
  25. },
  26. fail: () => {
  27. wx.showToast({
  28. title: '小程序登录失败',
  29. icon: 'none'
  30. });
  31. }
  32. })
  33. },
  34. onCheckboxChange() {
  35. this.setData({ checkedAgree: !this.data.checkedAgree });
  36. },
  37. /**
  38. *
  39. * 使用单独的 webview 页面展示用户协议
  40. */
  41. onShowAgreement(e) {
  42. const urls = [
  43. 'link1',
  44. 'link2'
  45. ];
  46. const url = urls[e.target.dataset.idx];
  47. // wx.navigateTo({
  48. // url: `/pages/webview/index?url=${url}`,
  49. // });
  50. },
  51. })