Commit b0386429fe9fc0f03943b27c0a7f3d153d36ced4
1 parent
9e4a978f
mp:支持 wx-news、wx-location 类型的消息
Showing
6 changed files
with
159 additions
and
14 deletions
yudao-ui-admin/src/views/mp/components/wx-location/main.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + 【微信消息 - 定位】 | ||
| 3 | +--> | ||
| 4 | +<template> | ||
| 5 | + <div> | ||
| 6 | + <el-link type="primary" target="_blank" :href="'https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx=' + locationY + '&pointy=' + locationX + '&name=' + label + '&ref=yudao'"> | ||
| 7 | + <img :src="'https://apis.map.qq.com/ws/staticmap/v2/?zoom=10&markers=color:blue|label:A|' + locationX + ',' + locationY + '&key=' + qqMapKey + '&size=250*180'"> | ||
| 8 | + <p/><i class="el-icon-map-location"></i>{{label}} | ||
| 9 | + </el-link> | ||
| 10 | + </div> | ||
| 11 | +</template> | ||
| 12 | + | ||
| 13 | +<script> | ||
| 14 | + export default { | ||
| 15 | + name: "wxLocation", | ||
| 16 | + props: { | ||
| 17 | + locationX: { | ||
| 18 | + required: true, | ||
| 19 | + type: Number | ||
| 20 | + }, | ||
| 21 | + locationY: { | ||
| 22 | + required: true, | ||
| 23 | + type: Number | ||
| 24 | + }, | ||
| 25 | + label: { // 地名 | ||
| 26 | + required: true, | ||
| 27 | + type: String | ||
| 28 | + }, | ||
| 29 | + qqMapKey: { // QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc | ||
| 30 | + required: false, | ||
| 31 | + type: String, | ||
| 32 | + default: 'TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E' // 需要自定义 | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + }; | ||
| 36 | +</script> |
yudao-ui-admin/src/views/mp/components/wx-msg/main.vue
| @@ -58,23 +58,20 @@ | @@ -58,23 +58,20 @@ | ||
| 58 | <div v-else-if="item.type === 'video' || item.type === 'shortvideo'" style="text-align: center"> | 58 | <div v-else-if="item.type === 'video' || item.type === 'shortvideo'" style="text-align: center"> |
| 59 | <wx-video-player :url="item.mediaUrl" /> | 59 | <wx-video-player :url="item.mediaUrl" /> |
| 60 | </div> | 60 | </div> |
| 61 | - <div v-if="item.type === 'link'" class="avue-card__detail"> | 61 | + <div v-else-if="item.type === 'link'" class="avue-card__detail"> |
| 62 | <el-link type="success" :underline="false" target="_blank" :href="item.url"> | 62 | <el-link type="success" :underline="false" target="_blank" :href="item.url"> |
| 63 | <div class="avue-card__title"><i class="el-icon-link"></i>{{ item.title }}</div> | 63 | <div class="avue-card__title"><i class="el-icon-link"></i>{{ item.title }}</div> |
| 64 | </el-link> | 64 | </el-link> |
| 65 | <div class="avue-card__info" style="height: unset">{{item.description}}</div> | 65 | <div class="avue-card__info" style="height: unset">{{item.description}}</div> |
| 66 | </div> | 66 | </div> |
| 67 | <!-- TODO 芋艿:待完善 --> | 67 | <!-- TODO 芋艿:待完善 --> |
| 68 | -<!-- <div v-if="item.repType == 'location'">--> | ||
| 69 | -<!-- <el-link type="primary" target="_blank" :href="'https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx='+item.repLocationY+'&pointy='+item.repLocationX+'&name='+item.repContent+'&ref=joolun'">--> | ||
| 70 | -<!-- <img :src="'https://apis.map.qq.com/ws/staticmap/v2/?zoom=10&markers=color:blue|label:A|'+item.repLocationX+','+item.repLocationY+'&key='+qqMapKey+'&size=250*180'">--> | ||
| 71 | -<!-- <p/><i class="el-icon-map-location"></i>{{item.repContent}}--> | ||
| 72 | -<!-- </el-link>--> | ||
| 73 | -<!-- </div>--> | 68 | + <div v-else-if="item.type === 'location'"> |
| 69 | + <wx-location :label="item.label" :location-y="item.locationY" :location-x="item.locationX" /> | ||
| 70 | + </div> | ||
| 74 | 71 | ||
| 75 | -<!-- <div v-if="item.repType == 'news'" style="width: 300px">--> | ||
| 76 | -<!-- <WxNews :objData="item.content.articles"></WxNews>--> | ||
| 77 | -<!-- </div>--> | 72 | + <div v-else-if="item.type === 'news'" style="width: 300px"> <!-- TODO 芋艿:待测试;详情页也存在类似的情况 --> |
| 73 | + <wx-news :articles="item.articles" /> | ||
| 74 | + </div> | ||
| 78 | 75 | ||
| 79 | <!-- <div v-if="item.repType == 'music'">--> | 76 | <!-- <div v-if="item.repType == 'music'">--> |
| 80 | <!-- <el-link type="success" :underline="false" target="_blank" :href="item.repUrl">--> | 77 | <!-- <el-link type="success" :underline="false" target="_blank" :href="item.repUrl">--> |
| @@ -105,14 +102,17 @@ | @@ -105,14 +102,17 @@ | ||
| 105 | // import WxNews from '@/components/wx-news/main.vue' | 102 | // import WxNews from '@/components/wx-news/main.vue' |
| 106 | import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'; | 103 | import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'; |
| 107 | import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'; | 104 | import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'; |
| 105 | + import WxNews from '@/views/mp/components/wx-news/main.vue'; | ||
| 106 | + import WxLocation from '@/views/mp/components/wx-location/main.vue'; | ||
| 108 | 107 | ||
| 109 | export default { | 108 | export default { |
| 110 | name: "wxMsg", | 109 | name: "wxMsg", |
| 111 | components: { | 110 | components: { |
| 112 | // WxReplySelect, | 111 | // WxReplySelect, |
| 113 | - // WxNews, | ||
| 114 | WxVideoPlayer, | 112 | WxVideoPlayer, |
| 115 | - WxVoicePlayer | 113 | + WxVoicePlayer, |
| 114 | + WxNews, | ||
| 115 | + WxLocation | ||
| 116 | }, | 116 | }, |
| 117 | props: { | 117 | props: { |
| 118 | wxUserId: { | 118 | wxUserId: { |
| @@ -140,7 +140,8 @@ | @@ -140,7 +140,8 @@ | ||
| 140 | mp: { | 140 | mp: { |
| 141 | nickname: '公众号', | 141 | nickname: '公众号', |
| 142 | avatar: require("@/assets/images/wechat.png"), | 142 | avatar: require("@/assets/images/wechat.png"), |
| 143 | - } | 143 | + }, |
| 144 | + qqMapKey: '' // | ||
| 144 | } | 145 | } |
| 145 | }, | 146 | }, |
| 146 | created() { | 147 | created() { |
yudao-ui-admin/src/views/mp/components/wx-news/main.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + - Copyright (C) 2018-2019 | ||
| 3 | + - All rights reserved, Designed By www.joolun.com | ||
| 4 | + 【微信消息 - 图文】 | ||
| 5 | + 芋道源码: | ||
| 6 | + ① 代码优化,补充注释,提升阅读性 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <div class="news-home"> | ||
| 10 | + <div v-for="(article, index) in articles" :key="index" class="news-div"> | ||
| 11 | + <!-- 头条 --> | ||
| 12 | + <a target="_blank" :href="article.url" v-if="index === 0"> | ||
| 13 | + <div class="news-main"> | ||
| 14 | + <div class="news-content"> | ||
| 15 | + <img class="material-img" :src="article.picUrl" width="280px" height="120px"/> | ||
| 16 | + <div class="news-content-title"> | ||
| 17 | + <span>{{article.title}}</span> | ||
| 18 | + </div> | ||
| 19 | + </div> | ||
| 20 | + </div> | ||
| 21 | + </a> | ||
| 22 | + <!-- 二条/三条等等 --> | ||
| 23 | + <a target="_blank" :href="article.url" v-else> | ||
| 24 | + <div class="news-main-item"> | ||
| 25 | + <div class="news-content-item"> | ||
| 26 | + <div class="news-content-item-title">{{article.title}}</div> | ||
| 27 | + <div class="news-content-item-img"> | ||
| 28 | + <img class="material-img" :src="article.picUrl" height="100%"/> | ||
| 29 | + </div> | ||
| 30 | + </div> | ||
| 31 | + </div> | ||
| 32 | + </a> | ||
| 33 | + </div> | ||
| 34 | + </div> | ||
| 35 | +</template> | ||
| 36 | + | ||
| 37 | +<script> | ||
| 38 | + export default { | ||
| 39 | + name: "wxNews", | ||
| 40 | + props: { | ||
| 41 | + articles: { | ||
| 42 | + type: Array // title - 标题;description - 描述;picUrl - 图片连接;url - 跳转链接 | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + }; | ||
| 46 | +</script> | ||
| 47 | + | ||
| 48 | +<style lang="scss" scoped> | ||
| 49 | + .news-home { | ||
| 50 | + background-color: #FFFFFF; | ||
| 51 | + width: 100%; | ||
| 52 | + margin: auto; | ||
| 53 | + } | ||
| 54 | + .news-main { | ||
| 55 | + width: 100%; | ||
| 56 | + margin: auto; | ||
| 57 | + } | ||
| 58 | + .news-content { | ||
| 59 | + background-color: #acadae; | ||
| 60 | + width: 100%; | ||
| 61 | + position: relative; | ||
| 62 | + } | ||
| 63 | + .news-content-title { | ||
| 64 | + display: inline-block; | ||
| 65 | + font-size: 12px; | ||
| 66 | + color: #FFFFFF; | ||
| 67 | + position: absolute; | ||
| 68 | + left: 0; | ||
| 69 | + bottom: 0; | ||
| 70 | + background-color: black; | ||
| 71 | + width: 98%; | ||
| 72 | + padding: 1%; | ||
| 73 | + opacity: 0.65; | ||
| 74 | + white-space: normal; | ||
| 75 | + box-sizing: unset!important | ||
| 76 | + } | ||
| 77 | + .news-main-item { | ||
| 78 | + background-color: #FFFFFF; | ||
| 79 | + padding: 5px 0; | ||
| 80 | + border-top: 1px solid #eaeaea; | ||
| 81 | + } | ||
| 82 | + .news-content-item { | ||
| 83 | + position: relative; | ||
| 84 | + } | ||
| 85 | + .news-content-item-title { | ||
| 86 | + display: inline-block; | ||
| 87 | + font-size: 10px; | ||
| 88 | + width: 70%; | ||
| 89 | + margin-left: 1%; | ||
| 90 | + white-space: normal | ||
| 91 | + } | ||
| 92 | + .news-content-item-img { | ||
| 93 | + display: inline-block; | ||
| 94 | + width: 25%; | ||
| 95 | + background-color: #acadae; | ||
| 96 | + margin-right: 1%; | ||
| 97 | + } | ||
| 98 | + .material-img { | ||
| 99 | + width: 100%; | ||
| 100 | + } | ||
| 101 | +</style> |
yudao-ui-admin/src/views/mp/components/wx-video-play/main.vue
| 1 | <!-- | 1 | <!-- |
| 2 | - Copyright (C) 2018-2019 | 2 | - Copyright (C) 2018-2019 |
| 3 | - All rights reserved, Designed By www.joolun.com | 3 | - All rights reserved, Designed By www.joolun.com |
| 4 | + 【微信消息 - 视频】 | ||
| 4 | 芋道源码: | 5 | 芋道源码: |
| 5 | ① bug 修复: | 6 | ① bug 修复: |
| 6 | 1)joolun 的做法:使用 mediaId 从微信公众号,下载对应的 mp4 素材,从而播放内容; | 7 | 1)joolun 的做法:使用 mediaId 从微信公众号,下载对应的 mp4 素材,从而播放内容; |
yudao-ui-admin/src/views/mp/components/wx-voice-play/main.vue
| 1 | <!-- | 1 | <!-- |
| 2 | - Copyright (C) 2018-2019 | 2 | - Copyright (C) 2018-2019 |
| 3 | - All rights reserved, Designed By www.joolun.com | 3 | - All rights reserved, Designed By www.joolun.com |
| 4 | + 【微信消息 - 语音】 | ||
| 4 | 芋道源码: | 5 | 芋道源码: |
| 5 | ① bug 修复: | 6 | ① bug 修复: |
| 6 | 1)joolun 的做法:使用 mediaId 从微信公众号,下载对应的 mp4 素材,从而播放内容; | 7 | 1)joolun 的做法:使用 mediaId 从微信公众号,下载对应的 mp4 素材,从而播放内容; |
yudao-ui-admin/src/views/mp/message/index.vue
| @@ -86,6 +86,9 @@ | @@ -86,6 +86,9 @@ | ||
| 86 | <el-tag size="mini">链接</el-tag>: | 86 | <el-tag size="mini">链接</el-tag>: |
| 87 | <a :href="scope.row.url" target="_blank">{{scope.row.title}}</a> | 87 | <a :href="scope.row.url" target="_blank">{{scope.row.title}}</a> |
| 88 | </div> | 88 | </div> |
| 89 | + <div v-else-if="scope.row.type === 'location'"> | ||
| 90 | + <wx-location :label="scope.row.label" :location-y="scope.row.locationY" :location-x="scope.row.locationX" /> | ||
| 91 | + </div> | ||
| 89 | <div v-else> | 92 | <div v-else> |
| 90 | <el-tag type="danger" size="mini">未知消息类型</el-tag> | 93 | <el-tag type="danger" size="mini">未知消息类型</el-tag> |
| 91 | </div> | 94 | </div> |
| @@ -115,13 +118,15 @@ import { getMessagePage } from "@/api/mp/message"; | @@ -115,13 +118,15 @@ import { getMessagePage } from "@/api/mp/message"; | ||
| 115 | import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'; | 118 | import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'; |
| 116 | import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'; | 119 | import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'; |
| 117 | import WxMsg from '@/views/mp/components/wx-msg/main.vue'; | 120 | import WxMsg from '@/views/mp/components/wx-msg/main.vue'; |
| 121 | +import WxLocation from '@/views/mp/components/wx-location/main.vue'; | ||
| 118 | 122 | ||
| 119 | export default { | 123 | export default { |
| 120 | name: "WxFansMsg", | 124 | name: "WxFansMsg", |
| 121 | components: { | 125 | components: { |
| 122 | WxVideoPlayer, | 126 | WxVideoPlayer, |
| 123 | WxVoicePlayer, | 127 | WxVoicePlayer, |
| 124 | - WxMsg | 128 | + WxMsg, |
| 129 | + WxLocation | ||
| 125 | }, | 130 | }, |
| 126 | data() { | 131 | data() { |
| 127 | return { | 132 | return { |