editMyself.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // pages/editMyself/editMyself.js
  2. const app = getApp()
  3. const util = require("../../utils/util")
  4. const urlDef = require("../../utils/urls")
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. index: 0,
  11. array:['未知','男','女'],
  12. name: '',
  13. orgName: '',
  14. src: ''
  15. },
  16. changeHead: function () {
  17. const that = this
  18. const urls = urlDef.urls;
  19. wx.chooseImage({
  20. count: 6,
  21. sourceType: ['album', 'camera'],
  22. success(res) {
  23. wx.showLoading({
  24. title: '上传中...',
  25. })
  26. for (var i in res.tempFilePaths) {
  27. wx.uploadFile({
  28. filePath: res.tempFilePaths[i],
  29. name: 'name',
  30. url: urls.file_upload,
  31. header: util.getHeaders(),
  32. success(res) {
  33. wx.showToast({
  34. title: '上传成功',
  35. })
  36. const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
  37. that.setData({
  38. src: rs.data[0].url
  39. })
  40. },
  41. fail(res) {
  42. wx.showToast({
  43. title: '上传失败',
  44. icon: none
  45. })
  46. },
  47. complete(res) {
  48. wx.hideLoading({
  49. success: (res) => { },
  50. })
  51. }
  52. })
  53. }
  54. }
  55. })
  56. },
  57. /**
  58. * 生命周期函数--监听页面加载
  59. */
  60. onLoad: function (options) {
  61. const sex = wx.getStorageSync('student').sex.substring(29,wx.getStorageSync('student').sex.length)
  62. let index = 0
  63. if( sex == 'bf7'){
  64. index = 0
  65. } else if( sex == 'fbc' ){
  66. index = 1
  67. } else if( sex == '098' ){
  68. index =2
  69. }
  70. this.setData({
  71. index,
  72. name: wx.getStorageSync('student').name,
  73. src: wx.getStorageSync('student').headImg,
  74. orgName: wx.getStorageSync('student').orgName,
  75. })
  76. },
  77. /**
  78. * 生命周期函数--监听页面初次渲染完成
  79. */
  80. onReady: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面显示
  84. */
  85. onShow: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面隐藏
  89. */
  90. onHide: function () {
  91. },
  92. /**
  93. * 生命周期函数--监听页面卸载
  94. */
  95. onUnload: function () {
  96. },
  97. /**
  98. * 页面相关事件处理函数--监听用户下拉动作
  99. */
  100. onPullDownRefresh: function () {
  101. },
  102. /**
  103. * 页面上拉触底事件的处理函数
  104. */
  105. onReachBottom: function () {
  106. },
  107. /**
  108. * 用户点击右上角分享
  109. */
  110. onShareAppMessage: function () {
  111. }
  112. })