my.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // pages/my/my.js
  2. import {
  3. createStoreBindings
  4. } from "mobx-miniprogram-bindings"
  5. import {
  6. store
  7. } from "../../store/index"
  8. import Dialog from '@vant/weapp/dialog/dialog';
  9. Page({
  10. /**
  11. * 页面的初始数据
  12. */
  13. data: {
  14. // 显示学管
  15. activeCustomer: false
  16. },
  17. closeLogin() {
  18. // 清除缓存,清空数据,返回首页
  19. },
  20. showCustomer() {
  21. this.setData({
  22. activeCustomer: !this.data.activeCustomer
  23. })
  24. },
  25. // 关闭dialog
  26. onClose() {
  27. this.setData({
  28. activeCustomer: false
  29. });
  30. },
  31. // 拨打电话
  32. onPhone() {
  33. wx.makePhoneCall({
  34. phoneNumber: '1340000' //仅为示例,并非真实的电话号码
  35. })
  36. },
  37. /**
  38. * 生命周期函数--监听页面加载
  39. */
  40. onLoad(options) {
  41. this.storeBindings = createStoreBindings(this, {
  42. store,
  43. fields: ["userInfo"],
  44. actions: {
  45. upDateActive: "upDateActive",
  46. setUser: "setUserInfo"
  47. }
  48. })
  49. if (wx.getStorageSync('userInfo')) {
  50. this.setUser(wx.getStorageSync('userInfo'))
  51. }
  52. },
  53. upload() {
  54. wx.chooseMedia({
  55. count: 1,
  56. mediaType: ['image'],
  57. sourceType: ['album', 'camera'],
  58. camera: 'back',
  59. success(res) {
  60. console.log(res.tempFiles[0].tempFilePath)
  61. console.log(res)
  62. wx.uploadFile({
  63. filePath: res.tempFiles[0].tempFilePath,
  64. name: 'file',
  65. url: 'http://purchase.platomix.net/prod-api/app-api/tutor/h5/upload',
  66. formData: {
  67. id: 1
  68. },
  69. success: (res) => {
  70. console.log(res, "data")
  71. }
  72. })
  73. }
  74. })
  75. },
  76. closeSign() {
  77. Dialog.confirm({
  78. title: '退出登录',
  79. message: '确认退出当前账号吗?',
  80. })
  81. .then(() => {
  82. wx.removeStorageSync('userInfo')
  83. this.upDateActive(0)
  84. this.setUser({})
  85. wx.reLaunch({
  86. url: "/pages/newIndex/newIndex"
  87. })
  88. // on confirm
  89. })
  90. .catch(() => {
  91. // on cancel
  92. });
  93. },
  94. /**
  95. * 生命周期函数--监听页面初次渲染完成
  96. */
  97. onReady() {
  98. },
  99. /**
  100. * 生命周期函数--监听页面显示
  101. */
  102. onShow() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面卸载
  111. */
  112. onUnload() {
  113. },
  114. /**
  115. * 页面相关事件处理函数--监听用户下拉动作
  116. */
  117. onPullDownRefresh() {
  118. },
  119. /**
  120. * 页面上拉触底事件的处理函数
  121. */
  122. onReachBottom() {
  123. },
  124. /**
  125. * 用户点击右上角分享
  126. */
  127. onShareAppMessage() {
  128. }
  129. })