| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 | 
							- const app = getApp();
 
- const util = require("../../../utils/util.js")
 
- Page({
 
-   data: {
 
-     ctx: false,
 
-     hidden: true,
 
-     showcamara: false,
 
-     type:'card',
 
-     phone:'',
 
-     studyUser :{
 
-       cardId:"",
 
-       cardImg:"",
 
-       nickname:"",
 
-       phone:'',
 
-       openid:'',
 
-       identify:0,
 
-       session_key:'',
 
-       cardBackImg:""
 
-     }
 
-   },
 
-   wxLogin(){
 
-     let that = this
 
-     wx.login({
 
-       success(wxres) {
 
-         if( !wxres.code){
 
-           util.showMsg("登入失败")
 
-         }else{
 
-           that.doLoginByCode( wxres.code )
 
-         }
 
-       }
 
-     })
 
-   },
 
-   doLoginByCode( code ){
 
-     app.formPost( "Auth.WxLoginByCode", {code}).then( (res)=>{
 
-       if( res.code == 200){
 
-         this.setData( {userInfo: res.data})
 
-         app.setUserInfo( res.data )
 
-         wx.navigateBack({
 
-           delta: 1
 
-         })
 
-       }
 
-     })
 
-   },
 
-   doIdentify( e ){
 
-     let that = this
 
-     wx.login({
 
-       success(wxres) {
 
-         if (wxres.code) {
 
-           that.doRegister( wxres.code, e.detail.value )
 
-         }
 
-       }
 
-     })
 
-   },
 
-   doRegister( code, info ){
 
-     let param = {
 
-       code: code,
 
-       phone:   info.phone,
 
-       cardId:  info.cardId,
 
-       nickname: info.nickname,
 
-     }
 
-     app.formPost( 'Auth.Register', param).then( res =>{
 
-       if( res.code == 200 ){
 
-         let studyUser= res.data
 
-         app.setUserInfo( studyUser )
 
-         util.showSuccess("登入成功")
 
-         this.setData({studyUser})
 
-       }else{
 
-         util.showMsg( res.msg  )
 
-       }
 
-     })
 
-   },
 
-   onReady: function (res) {
 
-     var ctx = wx.createCameraContext('myCamera')
 
-     this.setData({ ctx: ctx })
 
-   },
 
-   previewImage: function (e) {
 
-     var current = e.target.dataset.src;
 
-     wx.previewImage({
 
-       current: current, 
 
-       urls: [current]
 
-     })
 
-   } ,
 
-   takeCard(){
 
-     this.setData( {showcamara:true, type:'card'})
 
-   },
 
-   takeCardBack(){
 
-     this.setData( {showcamara:true, type:'cardBack'})
 
-   },
 
-   identify( err, {url} ){
 
-     if( err != 200 || !url ) {
 
-       util.showMsg("图片上传失败")
 
-       return
 
-     }
 
-     let type = this.data.type;
 
-     util.showBusy("识别图片中")
 
-     let studyUser = this.data.studyUser
 
-     let showcamara= false
 
-     app.formPost('Auth.wxUploadImg', {url, type}).then(res => {
 
-       if( res.code == 200 ){
 
-         util.showBusy("上传成功")
 
-         if ( type =="card"){
 
-           studyUser.cardImg = url
 
-           studyUser.address = res.data.Address
 
-           studyUser.nickname = res.data.Name
 
-           studyUser.cardId = res.data.IDNumber
 
-           studyUser.gender = res.data.Gender
 
-         }else{
 
-           studyUser.cardBackImg = url
 
-         }
 
-         wx.setStorageSync('@identify', studyUser)
 
-         this.setData({studyUser,showcamara})
 
-       }
 
-     })
 
-   },
 
-   chooseImg: function () {
 
-     var that = this
 
-     wx.chooseImage({
 
-       count: 1,
 
-       sizeType: ['compressed'],
 
-       sourceType: ['album'], 
 
-       success: function (res) {
 
-         that.setData( {showcamara:false})
 
-         util.showSuccess("图片上传中")
 
-         util.uploadFile( res.tempFilePaths[0], that.identify )
 
-       },
 
-       fail:(res)=>{
 
-         console.log( res)
 
-         util.showMsg("图片选择失败")
 
-       }
 
-     })
 
-   },
 
-   takePhoto() {
 
-     var that = this
 
-     var ctx = this.data.ctx
 
-     ctx.takePhoto({
 
-       quality: 'low',
 
-       success: (res) => {
 
-         app.message("图片上传中")
 
-         that.setData( {showcamara:false})
 
-         var tempImagePath = res.tempImagePath
 
-         util.uploadFile( tempImagePath, that.identify )
 
-       },
 
-       fail:  (res)=> {
 
-         app.message("图片上传中", "error")
 
-       }
 
-     })
 
-   },
 
-   onConfirm( e ){
 
-     let {phone} = e.detail.value
 
-     let info = this.data.info
 
-     let {card_img, card_back_img} = this.data.info
 
-     if( !card_img ) return util.showMsg( "身份证正面有误");
 
-     if( !card_back_img ) return util.showMsg( "身份证背面有误");
 
-     if( !phone || phone.length != 11 ) return util.showMsg( "手机号码有误");
 
-     util.http( '/maker/identifyMaker', {phone}, (err,res)=>{
 
-       if( err!= 0 ) return;
 
-       info.identify = 1
 
-       app.identifyUser( )
 
-       this.setData({info})
 
-     })
 
-   },
 
-   goBack() {
 
-     this.setData({showcamara:false})
 
-   }
 
- })
 
 
  |