preview.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <previewWrapper :pageId="pageId" @closePreview="closePreview" v-loading="loading">
  3. <p class="page-title paddingL30">
  4. 页面预览
  5. <el-button style="margin-left: 16px" icon="el-icon-document-copy" size="small" type="primary" round @click="doCopyAll">一键复制所有平台链接</el-button>
  6. </p>
  7. <div class="preview-info-wrapper" v-if="!loading">
  8. <el-form label-width="90px" label-position="left">
  9. <el-form-item v-for="(item, index) in pageLinkMap" :key="index" :label="item.label + ':'">
  10. <div class="preview-url-item">
  11. <span class="preview-url-desc">{{ item.desc }}</span>
  12. <br>
  13. <div class="preview-url-item--content">
  14. <div>
  15. <QrcodeVue :value="item.domain" :size="120" level="H"></QrcodeVue>
  16. <a class="share-wx-config-wrapper" target="_blank" :href="item.domain">{{item.domain}}</a>
  17. </div>
  18. <el-button icon="el-icon-document-copy" type="primary" size="mini" round @click="doCopy(item.domain)">复制链接</el-button>
  19. </div>
  20. </div>
  21. </el-form-item>
  22. <!--页面效果-->
  23. <el-form-item label="页面状态:">
  24. <span :class="[pageData.isPublish ? 'primary' : 'orange']">{{pageData.isPublish ? '已发布' : '未发布'}}</span>
  25. </el-form-item>
  26. </el-form>
  27. <div class="page-info">
  28. <div class="page-cover">
  29. <img :src="shareData.coverImage || defaultCoverImage" alt="">
  30. </div>
  31. <div class="page-title-des paddingT10">
  32. <div class="info-form-wrapper">
  33. {{shareData.title}}
  34. </div>
  35. <div class="info-form-wrapper ellipsis">
  36. {{shareData.description}}
  37. </div>
  38. </div>
  39. </div>
  40. <!-- <div class="clearfix paddingT30 text-center">-->
  41. <!-- <a :href="pageLink" target="_blank">-->
  42. <!-- <el-button type="primary">新标签打开链接</el-button>-->
  43. <!-- </a>-->
  44. <!-- </div>-->
  45. </div>
  46. </previewWrapper>
  47. </template>
  48. <script>
  49. import previewWrapper from '@client/components/preview-wrapper'
  50. import QrcodeVue from 'qrcode.vue'
  51. export default {
  52. components: {
  53. previewWrapper,
  54. QrcodeVue
  55. },
  56. props: {
  57. pageId: String
  58. },
  59. data() {
  60. return {
  61. loading: true,
  62. defaultCoverImage: require('@client/common/images/pagecover-image.png'),
  63. pageData: {}
  64. }
  65. },
  66. created(){
  67. this.getData()
  68. },
  69. computed: {
  70. pageLinkMap () {
  71. return [
  72. {
  73. label: '主域名',
  74. desc: '用于PC端页面使用',
  75. domain: 'https://www.jianyu360.cn/h5-pages/' + this.pageId
  76. },
  77. {
  78. label: '微信域名',
  79. desc: '用于手机微信端页面',
  80. domain: 'https://wx.jianyu360.cn/h5-pages/' + this.pageId
  81. },
  82. {
  83. label: 'H5',
  84. desc: '用于手机H5端页面',
  85. domain: 'https://h5.jianyu360.cn/jyapp/view/' + this.pageId
  86. },
  87. {
  88. label: 'APP端',
  89. desc: '用于APP端页面(常用与广告位无需配置域名)',
  90. domain: '/jyapp/view/' + this.pageId
  91. },
  92. {
  93. label: '开发测试',
  94. desc: '用于开发测试环节预览使用的地址',
  95. domain: this.$config.baseURL + (this.pageData.isPublish ? '/view/': '/in-preview/') + this.pageId
  96. }
  97. ]
  98. },
  99. shareData(){
  100. if(!this.pageData.shareConfig){
  101. return {}
  102. }
  103. if(this.pageData.shareConfig.shareWx){
  104. return {
  105. coverImage: this.pageData.shareConfig.coverImage,
  106. title: this.pageData.shareConfig.title,
  107. description: this.pageData.shareConfig.description,
  108. }
  109. }else{
  110. return {
  111. coverImage: this.pageData.coverImage,
  112. title: this.pageData.title,
  113. description: this.pageData.description,
  114. }
  115. }
  116. }
  117. },
  118. methods: {
  119. /**
  120. * 关闭弹窗事件
  121. */
  122. closePreview() {
  123. this.$emit('closePreview', false);
  124. },
  125. getData(){
  126. this.loading = true;
  127. this.$API.getPageDetail({pageId: this.pageId}).then(res => {
  128. this.loading = false;
  129. this.pageData = res.body;
  130. }).catch(() => {
  131. this.loading = false;
  132. })
  133. },
  134. doCopyAll: function () {
  135. const content = this.pageLinkMap.map(item => `${item.label}: ${item.domain}`).join('\n\n')
  136. this.$copyText(content).then(() => {
  137. this.$message.success('已复制所有平台链接')
  138. })
  139. },
  140. doCopy: function (url) {
  141. this.$copyText(url).then(() => {
  142. this.$message.success('已复制')
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. .preview-info-wrapper {
  150. padding: 30px 30px 60px;
  151. font-size: 16px;
  152. }
  153. .page-info {
  154. display: flex;
  155. padding: 12px;
  156. background-color: #f0f3f4;
  157. .page-cover {
  158. width: 80px;
  159. height: 80px;
  160. overflow: hidden;
  161. }
  162. .page-title-des {
  163. padding-left: 20px;
  164. flex: 1;
  165. overflow: hidden;
  166. }
  167. }
  168. .info-form-wrapper {
  169. display: flex;
  170. padding-bottom: 16px;
  171. .info-form-l {
  172. line-height: 42px;
  173. &.com-width {
  174. width: 120px;
  175. }
  176. }
  177. .info-form-r {
  178. flex: 1;
  179. padding-left: 10px;
  180. }
  181. }
  182. .share-wx-config-wrapper {
  183. margin-top: 14px;
  184. margin-right: 12px;
  185. display: block;
  186. padding: 10px 8px;
  187. background-color: #f0f3f4;
  188. }
  189. .preview-url-list {
  190. display: flex;
  191. flex-direction: column;
  192. .preview-url-item {
  193. display: flex;
  194. flex-direction: column;
  195. .preview-url-label {}
  196. .preview-url-desc {}
  197. .preview-url-item--content {
  198. display: flex;
  199. flex-direction: row;
  200. align-items: center;
  201. justify-content: center;
  202. }
  203. }
  204. }
  205. </style>