123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- const app = getApp()
- const host = app.globalData.host;
- Page({
-
- data: {
- sexArray: ["女","男"],
- recordArray: ["小学", "初中", "高中", "大专", "本科", "硕士", "博士"],
- sex: 0,
- record: 0,
- show: false,
- data:{
- }
- },
-
- 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
- })
- if (e.target.dataset.name == 0) {
- }
- },
- 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 () {
- }
- })
|