活动按钮状态流转
This commit is contained in:
537
pages/component/activity/apply.vue
Normal file
537
pages/component/activity/apply.vue
Normal file
@@ -0,0 +1,537 @@
|
||||
<!-- +----------------------------------------------------------------------
|
||||
| 麦沃德科技赋能开发者,助力商协会发展
|
||||
+----------------------------------------------------------------------
|
||||
| Copyright (c) 2017~2024 www.wdsxh.cn All rights reserved.
|
||||
+----------------------------------------------------------------------
|
||||
| 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
|
||||
+----------------------------------------------------------------------
|
||||
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
|
||||
+----------------------------------------------------------------------
|
||||
| 组件-活动报名 开发者: 麦沃德科技-半夏
|
||||
+---------------------------------------------------------------------- -->
|
||||
|
||||
<template>
|
||||
<view class="component-activity-apply">
|
||||
<!-- 表单数据 -->
|
||||
<form class="apply-form">
|
||||
<view class="form-item" v-for="(item, index) in applyField" :key="index">
|
||||
<!-- 标题 -->
|
||||
<view class="item-title">
|
||||
<text class="required" v-if="item.required == 1">*</text>
|
||||
<text class="text">{{item.label}}</text>
|
||||
<text class="tips" v-if="item.type == 'image' || item.type == 'video'">({{item.option}})</text>
|
||||
</view>
|
||||
<!-- 文本字段 -->
|
||||
<block v-if="item.type == 'text'">
|
||||
<view class="item-input" :class="{disabled: item.disabled}">
|
||||
<input class="input" :disabled="item.disabled" type="text" v-model="item.value" :placeholder="item.option" placeholder-class="placeholder" />
|
||||
</view>
|
||||
</block>
|
||||
<!-- 数字字段 -->
|
||||
<block v-else-if="item.type == 'number'">
|
||||
<view class="item-input" :class="{disabled: item.disabled}">
|
||||
<input class="input" :disabled="item.disabled" type="number" :maxlength="item.field == 'mobile' ? 11 : -1" v-model="item.value" :placeholder="item.option" placeholder-class="placeholder" />
|
||||
</view>
|
||||
</block>
|
||||
<!-- 单选按钮 -->
|
||||
<block v-else-if="item.type == 'radio'">
|
||||
<view class="item-radio">
|
||||
<view class="radio" :class="{active: item.value == option}" v-for="(option, num) in getOption(item.option)" :key="num" @click="selectRadio(index, option)">
|
||||
<image src="/static/select.png" mode="aspectFit"></image>
|
||||
<text>{{option}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 复选按钮 -->
|
||||
<block v-else-if="item.type == 'checkbox'">
|
||||
<view class="item-radio">
|
||||
<view class="radio" :class="{active: item.value.includes(option)}" v-for="(option, num) in getOption(item.option)" :key="num" @click="selectCheckbox(index, option)">
|
||||
<image src="/static/select.png" mode="aspectFit"></image>
|
||||
<text>{{option}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 下拉列表 -->
|
||||
<block v-else-if="item.type == 'select'">
|
||||
<view class="item-input" @click="openSelectPicker(index)">
|
||||
<view class="input text-ellipsis" v-if="item.value">{{item.value}}</view>
|
||||
<view class="input placeholder text-ellipsis" v-else>请选择{{item.label}}</view>
|
||||
<image class="icon" src="/static/del.png" mode="aspectFit" v-if="item.value" @click.stop="clearValue(index)"></image>
|
||||
<image class="icon" src="/static/right.png" mode="aspectFit" v-else></image>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 日期字段 -->
|
||||
<block v-else-if="item.type == 'date'">
|
||||
<view class="item-input" @click="openDatePicker(index)">
|
||||
<view class="input text-ellipsis" v-if="item.value">{{item.value}}</view>
|
||||
<view class="input placeholder text-ellipsis" v-else>请选择{{item.label}}</view>
|
||||
<image class="icon" src="/static/del.png" mode="aspectFit" v-if="item.value" @click.stop="clearValue(index)"></image>
|
||||
<image class="icon" src="/static/date.png" mode="aspectFit" v-else></image>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 时间字段 -->
|
||||
<block v-else-if="item.type == 'time'">
|
||||
<view class="item-input" @click="openTimePicker(index)">
|
||||
<view class="input text-ellipsis" v-if="item.value">{{item.value}}</view>
|
||||
<view class="input placeholder text-ellipsis" v-else>请选择{{item.label}}</view>
|
||||
<image class="icon" src="/static/del.png" mode="aspectFit" v-if="item.value" @click.stop="clearValue(index)"></image>
|
||||
<image class="icon" src="/static/time.png" mode="aspectFit" v-else></image>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 日期时间 -->
|
||||
<block v-else-if="item.type == 'datetime'">
|
||||
<uni-datetime-picker v-model="item.value" :is-meeting="true" @show="pageChange(true)" @maskClick="pageChange(false)" @change="pageChange(false)">
|
||||
<view class="item-input">
|
||||
<view class="input text-ellipsis" v-if="item.value">{{item.value}}</view>
|
||||
<view class="input placeholder text-ellipsis" v-else>请选择{{item.label}}</view>
|
||||
<image class="icon" src="/static/del.png" mode="aspectFit" v-if="item.value" @click.stop="clearValue(index)"></image>
|
||||
<image class="icon" src="/static/date.png" mode="aspectFit" v-else></image>
|
||||
</view>
|
||||
</uni-datetime-picker>
|
||||
</block>
|
||||
<!-- 文本域 -->
|
||||
<block v-else-if="item.type == 'textarea'">
|
||||
<view class="item-input">
|
||||
<textarea class="textarea" type="text" maxlength="-1" v-model="item.value" :placeholder="'请输入' + item.label" placeholder-class="placeholder" />
|
||||
</view>
|
||||
</block>
|
||||
<!-- 图片上传 -->
|
||||
<block v-else-if="item.type == 'image'">
|
||||
<view class="item-upload">
|
||||
<view class="upload-image" v-if="item.value && item.value.length > 0" v-for="(img, num) in item.value" :key="num" @click="previewImage(index, num)">
|
||||
<image class="image-select" :src="img" mode="aspectFill"></image>
|
||||
<image class="image-delete" src="/static/delete.png" mode="aspectFit" @click.stop="deleteImage(index, num)"></image>
|
||||
</view>
|
||||
<view class="upload-image" v-if="!item.value || item.value.length < 9" @click="chooseImage(index, 9)">
|
||||
<view class="image-background"></view>
|
||||
<view class="image-choose">
|
||||
<view class="icon">
|
||||
<image src="/static/camera.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="text">上传图片</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 视频上传 -->
|
||||
<block v-else-if="item.type == 'video'">
|
||||
<view class="item-upload">
|
||||
<view class="upload-image" v-if="item.value">
|
||||
<view class="image-video">
|
||||
<image class="video" src="/static/video.png" mode="aspectFill"></image>
|
||||
</view>
|
||||
<image class="image-delete" src="/static/delete.png" mode="aspectFit" @click="deleteVideo(index)"></image>
|
||||
</view>
|
||||
<view class="upload-image" v-else @click="chooseVideo(index)">
|
||||
<view class="image-background"></view>
|
||||
<view class="image-choose">
|
||||
<view class="icon">
|
||||
<image src="/static/camera.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="text">上传视频</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 地图选址 -->
|
||||
<block v-else-if="item.type == 'map'">
|
||||
<view class="item-input" @click="chooseLocation(index)">
|
||||
<view class="input text-ellipsis" v-if="item.value.address">{{item.value.address}}</view>
|
||||
<view class="input placeholder text-ellipsis" v-else>请选择{{item.label}}</view>
|
||||
<image class="icon" src="/static/del.png" mode="aspectFit" v-if="item.value.address" @click.stop="clearLocation(index)"></image>
|
||||
<image class="icon" src="/static/right.png" mode="aspectFit" v-else></image>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</form>
|
||||
<!-- 单项选择框 -->
|
||||
<select-picker ref="selectPicker" :is-meeting="true" :title="selectTitle" @onChange="pageChange" @confirm="changeSelectPicker"></select-picker>
|
||||
<!-- 日期选择框 -->
|
||||
<date-picker ref="datePicker" :is-meeting="true" @onChange="pageChange" @confirm="changeDatePicker"></date-picker>
|
||||
<!-- 时间选择框 -->
|
||||
<time-picker ref="timePicker" :is-meeting="true" @onChange="pageChange" @confirm="changeTimePicker"></time-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import selectPicker from "@/pages/component/picker/select.vue"
|
||||
import datePicker from "@/pages/component/picker/date.vue"
|
||||
import timePicker from "@/pages/component/picker/time.vue"
|
||||
export default {
|
||||
name: "activityApply",
|
||||
props: ["showData"],
|
||||
components: {
|
||||
selectPicker,
|
||||
datePicker,
|
||||
timePicker,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 入会字段
|
||||
applyField: [],
|
||||
// 会员级别
|
||||
levelList: [],
|
||||
// 行业分类
|
||||
industryList: [],
|
||||
// 单选标题
|
||||
selectTitle: "",
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
showData: {
|
||||
handler(value) {
|
||||
this.applyField = value || [];
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 改变页面滚动状态
|
||||
pageChange(state) {
|
||||
this.$emit("onChange", state)
|
||||
},
|
||||
// 获取选项数据
|
||||
getOption(option) {
|
||||
return option.split(",")
|
||||
},
|
||||
// 选择单选
|
||||
selectRadio(index, option) {
|
||||
if (this.applyField[index].value == option) {
|
||||
this.applyField[index].value = ""
|
||||
} else {
|
||||
this.applyField[index].value = option
|
||||
}
|
||||
},
|
||||
// 选择复选
|
||||
selectCheckbox(index, option) {
|
||||
if (this.applyField[index].value.includes(option)) {
|
||||
this.$delete(this.applyField[index].value, this.applyField[index].value.indexOf(option))
|
||||
} else {
|
||||
this.applyField[index].value.push(option)
|
||||
}
|
||||
},
|
||||
// 选择图片
|
||||
chooseImage(index, limit = 9) {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.chooseMedia({
|
||||
count: Number(limit) > 1 ? (limit - this.applyField[index].value.length) : 1,
|
||||
mediaType: ['image'],
|
||||
sourceType: ['album', 'camera'],
|
||||
sizeType: ['compressed'],
|
||||
success: (res) => {
|
||||
let list = res.tempFiles.map(item => item.tempFilePath)
|
||||
this.applyField[index].value = [...this.applyField[index].value, ...list]
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.chooseImage({
|
||||
count: Number(limit) > 1 ? (limit - this.applyField[index].value.length) : 1,
|
||||
sourceType: ['album', 'camera '],
|
||||
sizeType: ['compressed'],
|
||||
success: (res) => {
|
||||
let list = res.tempFilePaths
|
||||
this.applyField[index].value = [...this.applyField[index].value, ...list]
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
// 删除图片
|
||||
deleteImage(i, j) {
|
||||
this.$delete(this.applyField[i].value, j)
|
||||
},
|
||||
// 预览图片
|
||||
previewImage(i, j = 0) {
|
||||
let list = this.applyField[i].value
|
||||
uni.previewImage({
|
||||
urls: list,
|
||||
current: j
|
||||
});
|
||||
},
|
||||
// 选择视频
|
||||
chooseVideo(index) {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.chooseMedia({
|
||||
count: 1,
|
||||
mediaType: ['video'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
this.applyField[index].value = res.tempFiles[0].tempFilePath
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.chooseVideo({
|
||||
sourceType: ['camera', 'album'],
|
||||
success: (res) => {
|
||||
this.applyField[index].value = res.tempFilePath;
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
// 删除视频
|
||||
deleteVideo(index) {
|
||||
this.applyField[index].value = ""
|
||||
},
|
||||
// 选择下拉选项
|
||||
openSelectPicker(index) {
|
||||
if (this.applyField[index].disabled) return
|
||||
this.selectTitle = this.applyField[index].label
|
||||
let list = this.applyField[index].option.split(",")
|
||||
this.$refs.selectPicker.open(list, this.applyField[index].value, index)
|
||||
},
|
||||
// 改变下拉选项
|
||||
changeSelectPicker(value, index) {
|
||||
this.applyField[index].value = value
|
||||
},
|
||||
// 选择日期
|
||||
openDatePicker(index) {
|
||||
this.$refs.datePicker.open(this.applyField[index].value, index)
|
||||
},
|
||||
// 改变日期
|
||||
changeDatePicker(value, index) {
|
||||
this.applyField[index].value = value
|
||||
},
|
||||
// 选择时间
|
||||
openTimePicker(index) {
|
||||
this.$refs.timePicker.open(this.applyField[index].value, index)
|
||||
},
|
||||
// 改变时间
|
||||
changeTimePicker(value, index) {
|
||||
this.applyField[index].value = value
|
||||
},
|
||||
// 清空已选数据
|
||||
clearValue(index) {
|
||||
this.applyField[index].value = ""
|
||||
},
|
||||
// 地址选择
|
||||
chooseLocation(index) {
|
||||
uni.chooseLocation({
|
||||
success: (res) => {
|
||||
this.applyField[index].value = {
|
||||
latitude: res.latitude,
|
||||
longitude: res.longitude,
|
||||
name: res.name,
|
||||
address: res.address
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 清空地址
|
||||
clearLocation(index) {
|
||||
this.applyField[index].value = {
|
||||
latitude: "",
|
||||
longitude: "",
|
||||
name: "",
|
||||
address: "",
|
||||
}
|
||||
},
|
||||
// 获取表单数据
|
||||
getApplyField(fn) {
|
||||
fn(JSON.parse(JSON.stringify(this.applyField)))
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.component-activity-apply {
|
||||
.apply-form {
|
||||
.form-item {
|
||||
margin-top: 32rpx;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.item-title {
|
||||
color: #5A5B6E;
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
line-height: 44rpx;
|
||||
|
||||
.required {
|
||||
color: #E60012;
|
||||
}
|
||||
|
||||
.tips {
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
color: #666666;
|
||||
}
|
||||
}
|
||||
|
||||
.item-input {
|
||||
margin-top: 32rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 16rpx;
|
||||
background: #FFF;
|
||||
|
||||
&.disabled {
|
||||
.input {
|
||||
color: #8D929C;
|
||||
}
|
||||
}
|
||||
|
||||
.input {
|
||||
color: #5A5B6E;
|
||||
font-size: 28rpx;
|
||||
height: 104rpx;
|
||||
line-height: 104rpx;
|
||||
flex: 1;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
color: #5A5B6E;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
flex: 1;
|
||||
padding: 32rpx;
|
||||
height: 200rpx;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
color: #8D929C;
|
||||
font-size: 28rpx;
|
||||
line-height: 104rpx;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
padding-right: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.item-radio {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-left: -26rpx;
|
||||
padding-top: 8rpx;
|
||||
|
||||
.radio {
|
||||
border-radius: 8rpx;
|
||||
background: #FFF;
|
||||
padding: 16rpx;
|
||||
margin-left: 26rpx;
|
||||
margin-top: 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
image {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 8rpx;
|
||||
display: none;
|
||||
}
|
||||
|
||||
text {
|
||||
color: #8D929C;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--theme-color);
|
||||
|
||||
image {
|
||||
display: block;
|
||||
}
|
||||
|
||||
text {
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.item-upload {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 32rpx;
|
||||
column-gap: 3.5%;
|
||||
row-gap: 24rpx;
|
||||
|
||||
.upload-image {
|
||||
position: relative;
|
||||
width: 31%;
|
||||
height: 0;
|
||||
padding-top: 31%;
|
||||
|
||||
.image-select {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.image-video {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
border-radius: 10rpx;
|
||||
background: var(--theme-color);
|
||||
padding: 56rpx;
|
||||
}
|
||||
|
||||
.image-delete {
|
||||
position: absolute;
|
||||
top: -16rpx;
|
||||
right: -16rpx;
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.image-choose {
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
left: 20rpx;
|
||||
right: 20rpx;
|
||||
bottom: 20rpx;
|
||||
z-index: 6;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: #ffffff;
|
||||
border-radius: 10rpx;
|
||||
|
||||
.icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
padding: 18rpx;
|
||||
background: var(--theme-color);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.text {
|
||||
margin-top: 16rpx;
|
||||
color: var(--theme-color);
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.image-background {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
background: var(--theme-color);
|
||||
opacity: 0.08;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
295
pages/component/activity/certificate.vue
Normal file
295
pages/component/activity/certificate.vue
Normal file
@@ -0,0 +1,295 @@
|
||||
<!-- +----------------------------------------------------------------------
|
||||
| 麦沃德科技赋能开发者,助力商协会发展
|
||||
+----------------------------------------------------------------------
|
||||
| Copyright (c) 2017~2024 www.maiwd.cn All rights reserved.
|
||||
+----------------------------------------------------------------------
|
||||
| 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
|
||||
+----------------------------------------------------------------------
|
||||
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
|
||||
+----------------------------------------------------------------------
|
||||
| 组件-参会证书 开发者: 麦沃德科技-半夏
|
||||
+---------------------------------------------------------------------- -->
|
||||
|
||||
<template>
|
||||
<view class="component-activity-certificate">
|
||||
<!-- 参会证书 -->
|
||||
<canvas class="poster-canvas" :style="{width: posterWidth + 'px', height: posterHeight + 'px'}" canvas-id="myCanvas" id="myCanvas"></canvas>
|
||||
<!-- 参会证书模态框 -->
|
||||
<uni-popup ref="popupModal" type="center" @change="onChange">
|
||||
<view class="poster-popup flex-direction-column align-items-center" :style="{'--theme-color': themeColor, paddingTop: titleBarHeight + 'px'}">
|
||||
<view class="popup-close" @click="onClose()">
|
||||
<image class="icon" src="/static/closePopup.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<scroll-view scroll-y class="popup-content flex justify-content-center">
|
||||
<image class="image" :src="posterPath" mode="widthFix"></image>
|
||||
</scroll-view>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="popup-btn" @click="saveImage">保存相册</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef H5 -->
|
||||
<view class="popup-btn">长按图片保存相册</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from "vuex"
|
||||
import { loadImage, createPoster, canvasToTempFilePath } from "@/common/poster.js";
|
||||
export default {
|
||||
name: "activityCertificate",
|
||||
data() {
|
||||
return {
|
||||
// 标题栏高度
|
||||
titleBarHeight: 0,
|
||||
// 参会证书数据
|
||||
posterInfo: {},
|
||||
// 参会证书宽度
|
||||
posterWidth: 0,
|
||||
// 参会证书高度
|
||||
posterHeight: 0,
|
||||
// 图片资源是否准备完成
|
||||
posterReady: false,
|
||||
// 参会证书背景图片
|
||||
posterBackground: "",
|
||||
// 参会证书图片路径
|
||||
posterPath: "",
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
themeColor: state => state.app.themeColor,
|
||||
})
|
||||
},
|
||||
mounted() {
|
||||
// #ifdef MP-WEIXIN
|
||||
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
|
||||
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
|
||||
this.titleBarHeight = statusBarHeight + (menuButtonInfo.top - statusBarHeight) * 2 + menuButtonInfo.height
|
||||
// #endif
|
||||
},
|
||||
methods: {
|
||||
// 获取参会证书
|
||||
getPoster(activityId, applyId) {
|
||||
uni.showLoading({
|
||||
title: "加载中",
|
||||
mask: true
|
||||
})
|
||||
this.$util.request("activity.certificate", {
|
||||
id: activityId,
|
||||
apply_id: applyId,
|
||||
}).then(res => {
|
||||
if (res.code == 1) {
|
||||
this.posterInfo = res.data
|
||||
this.posterWidth = res.data.data.bg.width
|
||||
this.posterHeight = res.data.data.bg.height
|
||||
this.$nextTick(() => {
|
||||
this.showNucleus()
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('获取参会证书 ', error)
|
||||
})
|
||||
},
|
||||
// 获取图片资源
|
||||
async showNucleus() {
|
||||
this.loadingResources().then((state) => {
|
||||
// 状态为 true 表示加载完成
|
||||
if (state) {
|
||||
this.posterReady = true
|
||||
this.createImage()
|
||||
}
|
||||
});
|
||||
},
|
||||
// 加载图片资源
|
||||
async loadingResources() {
|
||||
this.posterBackground = await loadImage(this.posterInfo.data.bg.img);
|
||||
return true;
|
||||
},
|
||||
// 生成参会证书
|
||||
async createImage() {
|
||||
if (!this.posterReady) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '参会证书图片资源加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
};
|
||||
// 获取上下文对象
|
||||
const ctx = uni.createCanvasContext("myCanvas", this);
|
||||
// 创建参会证书
|
||||
let posterData = [{
|
||||
type: "image",
|
||||
url: this.posterBackground,
|
||||
config: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: parseFloat(this.posterWidth),
|
||||
h: parseFloat(this.posterHeight),
|
||||
},
|
||||
}]
|
||||
this.posterInfo.data.data.forEach((item) => {
|
||||
if (item.type == "text") {
|
||||
let content = ""
|
||||
if (item.item == "activity_name") content = this.posterInfo.activity_name || ""
|
||||
else if (item.item == "name") content = this.posterInfo.participant || ""
|
||||
else if (item.item == "time") content = this.posterInfo.time || ""
|
||||
let itemX = 0
|
||||
if (item.textAlign == "center") itemX = parseFloat(item.left) + parseFloat(item.width) / 2
|
||||
else if (item.textAlign == "right") itemX = parseFloat(item.left) + parseFloat(item.width)
|
||||
else itemX = parseFloat(item.left)
|
||||
let itemFont = "10px sans-serif"
|
||||
if (item.fontStyle == 2) {
|
||||
itemFont = `italic ${item.size} sans-serif`
|
||||
} else if (item.fontStyle == 3) {
|
||||
itemFont = `bold ${item.size} sans-serif`
|
||||
} else if (item.fontStyle == 4) {
|
||||
itemFont = `italic bold ${item.size} sans-serif`
|
||||
} else {
|
||||
itemFont = `${item.size} sans-serif`
|
||||
}
|
||||
posterData.push({
|
||||
type: "text",
|
||||
text: content || "",
|
||||
config: {
|
||||
x: itemX,
|
||||
y: parseFloat(item.top),
|
||||
color: item.color,
|
||||
font: itemFont,
|
||||
textAlign: item.textAlign,
|
||||
maxWidth: parseFloat(item.width),
|
||||
lineHeight: parseInt(item.height),
|
||||
isVerticalCenter: true
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
await createPoster(ctx, posterData)
|
||||
const imagePath = await canvasToTempFilePath("myCanvas", this);
|
||||
this.posterPath = imagePath;
|
||||
this.$refs.popupModal.open()
|
||||
uni.hideLoading()
|
||||
},
|
||||
// 保存参会证书
|
||||
saveImage() {
|
||||
uni.authorize({
|
||||
scope: 'scope.writePhotosAlbum',
|
||||
success: () => {
|
||||
uni.getImageInfo({
|
||||
src: this.posterPath,
|
||||
success: (img) => {
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: img.path,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: "保存成功",
|
||||
icon: "success",
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error(err);
|
||||
},
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error(err)
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
uni.showModal({
|
||||
title: '图片保存失败',
|
||||
content: '请确认是否已开启授权',
|
||||
confirmText: '开启授权',
|
||||
confirmColor: this.themeColor,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.openSetting({
|
||||
success: (setting) => {
|
||||
if (setting.authSetting["scope.writePhotosAlbum"]) {
|
||||
uni.showToast({
|
||||
title: '授权成功,请重新保存',
|
||||
icon: "none"
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请确定已打开保存权限',
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 关闭弹窗
|
||||
onClose() {
|
||||
this.$refs.popupModal.close()
|
||||
},
|
||||
// 改变页面滚动状态
|
||||
onChange(e) {
|
||||
this.$emit("onChange", e.show)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.component-activity-certificate {
|
||||
position: relative;
|
||||
z-index: 999;
|
||||
|
||||
.poster-canvas {
|
||||
position: fixed;
|
||||
top: 100vw;
|
||||
left: 100vh;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.poster-popup {
|
||||
.popup-close {
|
||||
width: 100%;
|
||||
margin-top: -112rpx;
|
||||
margin-bottom: 32rpx;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
.icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
max-height: 55vh;
|
||||
|
||||
.image {
|
||||
width: 92vw;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.popup-btn {
|
||||
margin-top: 32rpx;
|
||||
width: 336rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
padding: 26rpx 32rpx;
|
||||
border-radius: 16rpx;
|
||||
color: #FFFFFF;
|
||||
background: var(--theme-color);
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
686
pages/component/activity/index.vue
Normal file
686
pages/component/activity/index.vue
Normal file
@@ -0,0 +1,686 @@
|
||||
<!-- +----------------------------------------------------------------------
|
||||
| 麦沃德科技赋能开发者,助力商协会发展
|
||||
+----------------------------------------------------------------------
|
||||
| Copyright (c) 2017~2024 www.wdsxh.cn All rights reserved.
|
||||
+----------------------------------------------------------------------
|
||||
| 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
|
||||
+----------------------------------------------------------------------
|
||||
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
|
||||
+----------------------------------------------------------------------
|
||||
| 组件-活动列表 开发者: 麦沃德科技-半夏
|
||||
+---------------------------------------------------------------------- -->
|
||||
|
||||
<template>
|
||||
<view class="component-activity" :style="{'--theme-color': themeColor}">
|
||||
<view class="activity-item" :class="{special: showType == 1}" v-for="item in showData" :key="item.id" @click="toDetails(item)">
|
||||
<view class="item-header flex justify-content-between align-items-center" v-if="showType == 2">
|
||||
<view class="header-number">订单号:{{item.order_no}}</view>
|
||||
<view class="header-status">
|
||||
<text style="color: #FF626E;" v-if="item.pay_state == 1">待付款</text>
|
||||
<block v-else-if="item.pay_state == 2">
|
||||
<text style="color: #FF9100;" v-if="item.activity_state == 1">报名中</text>
|
||||
<text v-else-if="item.activity_state == 2">进行中</text>
|
||||
<text style="color: #666666;" v-else-if="item.activity_state == 3">已结束</text>
|
||||
</block>
|
||||
<text style="color: #FF9100;" v-else-if="item.pay_state == 3">退款中</text>
|
||||
<text style="color: #666666;" v-else-if="item.pay_state == 4">已退款</text>
|
||||
<text style="color: #FF626E;" v-else-if="item.pay_state == 5">已驳回</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item-info flex">
|
||||
<image class="info-image" :src="item.images" mode="aspectFill"></image>
|
||||
<view class="info-box flex-item">
|
||||
<view class="box-title text-ellipsis">{{item.name}}</view>
|
||||
<view class="box-tag flex align-items-center">
|
||||
<view class="icon" :style="{'background-image': 'url('+ iconTime +')'}" v-if="iconTime"></view>
|
||||
<text class="text flex-item text-ellipsis">{{item.start_time}} | {{item.week}}</text>
|
||||
</view>
|
||||
<view class="box-tag flex align-items-center" v-if="item.organizing_method == 1">
|
||||
<view class="icon" :style="{'background-image': 'url('+ iconNetwork +')'}" v-if="iconNetwork"></view>
|
||||
<text class="text flex-item text-ellipsis">报名成功后查看</text>
|
||||
</view>
|
||||
<view class="box-tag flex align-items-center" v-else-if="item.organizing_method == 2">
|
||||
<view class="icon" :style="{'background-image': 'url('+ iconLocation +')'}" v-if="iconLocation"></view>
|
||||
<text class="text flex-item text-ellipsis">{{item.address}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item-footer flex align-items-center" v-if="showType == 2">
|
||||
<view class="footer-label">
|
||||
<text v-if="item.organizing_method == 1">线上活动</text>
|
||||
<text v-else-if="item.organizing_method == 2">线下活动</text>
|
||||
</view>
|
||||
<view class="footer-price flex-item">
|
||||
<block v-if="item.fees > 0">
|
||||
<text>¥</text>{{item.fees}}
|
||||
</block>
|
||||
<block v-else>免费</block>
|
||||
</view>
|
||||
<view class="footer-btn flex">
|
||||
<!-- 报名中 -->
|
||||
<block v-if="item.activity_state == 1">
|
||||
<!-- 待付款 -->
|
||||
<block v-if="item.pay_state == 1">
|
||||
<view class="btn" style="background: #FF626E;" @click.stop="toCancel(item.id)">取消参加</view>
|
||||
<view class="btn" @click.stop="toPayment(item.activity_id)">去支付</view>
|
||||
</block>
|
||||
<!-- 已付款 -->
|
||||
<block v-else-if="item.pay_state == 2">
|
||||
<view style="background: #FF626E;" class="btn" @click.stop="handleCancel(item.id)" v-if="parseFloat(item.fees) == 0">取消参加</view>
|
||||
<view style="background: #FF626E;" class="btn" @click.stop="handleRefund(item.id,item.activity_id)" v-else-if="item.refund == 1">申请退款</view>
|
||||
<view class="btn" style="background: #FFB656;" @click.stop="showWebsite(item.url)" v-if="item.organizing_method == 1">线上地址</view>
|
||||
<view class="btn" style="background: #FFB656;" @click.stop="handleVerification(item.activity_id, item.verification_method)" v-else-if="item.organizing_method == 2 && item.is_verifying == 1 && item.is_sign_in == 2">
|
||||
<text v-if="item.verification_method == 1">扫码签到</text>
|
||||
<text v-else>参会凭证</text>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 已驳回 -->
|
||||
<block v-else-if="item.pay_state == 5">
|
||||
<view class="btn" style="background: #FF626E;">驳回原因</view>
|
||||
</block>
|
||||
</block>
|
||||
<!-- 进行中 -->
|
||||
<block v-else-if="item.activity_state == 2 && item.pay_state == 2">
|
||||
<view class="btn" style="background: #FFB656;" @click.stop="showWebsite(item.url)" v-if="item.organizing_method == 1">线上地址</view>
|
||||
<view class="btn" style="background: #FFB656;" @click.stop="handleVerification(item.activity_id, item.verification_method)" v-else-if="item.organizing_method == 2 && item.is_verifying == 1 && item.is_sign_in == 2">
|
||||
<text v-if="item.verification_method == 1">扫码签到</text>
|
||||
<text v-else>参会凭证</text>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 已结束 -->
|
||||
<block v-else-if="item.activity_state == 3 && item.pay_state == 2">
|
||||
<view class="btn" @click.stop="showCertificate(item.activity_id, item.id)">参会证书</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 参会凭证 -->
|
||||
<activity-poster ref="activityPoster" @onChange="pageChange"></activity-poster>
|
||||
<!-- 参会证书 -->
|
||||
<activity-certificate ref="activityCertificate" @onChange="pageChange"></activity-certificate>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from "vuex"
|
||||
import activityPoster from "@/pages/component/activity/poster.vue"
|
||||
import activityCertificate from "@/pages/component/activity/certificate.vue"
|
||||
import svgData from "@/common/svg.js"
|
||||
// #ifdef H5
|
||||
import wx from 'weixin-js-sdk';
|
||||
// #endif
|
||||
export default {
|
||||
name: "activityIndex",
|
||||
props: ["showData", "showType"],
|
||||
components: {
|
||||
activityPoster,
|
||||
activityCertificate,
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
themeColor: state => state.app.themeColor,
|
||||
iconTime: state => {
|
||||
return svgData.svgToUrl("time", state.app.themeColor)
|
||||
},
|
||||
iconLocation: state => {
|
||||
return svgData.svgToUrl("location", state.app.themeColor)
|
||||
},
|
||||
iconNetwork: state => {
|
||||
return svgData.svgToUrl("network", state.app.themeColor)
|
||||
},
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
// 改变页面滚动状态
|
||||
pageChange(state) {
|
||||
this.$emit("onChange", state)
|
||||
},
|
||||
// 申请退款
|
||||
handleRefund(applyId, activity_id) {
|
||||
uni.showModal({
|
||||
content: "确认申请退款此活动?",
|
||||
confirmColor: "#FF626E",
|
||||
confirmText: "确认退款",
|
||||
cancelColor: "#999999",
|
||||
cancelText: "取消退款",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: "加载中",
|
||||
mask: true
|
||||
})
|
||||
this.$util.request("activity.applyRefund", {
|
||||
activity_id: activity_id,
|
||||
apply_id: applyId
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
if (res.code == 1) {
|
||||
uni.redirectTo({
|
||||
url: "/pagesActivity/order/success"
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
uni.hideLoading()
|
||||
console.error('申请退款 ', error)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 未支付取消参加
|
||||
toCancel(applyId) {
|
||||
uni.showModal({
|
||||
content: "确认取消参加此活动?",
|
||||
confirmColor: "#FF626E",
|
||||
confirmText: "确认取消",
|
||||
cancelColor: "#999999",
|
||||
cancelText: "我再想想",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: "加载中",
|
||||
mask: true
|
||||
})
|
||||
this.$util.request("activity.applyDel", {
|
||||
id: applyId
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
if (res.code == 1) {
|
||||
uni.showToast({
|
||||
title: "取消成功",
|
||||
icon: "success",
|
||||
mask: true,
|
||||
duration: 1500
|
||||
})
|
||||
this.$emit("getOrderList");
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
uni.hideLoading()
|
||||
console.error('取消参加 ', error)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 去支付
|
||||
toPayment(id) {
|
||||
this.$util.toPage({
|
||||
mode: 1,
|
||||
path: "/pagesActivity/index/order?id=" + id
|
||||
})
|
||||
},
|
||||
// 取消参加
|
||||
handleCancel(applyId) {
|
||||
uni.showModal({
|
||||
content: "确认取消参加此活动?",
|
||||
confirmColor: "#FF626E",
|
||||
confirmText: "确认取消",
|
||||
cancelColor: "#999999",
|
||||
cancelText: "我再想想",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: "加载中",
|
||||
mask: true
|
||||
})
|
||||
this.$util.request("activity.applyCancel", {
|
||||
id: applyId
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
if (res.code == 1) {
|
||||
uni.showToast({
|
||||
title: "取消成功",
|
||||
icon: "success",
|
||||
mask: true,
|
||||
duration: 1500
|
||||
})
|
||||
this.$emit("getOrderList");
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
uni.hideLoading()
|
||||
console.error('取消参加 ', error)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 线上地址
|
||||
showWebsite(url) {
|
||||
if (url) {
|
||||
uni.showModal({
|
||||
content: url,
|
||||
confirmColor: this.themeColor,
|
||||
confirmText: "复制链接",
|
||||
cancelColor: "#999999",
|
||||
cancelText: "关闭页面",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.$util.toPage({
|
||||
mode: 8,
|
||||
content: url
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: "暂无线上地址,请稍后再试"
|
||||
})
|
||||
}
|
||||
},
|
||||
// 跳转详情
|
||||
toDetails(item) {
|
||||
if (this.showType == 2) {
|
||||
this.$util.toPage({
|
||||
mode: 1,
|
||||
path: `/pagesActivity/order/details?id=${item.id}&activity_id=${item.activity_id}`
|
||||
})
|
||||
} else if (this.showType == 3) {
|
||||
this.$util.toPage({
|
||||
mode: 1,
|
||||
path: "/pagesActivity/verification/details?id=" + item.id
|
||||
})
|
||||
} else {
|
||||
if (item.activity_auth == 2) {
|
||||
if (!uni.getStorageSync("token")) {
|
||||
uni.showModal({
|
||||
title: "系统提示",
|
||||
content: "该活动为会员专属,请登录后查看",
|
||||
confirmColor: this.themeColor,
|
||||
confirmText: "前往登录",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/login/index"
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
this.$util.toPage({
|
||||
mode: 1,
|
||||
path: "/pagesActivity/index/details?id=" + item.id
|
||||
})
|
||||
} else {
|
||||
this.$util.toPage({
|
||||
mode: 1,
|
||||
path: "/pagesActivity/index/details?id=" + item.id
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
// 活动核销
|
||||
handleVerification(id, method) {
|
||||
if (method == 1) {
|
||||
this.handleScan(id)
|
||||
} else {
|
||||
this.$refs.activityPoster.getPoster(id)
|
||||
}
|
||||
},
|
||||
// 扫码核销
|
||||
handleScan(id) {
|
||||
uni.showLoading({
|
||||
title: "加载中",
|
||||
mask: true
|
||||
})
|
||||
this.getAuthSetting(() => {
|
||||
uni.hideLoading()
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
if (res.path) {
|
||||
const parameter = this.getUrlParam(res.path)
|
||||
if (parameter && parameter.scene) {
|
||||
this.scanSign(parameter.scene, id)
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: "签到失败,请检查签到码是否正确",
|
||||
duration: 2500
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: "签到失败,请检查签到码是否正确",
|
||||
duration: 2500
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
wx.scanQRCode({
|
||||
needResult: 1,
|
||||
scanType: ["qrCode"],
|
||||
success: (res) => {
|
||||
if (res.resultStr) {
|
||||
const parameter = this.getUrlParam(res.resultStr)
|
||||
if (parameter && parameter.scene) {
|
||||
this.scanSign(parameter.scene, id)
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: "签到失败,请检查签到码是否正确",
|
||||
duration: 2500
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: "签到失败,请检查签到码是否正确",
|
||||
duration: 2500
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showModal({
|
||||
title: "系统提示",
|
||||
content: "当前设备暂不支持扫码核销,请稍后再试",
|
||||
showCancel: false,
|
||||
confirmText: "我知道了"
|
||||
})
|
||||
},
|
||||
});
|
||||
// #endif
|
||||
})
|
||||
},
|
||||
// 自助核销
|
||||
scanSign(value, id) {
|
||||
uni.showLoading({
|
||||
title: "加载中",
|
||||
mask: true
|
||||
})
|
||||
this.getLocation((location) => {
|
||||
if (!location) {
|
||||
uni.showToast({
|
||||
title: '位置获取失败,请确定已打开定位权限',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
return
|
||||
}
|
||||
this.$util.request("activity.scanSign", {
|
||||
activity_id: id,
|
||||
validate_value: value,
|
||||
lng: location.longitude,
|
||||
lat: location.latitude,
|
||||
}).then(res => {
|
||||
if (res.code == 1) {
|
||||
uni.showToast({
|
||||
icon: "success",
|
||||
title: "签到成功",
|
||||
duration: 2000
|
||||
})
|
||||
this.$emit("getOrderList");
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('核销签到', error)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取位置权限
|
||||
getAuthSetting(fn) {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.getSetting({
|
||||
success: (setting) => {
|
||||
if (setting.authSetting && setting.authSetting.hasOwnProperty("scope.userLocation")) {
|
||||
if (setting.authSetting["scope.userLocation"]) {
|
||||
if (fn) fn()
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请重新授权获取您的地理位置,否则部分功能将无法使用',
|
||||
confirmColor: this.themeColor,
|
||||
confirmText: "授权",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.openSetting({
|
||||
success: (result) => {
|
||||
if (result.authSetting["scope.userLocation"]) {
|
||||
if (fn) fn()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请确定已打开定位权限',
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
title: '位置获取失败',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请授权获取您的地理位置,否则部分功能将无法使用',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
if (fn) fn()
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (fn) fn()
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
title: '位置获取失败',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
if (fn) fn()
|
||||
// #endif
|
||||
},
|
||||
// 获取当前地址
|
||||
getLocation(fn) {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
geocode: true,
|
||||
success: (res) => {
|
||||
fn({
|
||||
latitude: res.latitude,
|
||||
longitude: res.longitude,
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
fn()
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
wx.ready(() => {
|
||||
wx.getLocation({
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
fn({
|
||||
latitude: res.latitude,
|
||||
longitude: res.longitude,
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
fn()
|
||||
},
|
||||
cancel: () => {
|
||||
fn()
|
||||
}
|
||||
});
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
// 截取地址栏参数
|
||||
getUrlParam(url) {
|
||||
const query = url.split("?")[1] || "";
|
||||
const params = {};
|
||||
query.split("&").forEach((pair) => {
|
||||
const [key, value] = pair.split("=");
|
||||
if (key) {
|
||||
params[key] = decodeURIComponent(value || "");
|
||||
}
|
||||
});
|
||||
return params;
|
||||
},
|
||||
// 参会证书
|
||||
showCertificate(activityId, applyId) {
|
||||
this.$refs.activityCertificate.getPoster(activityId, applyId)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.component-activity {
|
||||
.activity-item {
|
||||
margin-top: 32rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 10rpx;
|
||||
padding: 32rpx;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
&.special {
|
||||
background: transparent;
|
||||
border-radius: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.item-header {
|
||||
padding-bottom: 32rpx;
|
||||
border-bottom: 1rpx solid #E4E4E4;
|
||||
margin-bottom: 32rpx;
|
||||
|
||||
.header-number {
|
||||
color: #999999;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
|
||||
.header-status {
|
||||
color: var(--theme-color);
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.item-info {
|
||||
.info-image {
|
||||
width: 220rpx;
|
||||
height: 160rpx;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.info-box {
|
||||
margin-left: 32rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
|
||||
.box-title {
|
||||
color: #5A5B6E;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
|
||||
.box-tag {
|
||||
.icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
background-size: 32rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.text {
|
||||
color: #8D929C;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.item-footer {
|
||||
margin-top: 32rpx;
|
||||
|
||||
.footer-label {
|
||||
color: var(--theme-color);
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 8rpx;
|
||||
background: #F6F7FB;
|
||||
}
|
||||
|
||||
.footer-price {
|
||||
margin-left: 16rpx;
|
||||
color: var(--theme-color);
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
line-height: 50rpx;
|
||||
|
||||
text {
|
||||
font-size: 22rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.footer-btn {
|
||||
margin-left: 16rpx;
|
||||
|
||||
.btn {
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
padding: 14rpx 24rpx;
|
||||
border-radius: 8rpx;
|
||||
background: var(--theme-color);
|
||||
margin-left: 12rpx;
|
||||
|
||||
&:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
508
pages/component/activity/poster.vue
Normal file
508
pages/component/activity/poster.vue
Normal file
@@ -0,0 +1,508 @@
|
||||
<!-- +----------------------------------------------------------------------
|
||||
| 麦沃德科技赋能开发者,助力商协会发展
|
||||
+----------------------------------------------------------------------
|
||||
| Copyright (c) 2017~2024 www.maiwd.cn All rights reserved.
|
||||
+----------------------------------------------------------------------
|
||||
| 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
|
||||
+----------------------------------------------------------------------
|
||||
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
|
||||
+----------------------------------------------------------------------
|
||||
| 组件-参会凭证 开发者: 麦沃德科技-半夏
|
||||
+---------------------------------------------------------------------- -->
|
||||
|
||||
<template>
|
||||
<view class="component-activity-poster">
|
||||
<!-- 参会凭证 -->
|
||||
<canvas class="poster-canvas" :style="{width: posterWidth + 'px', height: posterHeight + 'px'}" canvas-id="myCanvas" id="myCanvas"></canvas>
|
||||
<!-- 二维码生成 -->
|
||||
<uqrcode class="poster-canvas" ref="qrcode" canvas-id="qrcode" :value="codeData" :options="{ margin: 4 }" v-if="codeData"></uqrcode>
|
||||
<!-- 参会凭证模态框 -->
|
||||
<uni-popup ref="popupModal" type="center" @change="onChange">
|
||||
<view class="poster-popup flex-direction-column align-items-center" :style="{'--theme-color': themeColor, paddingTop: titleBarHeight + 'px'}">
|
||||
<view class="popup-close" @click="onClose()">
|
||||
<image class="icon" src="/static/closePopup.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="popup-content flex justify-content-center">
|
||||
<image class="image" :src="posterPath" mode="aspectFit"></image>
|
||||
</view>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="popup-btn" @click="saveImage">保存相册</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef H5 -->
|
||||
<view class="popup-btn">长按图片保存相册</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from "vuex"
|
||||
import { loadImage, createPoster, canvasToTempFilePath } from "@/common/poster.js";
|
||||
export default {
|
||||
name: "activityPoster",
|
||||
data() {
|
||||
return {
|
||||
// 标题栏高度
|
||||
titleBarHeight: 0,
|
||||
// 参会凭证数据
|
||||
posterInfo: {},
|
||||
// 参会凭证宽度
|
||||
posterWidth: 0,
|
||||
// 参会凭证高度
|
||||
posterHeight: 0,
|
||||
// 图片资源是否准备完成
|
||||
posterReady: false,
|
||||
// 参会凭证用户头像
|
||||
posterAvatar: "",
|
||||
// 参会凭证二维码数据
|
||||
codeData: "",
|
||||
// 参会凭证二维码图片
|
||||
posterCode: "",
|
||||
// 参会凭证图片路径
|
||||
posterPath: "",
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
themeColor: state => state.app.themeColor,
|
||||
})
|
||||
},
|
||||
mounted() {
|
||||
// #ifdef MP-WEIXIN
|
||||
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
|
||||
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
|
||||
this.titleBarHeight = statusBarHeight + (menuButtonInfo.top - statusBarHeight) * 2 + menuButtonInfo.height
|
||||
// #endif
|
||||
},
|
||||
methods: {
|
||||
// 获取参会凭证
|
||||
getPoster(id) {
|
||||
uni.showLoading({
|
||||
title: "加载中",
|
||||
mask: true
|
||||
})
|
||||
this.posterWidth = uni.getSystemInfoSync().windowWidth;
|
||||
this.posterHeight = parseInt(this.posterWidth * (456 / 311));
|
||||
this.$util.request("activity.attendance", {
|
||||
activity_id: id,
|
||||
}).then(res => {
|
||||
if (res.code == 1) {
|
||||
this.posterInfo = res.data
|
||||
this.codeData = {
|
||||
wechatId: res.data.wechat_id,
|
||||
}
|
||||
this.codeData = JSON.stringify(this.codeData)
|
||||
this.createQrcode()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('获取参会凭证 ', error)
|
||||
})
|
||||
},
|
||||
// base64转临时路径
|
||||
base64ToPath(base64) {
|
||||
let arr = base64.split(',');
|
||||
let mime = arr[0].match(/:(.*?);/)[1];
|
||||
let bstr = atob(arr[1]);
|
||||
let n = bstr.length;
|
||||
let u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
let blob = new Blob([u8arr], {
|
||||
type: mime
|
||||
});
|
||||
let url = URL.createObjectURL(blob);
|
||||
return url;
|
||||
},
|
||||
// 生成二维码
|
||||
createQrcode() {
|
||||
if (this.$refs.qrcode && this.$refs.qrcode.toTempFilePath) {
|
||||
this.$refs.qrcode.toTempFilePath({
|
||||
success: res => {
|
||||
// #ifdef MP-WEIXIN
|
||||
const base64Data = res.tempFilePath.replace(/^data:image\/\w+;base64,/, '');
|
||||
const filePath = `${wx.env.USER_DATA_PATH}/qrcode.jpg`
|
||||
uni.getFileSystemManager().writeFile({
|
||||
filePath,
|
||||
data: base64Data,
|
||||
encoding: "base64",
|
||||
success: () => {
|
||||
this.posterCode = filePath
|
||||
this.showNucleus()
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
this.posterCode = this.base64ToPath(res.tempFilePath);
|
||||
this.showNucleus()
|
||||
// #endif
|
||||
},
|
||||
fail: () => {
|
||||
setTimeout(() => {
|
||||
this.createQrcode()
|
||||
}, 200);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.createQrcode()
|
||||
}, 200);
|
||||
}
|
||||
},
|
||||
// 获取图片资源
|
||||
async showNucleus() {
|
||||
this.loadingResources().then((state) => {
|
||||
if (state) {
|
||||
this.posterReady = true
|
||||
this.createImage()
|
||||
}
|
||||
});
|
||||
},
|
||||
// 加载图片资源
|
||||
async loadingResources() {
|
||||
this.posterCode = await loadImage(this.posterCode);
|
||||
this.posterAvatar = await loadImage(this.posterInfo.member_avatar);
|
||||
return true;
|
||||
},
|
||||
// 生成参会凭证
|
||||
async createImage() {
|
||||
if (!this.posterReady) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '参会凭证图片资源加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
};
|
||||
// 获取上下文对象
|
||||
const ctx = uni.createCanvasContext("myCanvas", this);
|
||||
// 设置背景色1
|
||||
const x1 = 0;
|
||||
const y1 = 0;
|
||||
const width1 = this.posterWidth;
|
||||
const height1 = this.posterHeight;
|
||||
const radius1 = parseInt(this.posterWidth * (20 / 311));
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x1 + radius1, y1);
|
||||
ctx.lineTo(x1 + width1 - radius1, y1);
|
||||
ctx.arc(x1 + width1 - radius1, y1 + radius1, radius1, -Math.PI / 2, 0);
|
||||
ctx.lineTo(x1 + width1, y1 + height1 - radius1);
|
||||
ctx.arc(x1 + width1 - radius1, y1 + height1 - radius1, radius1, 0, Math.PI / 2);
|
||||
ctx.lineTo(x1 + radius1, y1 + height1);
|
||||
ctx.arc(x1 + radius1, y1 + height1 - radius1, radius1, Math.PI / 2, Math.PI);
|
||||
ctx.lineTo(x1, y1 + radius1);
|
||||
ctx.arc(x1 + radius1, y1 + radius1, radius1, Math.PI, -Math.PI / 2);
|
||||
ctx.closePath();
|
||||
ctx.setFillStyle('#ffffff')
|
||||
ctx.fill();
|
||||
ctx.setStrokeStyle('#ffffff')
|
||||
ctx.stroke();
|
||||
// 设置背景色2
|
||||
const x2 = 2;
|
||||
const y2 = 2;
|
||||
const width2 = parseInt(this.posterWidth - 4);
|
||||
const height2 = parseInt(this.posterHeight - 4);
|
||||
const radius2 = parseInt(this.posterWidth * (20 / 311));
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x2 + radius2, y2);
|
||||
ctx.lineTo(x2 + width2 - radius2, y2);
|
||||
ctx.arc(x2 + width2 - radius2, y2 + radius2, radius2, -Math.PI / 2, 0);
|
||||
ctx.lineTo(x2 + width2, y2 + height2 - radius2);
|
||||
ctx.arc(x2 + width2 - radius2, y2 + height2 - radius2, radius2, 0, Math.PI / 2);
|
||||
ctx.lineTo(x2 + radius2, y2 + height2);
|
||||
ctx.arc(x2 + radius2, y2 + height2 - radius2, radius2, Math.PI / 2, Math.PI);
|
||||
ctx.lineTo(x2, y2 + radius2);
|
||||
ctx.arc(x2 + radius2, y2 + radius2, radius2, Math.PI, -Math.PI / 2);
|
||||
ctx.closePath();
|
||||
ctx.setFillStyle(this.$util.hexToRgb(this.themeColor, .1))
|
||||
ctx.fill();
|
||||
ctx.setStrokeStyle('rgba(255, 255, 255, 0)')
|
||||
ctx.stroke();
|
||||
// 设置背景色3
|
||||
const x3 = parseInt(this.posterWidth * (16 / 311));
|
||||
const y3 = parseInt(this.posterWidth * (64 / 311));
|
||||
const width3 = parseInt(this.posterWidth - this.posterWidth * (32 / 311));
|
||||
const height3 = parseInt(this.posterWidth * (228 / 311));
|
||||
const radius3 = parseInt(this.posterWidth * (10 / 311));
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x3 + radius3, y3);
|
||||
ctx.lineTo(x3 + width3 - radius3, y3);
|
||||
ctx.arc(x3 + width3 - radius3, y3 + radius3, radius3, -Math.PI / 2, 0);
|
||||
ctx.lineTo(x3 + width3, y3 + height3 - radius3);
|
||||
ctx.arc(x3 + width3 - radius3, y3 + height3 - radius3, radius3, 0, Math.PI / 2);
|
||||
ctx.lineTo(x3 + radius3, y3 + height3);
|
||||
ctx.arc(x3 + radius3, y3 + height3 - radius3, radius3, Math.PI / 2, Math.PI);
|
||||
ctx.lineTo(x3, y3 + radius3);
|
||||
ctx.arc(x3 + radius3, y3 + radius3, radius3, Math.PI, -Math.PI / 2);
|
||||
ctx.closePath();
|
||||
const grd2 = ctx.createLinearGradient(0, 0, 0, parseInt(this.posterWidth * (321 / 311)))
|
||||
grd2.addColorStop(0, "#ffffff")
|
||||
grd2.addColorStop(1, "rgba(255, 255, 255, 0.4)")
|
||||
ctx.setFillStyle(grd2)
|
||||
ctx.fill();
|
||||
ctx.setStrokeStyle('rgba(255, 255, 255, 0)')
|
||||
ctx.stroke();
|
||||
// 创建参会凭证
|
||||
await createPoster(ctx, [{
|
||||
type: "text",
|
||||
text: "活动参会凭证",
|
||||
config: {
|
||||
x: parseInt(this.posterWidth / 2),
|
||||
y: parseInt(this.posterWidth * (36 / 311)),
|
||||
color: this.themeColor,
|
||||
font: `bold ${parseInt(this.posterWidth * (24 / 311))}px sans-serif`,
|
||||
textAlign: "center",
|
||||
lineHeight: parseInt(this.posterWidth * (28 / 311)),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "image",
|
||||
url: this.posterAvatar,
|
||||
config: {
|
||||
x: parseInt(this.posterWidth * (32 / 311)),
|
||||
y: parseInt(this.posterWidth * (80 / 311)),
|
||||
w: parseInt(this.posterWidth * (68 / 311)),
|
||||
h: parseInt(this.posterWidth * (68 / 311)),
|
||||
r: parseInt(this.posterWidth * (6 / 248))
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: this.posterInfo.member_name,
|
||||
config: {
|
||||
x: parseInt(this.posterWidth * (108 / 311)),
|
||||
y: parseInt(this.posterWidth * (92 / 311)),
|
||||
color: "#5A5B6E",
|
||||
font: `bold ${parseInt(this.posterWidth * (18 / 311))}px sans-serif`,
|
||||
textAlign: "left",
|
||||
maxWidth: parseInt(this.posterWidth * (177 / 311)),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: this.posterInfo.mobile,
|
||||
config: {
|
||||
x: parseInt(this.posterWidth * (108 / 311)),
|
||||
y: parseInt(this.posterWidth * (118 / 311)),
|
||||
color: "#5A5B6E",
|
||||
fontSize: parseInt(this.posterWidth * (12 / 311)).toString(),
|
||||
textAlign: "left",
|
||||
maxWidth: parseInt(this.posterWidth * (177 / 311)),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: this.posterInfo.member_level_name,
|
||||
config: {
|
||||
x: parseInt(this.posterWidth * (108 / 311)),
|
||||
y: parseInt(this.posterWidth * (142 / 311)),
|
||||
color: "#5A5B6E",
|
||||
fontSize: parseInt(this.posterWidth * (12 / 311)).toString(),
|
||||
textAlign: "left",
|
||||
maxWidth: parseInt(this.posterWidth * (177 / 311)),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "活动",
|
||||
config: {
|
||||
x: parseInt(this.posterWidth * (32 / 311)),
|
||||
y: parseInt(this.posterWidth * (172 / 311)),
|
||||
color: "#5A5B6E",
|
||||
font: `bold ${parseInt(this.posterWidth * (14 / 311))}px sans-serif`,
|
||||
textAlign: "left",
|
||||
maxWidth: parseInt(this.posterWidth * (247 / 311)),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: this.posterInfo.activity_name,
|
||||
config: {
|
||||
x: parseInt(this.posterWidth * (32 / 311)),
|
||||
y: parseInt(this.posterWidth * (196 / 311)),
|
||||
color: this.themeColor,
|
||||
fontSize: parseInt(this.posterWidth * (14 / 311)).toString(),
|
||||
textAlign: "left",
|
||||
maxWidth: parseInt(this.posterWidth * (247 / 311)),
|
||||
wrap: true,
|
||||
lineNumber: 2,
|
||||
lineHeight: parseInt(this.posterWidth * (18 / 311)),
|
||||
isVerticalCenter: false
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "地址",
|
||||
config: {
|
||||
x: parseInt(this.posterWidth * (32 / 311)),
|
||||
y: parseInt(this.posterWidth * (235 / 311)),
|
||||
color: "#5A5B6E",
|
||||
font: `bold ${parseInt(this.posterWidth * (14 / 311))}px sans-serif`,
|
||||
textAlign: "left",
|
||||
maxWidth: parseInt(this.posterWidth * (247 / 311)),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: this.posterInfo.address,
|
||||
config: {
|
||||
x: parseInt(this.posterWidth * (32 / 311)),
|
||||
y: parseInt(this.posterWidth * (259 / 311)),
|
||||
color: this.themeColor,
|
||||
fontSize: parseInt(this.posterWidth * (14 / 311)).toString(),
|
||||
textAlign: "left",
|
||||
maxWidth: parseInt(this.posterWidth * (247 / 311)),
|
||||
wrap: true,
|
||||
lineNumber: 2,
|
||||
lineHeight: parseInt(this.posterWidth * (18 / 311)),
|
||||
isVerticalCenter: false
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "image",
|
||||
url: this.posterCode,
|
||||
config: {
|
||||
x: parseInt(this.posterWidth * (106 / 311)),
|
||||
y: parseInt(this.posterWidth * (308 / 311)),
|
||||
w: parseInt(this.posterWidth * (100 / 311)),
|
||||
h: parseInt(this.posterWidth * (100 / 311)),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "参会时,请出示二维码进行核销",
|
||||
config: {
|
||||
x: parseInt(this.posterWidth / 2),
|
||||
y: parseInt(this.posterWidth * (428 / 311)),
|
||||
color: "#5A5B6E",
|
||||
fontSize: parseInt(this.posterWidth * (14 / 311)).toString(),
|
||||
textAlign: "center",
|
||||
lineHeight: parseInt(this.posterWidth * (24 / 311)),
|
||||
},
|
||||
},
|
||||
])
|
||||
const imagePath = await canvasToTempFilePath("myCanvas", this);
|
||||
this.posterPath = imagePath;
|
||||
this.$refs.popupModal.open()
|
||||
uni.hideLoading()
|
||||
},
|
||||
// 保存参会凭证
|
||||
saveImage() {
|
||||
uni.authorize({
|
||||
scope: 'scope.writePhotosAlbum',
|
||||
success: () => {
|
||||
uni.getImageInfo({
|
||||
src: this.posterPath,
|
||||
success: (img) => {
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: img.path,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: "保存成功",
|
||||
icon: "success",
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error(err);
|
||||
},
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error(err)
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
uni.showModal({
|
||||
title: '图片保存失败',
|
||||
content: '请确认是否已开启授权',
|
||||
confirmText: '开启授权',
|
||||
confirmColor: this.themeColor,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.openSetting({
|
||||
success: (setting) => {
|
||||
if (setting.authSetting["scope.writePhotosAlbum"]) {
|
||||
uni.showToast({
|
||||
title: '授权成功,请重新保存',
|
||||
icon: "none"
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请确定已打开保存权限',
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 关闭弹窗
|
||||
onClose() {
|
||||
this.$refs.popupModal.close()
|
||||
},
|
||||
// 改变页面滚动状态
|
||||
onChange(e) {
|
||||
this.$emit("onChange", e.show)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.component-activity-poster {
|
||||
position: relative;
|
||||
z-index: 999;
|
||||
|
||||
.poster-canvas {
|
||||
position: fixed;
|
||||
top: 100vw;
|
||||
left: 100vh;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.poster-popup {
|
||||
.popup-close {
|
||||
width: 100%;
|
||||
margin-top: -112rpx;
|
||||
margin-bottom: 32rpx;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
.icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
.image {
|
||||
width: 80vw;
|
||||
height: 65vh;
|
||||
}
|
||||
}
|
||||
|
||||
.popup-btn {
|
||||
margin-top: 32rpx;
|
||||
width: 336rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
padding: 26rpx 32rpx;
|
||||
border-radius: 16rpx;
|
||||
color: #FFFFFF;
|
||||
background: var(--theme-color);
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user