uni-portal.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="uni-container">
  3. <!-- <h2 class="text-separated" style="padding-bottom: 40rpx;">统一发布页管理</h2> -->
  4. <h3 class="text-separated" style="padding: 0 0 20rpx 0;">步骤1:了解“统一发布页”</h3>
  5. <view style="margin-top: 20rpx;">
  6. <view class="text-separated">
  7. <text class="strong">uni-portal </text>
  8. <text>是 uni-app 提供的一套开箱即用的“统一发布页”。</text>
  9. </view>
  10. <view class="text-separated">
  11. <text class="strong">uni-portal </text>
  12. <text>可作为面向用户的统一业务名片,在一个页面集中展现:App下载地址、小程序二维码、H5访问链接等信息。</text>
  13. </view>
  14. <!-- #ifdef H5 -->
  15. <view class="text-separated">
  16. <text style="font-size: 16px;">uni-app 官方示例的发布页就是基于<text class="strong">uni-portal </text> 制作的,<a
  17. href="https://hellouniapp.dcloud.net.cn/portal" target="_blank" class="a-label">点击体验</a>
  18. </text>
  19. </view>
  20. <!-- #endif -->
  21. </view>
  22. <h3 class="text-separated" style="padding: 40rpx 0 20rpx 0;">步骤2:获取“统一发布页”</h3>
  23. <view class="flex text-separated" style="margin-top: 20rpx;">
  24. <text>
  25. <view class="strong">uni-portal </view> 可根据「应用管理」中所填写的应用信息,一键生成发布页:
  26. </text>
  27. <button class="custom-button" size="mini" type="primary" @click="publish"
  28. style="margin: 0;">生成并下载发布页</button>
  29. </view>
  30. <h3 class="text-separated" style="padding: 40rpx 0 20rpx 0;">步骤3:上传“统一发布页”</h3>
  31. <view style="margin-top: 20rpx;">
  32. <view class="text-separated">
  33. <text>
  34. 步骤2下载的“统一发布页”,是一个静态HTML页面,你可以直接在本地浏览器中打开访问。
  35. </text>
  36. </view>
  37. <view class="text-separated">
  38. <text>
  39. 为了让用户访问到这个“统一发布页”,你需要将该静态HTML文件上传到你的服务器中;推荐使用<a href="https://uniapp.dcloud.io/uniCloud/hosting"
  40. target="_blank" class="a-label" style="padding: 5px;">前端网页托管</a>,因为前端网页托管具备使用更简单、价格更便宜、访问更快等优点。
  41. </text>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. var download = function(content, filename) {
  48. var eleLink = document.createElement('a');
  49. eleLink.download = filename;
  50. eleLink.style.display = 'none';
  51. var blob = new Blob([content]);
  52. eleLink.href = URL.createObjectURL(blob);
  53. document.body.appendChild(eleLink);
  54. eleLink.click();
  55. document.body.removeChild(eleLink);
  56. };
  57. export default {
  58. data() {
  59. return {
  60. id: ''
  61. }
  62. },
  63. onLoad({
  64. id
  65. }) {
  66. this.id = id
  67. },
  68. methods: {
  69. publish() {
  70. if (!this.id) {
  71. uni.showModal({
  72. content: '页面出错,请返回重进',
  73. showCancel: false,
  74. success(res) {
  75. uni.redirectTo({
  76. url: '/pages/system/app/list'
  77. })
  78. }
  79. })
  80. return
  81. }
  82. this.$request('createPublishHtml', {
  83. id: this.id
  84. }, {
  85. functionName: 'uni-portal',
  86. showModal: false
  87. }).then(res => {
  88. // #ifdef H5
  89. if ('download' in document.createElement('a')) {
  90. download(res.body, 'index.html');
  91. } else {
  92. uni.showToast({
  93. icon: 'error',
  94. title: '浏览器不支持',
  95. duration: 800
  96. })
  97. }
  98. // #endif
  99. }).catch((res) => {
  100. uni.showModal({
  101. content: res.errMsg,
  102. showCancel: false
  103. })
  104. })
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. .strong {
  111. padding: 10rpx;
  112. display: inline-block;
  113. color: #c7254e;
  114. }
  115. .a-label {
  116. text-decoration: none;
  117. color: #0366d6;
  118. font-weight: bold;
  119. padding: 10rpx;
  120. }
  121. .text-separated {
  122. line-height: 2em;
  123. color: #2c3e50;
  124. }
  125. .tip {
  126. display: flex;
  127. flex-direction: column;
  128. align-items: flex-start;
  129. background-color: #f3f5f7;
  130. color: #2c3e50;
  131. padding: 10px;
  132. font-size: 32rpx;
  133. border: {
  134. color: #409EFF;
  135. left-width: 8px;
  136. left-style: solid;
  137. }
  138. text {
  139. margin-right: 15px;
  140. }
  141. .custom-button {
  142. margin-left: 0px;
  143. }
  144. }
  145. </style>