userchange.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // pages/userchange/userchange.js
  2. const {upLoad} = require('../../utils/util');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imageUrl:''
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad(options) {
  14. },
  15. /**
  16. * 生命周期函数--监听页面初次渲染完成
  17. */
  18. onReady() {
  19. },
  20. /**
  21. * 生命周期函数--监听页面显示
  22. */
  23. onShow() {
  24. },
  25. /**
  26. * 生命周期函数--监听页面隐藏
  27. */
  28. onHide() {
  29. },
  30. /**
  31. * 生命周期函数--监听页面卸载
  32. */
  33. onUnload() {
  34. },
  35. /**
  36. * 页面相关事件处理函数--监听用户下拉动作
  37. */
  38. onPullDownRefresh() {
  39. },
  40. /**
  41. * 页面上拉触底事件的处理函数
  42. */
  43. onReachBottom() {
  44. },
  45. /**
  46. * 用户点击右上角分享
  47. */
  48. onShareAppMessage() {
  49. },
  50. chooseImage() {
  51. wx.chooseImage({
  52. count: 1,//可选择图片数量
  53. sizeType: ['compressed'],//压缩图片
  54. sourceType: ['album','camera'],//来源
  55. success: (res) => {
  56. this.uploadImage(res.tempFilePaths[0]);
  57. }
  58. })
  59. },
  60. uploadImage(imagePath){
  61. upLoad( imagePath ).then((res) => {
  62. console.log(res);
  63. this.setData({
  64. imageUrl: res.Url
  65. });
  66. })
  67. },
  68. changeInfo:function(){
  69. }
  70. })