乐趣区

关于前端:封装公共请求事件

公共 jacecom.js

import api from './index.js'
const tiyanAll = {async tiyanApis(apidata){return new Promise((resolve,reject)=>{api.get(apidata, {}, (response) => {if (response.status >= 200 && response.status < 300) {
                    let data = response.data.data;
                    resolve(data)
                }
            })
         })

},
async ticketApi(apidata){return new Promise((resolve,reject)=>{api.get(apidata, {},(response) => {if (response.status >= 200 && response.status < 300) {
                    let data = response.data.data;
                    resolve(data)
                }
            })
        })

    }
  }
  export default tiyanAll;

index.vue 中:

async tiyanApi(){
    let letobjApi = {
          reportApi:'/rest76/user/vip_goods_of_report',
          ticketApi:'/rest76/pay/ticket'
      }
      
          let tiyanArr = await this.$jianCe.tiyanApis(letobjApi.reportApi)
          console.log(tiyanArr,'datass')
          let ticketdate = await this.$jianCe.ticketApi(letobjApi.ticketApi)
            console.log(ticketdate,'ticketdate')
        },
退出移动版