share.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <script lang="ts">
  2. import Vue from 'vue'
  3. import vueQr from 'vue-qr'
  4. import { getExpoList, getMyExpoInfo } from '@/api/expo'
  5. export default Vue.extend({
  6. name: 'Share',
  7. components: {
  8. vueQr
  9. },
  10. data() {
  11. return {
  12. rootPath: window.location.origin,
  13. shareType: 'link',
  14. currentExpo: {},
  15. renderData: {},
  16. shareData: {
  17. qrLogo: '',
  18. qrLogoSize: 2,
  19. qrLogoName: '',
  20. qrImage: ''
  21. },
  22. expoId: '',
  23. expoList: []
  24. }
  25. },
  26. mounted() {
  27. this.getExpoList()
  28. this.init()
  29. },
  30. methods: {
  31. init() {
  32. if (this.$route.query.id) {
  33. this.expoId = this.$route.query.id - 0
  34. this.getExpo()
  35. }
  36. },
  37. getExpoList() {
  38. getExpoList(1, 1000).then(res => {
  39. this.expoList = res.data.data
  40. }).catch(err => {
  41. this.$notify({
  42. title: '提示',
  43. message: '获取展会列表失败' + err,
  44. type: 'error'
  45. })
  46. })
  47. },
  48. initRenderData() {
  49. this.renderData = {
  50. title: this.currentExpo.expo_name,
  51. sub_title: '请编辑副标题',
  52. phone: this.currentExpo.contact_phone || '请编辑电话',
  53. address: this.currentExpo.location || '请编辑地址'
  54. }
  55. },
  56. getExpo() {
  57. getMyExpoInfo(this.expoId).then(res => {
  58. this.currentExpo = res.data
  59. this.initRenderData()
  60. }).catch(err => {
  61. this.$notify({
  62. title: '提示',
  63. message: '获取展会信息失败' + err,
  64. type: 'error'
  65. })
  66. })
  67. },
  68. copyText(text) {
  69. navigator.clipboard.writeText(text)
  70. this.$notify({
  71. title: '提示',
  72. message: '复制成功',
  73. type: 'success'
  74. })
  75. },
  76. qrImageReady(e) {
  77. this.shareData.qrImage = e
  78. },
  79. downloadQrImage() {
  80. const a = document.createElement('a')
  81. a.href = this.shareData.qrImage
  82. a.download = '二维码.png'
  83. a.click()
  84. },
  85. setQrLogo(file) {
  86. this.shareData.qrLogoName = file.name
  87. this.shareData.qrLogo = URL.createObjectURL(file)
  88. },
  89. goto(url) {
  90. window.open(url, '_blank')
  91. }
  92. }
  93. })
  94. </script>
  95. <template>
  96. <div class="share-center">
  97. <div class="share-type">
  98. <div class="sub-title">分享展会</div>
  99. <el-select v-model="expoId" placeholder="请选择参展名称" @change="getExpo()">
  100. <el-option v-for="item in expoList" :value="item.id" :label="item.expo_name" />
  101. </el-select>
  102. <div class="sub-title">分享方式</div>
  103. <el-radio-group v-model="shareType" class="radio-list">
  104. <el-radio border label="link">网页链接</el-radio>
  105. <el-radio border label="qrcode">二维码图片</el-radio>
  106. <!-- <el-radio border label="social_media" >社交媒体/社交软件</el-radio>-->
  107. <el-radio border label="post_image">生成海报图片</el-radio>
  108. <el-radio border label="wechat_insert">微信公众平台嵌入</el-radio>
  109. <el-radio border label="code_insert">网页代码嵌入</el-radio>
  110. </el-radio-group>
  111. </div>
  112. <div class="share-view">
  113. <div v-if="!expoId" class="chose-expo">
  114. <div class="sub-title">选择需要分享的展会</div>
  115. <el-select v-model="expoId" placeholder="请选择参展名称" @change="getExpo()">
  116. <el-option v-for="item in expoList" :value="item.id" :label="item.expo_name" />
  117. </el-select>
  118. </div>
  119. <div v-if="shareType==='link' && expoId" class="link-share">
  120. <div class="link-inner">
  121. {{ rootPath }}/register/{{ currentExpo.urla }}
  122. </div>
  123. <div class="button-list">
  124. <el-button size="small" icon="el-icon-link" round @click="goto(rootPath+'/register/'+currentExpo.urla)">打开链接</el-button>
  125. <el-button size="small" icon="el-icon-document-copy" round @click="copyText(rootPath+'/register/'+currentExpo.urla)">复制链接</el-button>
  126. </div>
  127. </div>
  128. <div v-if="shareType==='qrcode' && expoId" class="qrcode-share">
  129. <div class="qrcode-inner">
  130. <vue-qr :callback="qrImageReady" :logo-margin="4" :logo-src="shareData.qrLogo" :logo-scale="shareData.qrLogoSize*0.1" :text="rootPath+'/register/'+currentExpo.urla" :margin="16" :size="260" />
  131. <div class="title">{{ currentExpo.expo_name }}</div>
  132. </div>
  133. <div class="button-list">
  134. <el-button size="small" icon="el-icon-download" round @click="downloadQrImage">下载图片</el-button>
  135. </div>
  136. </div>
  137. <div v-if="shareType==='social_media' && expoId" class="social-share" />
  138. <div v-if="shareType==='post_image' && expoId" class="post-share">
  139. <div class="post-inner">
  140. <div class="post-temp blue-temp-1">
  141. <div class="title">{{ renderData.sub_title }}</div>
  142. <div class="sub-title">{{ renderData.title }}</div>
  143. <div class="phone" />
  144. <div class="address" />
  145. </div>
  146. <div class="border-box" />
  147. </div>
  148. </div>
  149. </div>
  150. <div class="share-config">
  151. <template v-if="['qrcode','post_image'].includes(shareType)">
  152. <div class="sub-title">二维码logo</div>
  153. <div class="logo-input">
  154. <img v-if="shareData.qrLogo" class="logo" :src="shareData.qrLogo">
  155. <div v-else class="logo" />
  156. <div class="file-name">{{ shareData.qrLogoName||'点击选择/拖拽logo图片' }}</div>
  157. <input type="file" accept="image/*" @change="setQrLogo($event.target.files[0])">
  158. <div v-if="shareData.qrLogo" class="del el-icon-close" @click="shareData.qrLogo=shareData.qrLogoName=''" />
  159. </div>
  160. <div class="sub-title">logo尺寸</div>
  161. <el-slider v-model="shareData.qrLogoSize" :min="1.5" :max="3.5" :step="0.1" show-tooltip />
  162. </template>
  163. </div>
  164. </div>
  165. </template>
  166. <style lang="scss" scoped>
  167. .share-center{
  168. overflow: hidden;
  169. padding: 0 !important;
  170. height: 100%;
  171. display: grid;
  172. grid-template-columns: 360px 1fr 360px;
  173. .sub-title{
  174. font-size: 14px;
  175. margin-left: 4px;
  176. color: grey;
  177. font-weight: 500;
  178. margin-bottom: 8px;
  179. }
  180. .share-type{
  181. z-index: 2;
  182. position: relative;
  183. box-shadow: 0 1px 4px 0 #00000022;
  184. padding: 16px;
  185. .el-select{
  186. width: 100%;
  187. margin-bottom: 4px;
  188. }
  189. .radio-list{
  190. display: flex;
  191. flex-direction: column;
  192. gap: 6px;
  193. .el-radio{
  194. margin: 0;
  195. width: 100%;
  196. }
  197. }
  198. }
  199. .share-config{
  200. z-index: 2;
  201. position: relative;
  202. box-shadow: 0 1px 4px 0 #00000022;
  203. padding: 16px;
  204. .logo-input{
  205. transition-duration: 300ms;
  206. overflow: hidden;
  207. position: relative;
  208. border-radius: 8px;
  209. background-color: #f6f6f6;
  210. width: 100%;
  211. height: 80px;
  212. padding: 12px;
  213. display: grid;
  214. grid-gap: 12px;
  215. grid-template-columns: 56px 1fr;
  216. align-items: center;
  217. .del{
  218. padding: 6px;
  219. position: absolute;
  220. right: 6px;
  221. top: 6px;
  222. border-radius: 50%;
  223. cursor: pointer;
  224. &:hover{
  225. background-color: #e3e3e3;
  226. }
  227. }
  228. .logo{
  229. border-radius: 6px;
  230. object-fit: cover;
  231. background-color: white;
  232. width: 56px;
  233. height: 56px;
  234. }
  235. .file-name{
  236. text-overflow: ellipsis;
  237. white-space: nowrap;
  238. overflow: hidden;
  239. flex: 1;
  240. font-size: 13px;
  241. }
  242. input{
  243. position: absolute;
  244. top: 0;
  245. left: 0;
  246. width: 100%;
  247. height: 100%;
  248. opacity: 0;
  249. }
  250. }
  251. }
  252. .share-view{
  253. z-index: 1;
  254. display: flex;
  255. justify-content: center;
  256. align-items: center;
  257. position: relative;
  258. background-color: #F9FAFB;
  259. .chose-expo{
  260. box-shadow: 0 1px 4px 0 #00000022;
  261. padding: 16px;
  262. border-radius: 8px;
  263. background-color: white;
  264. width: 360px;
  265. .el-select{
  266. width: 100%;
  267. }
  268. }
  269. .button-list{
  270. text-align: right;
  271. margin-top: 8px;
  272. }
  273. .qrcode-share{
  274. .qrcode-inner{
  275. overflow: hidden;
  276. background-color: white;
  277. box-shadow: 0 1px 4px 0 #00000022;
  278. border-radius: 8px;
  279. .title{
  280. font-size: 14px;
  281. font-weight: bold;
  282. text-align: center;
  283. margin-bottom: 16px;
  284. }
  285. }
  286. }
  287. .post-share{
  288. width: 100%;
  289. height: 100%;
  290. background-size: cover;
  291. background-position: center;
  292. position: relative;
  293. background-image: url("/static/image/prototype/wallpost/prototypewall.jpg");
  294. display: flex;
  295. justify-content: center;
  296. align-items: center;
  297. .post-inner{
  298. padding: 8px 8px 13px 15px;
  299. position: relative;
  300. background-color: white;
  301. .border-box{
  302. border: 20px solid;
  303. border-image: url("/static/image/prototype/wallpost/prototypepost.png") 20 stretch;
  304. position: absolute;
  305. top: 0;
  306. left: 0;
  307. width: 100%;
  308. height: 100%;
  309. }
  310. .post-temp{
  311. width: 280px;
  312. }
  313. .blue-temp-1{
  314. overflow: hidden;
  315. display: block;
  316. padding: 8px;
  317. position: relative;
  318. background: #EAFBFF;
  319. &::before{
  320. content: '';
  321. position: absolute;
  322. top: 0;
  323. right: 0;
  324. //width: 100px;
  325. //height: 20px;
  326. border-top: 14px solid #45A8FF;
  327. border-right: 100px solid #45A8FF;
  328. border-bottom: 14px solid transparent;
  329. border-left: 100px solid transparent;
  330. }
  331. .title{
  332. color: #45A8FF;
  333. font-weight: 1000;
  334. text-align: center;
  335. letter-spacing: 1.1px;
  336. font-size: 24px;
  337. line-height: 1.1;
  338. margin: 24px auto 0;
  339. width: 110px;
  340. }
  341. .sub-title{
  342. position: relative;
  343. width: fit-content;
  344. padding: 2px 12px;
  345. margin: 6px auto 0;
  346. background: #45A8FF;
  347. color: white;
  348. }
  349. }
  350. }
  351. }
  352. .link-share{
  353. .link-inner{
  354. font-size: 15px;
  355. border-radius: 8px;
  356. box-shadow: 0 1px 4px 0 #00000022;
  357. padding: 16px 24px;
  358. background-color: white;
  359. }
  360. }
  361. }
  362. }
  363. </style>