|
@@ -7,7 +7,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getCommonAdList } from '@/api/modules'
|
|
|
+import { fetchJyAdList } from '@/utils'
|
|
|
export default {
|
|
|
name: 'adsense',
|
|
|
props: {
|
|
@@ -30,38 +30,16 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
async getAdList(params) {
|
|
|
- if (!params) return
|
|
|
- const codes = [params]
|
|
|
- try {
|
|
|
- const { data = {}, error_code: code } = await getCommonAdList({ codes })
|
|
|
- const ad = data[params]
|
|
|
- if (code === 0 && ad) {
|
|
|
- if (Array.isArray(ad)) {
|
|
|
- this.adList = ad.map(this.adConfigFormatter)
|
|
|
- } else {
|
|
|
- this.adList = [this.adConfigFormatter(ad)]
|
|
|
- }
|
|
|
- this.url = this.adList[0].pic
|
|
|
- this.$emit('show')
|
|
|
- this.link = this.adList[0].link
|
|
|
+ return fetchJyAdList(params).then(list => {
|
|
|
+ this.adList = list
|
|
|
+ if (this.adList.length === 0) {
|
|
|
+ return
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.log(error)
|
|
|
- }
|
|
|
- },
|
|
|
- adConfigFormatter(config) {
|
|
|
- return {
|
|
|
- pic: config?.s_pic,
|
|
|
- link: config?.s_link,
|
|
|
- name: config?.s_picalt || config?.s_remark,
|
|
|
- type: config?.o_extend?.linktype,
|
|
|
- title: config?.s_remark,
|
|
|
- extend: {
|
|
|
- width: config?.o_extend?.width,
|
|
|
- height: config?.o_extend?.height,
|
|
|
- type: config?.o_extend?.linktype
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ this.url = this.adList[0].pic
|
|
|
+ this.$emit('show')
|
|
|
+ this.link = this.adList[0].link
|
|
|
+ })
|
|
|
},
|
|
|
openUrl() {
|
|
|
if (this.link) {
|