yesweb-ajax使用


介绍

yesweb-ajaxyesweb 开发框架中的一个API请求组件,包含了签名加密算法,使用这个库可快速的实现和 yesweb 快速开发看框架 API 的对接

安装

npm inistall -save yesweb-ajax

初始化配置

main.js 中配置

import server_config from './config/index' 
import ajax from 'yesweb-ajax'

var ajax_store = {
  serverHost: server_config.serverHost,
  client: server_config.client,
  businessCode: server_config.businessCode,
  user: {
    token: "",
    secretID: "",
    secretKey: "JCKJ0377",
  }
}
const ajaxOption = {
  actionLogin(message) {
    console.log('子应用:跳转到登录窗口:' + message)
  },
  actionError(o) {
    Vue.$vux.alert.show({
      title: o.title,
      content: o.message
    })
  },
  updateSecretKey(data){
    console.log('secretID='+data.secretID)
    console.log('secretKey='+data.secretKey)
  },
  axiosRequestConfig(config){
  }
}
ajax.init(ajax_store, ajaxOption)

config 配置

config/config.dev.js

module.exports = {
  serverHost: 'http://127.0.0.1:5000'
};

config/config.pro.js

module.exports = {
  serverHost: 'http://demoAPI.yesdotnet.com'
};

config/index.js

var _env={};
if (process.env.NODE_ENV === 'development') _env = require('./config.dev.js')
if (process.env.NODE_ENV === 'production') _env = require('./config.pro.js')

var config = {
  client: 'mobile_scan',
  businessCode: 'DENG'
}
module.exports = Object.assign(config, _env)
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
YES开发框架
评论列表

发表评论

评论内容
昵称:
关联文章