增加列表和详情页的互动
This commit is contained in:
parent
dddbed3b6f
commit
fce12be42a
@ -1,3 +1,39 @@
|
|||||||
|
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
export const EventBus = new Vue()
|
export const EventBus = new Vue()
|
||||||
|
/**
|
||||||
|
* 自定义题目更新
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const EVENT_SHOP_PUZZLES_UPDATE = 'event_shop_puzzles_update'
|
||||||
|
/**
|
||||||
|
* 活动数据更新
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const EVENT_ACTIVITY_UPDATE = 'event_activity_update'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挑战数据更新
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const EVENT_EXAM_UPDATE = 'event_exam_update'
|
||||||
|
/**
|
||||||
|
* 游戏数据更新
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const EVENT_GAME_UPDATE = 'event_game_update'
|
||||||
|
/**
|
||||||
|
* 优惠券信息更新
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const EVENT_COUPON_UPDATE = 'event_coupon_update'
|
||||||
|
/**
|
||||||
|
* 题目信息更新
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const EVENT_PUZZLE_UPDATE = 'event_puzzle_update'
|
||||||
|
/**
|
||||||
|
* 店铺信息更新
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const EVENT_SHOP_UPDATE = 'event_shop_update'
|
||||||
|
@ -394,13 +394,7 @@ import Sticky from '@/components/Sticky/index.vue'
|
|||||||
import UploadImage from '@/components/UploadImage/index.vue'
|
import UploadImage from '@/components/UploadImage/index.vue'
|
||||||
import RegionPicker from '@/components/RegionPicker/index.vue'
|
import RegionPicker from '@/components/RegionPicker/index.vue'
|
||||||
import { getMyShop, getShops } from '@/api/shop'
|
import { getMyShop, getShops } from '@/api/shop'
|
||||||
import {
|
import { defaultActivityData, defaultRewardData, getActivity, IRewardData, saveActivity } from '@/api/activity'
|
||||||
defaultActivityData,
|
|
||||||
defaultRewardData,
|
|
||||||
getActivity,
|
|
||||||
IRewardData,
|
|
||||||
saveActivity
|
|
||||||
} from '@/api/activity'
|
|
||||||
import { sec2TimeStr, timeStr2Sec } from '@/utils'
|
import { sec2TimeStr, timeStr2Sec } from '@/utils'
|
||||||
import { getAllCategory } from '@/api/question'
|
import { getAllCategory } from '@/api/question'
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
@ -409,6 +403,7 @@ import { IShopData } from '@/api/types'
|
|||||||
import { ElTree } from 'element-ui/types/tree'
|
import { ElTree } from 'element-ui/types/tree'
|
||||||
import { UserModule } from '@/store/modules/user'
|
import { UserModule } from '@/store/modules/user'
|
||||||
import UploadCorpImage from '@/components/UploadCorpImage/index.vue'
|
import UploadCorpImage from '@/components/UploadCorpImage/index.vue'
|
||||||
|
import { EVENT_ACTIVITY_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ActivityEditor',
|
name: 'ActivityEditor',
|
||||||
@ -594,6 +589,7 @@ export default class extends Vue {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
|
EventBus.$emit(EVENT_ACTIVITY_UPDATE, {})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Submit Error!')
|
console.error('Submit Error!')
|
||||||
return false
|
return false
|
||||||
|
@ -139,6 +139,7 @@ import { parseTime } from '@/utils'
|
|||||||
import { getAllCategory, getAllTags } from '@/api/question'
|
import { getAllCategory, getAllTags } from '@/api/question'
|
||||||
import { deleteActivity, getActivitys, publishActivity, IActivityData } from '@/api/activity'
|
import { deleteActivity, getActivitys, publishActivity, IActivityData } from '@/api/activity'
|
||||||
import { UserModule } from '@/store/modules/user'
|
import { UserModule } from '@/store/modules/user'
|
||||||
|
import { EVENT_ACTIVITY_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ActivityList',
|
name: 'ActivityList',
|
||||||
@ -201,6 +202,13 @@ export default class extends Vue {
|
|||||||
}
|
}
|
||||||
await this.getRemoteCategory()
|
await this.getRemoteCategory()
|
||||||
await this.getList()
|
await this.getList()
|
||||||
|
EventBus.$on(EVENT_ACTIVITY_UPDATE, () => {
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeDestory() {
|
||||||
|
EventBus.$off(EVENT_ACTIVITY_UPDATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getList() {
|
private async getList() {
|
||||||
|
@ -323,6 +323,7 @@ import { UserModule } from '@/store/modules/user'
|
|||||||
import { defaultRewardData, IRewardData } from '@/api/activity'
|
import { defaultRewardData, IRewardData } from '@/api/activity'
|
||||||
import PuzzleList from './components/PuzzleList.vue'
|
import PuzzleList from './components/PuzzleList.vue'
|
||||||
import UploadCorpImage from '@/components/UploadCorpImage/index.vue'
|
import UploadCorpImage from '@/components/UploadCorpImage/index.vue'
|
||||||
|
import { EVENT_EXAM_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ExamEditor',
|
name: 'ExamEditor',
|
||||||
components: {
|
components: {
|
||||||
@ -472,6 +473,7 @@ export default class extends Vue {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
|
EventBus.$emit(EVENT_EXAM_UPDATE, {})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Submit Error!')
|
console.error('Submit Error!')
|
||||||
return false
|
return false
|
||||||
|
@ -137,6 +137,7 @@ import { parseTime } from '@/utils'
|
|||||||
import { getAllCategory, getAllTags, IQuestionData } from '@/api/question'
|
import { getAllCategory, getAllTags, IQuestionData } from '@/api/question'
|
||||||
import { deleteExam, getExams } from '@/api/exam'
|
import { deleteExam, getExams } from '@/api/exam'
|
||||||
import { UserModule } from '@/store/modules/user'
|
import { UserModule } from '@/store/modules/user'
|
||||||
|
import { EVENT_EXAM_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ExamList',
|
name: 'ExamList',
|
||||||
@ -198,6 +199,13 @@ export default class extends Vue {
|
|||||||
}
|
}
|
||||||
await this.getRemoteCategory()
|
await this.getRemoteCategory()
|
||||||
await this.getList()
|
await this.getList()
|
||||||
|
EventBus.$on(EVENT_EXAM_UPDATE, () => {
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeDestory() {
|
||||||
|
EventBus.$off(EVENT_EXAM_UPDATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getList() {
|
private async getList() {
|
||||||
|
@ -150,6 +150,7 @@ import {
|
|||||||
import { ITagView, TagsViewModule } from '@/store/modules/tags-view'
|
import { ITagView, TagsViewModule } from '@/store/modules/tags-view'
|
||||||
import UploadImage from '@/components/UploadImage/index.vue'
|
import UploadImage from '@/components/UploadImage/index.vue'
|
||||||
import { AppModule } from '@/store/modules/app'
|
import { AppModule } from '@/store/modules/app'
|
||||||
|
import { EVENT_GAME_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'GameEdit',
|
name: 'GameEdit',
|
||||||
@ -249,6 +250,7 @@ export default class extends Vue {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
|
EventBus.$emit(EVENT_GAME_UPDATE, {})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Submit Error!')
|
console.error('Submit Error!')
|
||||||
return false
|
return false
|
||||||
|
@ -100,6 +100,7 @@ import { Component, Vue } from 'vue-property-decorator'
|
|||||||
import Pagination from '@/components/Pagination/index.vue'
|
import Pagination from '@/components/Pagination/index.vue'
|
||||||
import { parseTime } from '@/utils'
|
import { parseTime } from '@/utils'
|
||||||
import { deleteGame, getGames, IGameData } from '@/api/game'
|
import { deleteGame, getGames, IGameData } from '@/api/game'
|
||||||
|
import { EVENT_GAME_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'GameList',
|
name: 'GameList',
|
||||||
@ -145,10 +146,13 @@ export default class extends Vue {
|
|||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.getList()
|
this.getList()
|
||||||
|
EventBus.$on(EVENT_GAME_UPDATE, () => {
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
activated() {
|
beforeDestory() {
|
||||||
this.getList()
|
EventBus.$off(EVENT_GAME_UPDATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getList() {
|
private async getList() {
|
||||||
|
@ -133,6 +133,7 @@ import { getShops } from '@/api/shop'
|
|||||||
import { parseTime } from '@/utils'
|
import { parseTime } from '@/utils'
|
||||||
import { deleteCoupon, getCoupons } from '@/api/coupon'
|
import { deleteCoupon, getCoupons } from '@/api/coupon'
|
||||||
import { UserModule } from '@/store/modules/user'
|
import { UserModule } from '@/store/modules/user'
|
||||||
|
import { EVENT_COUPON_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'CouponList',
|
name: 'CouponList',
|
||||||
@ -191,6 +192,9 @@ export default class extends Vue {
|
|||||||
this.listQuery.shop = UserModule.department
|
this.listQuery.shop = UserModule.department
|
||||||
}
|
}
|
||||||
await this.getList()
|
await this.getList()
|
||||||
|
EventBus.$on(EVENT_COUPON_UPDATE, () => {
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getList() {
|
private async getList() {
|
||||||
@ -202,6 +206,10 @@ export default class extends Vue {
|
|||||||
this.total = data.total
|
this.total = data.total
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeDestory() {
|
||||||
|
EventBus.$off(EVENT_COUPON_UPDATE)
|
||||||
|
}
|
||||||
|
|
||||||
private async handleDelete(scope: any) {
|
private async handleDelete(scope: any) {
|
||||||
const { $index, row } = scope
|
const { $index, row } = scope
|
||||||
await this.$confirm('确认删除该优惠券?', 'Warning', {
|
await this.$confirm('确认删除该优惠券?', 'Warning', {
|
||||||
|
@ -134,6 +134,7 @@ import Tinymce from '@/components/Tinymce/index.vue'
|
|||||||
import { getShops } from '@/api/shop'
|
import { getShops } from '@/api/shop'
|
||||||
import { defaultCouponData, getCoupon, saveCoupon } from '@/api/coupon'
|
import { defaultCouponData, getCoupon, saveCoupon } from '@/api/coupon'
|
||||||
import { UserModule } from '@/store/modules/user'
|
import { UserModule } from '@/store/modules/user'
|
||||||
|
import { EVENT_COUPON_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'CouponEditor',
|
name: 'CouponEditor',
|
||||||
@ -263,6 +264,7 @@ export default class extends Vue {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
|
EventBus.$emit(EVENT_COUPON_UPDATE, {})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Submit Error!')
|
console.error('Submit Error!')
|
||||||
return false
|
return false
|
||||||
|
@ -193,6 +193,7 @@ import {
|
|||||||
saveQuestion,
|
saveQuestion,
|
||||||
saveTag
|
saveTag
|
||||||
} from '@/api/question'
|
} from '@/api/question'
|
||||||
|
import { EVENT_PUZZLE_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'QuestionPrepare',
|
name: 'QuestionPrepare',
|
||||||
@ -346,6 +347,7 @@ export default class extends Vue {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
|
EventBus.$emit(EVENT_PUZZLE_UPDATE, {})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Submit Error!')
|
console.error('Submit Error!')
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
@ -143,6 +143,7 @@ import {
|
|||||||
getQuestions,
|
getQuestions,
|
||||||
IQuestionData
|
IQuestionData
|
||||||
} from '@/api/question'
|
} from '@/api/question'
|
||||||
|
import { EVENT_PUZZLE_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'QuestionList',
|
name: 'QuestionList',
|
||||||
@ -198,6 +199,13 @@ export default class extends Vue {
|
|||||||
this.getList()
|
this.getList()
|
||||||
this.getRemoteTags()
|
this.getRemoteTags()
|
||||||
this.getRemoteCategory()
|
this.getRemoteCategory()
|
||||||
|
EventBus.$on(EVENT_PUZZLE_UPDATE, () => {
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeDestory() {
|
||||||
|
EventBus.$off(EVENT_PUZZLE_UPDATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getList() {
|
private async getList() {
|
||||||
|
@ -160,7 +160,7 @@ import Tinymce from '@/components/Tinymce/index.vue'
|
|||||||
import UploadImage from '@/components/UploadImage/index.vue'
|
import UploadImage from '@/components/UploadImage/index.vue'
|
||||||
import { defaultQuestionData } from '@/api/question'
|
import { defaultQuestionData } from '@/api/question'
|
||||||
import { deleteShopQuestion, getShopQuestion, saveShopQuestion } from '@/api/shoppuzzle'
|
import { deleteShopQuestion, getShopQuestion, saveShopQuestion } from '@/api/shoppuzzle'
|
||||||
import { EventBus } from '@/utils/event-bus'
|
import { EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ShopPuzzleEdit',
|
name: 'ShopPuzzleEdit',
|
||||||
@ -286,7 +286,7 @@ export default class extends Vue {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
EventBus.$emit('shop_puzzles_update', {})
|
EventBus.$emit(EVENT_SHOP_PUZZLES_UPDATE, {})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Submit Error!')
|
console.error('Submit Error!')
|
||||||
this.loading = false
|
this.loading = false
|
||||||
@ -304,7 +304,7 @@ export default class extends Vue {
|
|||||||
})
|
})
|
||||||
await deleteShopQuestion(this.postForm.shop!, this.postForm._id!)
|
await deleteShopQuestion(this.postForm.shop!, this.postForm._id!)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
EventBus.$emit('shop_puzzles_update', {})
|
EventBus.$emit(EVENT_SHOP_PUZZLES_UPDATE, {})
|
||||||
this.$store.dispatch('delView', this.$route)
|
this.$store.dispatch('delView', this.$route)
|
||||||
this.$router.go(-1)
|
this.$router.go(-1)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -157,7 +157,7 @@ import { IQuestionData } from '@/api/question'
|
|||||||
import { UserModule } from '@/store/modules/user'
|
import { UserModule } from '@/store/modules/user'
|
||||||
import { deleteShopQuestion, getShopCategory, getShopQuestions } from '@/api/shoppuzzle'
|
import { deleteShopQuestion, getShopCategory, getShopQuestions } from '@/api/shoppuzzle'
|
||||||
import { IShopData } from '@/api/types'
|
import { IShopData } from '@/api/types'
|
||||||
import { EventBus } from '@/utils/event-bus'
|
import { EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ShopPuzzles',
|
name: 'ShopPuzzles',
|
||||||
@ -223,13 +223,13 @@ export default class extends Vue {
|
|||||||
await this.getList()
|
await this.getList()
|
||||||
}
|
}
|
||||||
// this.getList()
|
// this.getList()
|
||||||
EventBus.$on('shop_puzzles_update', () => {
|
EventBus.$on(EVENT_SHOP_PUZZLES_UPDATE, () => {
|
||||||
this.getList()
|
this.getList()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeDestory() {
|
beforeDestory() {
|
||||||
EventBus.$off('shop_puzzles_update')
|
EventBus.$off(EVENT_SHOP_PUZZLES_UPDATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getList() {
|
private async getList() {
|
||||||
|
@ -122,6 +122,7 @@ import RegionPicker from '@/components/RegionPicker/index.vue'
|
|||||||
import { defaultShopData, getShop, saveShop } from '@/api/shop'
|
import { defaultShopData, getShop, saveShop } from '@/api/shop'
|
||||||
import { addressToLoc, IAreaData, queryArea } from '@/api/map'
|
import { addressToLoc, IAreaData, queryArea } from '@/api/map'
|
||||||
import i18n from '@/lang'
|
import i18n from '@/lang'
|
||||||
|
import { EVENT_SHOP_PUZZLES_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ShopEditor',
|
name: 'ShopEditor',
|
||||||
@ -219,6 +220,7 @@ export default class extends Vue {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
|
EventBus.$emit(EVENT_SHOP_UPDATE, {})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Submit Error!')
|
console.error('Submit Error!')
|
||||||
return false
|
return false
|
||||||
|
@ -151,6 +151,7 @@ import Pagination from '@/components/Pagination/index.vue'
|
|||||||
import { deleteShop, getShops, updateShopPublish } from '@/api/shop'
|
import { deleteShop, getShops, updateShopPublish } from '@/api/shop'
|
||||||
import { parseTime } from '@/utils'
|
import { parseTime } from '@/utils'
|
||||||
import i18n from '@/lang'
|
import i18n from '@/lang'
|
||||||
|
import { EVENT_SHOP_PUZZLES_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ShopList',
|
name: 'ShopList',
|
||||||
@ -186,10 +187,13 @@ export default class extends Vue {
|
|||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.getList()
|
this.getList()
|
||||||
|
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
activated() {
|
beforeDestory() {
|
||||||
this.getList()
|
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getList() {
|
private async getList() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user