123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- // pages/upload/upload.js
- const app = getApp()
- const host = app.globalData.host;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- show:false,
- idnoimg_face: "", //正面照
- idnoimg_back: "", //反面照
- halfbody_img: "", //半身照
- education_img: "", //学历照
- id:''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- id:JSON.parse(options.id),
- openid: app.globalData.openid
- })
- wx.request({
- url: host + '/api/wx/signup',
- method: 'GET',
- data: { id: options.id },
- success:res=>{
- this.setData({
- idnoimg_face: res.data.data.idnoimg_face, //正面照
- idnoimg_back: res.data.data.idnoimg_back, //反面照
- halfbody_img: res.data.data.halfbody_img, //半身照
- education_img: res.data.data.education_img, //学历照
- })
- }
- })
- },
- post:function(){
- var formData ={}
- formData.id=this.data.id
-
- formData.idnoimg_face = this.data.idnoimg_face
- formData.idnoimg_back = this.data.idnoimg_back
- formData.halfbody_img = this.data.halfbody_img
- formData.education_img = this.data.education_img
- if (formData.idnoimg_face == '') {
- wx.showToast({
- title: '正面照不存在!',
- icon: 'none',
- duration: 2000
- })
- return false
- }
- if (formData.idnoimg_back == '') {
- wx.showToast({
- title: '反面照不存在!',
- icon: 'none',
- duration: 2000
- })
- return false
- }
- if (formData.halfbody_img == '') {
- wx.showToast({
- title: '半身照不存在!',
- icon: 'none',
- duration: 2000
- })
- return false
- }
- if (formData.education_img == '') {
- wx.showToast({
- title: '学历照不存在!',
- icon: 'none',
- duration: 2000
- })
- return false
- }
- wx.request({
- url: host+'/api/wx/signup',
- method:'PUT',
- header: {
- openid: this.data.openid
- },
- data: formData,
- success:res=>{
- if(res.data.status == 'suc'){
- wx.showToast({
- title: '提交成功',
- icon: 'success',
- duration: 2000
- })
- setTimeout(function(){
- wx.switchTab({
- url: '../apply/apply',
- })
- },2000)
- }
- }
- })
- },
- 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.uploadFile({
- url: host+'/api/wx/uploadfile',
- filePath: res.tempFilePaths[0],
- name: 'file',
- formData: {
- 'file': res.tempFilePaths[0]
- },
- success:res=>{
- var data=JSON.parse(res.data)
- console.log(data)
- if(id == 1){ //正面
- _this.setData({
- idnoimg_face: data.data.url
- })
- }
- if (id == 2) { //反面
- _this.setData({
- idnoimg_back: data.data.url
- })
- }
- if (id == 3) { //半身照
- _this.setData({
- halfbody_img: data.data.url
- })
- }
- if (id == 4) { //学历照
- _this.setData({
- education_img: data.data.url
- })
- }
- }
- })
- },
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|