123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <template>
- <div class='myphoto'>
- <div class="top">
- <img src="@/assets/img/MyPhoto/back.png" alt="" @click="goBack()">
- <img src="@/assets/img/MyPhoto/mypic.png" alt="">
- </div>
- <div class="tips">
- 最多存20张,长按图片保存<br />
- </div>
- <div v-if="myPhoto.length == 0" class="noImg">
- 暂无相片
- </div>
- <div v-else class="imgList">
- <div class="imgItem" v-for="(item, index) in myPhoto" :key="index">
- <img :src="item.msg" alt="">
- <img @click="deletePic(index)" class="close" src="@/assets/img/MyPhoto/close-icon.png" alt="">
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- components: {},
- data() {
- return {
- myPhoto: []
- };
- },
- computed: {},
- watch: {},
- methods: {
- goBack() {
- this.$emit('sonBack')
- },
- deletePic(data) {
- this.$dialog
- .confirm({
- title: '四维艺术',
- message: '删除后无法恢复,是否删除?',
- })
- .then(() => {
- // on confirm
- console.log(data.msg)
- console.log(this.myPhoto)
- // this.myPhoto = this.myPhoto.filter((item) => {
- // return item.msg === data.msg
- // })
- this.myPhoto.splice(data, 1)
- localStorage.setItem('myPhoto', JSON.stringify(this.myPhoto))
- })
- .catch(() => {
- // on cancel
- });
- }
- },
- created() {
- },
- mounted() {
- //从store中获取我的相片列表
- this.myPhoto = localStorage.getItem('myPhoto') ? JSON.parse(localStorage.getItem('myPhoto')) : []
- },
- beforeCreate() { }, //生命周期 - 创建之前
- beforeMount() { }, //生命周期 - 挂载之前
- beforeUpdate() { }, //生命周期 - 更新之前
- updated() { }, //生命周期 - 更新之后
- beforeDestroy() { }, //生命周期 - 销毁之前
- destroyed() { }, //生命周期 - 销毁完成
- activated() { }, //如果页面有keep-alive缓存功能,这个函数会触发
- }
- </script>
- <style lang='less' scoped>
- .myphoto {
- width: 100%;
- height: 100%;
- .top {
- width: 100%;
- display: flex;
- justify-content: space-between;
- padding: 10px;
- img {
- height: 2.2rem;
- }
- }
- .tips {
- color: #00b3ec;
- font-size: 10px;
- text-align: right;
- padding-right: 10px;
- margin-top: -10px;
- }
- .noImg {
- width: 100%;
- height: 30vh;
- display: flex;
- justify-content: center;
- align-items: center;
- color: #999;
- }
- .imgList {
- width: 100%;
- // max-height: 80vh;
- overflow: auto;
- padding: 10px;
- box-sizing: border-box;
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: 10px;
- overflow: auto;
- .imgItem {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .close {
- width: 35px;
- height: 35px;
- // margin-top: 3px;
- }
- }
- img {
- width: 100%;
- // height: 20vh;
- object-fit: cover;
- }
- }
- ::-webkit-scrollbar {
- display: none;
- /* 隐藏滚动条 */
- }
- }
- </style>
|