changeGroupDetail.vue 3.34 KB
<template>
	<view>
		<uni-collapse>
			<uni-collapse-item :title="n.newName" v-for="n in list" :key="n.id" open>
				<view class="collapseBody">
					<view>
						<label>会员编号:</label>
						<text>{{n.memCode}}</text>
					</view>
					<view>
						<label>团体会员名称:</label>
						<view>
							{{n.oldName}}
								<text class="text-primary" v-if="n.oldName!=n.newName">变更为 </text>
								<text class="text-danger" v-if="n.oldName!=n.newName">{{ n.newName }}</text>
							
						</view>
					</view>

					<view v-if="n.fileUrl">
						<label>附件:</label>
						<text class="text-primary" @click="showImg(n)">
							查看附件
						</text>
					</view>
				</view>

			</uni-collapse-item>
		</uni-collapse>

	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import * as api from '@/common/api.js'
	import config from '@/config.js'
	const queryParams = ref({})
	const total = ref(0)
	const list = ref([])
	const popup = ref(null)
	const type = ref('')
	const form = ref({})
	onLoad((option) => {
		if (option.rangeId) {
			queryParams.value.rangeId = option.rangeId
			getList()
		}
	})

	function getList() {
		uni.showLoading({
			title: '加载中'
		})
		api.getChangeGroupByRangeId(queryParams.value).then(res => {
			list.value = res.rows
			list.value.forEach(item => {
				item.fileUrl = JSON.parse(item.fileUrl)
			})
			total.value = res.total
			uni.hideLoading()
		})
	}

	function showImg(n) {
		var str = config.baseUrl_api + n.fileUrl[0]?.url
		if (n.fileUrl[0]?.url.indexOf('png') > -1 || n.fileUrl[0]?.url.indexOf('jpg') > -1 || n.fileUrl[0]?.url.indexOf(
				'jpeg') > -1) {
			uni.previewImage({
				urls: [str],
				success: function(res) {
					console.log('success', res)
				},
				fail: function(res) {
					console.log('fail', res)
				},
				complete: function(res) {
					console.log('complete', res)
				}
			})
		} else {
			goWebView(str)
		}
	}

	function goWebView(url) {
		url = url.replace("http://", "https://")
		uni.showLoading({
			title: '下载中'
		});
		uni.downloadFile({
			url: url,
			success: function(res) {
				uni.hideLoading();
				var filePath = res.tempFilePath;
				uni.showLoading({
					title: '正在打开'
				});
				uni.openDocument({
					filePath: filePath,
					showMenu: true,
					success: function(res) {
						uni.hideLoading();
					},
					fail: function(err) {
						uni.hideLoading();
						uni.showToast({
							title: err,
							icon: 'none',
							duration: 2000
						});
					}
				});
			},
			fail: function(error) {
				uni.hideLoading();
				uni.showToast({
					title: `下载失败`,
					icon: 'none',
					duration: 2000
				});
			}
		});
	}
</script>
<style scoped lang="scss">
	.flexbox {
		padding: 30rpx 30rpx 0
	}

	.danger-button {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.collapseBody {
		padding: 0 30rpx;
		box-sizing: border-box;
		font-size: 28rpx;

		&>view {
			margin: 0 0 20rpx;display: flex;

			label {
				width: 7em;
				color: #999;
				display: inline-block;
				text-align: right;flex:0 0 auto;
			}
			view{flex:1 1 auto;}
		}
	}

	.popBody {
		background: #fff;
		padding: 30rpx;
	}
</style>