async and await the application

community-survey-sys project

ShareQuestionnaireModal.vue:

    async queryShareScope () {
      let releaseSet = getReleaseSet({ wjId: this.wjId })
      let dictList = queryWjDictList({ type: 'PLATFORM' })
      // let appId = getAppid({code: 'share'})

      await Promise.all([releaseSet, dictList]).then(([releaseRes, dictListRes]) => {
        let platformList = []
        let dictList = []
        if (releaseRes.data.code === '0') {
          platformList = releaseRes.data.data.platformList
//          platformList = [
//            {
//              createTime: 1952001,
//              id: 2,
//              platformCode: 'scpg',
//              status: 1,
//              updateTime: 1952001,
//              wjId: 132006
//            }]
          console.log('platformList', platformList)
        } else {
          this.showToast(releaseRes.data.message)
          return
        }

        if (dictListRes.data.code === '0') {
          dictList = dictListRes.data.data.dictList
        } else {
          this.showToast(dictListRes.data.message)
          return
        }
        this.shareList = platformList.map(item => {
          let name = ''
//          dictList = [{code: 1, name: '印力', value: 'scpg'}]
          dictList.forEach(subitem => {
            if (subitem.value === item.platformCode) {
              name = subitem.name
            }
          })
          return {appName: name, platformCode: item.platformCode}
        })
        this.shareList.map((item, index) =>{
          if (Item.appName === 'force plate' ) {
             the this .shareList.splice (index,. 1 ) 
          } 
        }) 

        // IF (appIdRes.data.code === '0') { 
        //    this.appId = appIdRes.data.data.list 
        // } the else { 
        //    // this.showToast (appIdRes.data.message) -1 // always here, influence of the interface, turn off the prompt 
        // } 
        // this.appId. Map ((Item, index) => { 
        //    this.shareList.push ({appName: item.val, platformCode: 'scpg', for appId: item.appId}) 
        // }) 
        the console.log ( 'dictList' , dictList) 
        the console.log ( 'shareList', the this .shareList)
         // this.toggleTab (0) 
      }) 
      getAppId ({code: . 'Share'}) the then (appIdRes => {
         IF (appIdRes.data.code === '0' ) {
           the this .appId = appIdRes .data.data.list 
        } the else {
           // this.showToast (appIdRes.data.message) // there is always -1, influence of the interface, turn off the prompt 
        }
         the this .appId.map ((Item, index) => {
           the this .shareList.push ({appName: item.val, platformCode: 'scpg' , for appId: item.appId}) 
        }) 
      .}) the catch (ERR => {
        console.log('err:', err)
      })
      this.toggleTab(0)
    },

 

Guess you like

Origin www.cnblogs.com/benbendu/p/12572744.html