Просмотр исходного кода

promise函数catch事件处理

ZhangWenQiang 6 лет назад
Родитель
Сommit
b873401cad
5 измененных файлов с 21 добавлено и 6 удалено
  1. 15 2
      pages/detail/index.js
  2. 1 1
      pages/detail/index.wxml
  3. 2 0
      pages/mine/index.js
  4. 1 1
      pages/mine/index.wxml
  5. 2 2
      utils/http.js

+ 15 - 2
pages/detail/index.js

@@ -68,7 +68,7 @@ Page({
       isLogin: isLogin
     })
     this.fetchData();
-    this.fetchPtList();
+    // this.fetchPtList();
   },
 
   onShareAppMessage: function() {
@@ -225,10 +225,17 @@ Page({
           }
           Object.assign(paramsObj);
           positionApply(paramsObj).then(data => {
+            console.log("sdfg",data);
             showToast('申请职位成功', 'success')
             setTimeout(function() {
               wx.navigateBack();
             }, 2000)
+          }).catch(data => {
+            console.log('No!',data)
+            showToast(data.errmsg);
+            wx.navigateTo({
+              url: '/pages/user-info/user-info',
+            })
           })
         } else if (res.cancel) {
 
@@ -271,6 +278,12 @@ Page({
             wx.navigateTo({
               url: '../pt-detail/index?gd=' + hpPositionGroupId + '&pc=' + self.data.positionCategory + '&pd=' + self.data.hpPositionId,
             })
+          }).catch(data => {
+            console.log('No!', data)
+            showToast(data.errmsg);
+            wx.navigateTo({
+              url: '/pages/user-info/user-info',
+            })
           })
         } else if (res.cancel) {
 
@@ -378,7 +391,7 @@ Page({
     this.setData({
       showAllPt: false,
       showJoinPt: true,
-      joinPtList: this.data.allPtList[index]
+      joinPtList: this.data.storeAction[index]
     })
   },
 

+ 1 - 1
pages/detail/index.wxml

@@ -731,7 +731,7 @@
     <view class='title'>
       该岗位已有{{postitionDetail.startGroupNumber}}位伙伴发起了拼工
     </view>
-    <block wx:for="{{allPtList}}" wx:key="*this" wx:for-item="item" wx:for-index="idx">
+    <block wx:for="{{storeAction}}" wx:key="*this" wx:for-item="item" wx:for-index="idx">
       <view class='allpt_list'>
         <view class='left'>
           <block wx:for="{{item}}" wx:for-item="item1" wx:key="il1">

+ 2 - 0
pages/mine/index.js

@@ -101,6 +101,8 @@ Page({
           percent: percent
         })
       }
+    }).catch(data => {
+      console.log('No!', data)
     })
   },
   //获取用户认证状态

+ 1 - 1
pages/mine/index.wxml

@@ -62,7 +62,7 @@
     <view class='jltb'>
       <image src='{{imgServerUrl}}/images/happyjob/jianli.png'></image>
       <view class='wenzi'>
-        <block wx:if="{{userResume}}">
+        <block wx:if="{{userResume.id}}">
           <text class='wenzi1'>{{userResume.realName}}的简历</text>
         </block>
         <block wx:else>

+ 2 - 2
utils/http.js

@@ -60,8 +60,8 @@ const http = (params) => {
           } else if (errorCode == 40005) {
             //用户信息和微信信息不匹配
           } else if (errorCode == 1015) {
-            //用户尚未创建简历  
-            return;          
+            //用户尚未创建简历
+            return reject(res.data);     
           } else if (errorCode == 40007) {
             //账号类型不符
           } else if (errorCode == 2006) {