提交 c5652d10 编写于 作者: guangjun.yang's avatar guangjun.yang

vuex

上级 3954c1f3
...@@ -94,7 +94,7 @@ export default { ...@@ -94,7 +94,7 @@ export default {
this.list = this.parmData; this.list = this.parmData;
this.$store.dispatch("setSource", []); // this.$store.dispatch("setSource", []);
//this.pageNo = this.adjustPageNo; //this.pageNo = this.adjustPageNo;
// if(window.__isAndroid){ // if(window.__isAndroid){
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<div class="couse-cont"> <div class="couse-cont">
<!-- <div class="couse-list" v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="10" :style="'height:'+clientHeight"> --> <!-- <div class="couse-list" v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="10" :style="'height:'+clientHeight"> -->
<div class="couse-list" infinite-scroll-disabled="loading" infinite-scroll-distance="10" :style="'height:'+clientHeight"> <div class="couse-list" infinite-scroll-disabled="loading" infinite-scroll-distance="10" :style="'height:'+clientHeight">
<div v-show="index < 4" :class="index%2==1 ? 'course-item end-left' : 'course-item'" :key="index" v-for="(item,index) in list"> <div v-show="index < 4" :class="index%2==1 ? 'course-item end-left' : 'course-item'" :key="index" v-for="(item,index) in parmData">
<div class="course-pic" @click="goToPage(item)"> <div class="course-pic" @click="goToPage(item)">
<img v-lazy="item.courseInfoUrl" class="pic-tec" /> <img v-lazy="item.courseInfoUrl" class="pic-tec" />
<span class="course-tag">{{item.disName}}</span> <span class="course-tag">{{item.disName}}</span>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</p> </p>
<div class="course-opt"> <div class="course-opt">
<span class="opt-info">{{!item.showTime ? '' : item.showTime + ' |'}} {{item.joinNum}}人已学</span> <span class="opt-info">{{!item.showTime ? '' : item.showTime + ' |'}} {{item.joinNum}}人已学</span>
<span :class="item.whetherFavors==2?'opt collect':'opt collected'"@click="collectFun(item.whetherFavors,item.id,item.name)"> <span :class="item.whetherFavors==2?'opt collect':'opt collected'" @click="collectFun(item.whetherFavors,item.id,item.name)">
{{item.whetherFavors==2?'收藏':'已收藏'}} {{item.whetherFavors==2?'收藏':'已收藏'}}
</span> </span>
...@@ -98,9 +98,9 @@ export default { ...@@ -98,9 +98,9 @@ export default {
}, },
mounted() { mounted() {
this.list = this.parmData; // this.list = this.parmData;
this.$store.dispatch("setSource", []); // this.$store.dispatch("setSource", []);
//this.pageNo = this.adjustPageNo; //this.pageNo = this.adjustPageNo;
// if(window.__isAndroid){ // if(window.__isAndroid){
......
const getters = { const getters = {
// sidebar: state => state.app.sidebar, userInfo: state => state.sousuo.userInfo,
// token: state => state.user.token, navBarHeight: state => state.sousuo.navBarHeight
// avatar: state => state.user.avatar,
} }
export default getters export default getters
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import common from './modules/common' import sousuo from './modules/sousuo'
import diagnosis from './modules/diagnosis'
import gpRanking from './modules/gpRanking'
import adjustDataList from './modules/adjustList'
import getters from './getters' import getters from './getters'
Vue.use(Vuex) Vue.use(Vuex)
const store = new Vuex.Store({ const store = new Vuex.Store({
modules: { modules: {
common, sousuo
diagnosis,
gpRanking,
adjustDataList
}, },
getters getters
}) })
......
const adjustList = {
state: {
adjustLists:[]
},
mutations: {
SET_DATA: (state, adjustLists) => {
console.log(state);
state.adjustLists = adjustLists
},
},
actions: {
setSource({ commit }, adjustLists) {
commit('SET_DATA', adjustLists)
},
}
}
export default adjustList
import router from '@/router/router'
import { uniqueArray } from '@/utils'
const common = {
state: {
homeTabs: [],
homeTabsActiveName: '',
comModObject: null
},
mutations: {
SET_HOME_TABS: (state, homeTabs) => {
state.homeTabs = homeTabs
},
SET_HOME_TABS_ACTIVE_NAME: (state, homeTabsActiveName) => {
state.homeTabsActiveName = homeTabsActiveName
},
SET_COMMON_OBJECT: (state, comModObject) => {
state.comModObject = comModObject
}
},
actions: {
setHomeTabs({ commit }, homeTabs) {
commit('SET_HOME_TABS', homeTabs)
},
setHomeTabsActiveName({ commit }, homeTabsActiveName) {
commit('SET_HOME_TABS_ACTIVE_NAME', homeTabsActiveName)
},
// 添加tab
addTabs({ commit, state }, tab) {
let homeTabs = state.homeTabs.slice()
if (homeTabs.length === 0) {
tab.closable = false
} else {
homeTabs[0].closable = false
}
homeTabs.push(tab)
homeTabs = uniqueArray(homeTabs, 'name')
commit('SET_HOME_TABS', homeTabs)
commit('SET_HOME_TABS_ACTIVE_NAME', tab.name)
},
// 删除tab(单个)
removeOneTab({ commit, state }, tabName) {
logger.warn(tabName)
const homeTabs = state.homeTabs.slice()
let name
for (let i = 0; i < homeTabs.length; i++) {
let item = homeTabs[i]
if (item.name === tabName) {
homeTabs.splice(i, 1)
item = homeTabs[i]
if (state.tabsActiveName === tabName) {
if (item) {
name = item.name
} else {
name = homeTabs[i - 1].name
}
commit('SET_HOME_TABS_ACTIVE_NAME', name)
router.push({ path: name })
}
break
}
}
commit('SET_HOME_TABS', homeTabs)
},
// 删除tabs(多个)
removeAllTabs({ commit, state }) {
const homeTabs = state.homeTabs.slice()
if (homeTabs.length === 0) {
return
}
const firstTab = [homeTabs.shift()]
commit('SET_HOME_TABS_ACTIVE_NAME', firstTab[0].name)
router.push({
path: firstTab[0].name
})
commit('SET_HOME_TABS', firstTab)
},
setCommonObjct({ commit, state }) {
commit('SET_COMMON_OBJECT', state.comModObject)
}
}
}
export default common
const diagnosis = {
state: {
},
mutations: {
},
actions: {
}
}
export default diagnosis
const gpRankings = {
state: {
},
mutations: {
},
actions: {
}
}
export default gpRankings
const sousuo = {
state: {
userInfo: {},
navBarHeight: {}
},
mutations: {
SET_USER_INFO: (state, userInfo) => {
console.log(state, userInfo);
state.userInfo = userInfo
},
SET_NAVBAR_HEIGHT: (state, navBarHeight) => {
console.log(state, navBarHeight);
state.navBarHeight = navBarHeight
}
},
actions: {
setUserInfo({ commit }, userInfo) {
commit('SET_USER_INFO', userInfo)
},
setNavBarHeight({ commit }, navBarHeight) {
commit('SET_NAVBAR_HEIGHT', navBarHeight)
},
}
}
export default sousuo
const yqyHome = {
state: {
userMse: {},
},
mutations: {
SET_USERMSE: (state, userMse) => {
state.userMse = userMse
},
},
actions: {
setUserMse({ commit }, userMse) {
commit('SET_USERMSE', userMse)
},
}
}
export default yqyHome
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
e.rocNative = { e.rocNative = {
// 参数说明 e:回传回来的移动端服务名称; t:前端自己传递的回调JS方法 // 参数说明 e:回传回来的移动端服务名称; t:前端自己传递的回调JS方法
__nativeCall: function (e, t, n) { __nativeCall: function (e, t, n) {
if(t == '__nativeCallMsg'){
__nativeCallMsg(n)
}
if(t == '__refresh'){ if(t == '__refresh'){
__refresh(n) __refresh(n)
} }
...@@ -16,7 +13,6 @@ ...@@ -16,7 +13,6 @@
if(t == '__getStatusBarHeight'){ if(t == '__getStatusBarHeight'){
__getStatusBarHeight(n); __getStatusBarHeight(n);
} }
if(t == 'pauseAudioView'){ if(t == 'pauseAudioView'){
__pauseAudioView(n); __pauseAudioView(n);
} }
...@@ -26,9 +22,6 @@ ...@@ -26,9 +22,6 @@
if(t == 'closeAudioView'){ if(t == 'closeAudioView'){
__closeAudioView(n); __closeAudioView(n);
} }
if(t == 'getToken'){
__getToken(n);
}
if(t == '__isFirstTime'){ if(t == '__isFirstTime'){
window.__isFirstTime(n) window.__isFirstTime(n)
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<section></section> <section></section>
<NoResultPage/> <NoResultPage/>
<SplitLine borderWidth="3px"/> <SplitLine borderWidth="3px"/>
<CourseAdjust/> <CourseAdjust v-show="adjustList.length > 0" :paraData="adjustList"/>
</article> </article>
<!-- 有结果页面 --> <!-- 有结果页面 -->
...@@ -86,6 +86,7 @@ import ConfirmTip from '@/components/common/confirm-tip' ...@@ -86,6 +86,7 @@ import ConfirmTip from '@/components/common/confirm-tip'
export default { export default {
data() { data() {
return { return {
// token: '',
navIndex: '0', navIndex: '0',
showLoading: false, showLoading: false,
hasResult: true, hasResult: true,
...@@ -109,7 +110,8 @@ export default { ...@@ -109,7 +110,8 @@ export default {
showTab3: true, showTab3: true,
showTab4: true, showTab4: true,
showTitle: false, showTitle: false,
showOrder: true showOrder: true,
adjustList: []
} }
}, },
components: { components: {
...@@ -135,6 +137,20 @@ export default { ...@@ -135,6 +137,20 @@ export default {
created(){ created(){
this.searchText = this.$route.query.searchText || '' this.searchText = this.$route.query.searchText || ''
console.log(this.searchText) console.log(this.searchText)
let _this = this;
window.__getUserInfo = function(params){
_this.token = params.userToken
// _this.SET_USER_INFO(params)
_this.search()
_this.getAdjustData()
}
if(window.__isWeb) {
_this.getAdjustData()
// _this.search()
}
window.__refresh = function(){
_this.getUserInfo()
}
}, },
mounted(){ mounted(){
// this.search(this.searchText) // this.search(this.searchText)
...@@ -146,7 +162,7 @@ export default { ...@@ -146,7 +162,7 @@ export default {
this.navIndex = index this.navIndex = index
}, },
// 搜索结果 // 搜索结果
search(searchText) { search() {
this.showLoading = true this.showLoading = true
let _this = this, let _this = this,
para = { para = {
...@@ -241,6 +257,31 @@ export default { ...@@ -241,6 +257,31 @@ export default {
d[i].play = '0'; d[i].play = '0';
} }
return d; return d;
},
//为您推荐
getAdjustData(){
this.adjustList = []
let _this = this,
parm = {
pageNo: 1,
pageSize: 10,
token: _this.token,
setEntry: 'headers',
}
_this.GET('contents/courses/recommendCourseList',parm).then(function(res){
if(res.code === '000000'){
_this.adjustList = res.data || [];
// _this.adjustPageNo = 1;
// _this.SET_DATA(_this.adjustList)
// if(_this.adjustList.length>0){
// _this.userToken = userToken
// }
}
})
},
getUserInfo: function () {
rocNative.getUserInfo({'__funcName': '__getUserInfo'})
} }
}, },
} }
......
...@@ -14,16 +14,18 @@ ...@@ -14,16 +14,18 @@
</template> </template>
<script> <script>
import {mapState, mapMutations} from 'vuex'
import SearchHeader from '../components/business/search-header'; import SearchHeader from '../components/business/search-header';
import SplitLine from '../components/business/split-line'; import SplitLine from '../components/business/split-line';
import HistoryLabels from '../components/business/history-labels'; import HistoryLabels from '../components/business/history-labels';
import HotLabels from '../components/business/hot-labels'; import HotLabels from '../components/business/hot-labels';
// import { Search } from 'mint-ui';
export default { export default {
data() { data() {
return { return {
searchText: '' searchText: '',
token: ''
} }
}, },
components: { components: {
...@@ -35,11 +37,47 @@ export default { ...@@ -35,11 +37,47 @@ export default {
created(){ created(){
}, },
computed:{
...mapState([
'sousuo'
])
},
mounted(){ mounted(){
this.getData() let _self = this;
window.__getUserInfo = function(params){
_self.token = params.userToken
// _self.SET_USER_INFO(params)
_self.getData()
}
window.__refresh = function(){
_self.getUserInfo()
}
window.__getStatusBarHeight = function(params){
_self.SET_NAVBAR_HEIGHT(params)
}
// window.__getStatusBarHeight = function(parm){
// //lert(parm.statusBarHeight)
// if(window.__isAndroid){
// _this.popHeight = parseInt(parm.statusBarHeight)/2.5
// }else{
// _this.popHeight = parm.statusBarHeight
// }
// _this.ptop = _this.popHeight+'px';
// _this.menuptop = _this.popHeight+'px'
// // alert(parm.statusBarHeight);
// }
if(window.__isWeb) {
_self.getData()
}
_self.getUserInfo()
_self.getStatusBarHeight()
}, },
methods: { methods: {
...mapMutations([
'SET_USER_INFO', 'SET_NAVBAR_HEIGHT'
]),
// 跳转到结果页面,并 // 跳转到结果页面,并
search() { search() {
if(!this.searchText) return; if(!this.searchText) return;
...@@ -67,6 +105,12 @@ export default { ...@@ -67,6 +105,12 @@ export default {
} }
} }
}) })
},
getUserInfo: function () {
rocNative.getUserInfo({'__funcName': '__getUserInfo'})
},
getStatusBarHeight: function () {
rocNative.getStatusBarHeight({'__funcName': '__getStatusBarHeight'})
} }
}, },
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册