index.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // pages/home/index.ts
  2. const app = getApp<IAppOption>();
  3. import { compareVersion } from "../../utils/util";
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. pageBGIMG: "",
  10. btnBGIMG: "",
  11. btnText: "登记/查询选手信息",
  12. isliveText: ""
  13. },
  14. lvru() {
  15. app.getUser({
  16. noloading: true,
  17. data: {},
  18. success: (res: any) => {
  19. // if (this.data.isliveText) {
  20. if (this.data.isliveText && (!res.SAVE_USER_INFO || !res.UPLOAD_FACE)) {
  21. // 停止录脸操作
  22. wx.showToast({
  23. icon: "none",
  24. title: this.data.isliveText
  25. })
  26. return
  27. }
  28. if (!res.SAVE_USER_INFO) {
  29. // 未上传用户信息,跳转用户信息页
  30. wx.navigateTo({
  31. url: "/pages/entry/index"
  32. })
  33. return;
  34. }
  35. if (!res.UPLOAD_FACE) {
  36. // 未上传人脸信息,跳转人脸采集页
  37. let url = "/pages/faceRecognition/index";
  38. const version: string = app.globalData.SystemInfo?.SDKVersion || "";
  39. if (compareVersion(version, "2.25.0") !== -1) url = "/pages/faceRecognitionVK/index";
  40. wx.navigateTo({ url })
  41. return;
  42. }
  43. wx.navigateTo({
  44. url: "/pages/downloadPage/index"
  45. })
  46. }
  47. })
  48. },
  49. inited(res: any) {
  50. const { homePage: { BGIMG, btnBGIMG }, config: { isliveText } } = res;
  51. this.setData({
  52. pageBGIMG: BGIMG + "?" + Date.now(),
  53. btnBGIMG: btnBGIMG + "?" + Date.now(),
  54. isliveText
  55. })
  56. },
  57. /**
  58. * 生命周期函数--监听页面加载
  59. */
  60. onLoad() {
  61. app.getPageInfo({
  62. success: (res: any) => {
  63. const configPage = res || {};
  64. this.inited(configPage);
  65. }
  66. })
  67. },
  68. /**
  69. * 生命周期函数--监听页面初次渲染完成
  70. */
  71. onReady() { },
  72. /**
  73. * 生命周期函数--监听页面显示
  74. */
  75. onShow() {
  76. // 获取用户信息
  77. // app.getUser({
  78. // data: {},
  79. // success: (res: any) => {
  80. // if (!res) return;
  81. // if (res.UPLOAD_FACE && res.SAVE_USER_INFO) {
  82. // // 已经录过脸并且用户信息已经上传,跳转视频下载页
  83. // // this.setData({
  84. // // btnText: "进入下载页"
  85. // // })
  86. // return wx.reLaunch({
  87. // url: "/pages/downloadPage/index"
  88. // })
  89. // }
  90. // },
  91. // complete: () => {
  92. // app.globalData.getUserLoad = false;
  93. // }
  94. // })
  95. },
  96. /**
  97. * 生命周期函数--监听页面隐藏
  98. */
  99. onHide() { },
  100. /**
  101. * 生命周期函数--监听页面卸载
  102. */
  103. onUnload() { },
  104. /**
  105. * 页面相关事件处理函数--监听用户下拉动作
  106. */
  107. onPullDownRefresh() { },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom() { },
  112. /**
  113. * 用户点击右上角分享
  114. */
  115. onShareAppMessage() { }
  116. })
  117. export { }