1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import Vue from 'vue'
- import Vuex from 'vuex'
- import axios from "axios"
- Vue.use(Vuex)
- // 创建一个新的 store 实例
- const store = new Vuex.Store({
- // 状态数据声明
- state () {
- return {
- phone :'',
- webSocketMsg:'1',
- Termsofinvitation:{},//商邀表格全局变量
- PaymentRequest:{},//日常付款全局变量
- }
- },
- // 在 mutations 内封装数据更新方法
- mutations: {
- SET_WS_MSG: (state, msg) =>{
- state.webSocketMsg = msg
- },
- setphone(state,phone){
- state.phone=phone
- }
- },
- actions:{
- vlogin(context,form){
- console.log(form)
- return new Promise((resolve,reject)=>{//Promise异步任务执行 抛出错误
- axios.post(//axios的基本操作
- "http://132.232.92.186:8888/api/login",
- `number=${form.number}&password=${form.password}`
- ).then(result=>{
- console.log(result)
- if(result.status>=200 && result.status<300){
- resolve();//抛出正确
- }else{
- reject(result.data);//抛出错误
- }
- })
- })
- }
- }
- });
- // 导出状态对象
- export default store
|