index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {
  2. createStoreBindings
  3. } from 'mobx-miniprogram-bindings'
  4. import {
  5. store
  6. } from '~/store/index'
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. victory: {},
  13. defeated: {},
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad(options) {
  19. this.storeBindings = createStoreBindings(this, {
  20. store,
  21. fields: {
  22. userInfo: 'userInfo',
  23. readDetail: 'readDetail',
  24. pkData: 'pkData'
  25. },
  26. })
  27. this.storeBindings.updateStoreBindings()
  28. this.compareScore()
  29. },
  30. compareScore() {
  31. let pkData = {
  32. audioPath: "https://reader-wx.ai160.com/reader/resource/20221222/1671682237419428.mp3",
  33. avatar: "wxfile://,tmp_ba795553cc21cd941badc3ce06597c245f08fd6a674fe165.jpg",
  34. nickName: "小舞",
  35. score: 96,
  36. }
  37. let score = pkData.score
  38. let myResult = {
  39. audioPath: this.data.readDetail.tempFilePath,
  40. nickName: this.data.userInfo.nickName || this.data.userInfo.uid,
  41. avatar: this.data.userInfo.avatar,
  42. score: this.data.readDetail.myOverall || 100
  43. }
  44. this.setData({
  45. victory: myResult.score > score ? myResult : pkData,
  46. defeated: myResult.score < score ? myResult : pkData,
  47. })
  48. },
  49. result() {
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide() {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload() {
  60. },
  61. /**
  62. * 页面相关事件处理函数--监听用户下拉动作
  63. */
  64. onPullDownRefresh() {
  65. },
  66. /**
  67. * 页面上拉触底事件的处理函数
  68. */
  69. onReachBottom() {
  70. },
  71. /**
  72. * 用户点击右上角分享
  73. */
  74. onShareAppMessage() {
  75. }
  76. })