123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- // pages/editMyself/editMyself.js
- const app = getApp()
- const util = require("../../utils/util")
- const urlDef = require("../../utils/urls")
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- index: 0,
- array:['未知','男','女'],
- name: '',
- src: ''
- },
- changeHead: function () {
- const that = this
- const urls = urlDef.urls;
- wx.chooseImage({
- count: 6,
- sourceType: ['album', 'camera'],
- success(res) {
- wx.showLoading({
- title: '上传中...',
- })
- for (var i in res.tempFilePaths) {
- wx.uploadFile({
- filePath: res.tempFilePaths[i],
- name: 'name',
- url: urls.file_upload,
- header: util.getHeaders(),
- success(res) {
- wx.showToast({
- title: '上传成功',
- })
- const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
- that.setData({
- src: rs.data[0].url
- })
- },
- fail(res) {
- wx.showToast({
- title: '上传失败',
- icon: none
- })
- },
- complete(res) {
- wx.hideLoading({
- success: (res) => { },
- })
- }
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- const sex = wx.getStorageSync('student').sex.substring(29,wx.getStorageSync('student').sex.length)
- let index = 0
- if( sex == 'bf7'){
- index = 0
- } else if( sex == 'fbc' ){
- index = 1
- } else if( sex == '098' ){
- index =2
- }
- this.setData({
- index,
- name: wx.getStorageSync('student').name,
- src: wx.getStorageSync('student').headImg
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|