• async和await的应用


    community-survey-sys项目

    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 === '印力') {
                this.shareList.splice(index, 1)
              }
            })
    
            // if (appIdRes.data.code === '0') {
            //   this.appId = appIdRes.data.data.list
            // } else {
            //   // this.showToast(appIdRes.data.message) // 这里总是-1,影响界面,先关掉提示
            // }
            // this.appId.map((item, index) => {
            //   this.shareList.push({appName: item.val, platformCode: 'scpg', appId: item.appId})
            // })
            console.log('dictList', dictList)
            console.log('shareList', this.shareList)
            // this.toggleTab(0)
          })
          getAppid({code: 'share'}).then(appIdRes => {
            if (appIdRes.data.code === '0') {
              this.appId = appIdRes.data.data.list
            } else {
              // this.showToast(appIdRes.data.message) // 这里总是-1,影响界面,先关掉提示
            }
            this.appId.map((item, index) => {
              this.shareList.push({appName: item.val, platformCode: 'scpg', appId: item.appId})
            })
          }).catch(err => {
            console.log('err:', err)
          })
          this.toggleTab(0)
        },
  • 相关阅读:
    团队开发冲刺第二阶段_1
    团队开发冲刺第一阶段_7
    mysql 官方集群
    Tomcat提高并发
    Percona XtraDB Cluster 5.7
    Mysql常用配置及优化
    Linux 常用命令
    数据库主从复制
    Linux 环境下Web环境搭建————ActiveMQ
    Linux 下Web环境搭建————redis
  • 原文地址:https://www.cnblogs.com/benbendu/p/12572744.html
Copyright © 2020-2023  润新知