Commit 2a7ba4dd by 程默

vuex

parent e6b85eb8
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
import Store from './store/index'
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
Vue.prototype.$store=Store
const app = new Vue(App) const app = new Vue(App)
app.$mount() app.$mount()
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<script> <script>
import spokesman from "@/api/spokesman.js"; import spokesman from "@/api/spokesman.js";
import { serialize,getQueryVariable } from "@/utils/index"; import { serialize, getQueryVariable } from "@/utils/index";
export default { export default {
data() { data() {
return { return {
...@@ -42,11 +42,21 @@ export default { ...@@ -42,11 +42,21 @@ export default {
if (options.share) { if (options.share) {
//来自分享 //来自分享
this.link = decodeURIComponent(options.share); this.link = decodeURIComponent(options.share);
this.spokesmanGroupId=getQueryVariable(this.link,"spokesmanGroupId"); this.spokesmanGroupId =
this.spokesmanShopId=getQueryVariable(this.link,"spokesmanShopId"); getQueryVariable(this.link, "spokesmanGroupId") || "";
this.spokesmanRelId=getQueryVariable(this.link,"spokesmanRelId"); this.spokesmanShopId =
this.spokesmanBindId=getQueryVariable(this.link,"spokesmanBindId"); getQueryVariable(this.link, "spokesmanShopId") || "";
this.spokesmanRelId = getQueryVariable(this.link, "spokesmanRelId") || "";
this.spokesmanBindId =
getQueryVariable(this.link, "spokesmanBindId") || "";
if (this.spokesmanGroupId != "") {
this.$store.commit("setSpokesman", {
spokesmanGroupId: this.spokesmanGroupId,
spokesmanShopId: this.spokesmanShopId,
spokesmanRelId: this.spokesmanRelId,
spokesmanBindId: this.spokesmanBindId
});
}
this.page = ""; this.page = "";
this.params = ""; this.params = "";
} else if (options.from && options.from == "h5login") { } else if (options.from && options.from == "h5login") {
...@@ -80,7 +90,6 @@ export default { ...@@ -80,7 +90,6 @@ export default {
} }
console.log("url", this.link + this.page + this.params); console.log("url", this.link + this.page + this.params);
this.getSpokesman(); this.getSpokesman();
//获取店铺信息
}, },
components: { components: {
// card // card
......
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
this.backParams = serialize(options.params); this.backParams = serialize(options.params);
} }
console.log(options, "登录页面", this.backPath, this.backParams); console.log(options, "登录页面", this.backPath, this.backParams);
// console.log(this.$store.state.spokesmanGroupId,'-----------0---------------') console.log(this.$store.state.spokesmanGroupId,'-----------0---------------')
this.getshop(); this.getshop();
this.init(); this.init();
}, },
......
import Vue from "vue";
import Vuex from "vuex";
import state from "./state";
import mutations from "./mutations"
Vue.use(Vuex);
export default new Vuex.Store({
state,
mutations
})
\ No newline at end of file
const mutations = {
setSpokesman(state, obj) {
for (let [key, val] of Object.entries(obj)) {
state[key] = val;
}
}
}
export default mutations
\ No newline at end of file
const state={
spokesmanGroupId:"",
spokesmanShopId:"",
spokesmanRelId:"",
spokesmanBindId:""
}
export default state
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment