Files
dvcp_v2_wxcp_app/src/saas/AppCountryAlbum/components/watermark/Watermark7.vue

214 lines
4.7 KiB
Vue
Raw Normal View History

2022-05-16 18:04:46 +08:00
<template>
2022-05-25 10:49:43 +08:00
<div class="Watermark7" @click.stop="linkTo('./WatermarkConfig')">
2022-05-17 16:13:03 +08:00
<image src="../../images/hjws.png" />
2022-05-24 13:49:03 +08:00
<h2 v-if="isShowTitle">{{ title }}</h2>
2022-05-17 16:13:03 +08:00
<div class="middle">
<div class="top">
<h2>{{ time }}</h2>
2022-05-19 17:29:44 +08:00
<span>{{ weather }}</span>
2022-05-17 16:13:03 +08:00
</div>
<div class="bottom">{{ date }} {{ weekCn }}</div>
2022-05-16 18:04:46 +08:00
</div>
2022-05-24 16:31:10 +08:00
<div class="bottom" v-if="isShowAddress">{{ address }}</div>
2022-05-16 18:04:46 +08:00
</div>
</template>
<script>
2022-05-17 16:13:03 +08:00
import {mapActions} from 'vuex'
export default {
2022-05-19 17:29:44 +08:00
props: ['config'],
2022-05-17 16:13:03 +08:00
data () {
return {
date: '',
time: '',
2022-05-19 17:29:44 +08:00
title: '',
2022-05-17 16:13:03 +08:00
week: '',
2022-05-24 13:49:03 +08:00
weather: '',
address: '',
2022-05-19 17:29:44 +08:00
timer: null,
2022-05-24 13:49:03 +08:00
isShowTitle: true,
2022-05-19 17:29:44 +08:00
isShowAddress: true,
configList: []
2022-05-17 16:13:03 +08:00
}
},
computed: {
weekCn() {
if (this.week === 1) {
return '星期一'
}
if (this.week === 2) {
return '星期二'
}
if (this.week === 3) {
return '星期三'
}
if (this.week === 4) {
return '星期四'
}
if (this.week === 5) {
return '星期五'
}
if (this.week === 6) {
return '星期六'
}
return '星期天'
}
},
2022-05-19 17:29:44 +08:00
watch: {
configList: {
handler: function (v) {
if (v.length) {
const address = v.filter(v => v.type === '3')[0]
const title = v.filter(v => v.type === '5')[0]
this.isShowAddress = address.status === '1'
2022-05-24 13:49:03 +08:00
this.isShowTitle = title.status === '1'
2022-05-19 17:29:44 +08:00
this.title = title.defaultValue || ''
2022-05-24 13:49:03 +08:00
this.address = uni.getStorageSync('address').address || ''
this.weather = uni.getStorageSync('address').weather || ''
2022-05-19 17:29:44 +08:00
}
},
deep: true
},
},
2022-05-17 16:13:03 +08:00
created () {
2022-05-24 11:14:29 +08:00
this.configList = JSON.parse(JSON.stringify(this.config)).map(v => {
2022-05-24 13:49:03 +08:00
if (v.fieldType === '3') {
v.defaultValue = uni.getStorageSync('address').address || ''
}
if (v.fieldType === '2') {
v.defaultValue = uni.getStorageSync('address').weather || ''
}
2022-05-24 11:14:29 +08:00
if (v.fieldType === '7') {
v.defaultValue = this.$dayjs().format('YYYY-MM-DD')
this.week = new Date().getDay()
}
if (v.fieldType === '6') {
v.defaultValue = this.$dayjs().format('HH:mm')
}
return v
})
2022-05-17 16:13:03 +08:00
this.date = this.$dayjs(new Date).format('YYYY-MM-DD')
this.time = this.$dayjs().format('HH:mm')
2022-05-24 13:49:03 +08:00
this.week = new Date().getDay()
2022-05-17 16:13:03 +08:00
2022-05-19 17:29:44 +08:00
uni.$on('change', e => {
this.configList = e
})
2022-05-17 16:13:03 +08:00
this.injectJWeixin(['getLocation']).then(res => {
console.log(res)
wx.getLocation({
type: 'wgs84',
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
var speed = res.speed
var accuracy = res.accuracy
}
});
})
},
destroyed () {
clearInterval(this.timer)
},
methods: {
...mapActions(['injectJWeixin']),
getLocation () {
uni.getLocation({
type: 'wgs84',
success: res => {
console.log(res)
this.$http.get('https://apis.map.qq.com/ws/geocoder/v1/?location=39.984154,116.307490&key=3RZBZ-LZUCF-CT6J5-NWKZH-FCWOQ-UUFKY&get_poi=1').then(res => {
console.log(res)
})
},
fail: error => {
console.log(error)
}
})
},
linkTo (url) {
2022-05-19 17:29:44 +08:00
uni.setStorageSync('waterConfig', this.configList)
2022-05-17 16:13:03 +08:00
uni.navigateTo({
url
})
}
}
}
2022-05-16 18:04:46 +08:00
</script>
<style lang="scss" scoped>
2022-05-17 16:13:03 +08:00
.Watermark7 {
width: 400px;
font-size: 0;
box-sizing: border-box;
h2 {
font-weight: normal;
}
2022-05-16 18:04:46 +08:00
* {
box-sizing: border-box;
}
2022-05-17 16:13:03 +08:00
& > image {
width: 100%;
height: 64px;
2022-05-16 18:04:46 +08:00
}
2022-05-17 16:13:03 +08:00
& > .bottom {
line-height: 1.3;
padding: 10px 16px;
font-size: 26px;
text-align: justify;
background: rgba(27, 120, 65, 0.8);
}
.middle {
line-height: 1;
padding: 16px;
background: rgba(0, 0, 0, 0.5);
.top {
display: flex;
align-items: center;
margin-bottom: 6px;
h2 {
margin-right: 16px;
color: #FFFFFF;
font-size: 48px;
}
span {
color: #62CD8B;
font-size: 26px;
}
2022-05-16 18:04:46 +08:00
}
2022-05-17 16:13:03 +08:00
.bottom {
font-size: 26px;
2022-05-16 18:04:46 +08:00
}
}
2022-05-17 16:13:03 +08:00
& > h2 {
height: 64px;
line-height: 64px;
text-align: center;
color: #fff;
font-size: 32px;
background: #1B7841;
2022-05-16 18:04:46 +08:00
}
}
</style>