Commit b0386429fe9fc0f03943b27c0a7f3d153d36ced4

Authored by YunaiV
1 parent 9e4a978f

mp:支持 wx-news、wx-location 类型的消息

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 58 <div v-else-if="item.type === 'video' || item.type === 'shortvideo'" style="text-align: center">
59 59 <wx-video-player :url="item.mediaUrl" />
60 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 62 <el-link type="success" :underline="false" target="_blank" :href="item.url">
63 63 <div class="avue-card__title"><i class="el-icon-link"></i>{{ item.title }}</div>
64 64 </el-link>
65 65 <div class="avue-card__info" style="height: unset">{{item.description}}</div>
66 66 </div>
67 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 76 <!-- <div v-if="item.repType == 'music'">-->
80 77 <!-- <el-link type="success" :underline="false" target="_blank" :href="item.repUrl">-->
... ... @@ -105,14 +102,17 @@
105 102 // import WxNews from '@/components/wx-news/main.vue'
106 103 import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue';
107 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 108 export default {
110 109 name: "wxMsg",
111 110 components: {
112 111 // WxReplySelect,
113   - // WxNews,
114 112 WxVideoPlayer,
115   - WxVoicePlayer
  113 + WxVoicePlayer,
  114 + WxNews,
  115 + WxLocation
116 116 },
117 117 props: {
118 118 wxUserId: {
... ... @@ -140,7 +140,8 @@
140 140 mp: {
141 141 nickname: '公众号',
142 142 avatar: require("@/assets/images/wechat.png"),
143   - }
  143 + },
  144 + qqMapKey: '' //
144 145 }
145 146 },
146 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 2 - Copyright (C) 2018-2019
3 3 - All rights reserved, Designed By www.joolun.com
  4 + 【微信消息 - 视频】
4 5 芋道源码:
5 6 ① bug 修复:
6 7 1)joolun 的做法:使用 mediaId 从微信公众号,下载对应的 mp4 素材,从而播放内容;
... ...
yudao-ui-admin/src/views/mp/components/wx-voice-play/main.vue
1 1 <!--
2 2 - Copyright (C) 2018-2019
3 3 - All rights reserved, Designed By www.joolun.com
  4 + 【微信消息 - 语音】
4 5 芋道源码:
5 6 ① bug 修复:
6 7 1)joolun 的做法:使用 mediaId 从微信公众号,下载对应的 mp4 素材,从而播放内容;
... ...
yudao-ui-admin/src/views/mp/message/index.vue
... ... @@ -86,6 +86,9 @@
86 86 <el-tag size="mini">链接</el-tag>:
87 87 <a :href="scope.row.url" target="_blank">{{scope.row.title}}</a>
88 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 92 <div v-else>
90 93 <el-tag type="danger" size="mini">未知消息类型</el-tag>
91 94 </div>
... ... @@ -115,13 +118,15 @@ import { getMessagePage } from &quot;@/api/mp/message&quot;;
115 118 import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue';
116 119 import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue';
117 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 123 export default {
120 124 name: "WxFansMsg",
121 125 components: {
122 126 WxVideoPlayer,
123 127 WxVoicePlayer,
124   - WxMsg
  128 + WxMsg,
  129 + WxLocation
125 130 },
126 131 data() {
127 132 return {
... ...