mirror of
https://github.com/caojiezi2003/clock-shop.git
synced 2024-11-23 15:49:46 +00:00
add radom btn
add radom btn
This commit is contained in:
parent
1854bf23f8
commit
32bf0cfa90
1
source/.gitignore
vendored
1
source/.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
|
package-lock.json
|
||||||
/dist
|
/dist
|
||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
|
@ -9,16 +9,17 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ppo from 'ppo';
|
import ppo from 'ppo';
|
||||||
import Vue from 'vue';
|
import EventBus from '../utils/eventbus';
|
||||||
const bus = new Vue();
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Btn',
|
name: 'Btn',
|
||||||
props: ['active'],
|
props: ['active', 'index'],
|
||||||
created: function () {
|
created: function () {
|
||||||
bus.$on('BTN_CLICK', id => {
|
EventBus.$on('BTN_CLICK', index => {
|
||||||
if (id !== this.id) {
|
if (index !== this.index) {
|
||||||
this.isActive = false;
|
this.isActive = false;
|
||||||
|
}else{
|
||||||
|
this.isActive = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
click() {
|
click() {
|
||||||
this.isActive = true;
|
this.isActive = true;
|
||||||
bus.$emit('BTN_CLICK', this.id);
|
//EventBus.$emit('BTN_CLICK', this.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<ul id="portfolio-flters">
|
<ul id="portfolio-flters">
|
||||||
<Btn @click.native="tabClick(0)" active=true>Beautiful Style</Btn>
|
<Btn v-for="btn in btns" :key="btn.index" :index="btn.index"
|
||||||
<Btn @click.native="tabClick(1)">Creative Design</Btn>
|
@click.native="tabClick(btn.index)">
|
||||||
<Btn @click.native="tabClick(2)">Electronic Clock</Btn>
|
{{ btn.text }}
|
||||||
|
</Btn>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -40,9 +41,18 @@
|
|||||||
<script>
|
<script>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import Btn from './Btn.vue'
|
import Btn from './Btn.vue';
|
||||||
|
import EventBus from '../utils/eventbus';
|
||||||
|
import { arrShuffle } from '../utils/util';
|
||||||
|
|
||||||
const PAGES = 9;
|
const PAGES = 6;
|
||||||
|
|
||||||
|
let BTNS = [
|
||||||
|
{ index: 0, text: "Beautiful Style" },
|
||||||
|
{ index: 1, text: "Creative Design" },
|
||||||
|
{ index: 2, text: "Electronic Clock" }];
|
||||||
|
|
||||||
|
BTNS = arrShuffle(BTNS);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Content',
|
name: 'Content',
|
||||||
@ -51,9 +61,10 @@ export default {
|
|||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
currentTab: 0,
|
currentTab: BTNS[0].index,
|
||||||
pageNum: 0,
|
pageNum: 0,
|
||||||
data: [],
|
data: [],
|
||||||
|
btns: BTNS,
|
||||||
get items() {
|
get items() {
|
||||||
const frist = this.pageNum * PAGES;
|
const frist = this.pageNum * PAGES;
|
||||||
const num = frist + PAGES;
|
const num = frist + PAGES;
|
||||||
@ -61,6 +72,7 @@ export default {
|
|||||||
return this.allItems ? this.allItems.slice(frist, num) : null;
|
return this.allItems ? this.allItems.slice(frist, num) : null;
|
||||||
},
|
},
|
||||||
get allItems() {
|
get allItems() {
|
||||||
|
EventBus.$emit('BTN_CLICK', this.currentTab);
|
||||||
return this.data[this.currentTab] || []
|
return this.data[this.currentTab] || []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div style="visibility: visible; animation-name: zoomIn;" class="col-md-12 text-center wow zoomIn">
|
<div style="visibility: visible; animation-name: zoomIn;" class="col-md-12 text-center wow zoomIn">
|
||||||
<div class="footer_copyright">
|
<div class="footer_copyright">
|
||||||
<p> © Copyright, a-jie All Rights Reserved.</p>
|
<p> © Copyright, anonymous All Rights Reserved.</p>
|
||||||
<div class="credits">
|
<div class="credits">
|
||||||
WebSite designed by <a href="https://bootstrapmade.com/">BootstrapMade.com</a>
|
WebSite designed by <a href="https://bootstrapmade.com/">BootstrapMade.com</a>
|
||||||
</div>
|
</div>
|
||||||
|
4
source/src/utils/eventbus.js
Normal file
4
source/src/utils/eventbus.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import Vue from 'vue';
|
||||||
|
const EventBus = new Vue();
|
||||||
|
|
||||||
|
export default EventBus;
|
15
source/src/utils/util.js
Normal file
15
source/src/utils/util.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
const arrShuffle = (arr) => {
|
||||||
|
let len = arr.length;
|
||||||
|
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
let end = len - 1;
|
||||||
|
let index = (Math.random() * (end + 1)) >> 0;
|
||||||
|
let t = arr[end];
|
||||||
|
arr[end] = arr[index];
|
||||||
|
arr[index] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { arrShuffle };
|
Loading…
Reference in New Issue
Block a user