123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- // pages/user/user.js
- const app = getApp()
- const host = app.globalData.host;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- sexArray: ["女","男"], //性别
- recordArray: ["小学", "初中", "高中", "大专", "本科", "硕士", "博士"], //学历
- sex: 0,
- record: 0,
- show: false,
- data:{
- },
- img: ''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.request({
- url: host+'/api/wx/authinfo',
- header: {
- openid: app.globalData.openid
- },
- success:res=>{
- let edu = this.data.recordArray.indexOf(res.data.data.education)
- this.setData({
- data:res.data.data,
- sex:res.data.data.sex,
- record:edu
- })
- }
- })
- },
- inputChange:function(e){
- var data=this.data.data
- data[e.target.dataset.name] = e.detail.value
- console.log(data)
- this.setData({
- data: data
- })
- },
- pickerChange:function(e){
- if (e.target.dataset.name == 'sex') {
- this.setData({
- sex: e.detail.value
- })
- };
- if (e.target.dataset.name == 'record') {
- this.setData({
- record: e.detail.value
- })
- };
- },
- showImg: function (e) {
- this.setData({
- show: true,
- img: '../../images/zj' + e.target.dataset.id + '.jpg'
- })
- },
- hideImg: function (e) {
- this.setData({
- show: false
- })
- },
- takePhoto: function (e) {
- let id = e.target.dataset.id
- var _this = this
- wx.chooseImage({
- count: 1,
- success: function (res) {
- console.log(res.tempFilePaths[0])
- wx.showLoading({
- title: '正在上传',
- })
- wx.uploadFile({
- url: host + '/api/wx/uploadfile',
- filePath: res.tempFilePaths[0],
- name: 'file',
- formData: {
- 'file': res.tempFilePaths[0]
- },
- success: res => {
- wx.hideLoading()
- var data = JSON.parse(res.data)
- var _data = _this.data.data
- console.log(_data)
- if (id == 1) { //正面
- _data.idnoimg_face = data.data.url
- }
- if (id == 2) { //反面
- _data.idnoimg_back = data.data.url
- }
- if (id == 3) { //半身照
- _data.halfbody_img = data.data.url
- }
- if (id == 4) { //学历照
- _data.education_img = data.data.url
- }
- _this.setData({
- data:_data,
-
- })
- }
- })
- },
- })
- },
- post:function(){
- var data=this.data.data
- data.sex=this.data.sex
- data.education = this.data.recordArray[this.data.record]
- wx.showLoading({
- title: '',
- })
- wx.request({
- url: host + '/api/wx/authinfo',
- header: {
- openid: app.globalData.openid
- },
- method:'PUT',
- success: res => {
- wx.showToast({
- title: '提交成功',
- icon: 'success',
- duration: 2000
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|