SoftwareDetail.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div class="software-detail" v-loading="loading">
  3. <div class="pt-3" style="padding-left: 2.5%">
  4. <div class="media">
  5. <img class="mr-3" :src="items.src" width="50" height="50" :alt="items.title">
  6. <div class="media-body">
  7. <h5 class="mt-0 mb-1">{{ items.title }}</h5>
  8. {{ items.productName }}
  9. </div>
  10. </div>
  11. </div>
  12. <div class="pt-3">
  13. <el-tabs v-model="activeName" type="card" @tab-click="checkOnline">
  14. <el-tab-pane class="pl-3 software-content" name="first">
  15. <span slot="label" class="detail-title"><span class="iconbg iconbg-purple rounded"><i class="fas fa-download"></i></span>下载软件</span>
  16. <div class="details" v-for="down in downlist">
  17. <div class="float-right">
  18. <button @click="downloadSoftware(down.down_id, down.version)" class="btn btn-white btn-sm"><i class="fas fa-download mr-2"></i>下载</button>
  19. </div>
  20. <h5 class="w-25 d-inline-block">{{ down.title }}</h5>
  21. <div class="w-50 d-inline-block"><span v-if="down.key_number !== ''">锁号:{{ down.key_number }}</span></div>
  22. </div>
  23. </el-tab-pane>
  24. <el-tab-pane class="pl-3 software-content" name="second" v-html="items.content">
  25. <span slot="label" class="detail-title"><span class="iconbg iconbg-green rounded"><i class="fas fa-info"></i></span>软件详情</span>
  26. </el-tab-pane>
  27. <el-tab-pane class="pl-3 software-content" name="third">
  28. <span slot="label" class="detail-title"><span class="iconbg iconbg-yellow rounded"><i class="fas fa-video"></i></span>动画教程</span>
  29. <h1 class="vide-title" v-if="video1.length > 0">专属教程</h1>
  30. <div class="row" v-if="video1.length > 0">
  31. <div class="col-auto mb-4" v-for="video in video1" :key="video.aid">
  32. <div class="card card-width">
  33. <img class="card-img-top" :src="SmartCostUrl+video.img_url" :alt="video.title">
  34. <div class="card-body p-3">
  35. <button class="btn btn-success btn-block btn-sm" @click="showVideo(video.aid)"><i class="fas fa-play-circle pr-1"></i>播放</button>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <h1 class="vide-title">通用教程</h1>
  41. <div class="row">
  42. <div class="col-auto mb-4" v-for="video in video2" :key="video.aid">
  43. <div class="card card-width">
  44. <img class="card-img-top" :src="SmartCostUrl+video.img_url" :alt="video.title">
  45. <div class="card-body p-3">
  46. <button class="btn btn-success btn-block btn-sm" @click="showVideo(video.aid)"><i class="fas fa-play-circle pr-1"></i>播放</button>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </el-tab-pane>
  52. </el-tabs>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import mixin from '../mixin'
  58. const fs = require('fs-extra')
  59. const path = require('path')
  60. export default {
  61. mixins: [mixin],
  62. data () {
  63. return {
  64. activeName: 'first',
  65. loading: false,
  66. items: '',
  67. downlist: '',
  68. SmartCostUrl: 'https://smartcost.com.cn',
  69. video1: '',
  70. video2: ''
  71. }
  72. },
  73. created () {
  74. this.fetchData()
  75. },
  76. watch: {
  77. 'activeName': function (val) {
  78. if (val === 'second') {
  79. if (!this.checkOnline()) {
  80. this.$message.error('当前网络不可用,图片信息将无法加载')
  81. }
  82. } else if (val === 'third') {
  83. if (!this.checkOnline()) {
  84. this.$message.error('当前网络不可用,无法获取视频信息')
  85. } else {
  86. let productid = this.$route.params.pid
  87. let self2 = this
  88. this.$http({
  89. url: this.SmartCostUrl + '/animation/list?pid=' + productid,
  90. method: 'get',
  91. timeout: 5000
  92. }).then(function (response) {
  93. if (response.data.err === 0) {
  94. self2.video1 = response.data.info.list1
  95. self2.video2 = response.data.info.list2
  96. } else {
  97. this.$message.error(response.data.msg)
  98. }
  99. }).catch(function (error2) {
  100. throw error2
  101. })
  102. }
  103. }
  104. }
  105. },
  106. methods: {
  107. fetchData () {
  108. this.loading = true
  109. let softwarejson = path.join('data/sc_software.json')
  110. let softwarelist = fs.readJsonSync(softwarejson).sc_product
  111. let pid = this.$route.params.pid
  112. let loadings = true
  113. let items = softwarelist.find(function (item) {
  114. if (item.product_id === pid) {
  115. loadings = false
  116. }
  117. return item.product_id === pid
  118. })
  119. this.items = items
  120. let downlist = fs.readJsonSync(softwarejson).sc_down
  121. let newdownlist = downlist.filter(function (item) {
  122. return item.product_id === pid
  123. })
  124. this.downlist = newdownlist
  125. this.loading = loadings
  126. },
  127. downloadSoftware (downID, version) {
  128. // 先判断是否已在下载列表中,再加入列表中
  129. let downloaditem = this.$db.read().get('sc_download').find({ down_id: downID, version: version, delete: false }).value()
  130. if (!downloaditem) {
  131. this.$emit('softwareDownload', downID)
  132. } else {
  133. let info = this.downlist.find(function (item) {
  134. return item.down_id === downID
  135. })
  136. this.$message({
  137. showClose: true,
  138. message: info.fulltitle + '已存在下载列中',
  139. iconClass: '',
  140. type: 'warning'
  141. })
  142. }
  143. },
  144. checkOnline () {
  145. if (!navigator.onLine) {
  146. return false
  147. } else {
  148. return true
  149. }
  150. },
  151. showVideo (id) {
  152. let url = this.SmartCostUrl + '/video/' + id
  153. this.$electron.shell.openItem(url)
  154. }
  155. }
  156. }
  157. /**
  158. * 原生方法打开v-html引入a标签的点击事件
  159. * @type {Electron}
  160. */
  161. const electron = require('electron')
  162. window.openURL = function (url) {
  163. electron.shell.openExternal(url)
  164. }
  165. </script>