step1.vue
2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
<view>
<!-- 报名须知 -->
<view class="title-left-border">报名须知</view>
<view class="flexRow">
<label>附件下载:</label>
<view>
<text class="underLine text-danger" @click="downLoad(config.trainUrl_api+activity?.signNoticeAttachment?.url)">《报名须知》</text>
</view>
</view>
<view class="flexRow" @click="changeAgree">
<uni-icons type="checkbox-filled" v-if="agree" color="#C5161E" size="20"></uni-icons>
<uni-icons type="checkbox" color="#bbbbbb" v-else size="20"></uni-icons>
<view>我确认已经仔细阅读报名须知</view>
</view>
</view>
<view class="fixedBottom">
<button class="btn" @click="next" :class="agree?'btn-red':'btn-gary'">阅读并同意</button>
</view>
</template>
<script setup>
import {
onLoad
} from '@dcloudio/uni-app'
import {
ref,
reactive,
toRefs
} from 'vue'
import * as train from '@/training/train.js'
import config from '@/config.js';
const emit = defineEmits(['next'])
const agree = ref(false)
defineProps({
activity: {
type: Object,
default: () => {}
}
})
function changeAgree() {
if (agree.value) {
agree.value = false
} else {
agree.value = true
}
}
function downLoad(url) {
console.log(url)
// url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
console.log(res)
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: '打开失败',
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
console.log(error)
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
function next() {
if (agree.value) {
emit('next')
} else {
uni.showToast({
title: `请确认报名须知`,
icon: 'none'
})
}
}
</script>
<style scoped lang="scss">
.flexRow {margin: 30rpx 0 0;align-items: center;
display: flex;font-size: 28rpx;
label{color: #999;}
view{margin-left: 20rpx;}
}
</style>