me.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // pages/me/me.js
  2. Page({
  3. data: {
  4. // role: "teacher",
  5. userInfo: {
  6. avatar: '../../image/imgs/avatar.jpg',
  7. name: '',
  8. role: '',
  9. phone: ''
  10. },
  11. // orderStatus: [
  12. // { text: '全部订单', type: 1 },
  13. // { text: '待付款', type: 2 },
  14. // { text: '待收货', type: 3 },
  15. // { text: '已完成', type: 4 }
  16. // ],
  17. historyItems: [
  18. {
  19. id: 1,
  20. thumbnail: '../../image/imgs/item1.jpg',
  21. name: '趣味识字卡片',
  22. date: '2023-10-15 14:30'
  23. },
  24. {
  25. id: 2,
  26. thumbnail: '../../image/imgs/item2.jpg',
  27. name: '趣味识字卡片',
  28. date: '2023-10-15 14:30'
  29. },
  30. // 更多历史记录...
  31. ],
  32. xiugaiimg: '',
  33. xiangjiimg: '',
  34. xiazi: '',
  35. souchangs: '',
  36. },
  37. onLoad(options) {
  38. this.getUserInfo();
  39. const fileIDs = [
  40. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiugai.png',
  41. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiangji.png',
  42. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiazi.png',
  43. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/soucangs.png'
  44. ];
  45. // 并发下载多个 fileID
  46. Promise.all(
  47. fileIDs.map(fileID => wx.cloud.downloadFile({ fileID }))
  48. ).then(results => {
  49. // 每个 result 对应一个下载结果
  50. const tempFilePaths = results.map(r => r.tempFilePath);
  51. console.log('全部下载成功:', tempFilePaths);
  52. this.setData({
  53. xiugaiimg: tempFilePaths[0],
  54. xiangjiimg: tempFilePaths[1],
  55. xiazi: tempFilePaths[2],
  56. souchangs: tempFilePaths[3],
  57. });
  58. }).catch(err => {
  59. console.error('有文件下载失败:', err);
  60. });
  61. },
  62. getUserInfo() {
  63. // 模拟获取用户信息的逻辑
  64. const userInfo = {
  65. avatar: '../../image/imgs/avatar.jpg',
  66. name: '琳老师',
  67. role: '老师',
  68. phone: '131****9345'
  69. };
  70. this.setData({ userInfo });
  71. },
  72. handleLogout() {
  73. wx.navigateTo({
  74. url: `/subpackages/logoff/logoff`
  75. });
  76. // 处理用户注销的逻辑
  77. // wx.showModal({
  78. // title: '提示',
  79. // content: '确定要注销吗?',
  80. // success: (res) => {
  81. // if (res.confirm) {
  82. // // 注销成功后的处理逻辑
  83. // wx.showToast({
  84. // title: '已注销',
  85. // icon: 'success'
  86. // });
  87. // }
  88. // }
  89. // });
  90. },
  91. // 跳转
  92. goToGoodsList(e) {
  93. const type = e.currentTarget.dataset.type;
  94. wx.navigateTo({
  95. url: `/subpackages/order/order?type=${type}`
  96. });
  97. },
  98. goToGoodsLists() {
  99. wx.navigateTo({
  100. url: `/subpackages/changename/changename`
  101. });
  102. }
  103. });