index.ux 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div class="short-wrap">
  3. <div class="short-content" @click="createShortcut">
  4. <image src="../../assets/imgs/sign_banner.png"></image>
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import shortcut from '@system.shortcut'
  10. import prompt from '@system.prompt'
  11. import { userAddDsktop } from '../../api/index.js'
  12. export default {
  13. data: {},
  14. onInit() {},
  15. createShortcut() {
  16. // 创建快捷方式
  17. shortcut.hasInstalled({
  18. success: ret => {
  19. if (!ret) {
  20. shortcut.install({
  21. message: '添加【海天阅读】到桌面,方便下次阅读',
  22. success: () => {
  23. this.$emit('addshort', { installed: true })
  24. if (this.$app.$def.data.backClickCount === 0) {
  25. this.$app.$def.data.backClickCount++
  26. return true
  27. }
  28. userAddDsktop(1)
  29. .then(res => {
  30. //TODO 加桌后统计上报
  31. })
  32. .catch(r => {
  33. //TODO 失败后统计上报
  34. })
  35. },
  36. fail: code => {
  37. console.log(code)
  38. this.$emit('addshort', { installed: false, msg: code })
  39. }
  40. })
  41. }
  42. }
  43. })
  44. }
  45. }
  46. </script>
  47. <style lang="less" scoped>
  48. .short {
  49. &-wrap {
  50. position: fixed;
  51. bottom: 190px;
  52. height: 148px;
  53. z-index: 60;
  54. justify-content: center;
  55. width: 100%;
  56. opacity: 0.95;
  57. }
  58. &-content {
  59. width: 678px;
  60. height: 152px;
  61. align-items: center;
  62. justify-content: center;
  63. opacity: 0.95;
  64. image {
  65. width: 678px;
  66. height: 152px;
  67. }
  68. }
  69. &-left {
  70. color: #fff;
  71. font-size: 28px;
  72. font-weight: bold;
  73. text-align: center;
  74. background-color: #ff453c;
  75. width: 444px;
  76. height: 80px;
  77. border-top-left-radius: 40px;
  78. border-bottom-left-radius: 40px;
  79. opacity: 0.95;
  80. }
  81. &-right {
  82. text-align: center;
  83. font-weight: bold;
  84. font-size: 28px;
  85. background-color: #ffb540;
  86. width: 206px;
  87. height: 80px;
  88. border-top-right-radius: 40px;
  89. border-bottom-right-radius: 40px;
  90. opacity: 0.95;
  91. }
  92. }
  93. </style>