You've already forked guangan-mp
1.0.0
This commit is contained in:
75
pages/thumb/detail.vue
Normal file
75
pages/thumb/detail.vue
Normal file
@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<view class="flex flex-column" style="width:100vw;height: 100vh;">
|
||||
<i-loading v-if="loading"></i-loading>
|
||||
<view class="bg-white px-3 pb-3 mx-2 rounded-lg mt-2">
|
||||
<view class="pt-3 font30">
|
||||
<view class="text-muted">点赞内容</view>
|
||||
<view class="mt-2">{{info.content}}</view>
|
||||
</view>
|
||||
<view class="flex align-center justify-between pt-3 font30">
|
||||
<view class="text-muted">点赞时间</view>
|
||||
<view>{{info.create_at}}</view>
|
||||
</view>
|
||||
<view class="pt-3 font30" v-if="info.imgs_arr.length > 0">
|
||||
<view class="text-muted">图片</view>
|
||||
<view class="mt-2">
|
||||
<image v-for="(item, index) in info.imgs_arr" :key="index" :src="item" mode="aspectFill" class="rounded-lg" style="width: 100px;height: 100px;margin-right: 10px;" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { TaCache } from '../../common/cache';
|
||||
import { TaAjax } from '@/common/ajax'
|
||||
|
||||
export default {
|
||||
onLoad(options) {
|
||||
const userInfo = TaCache.get('auth.user');
|
||||
if (!userInfo) {
|
||||
this.login = false
|
||||
} else {
|
||||
this.login = true
|
||||
}
|
||||
this.id = options.id
|
||||
if (!this.id) {
|
||||
uni.showToast({
|
||||
title: '缺少参数',
|
||||
icon: 'none'
|
||||
})
|
||||
return uni.navigateBack()
|
||||
}
|
||||
this.loadInfo()
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
id: 0,
|
||||
loading: false,
|
||||
login: false,
|
||||
info: {},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadInfo() {
|
||||
this.loading = true
|
||||
TaAjax.get((this.login ? '/cms/api.auth.Thumb/info?id=' : '/cms/api.Thumb/info?id=') + this.id).then(res => {
|
||||
console.log(res)
|
||||
this.info = res.data
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.info,
|
||||
icon: 'error',
|
||||
})
|
||||
uni.navigateBack()
|
||||
}).finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
102
pages/thumb/list.vue
Normal file
102
pages/thumb/list.vue
Normal file
@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<view class="flex flex-column flex-1" style="height: 100vh;">
|
||||
<i-loading v-if="loading" />
|
||||
<view class="flex flex-column flex-1">
|
||||
<scroll-view class="flex-1" :scroll-y="true" :refresher-enabled="true"
|
||||
:refresher-triggered="refresh" @refresherrefresh="refreshData" @scrolltolower="loadData">
|
||||
<view class="px-2">
|
||||
<i-thumb-list :resdata="shareList" />
|
||||
</view>
|
||||
<uni-load-more :status="more_status" @clickLoadMore="loadData"></uni-load-more>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import { TaCache } from '@/common/cache';
|
||||
import {
|
||||
TaAjax
|
||||
} from '@/common/ajax';
|
||||
import {
|
||||
friendlyDate
|
||||
} from '@/common/util';
|
||||
export default {
|
||||
computed: {
|
||||
more_status() {
|
||||
if (this.finish) {
|
||||
return 'no-more';
|
||||
} else if (this.loading) {
|
||||
return 'loading';
|
||||
} else {
|
||||
return 'more';
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
shareList: [],
|
||||
curPage: 1,
|
||||
loading: true,
|
||||
refresh: true,
|
||||
finish: false,
|
||||
login: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const userInfo = TaCache.get('auth.user');
|
||||
if (!userInfo) {
|
||||
this.login = false
|
||||
} else {
|
||||
this.login = true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadData() {
|
||||
if (this.refresh) {
|
||||
this.shareList.length = 0;
|
||||
this.finish = false;
|
||||
}
|
||||
if (this.finish) {
|
||||
return;
|
||||
}
|
||||
TaAjax.get(this.login ? '/cms/api.auth.Thumb/index' : '/cms/api.Thumb/index', {
|
||||
page: this.curPage
|
||||
}).then((result) => {
|
||||
const data = result.data;
|
||||
const data_list = data.data.map((share) => {
|
||||
share.create_at = friendlyDate(new Date(share.publish_at.replace(/\-/g, '/'))
|
||||
.getTime());
|
||||
share.imgs = share.imgs_arr;
|
||||
return share;
|
||||
});
|
||||
if (this.refresh) {
|
||||
this.shareList.length = 0;
|
||||
}
|
||||
this.shareList = this.shareList.concat(data_list);
|
||||
this.finish = data.total <= this.shareList.length;
|
||||
this.curPage++;
|
||||
}).catch((e) => {
|
||||
console.warn(e)
|
||||
if (this.shareList.length == 0) {
|
||||
this.finish = true;
|
||||
}
|
||||
}).finally(() => {
|
||||
this.refresh = false;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
refreshData() {
|
||||
this.finish = false;
|
||||
this.refresh = true;
|
||||
this.curPage = 1;
|
||||
this.loadData();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
129
pages/thumb/thumb.vue
Normal file
129
pages/thumb/thumb.vue
Normal file
@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<view class="flex flex-column" style="width:100vw;height: 100vh; background-color: #F5F6F8;">
|
||||
<view class="bg-white mt-2 p-2 rounded-lg" style="padding-bottom: 200rpx;">
|
||||
<view class="flex-1 pt-3" style="color: #666666;">点赞城市内容:</view>
|
||||
<view class="border border-light rounded py-3 flex align-center justify-between" style="height: 200rpx;">
|
||||
<textarea v-model="form.content" autoHeight class="flex-1 font28" placeholder="点赞城市内容" />
|
||||
</view>
|
||||
<view class="flex-1 py-3">相关图片:</view>
|
||||
<view class="flex py-3 mb-6">
|
||||
<div class="flex flex-wrap w-25 position-relative" v-for="(item,index) in img_array" :key='index'>
|
||||
<img class="img-add" :src="item" @click="previewImage(index)" alt=""/>
|
||||
<img class='img-delete position-absolute' src='/static/images/delete.png' @click='deleteImage(index)'>
|
||||
</div>
|
||||
<div class="flex flex-wrap w-25" @click="chooseImages()">
|
||||
<img class='img-add' src="/static/images/addImage.png" alt="">
|
||||
</div>
|
||||
</view>
|
||||
</view>
|
||||
<view class="fixed-bottom border-top bg-white py-2 px-3">
|
||||
<view class="bg-danger py-3 font30 text-center text-white shadow rounded-circle" @click="onSubmit">
|
||||
立即提交
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { TaCache } from '@/common/cache';
|
||||
import {
|
||||
TaAjax, TaPost, baseUrl
|
||||
} from '@/common/ajax';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
title: "点赞城市",
|
||||
content: "",
|
||||
imgs: "",
|
||||
},
|
||||
img_array: [],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const that = this;
|
||||
const userInfo = TaCache.get('auth.user');
|
||||
if (!userInfo) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/user/login"
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
chooseImages() {
|
||||
const that = this;
|
||||
uni.chooseMedia({
|
||||
mediaType: ['image', 'video'],
|
||||
sourceType: ['album', 'camera'],
|
||||
sizeType: ['original'],
|
||||
success(res) {
|
||||
for(let i=0;i<res.tempFiles.length;i++){
|
||||
const tempFilePath = res.tempFiles[i].tempFilePath
|
||||
const loadingId = uni.showLoading({
|
||||
title: '上传中...',
|
||||
mask: true,
|
||||
})
|
||||
uni.uploadFile({
|
||||
url: baseUrl + '/custom/api.Upload/file',
|
||||
filePath: tempFilePath,
|
||||
name: 'file',
|
||||
success(res) {
|
||||
const responseStr = res.data;
|
||||
const response = JSON.parse(res.data);
|
||||
const data = response.data;
|
||||
const url = data.url;
|
||||
that.img_array.push(url);
|
||||
},
|
||||
complete() {
|
||||
uni.hideLoading(loadingId)
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
previewImage(idx = 0) {
|
||||
uni.previewImage({
|
||||
urls: this.img_array,
|
||||
current: idx,
|
||||
loop: true,
|
||||
})
|
||||
},
|
||||
deleteImage(idx) {
|
||||
this.img_array.splice(idx, 1)
|
||||
},
|
||||
onSubmit() {
|
||||
this.form.images = this.img_array.join("|")
|
||||
TaPost('/cms/api.auth.Thumb/add', this.form).then((result) => {
|
||||
if (result.code == 0) {
|
||||
return uni.showToast({
|
||||
icon: 'error',
|
||||
title: result.info,
|
||||
})
|
||||
}
|
||||
const id = result.data
|
||||
uni.switchTab({
|
||||
url: "/pages/index/index"
|
||||
})
|
||||
return uni.showToast({
|
||||
icon: 'success',
|
||||
title: result.info,
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.img-add {
|
||||
width: 180rpx;
|
||||
height: 180rpx;
|
||||
}
|
||||
.img-delete {
|
||||
top: 0;
|
||||
right: 0;
|
||||
height: 48rpx;
|
||||
width: 48rpx;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user