useimg.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div class="img-layout" :class="{agreement:$route.params.name==='agreement'}">
  3. <img :src="images" alt="">
  4. <!-- <img v-if="$route.params.name==='agreement'" :src="`${$cdn}images/agreement/eight/${language === 'en' ? 'en' : 'zh'}/2-more.jpg`" alt=""> -->
  5. </div>
  6. </template>
  7. <script>
  8. import data from './temp/config'
  9. import {mapState} from 'vuex'
  10. let current = {
  11. 0: 'eight',
  12. 1: 'binocular'
  13. }
  14. export default {
  15. data () {
  16. return {
  17. }
  18. },
  19. computed: {
  20. ...mapState({
  21. language: state => state.language.current
  22. }),
  23. images () {
  24. let use = parseInt(this.$route.params.type) === 0 ? data.use.data.pro : data.use.data.lite
  25. let name = this.$route.params.name
  26. let img = ''
  27. for (let i = 0; i < use.length; i++) {
  28. let item = use[i]
  29. if (!item.sub) {
  30. console.log(item.img)
  31. if (parseInt(item.img) === parseInt(this.$route.params.id)) {
  32. img = this.$cdn + `images/${name}/${current[this.$route.params.type]}/${this.language === 'en' ? 'en' : 'zh'}/${this.$route.params.id}.jpg`
  33. return img
  34. }
  35. }
  36. if (item.sub) {
  37. for (let j = 0; j < item.sub.length; j++) {
  38. let sub = item.sub[j]
  39. if (parseInt(sub.img) === parseInt(this.$route.params.id)) {
  40. img = this.$cdn + `images/${name}/${current[this.$route.params.type]}/${this.language === 'en' ? 'en' : 'zh'}/${sub.img}.jpg`
  41. return img
  42. }
  43. }
  44. }
  45. }
  46. return img
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .img-layout{
  53. width: 100%;
  54. background-color: #fff;
  55. min-height: 400px;
  56. img{
  57. margin: 30px 0;
  58. width:100%;
  59. }
  60. }
  61. .agreement{
  62. img{
  63. margin: 0;
  64. }
  65. }
  66. </style>