tanyanfei 4 years ago
parent
commit
1b5dddcdda

+ 36 - 32
app.js

@@ -1,15 +1,45 @@
 //app.js
 App({
   onLaunch: function () {
+    
+    this.getOpenid()
+    // 获取用户信息
+    // wx.getSetting({
+    //   success: res => {
+    //     if (res.authSetting['scope.userInfo']) {
+    //       // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
+    //       wx.getUserInfo({
+    //         success: res => {
+    //           // 可以将 res 发送给后台解码出 unionId
+    //           this.globalData.userInfo = res.userInfo
+
+    //           // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+    //           // 所以此处加入 callback 以防止这种情况
+    //           if (this.userInfoReadyCallback) {
+    //             this.userInfoReadyCallback(res)
+    //           }
+    //         }
+    //       })
+    //     }
+    //   }
+    // })
+    // wx.request({
+    //   url:'https://www.scxjc.club/api/wx/sujectitem',
+    //   success: res => {
+    //     this.globalData.categoryArray = res.data.data
+    //   }
+    // })
+  },
+  getOpenid:function(){
     var openid;
-    var _this=this;
+    var _this = this;
     wx.getStorage({
       key: 'openid',
-      success: function(res) {
-        openid=res.data
+      success: function (res) {
+        openid = res.data
         _this.globalData.openid = openid
       },
-      fail:res=>{
+      fail: res => {
         // 登录
         wx.login({
           success: res => {
@@ -22,45 +52,19 @@ App({
                 code: res.code
               },
               success: res => {
-                if (res.data.data.openid){
+                if (res.data.data.openid) {
                   _this.globalData.openid = res.data.data.openid
                   wx.setStorage({
                     key: 'openid',
                     data: res.data.data.openid,
                   })
-                } 
+                }
               }
             })
           }
         })
       }
     })   
-    // 获取用户信息
-    wx.getSetting({
-      success: res => {
-        if (res.authSetting['scope.userInfo']) {
-          // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
-          wx.getUserInfo({
-            success: res => {
-              // 可以将 res 发送给后台解码出 unionId
-              this.globalData.userInfo = res.userInfo
-
-              // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-              // 所以此处加入 callback 以防止这种情况
-              if (this.userInfoReadyCallback) {
-                this.userInfoReadyCallback(res)
-              }
-            }
-          })
-        }
-      }
-    })
-    // wx.request({
-    //   url:'https://www.scxjc.club/api/wx/sujectitem',
-    //   success: res => {
-    //     this.globalData.categoryArray = res.data.data
-    //   }
-    // })
   },
   globalData: {
     userInfo: null,

BIN
images/addr.png


BIN
images/lou.png


BIN
images/phone.png


+ 31 - 0
pages/apply/apply.js

@@ -30,6 +30,9 @@ Page({
       },
       method:'GET',
       success:res=>{
+        if (res.statusCode == 403){
+          this.save()
+        }else{
           wx.hideLoading()
           let data=res.data.data
           for(let i=0;i<data.length;i++){
@@ -38,9 +41,37 @@ Page({
           this.setData({
             list: data
           })
+        }
       }
     })
   },
+  save: function () {
+    var _this = this
+    wx.showLoading({
+      title: '正在登录',
+    })
+    wx.getStorage({
+      key: 'userInfo',
+      success: function (res) {
+        console.log(res)
+        wx.request({
+          url: host + '/api/wx/auth',
+          method: 'POST',
+          data: {
+            nickname: res.data.nickName,
+            avatar: res.data.avatarUrl,
+            openid: app.globalData.openid,
+          },
+          success: res => {
+            wx.hideLoading()
+            _this.getData();
+
+          }
+        })
+      },
+    })
+
+  },
   pay:function(e){
     wx.navigateTo({
       url: '../pay/pay?id='+e.target.dataset.id,

+ 1 - 1
pages/index/index.js

@@ -60,7 +60,7 @@ Page({
     })
     console.log(app.globalData.openid)
     wx.request({
-      url: host+'/api/wx/authinfo',
+      url: host+'/api/wx/auth',
       method:'POST',
       data:{
         nickname: e.detail.userInfo.nickName, 

+ 3 - 0
pages/intro/intro.wxml

@@ -11,12 +11,15 @@
       <view class="content link">
           <view>
               {{data.title}}
+               <image src="../../images/lou.png" mode="widthFix"></image>
           </view>
           <view wx:if="{{data.phone}}" bindtap="phone">
               {{data.phone}}
+              <image src="../../images/phone.png" mode="widthFix"></image>
           </view>
           <view wx:if="{{data.address}}" bindtap="openMap">
               {{data.address}}
+              <image src="../../images/addr.png" mode="widthFix"></image>
           </view>
       </view>
     </block>

+ 4 - 0
pages/intro/intro.wxss

@@ -15,4 +15,8 @@
   padding: 15px 0;
   border-bottom: 1px solid #F2F3F4;
 
+}
+.link image{
+  float: right;
+  width: 40rpx;
 }

+ 34 - 4
pages/message/message.js

@@ -20,13 +20,43 @@ Page({
     wx.request({
       url: host+'/api/wx/notice',
       success:res=>{
-        console.log(res.data)
-        this.setData({
-          list:res.data.data
-        })
+        if (res.statusCode == 403) {
+          this.save()
+        } else {
+          this.setData({
+            list:res.data.data
+          })
+        }
       }
     })
   },
+  save: function () {
+    var _this = this
+    wx.showLoading({
+      title: '正在登录',
+    })
+    wx.getStorage({
+      key: 'userInfo',
+      success: function (res) {
+        console.log(res)
+        wx.request({
+          url: host + '/api/wx/auth',
+          method: 'POST',
+          data: {
+            nickname: res.data.nickName,
+            avatar: res.data.avatarUrl,
+            openid: app.globalData.openid,
+          },
+          success: res => {
+            wx.hideLoading()
+            _this.getData();
+
+          }
+        })
+      },
+    })
+
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 17 - 1
pages/myPapers/myPapers.js

@@ -1,4 +1,6 @@
 // pages/myPapers/myPapers.js
+const app = getApp()
+const host = app.globalData.host;
 Page({
 
   /**
@@ -14,7 +16,21 @@ Page({
   onLoad: function (options) {
 
   },
-
+  preview:function(){
+    wx.request({
+      url: host+'/api/wx/classhourcard',
+      success:res=>{
+        let data=res.data.data,urls=[]
+        for(let i=0;i<data.length;i++){
+          urls.push(data[i].url)
+        }
+        wx.previewImage({
+          current: urls[0], // 当前显示图片的http链接
+          urls: urls // 需要预览的图片http链接列表
+        })
+      }
+    })
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 1 - 0
pages/myPapers/myPapers.wxml

@@ -3,4 +3,5 @@
     <navigator url="../web/web?url=" class="list"> 电子证书 </navigator>
     <navigator url="../web/web?url=" class="list"> 合格证查询 </navigator>
     <navigator url="../web/web?url=" class="list"> 从业人员查询 </navigator>
+    <view bindtap="preview" class="list" class="list">学时证明 </view>
 </view>

+ 5 - 13
pages/pay/pay.js

@@ -19,7 +19,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    
       wx.request({
         url: host + '/api/wx/signup',
         method: 'GET',
@@ -44,7 +44,8 @@ Page({
     };
   },
   pay:function(e){
-    console.log(e.detail.value)
+    
+    // console.log(e.detail.value)
     var data = this.data.data, form = e.detail.value;
     wx.showLoading({
       title: '正在提交...',
@@ -75,17 +76,8 @@ Page({
             signType: 'MD5',
             paySign: paySign,
             success(res) { 
-              wx.showModal({
-                content: '支付成功',
-                showCancel: false,
-                confirmText: '返回报名页面',
-                success(res) {
-                  if (res.confirm) {
-                    wx.redirectTo({
-                      url: '/pages/apply/apply'
-                    });
-                  } 
-                }
+              wx.switchTab({
+                url: '/pages/apply/apply'
               });
             },
             fail(res) { console.log(res)}

+ 3 - 1
pages/pay/pay.wxml

@@ -7,6 +7,7 @@
       <label>发票类型</label>
       <picker name='account' data-name='account' bindchange="pickerChange"  range="{{accountArray}}">
         <view class="picker">
+        <!-- <text wx:if="{{account<0}}">请选择</text> -->
           {{accountArray[account]}}
         </view>
       </picker>
@@ -16,10 +17,11 @@
       <label>税号</label>
       <input name='bill_no' placeholder="请输入税号"></input>
   </view>
-  <view class="item">
+  <view class="item"  wx:if='{{account >= 1}}'>
       <label>发票方式</label>
       <picker name='account_type' data-name='account_type' bindchange="pickerChange"  range="{{accountTypeArray}}">
         <view class="picker">
+        <!-- <text wx:if="{{account_type<0}}">请选择</text> -->
           {{accountTypeArray[account_type]}}
         </view>
       </picker>

+ 4 - 0
pages/pay/pay.wxss

@@ -19,6 +19,7 @@ form{
   width: 60px;
   vertical-align: middle;
   text-align: right;
+  font-weight: 600;
 }
 .item input,.item picker{
   display: inline-block;
@@ -27,6 +28,7 @@ form{
   padding-left: 20px;
   vertical-align: middle;
 }
+
 .item image{
   position: absolute;
   right: 12px;
@@ -46,6 +48,7 @@ form{
 .fee text{
   float: right;
   color: #E85546;
+  font-weight: 600;
 }
 
 .bottom{
@@ -62,6 +65,7 @@ form{
 .bottom text{
   color: #E85546;
   margin-left: 12px;
+  font-weight: 600;
 }
 .bottom button{
   width:100px !important;

+ 10 - 7
pages/post/post.js

@@ -35,7 +35,6 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    console.log(options.type,options.s_id)
     this.setData({
       type: options.type
     })
@@ -85,11 +84,15 @@ Page({
         }
         //修改报名
         if(options.type == 2){
+          wx.showLoading({
+            title: '',
+          })
             wx.request({
               url: host+'/api/wx/signup',
               method:'GET',
               data:{id:options.id},
               success:res=>{
+                wx.hideLoading()
                 let data = res.data.data, subject_item = data.subject_item.split('|');
                 let list = sub_list.filter(item => item.name == subject_item[0]);
                 let categoryArray = list[0].children, subject = 0,
@@ -238,17 +241,17 @@ Page({
       })
       return false
     }
-    if (formData.idno == '') {
+    if (formData.idno.length < 18) {
       wx.showToast({
-        title: '身份证不能为空!',
+        title: '请填写正确的身份证号',
         icon: 'none',
         duration: 2000
       })
       return false
     }
-    if (formData.phone == '') {
+    if (!(/^1[3456789]\d{9}$/.test(formData.phone))) {
       wx.showToast({
-        title: '手机号不能为空!',
+        title: '请填写正确的手机号',
         icon: 'none',
         duration: 2000
       })
@@ -311,14 +314,14 @@ Page({
 
 
     wx.showLoading({
-      title: '',
+      title: '正在提交',
     })
     
     wx.request({
       url: host + '/api/wx/signup',
       method: method,
       header: {
-        openid: this.data.openid
+        openid: app.globalData.openid
       },
       data: post_data,
       success: res => {

+ 1 - 0
pages/post/post.wxml

@@ -23,6 +23,7 @@
       <label>文化程度</label>
       <picker name='education' data-name='record'  bindchange="pickerChange" value="{{record}}" range="{{recordArray}}">
         <view class="picker">
+        <text wx:if="{{record<0}}">请选择</text>
           {{recordArray[record]}}
         </view>
       </picker>

+ 13 - 11
pages/upload/upload.js

@@ -67,7 +67,7 @@ Page({
     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 == '') {
+    if (!formData.idnoimg_face) {
       wx.showToast({
         title: '正面照不存在!',
         icon: 'none',
@@ -75,7 +75,7 @@ Page({
       })
       return false
     }
-    if (formData.idnoimg_back == '') {
+    if (!formData.idnoimg_back) {
       wx.showToast({
         title: '反面照不存在!',
         icon: 'none',
@@ -83,7 +83,7 @@ Page({
       })
       return false
     }
-    if (formData.halfbody_img == '') {
+    if (!formData.halfbody_img) {
       wx.showToast({
         title: '半身照不存在!',
         icon: 'none',
@@ -91,7 +91,7 @@ Page({
       })
       return false
     }
-    if (formData.education_img == '') {
+    if (!formData.education_img) {
       wx.showToast({
         title: '学历照不存在!',
         icon: 'none',
@@ -146,15 +146,12 @@ Page({
     })
   },
   takePhoto:function(e){
-    let id=e.target.dataset.id
+    var 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],
@@ -165,7 +162,11 @@ Page({
           success:res=>{
             wx.hideLoading()
             var data=JSON.parse(res.data)
-            console.log(data)
+            wx.showToast({
+              title: '上传成功' + data.data.url,
+              icon: 'none',
+              duration: 2000
+            })
             if(id == 1){  //正面
               _this.setData({
                 idnoimg_face: data.data.url
@@ -194,8 +195,9 @@ Page({
           },
           fail: res => {
             wx.hideLoading()
+            wx.hideLoading()
             wx.showToast({
-              title: res.data.message,
+              title: res,
               icon: 'none',
               duration: 2000
             })

+ 48 - 9
pages/user/user.js

@@ -22,21 +22,60 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    this.getData()
+  },
+  getData:function(){
+    wx.showLoading({
+      title: '',
+    })
     wx.request({
-      url: host+'/api/wx/authinfo',
+      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
-        })   
+      success: res => {
+        console.log(res)
+        wx.hideLoading()
+        if (res.statusCode == 403) {
+          this.save()
+        } else {
+          let edu = this.data.recordArray.indexOf(res.data.data.education)
+          this.setData({
+            data: res.data.data,
+            sex: res.data.data.sex==1 ? 1:0,
+            record: edu
+          })
+        }
       }
     })
   },
+  save:function(){
+    var _this=this
+    wx.showLoading({
+      title: '正在登录',
+    })
+    wx.getStorage({
+      key: 'userInfo',
+      success: function(res) {
+        console.log(res)
+        wx.request({
+          url: host + '/api/wx/auth',
+          method: 'POST',
+          data: {
+            nickname: res.data.nickName,
+            avatar: res.data.avatarUrl,
+            openid: app.globalData.openid,
+          },
+          success: res => {
+            wx.hideLoading()
+            _this.getData();
+            
+          }
+        })
+      },
+    })
+    
+  },
   inputChange:function(e){
     var data=this.data.data
     data[e.target.dataset.name] = e.detail.value
@@ -137,7 +176,7 @@ Page({
   },
   post:function(){
       var data=this.data.data
-      data.sex=this.data.sex
+      data.sex=this.data.sex==1?1:2
       data.education = this.data.recordArray[this.data.record]
       wx.showLoading({
         title: '',

+ 2 - 2
pages/user/user.wxml

@@ -36,10 +36,10 @@
       <input bindinput="inputChange" data-name='company'  value="{{data.company}}" placeholder="请输入您的单位名称"></input>
   </view>
   
-  <view class="item xs">
+  <!-- <view class="item xs">
       <label>学时证明</label>
       <image bindtap="preview" wx:if='{{data.classhour_imgs}}' src="{{data.classhour_imgs[0]}}" mode="widthFix"></image>
-  </view>
+  </view> -->
 </form>
 
 <view class="content">