test.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // pages/aatest/test.js
  2. import { userUploadHeadImg } from '../../api/upload'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. headImg: '',
  9. nickname: ''
  10. },
  11. handleToast () {
  12. wx.showToast({
  13. title: '测试Toast',
  14. icon: 'success'
  15. }).then(res => {
  16. console.log('success t', res);
  17. })
  18. },
  19. submit () {
  20. console.log(this.data.headImg, this.data.nickname);
  21. },
  22. bindinputNickName (e) {
  23. console.log(e);
  24. },
  25. onChooseAvatar(e) {
  26. const { avatarUrl } = e.detail
  27. console.log(e);
  28. this.setData({
  29. headImg: avatarUrl
  30. })
  31. var data = {
  32. filePath: avatarUrl
  33. }
  34. wx.showLoading({
  35. title: '上传中...',
  36. mask: true
  37. })
  38. userUploadHeadImg(data).then(res => {
  39. wx.hideLoading()
  40. console.log(JSON.parse(res), 'userUploadHeadImg');
  41. }).catch(e => {
  42. wx.hideLoading()
  43. wx.showModal({
  44. content: e,
  45. confirmColor: '#333',
  46. showCancel: false
  47. })
  48. })
  49. },
  50. /**
  51. * 生命周期函数--监听页面加载
  52. */
  53. onLoad(options) {
  54. this.getSystemInfoSync()
  55. },
  56. getSystemInfoSync () {
  57. wx.getSystemInfo({
  58. success (res) {
  59. console.log(res.model)
  60. console.log(res.pixelRatio)
  61. console.log(res.windowWidth)
  62. console.log(res.windowHeight)
  63. console.log(res.language)
  64. console.log(res.version)
  65. console.log(res.platform)
  66. }
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面初次渲染完成
  71. */
  72. onReady() {
  73. },
  74. /**
  75. * 生命周期函数--监听页面显示
  76. */
  77. onShow() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面卸载
  86. */
  87. onUnload() {
  88. },
  89. /**
  90. * 页面相关事件处理函数--监听用户下拉动作
  91. */
  92. onPullDownRefresh() {
  93. },
  94. /**
  95. * 页面上拉触底事件的处理函数
  96. */
  97. onReachBottom() {
  98. },
  99. /**
  100. * 用户点击右上角分享
  101. */
  102. onShareAppMessage() {
  103. }
  104. })