app.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div class="hc-app-body h-full w-full">
  3. <img class="bg-img h-full w-full" :src="bgImg" alt="">
  4. <div class="app-body h-full w-full">
  5. <div class="app-company-name hc-flex-center">
  6. <img :src="companyName" alt="">
  7. </div>
  8. <div class="app-title">
  9. <div class="icon-box hc-flex-center">
  10. <img :src="appIcon" alt="">
  11. </div>
  12. <div class="title-box">
  13. <div class="name">工程云家</div>
  14. <div class="version">当前版本:{{androidInfo.versionNumber}}</div>
  15. <div class="time">更新时间:{{androidInfo.updateTime}}</div>
  16. </div>
  17. </div>
  18. <div class="app-tip">苹果手机或微信等,请点击右上角,在浏览器中打开此页面。(尽量在浏览器中打开此页,否则可能会无法下载)</div>
  19. <div class="app-btn">
  20. <template v-if="isPcType === 'pc'">
  21. <el-button type="success" @click="downloadAndroid">
  22. <i class="i-ic-baseline-android"/>
  23. <span class="ml-1">下载安卓APP</span>
  24. </el-button>
  25. <el-button type="success" @click="downloadApple">
  26. <i class="i-ic-baseline-apple"/>
  27. <span class="ml-1">下载苹果APP</span>
  28. </el-button>
  29. </template>
  30. <el-row :gutter="20" v-if="isPcType === 'mobile'">
  31. <el-col :span="12">
  32. <el-button type="success" @click="downloadAndroid">
  33. <i class="i-ic-baseline-android"/>
  34. <span class="ml-1">下载安卓APP</span>
  35. </el-button>
  36. </el-col>
  37. <el-col :span="12">
  38. <el-button type="success" @click="downloadApple">
  39. <i class="i-ic-baseline-apple"/>
  40. <span class="ml-1">下载苹果APP</span>
  41. </el-button>
  42. </el-col>
  43. </el-row>
  44. </div>
  45. <div class="h-100px" v-if="isPcType === 'mobile'"/>
  46. </div>
  47. </div>
  48. </template>
  49. <script setup>
  50. import {onMounted, onUnmounted, ref} from "vue";
  51. import {getNewVersion} from "~src/request/index";
  52. import bgImg from '~src/assets/archives/topHead.png'
  53. import companyName from '~src/assets/index/companyName.png'
  54. import appIcon from '~src/assets/index/app-icon.png'
  55. import {getObjValue, isNullES, newWindow} from "js-fast-way";
  56. import { ElMessage } from 'element-plus'
  57. //渲染完成
  58. const isPcType = ref('mobile')
  59. onMounted(() => {
  60. const dom = document.documentElement
  61. isPcType.value = `${dom.offsetWidth > 700 ?'pc':'mobile'}`
  62. dom.setAttribute('class', `${dom.offsetWidth > 700 ?'hc-app-pc':'hc-app-mobile'}`)
  63. getApiData()
  64. })
  65. //获取接口数据
  66. const androidInfo = ref({})
  67. const appleInfo = ref({})
  68. const getApiData = async () => {
  69. androidInfo.value = await getAppInfo(1) //安卓
  70. appleInfo.value = await getAppInfo(2) //ios
  71. }
  72. //获取APP数据
  73. const getAppInfo = async (type) => {
  74. const { data } = await getNewVersion({
  75. softwareType: type,
  76. fileType: 0,
  77. platform: 'client',
  78. })
  79. return getObjValue(data)
  80. }
  81. //下载安卓APP
  82. const downloadAndroid = () => {
  83. const info = androidInfo.value
  84. if (isNullES(info.fileUrl)) {
  85. ElMessage.warning('系统维护中,请稍后再试')
  86. return
  87. }
  88. newWindow(info.fileUrl)
  89. }
  90. //下载苹果APP
  91. const downloadApple = () => {
  92. const info = appleInfo.value
  93. if (isNullES(info.fileUrl)) {
  94. ElMessage.warning('系统维护中,请稍后再试')
  95. return
  96. }
  97. newWindow(info.fileUrl)
  98. }
  99. //页面卸载
  100. onUnmounted(() => {
  101. document.documentElement.removeAttribute('class')
  102. })
  103. </script>
  104. <style lang="scss">
  105. html.hc-app-mobile,
  106. html.hc-app-mobile body,
  107. html.hc-app-mobile body #app {
  108. position: relative;
  109. padding: 0;
  110. margin: 0;
  111. width: 100%;
  112. height: 100%;
  113. }
  114. .hc-app-body {
  115. position: relative;
  116. .bg-img {
  117. position: fixed;
  118. inset: 0;
  119. object-fit: cover;
  120. }
  121. .app-body {
  122. position: relative;
  123. .app-company-name {
  124. position: relative;
  125. padding: 20px;
  126. height: 30px;
  127. img {
  128. height: 100%;
  129. }
  130. }
  131. .app-tip {
  132. position: relative;
  133. padding: 0 20px;
  134. color: white;
  135. font-size: 14px;
  136. }
  137. .app-title {
  138. position: relative;
  139. padding: 0 20px;
  140. color: white;
  141. display: flex;
  142. .icon-box {
  143. position: relative;
  144. width: 80px;
  145. img {
  146. width: 100%;
  147. }
  148. }
  149. .title-box {
  150. position: relative;
  151. width: calc(100% - 80px);
  152. padding-left: 14px;
  153. font-size: 13px;
  154. .name {
  155. font-size: 18px;
  156. margin-top: 6px;
  157. margin-bottom: 2px;
  158. }
  159. }
  160. }
  161. .app-btn {
  162. position: relative;
  163. padding: 24px;
  164. overflow: hidden;
  165. .el-button {
  166. width: 100%;
  167. height: 40px;
  168. font-size: 16px;
  169. i {
  170. font-size: 18px;
  171. }
  172. }
  173. }
  174. }
  175. }
  176. .hc-app-pc .hc-app-body .app-body {
  177. width: 350px;
  178. margin: auto;
  179. .app-title {
  180. margin-top: 40%;
  181. }
  182. .app-btn {
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. .el-button {
  187. width: auto;
  188. }
  189. .el-button + .el-button {
  190. margin-left: 24px;
  191. }
  192. }
  193. }
  194. </style>