You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

521 lines
13 KiB

3 years ago
<template>
<!--pages/activity/detail/index.wxml-->
<view class="activityDetail-page">
<view class="activity-info-box">
<view class="activity-banner">
<image :src="activityDetail.images" mode="widthFix"></image>
</view>
<view class="activity-title line2">{{activityDetail.name}}</view>
<view class="activity-tips-box acea-row">
<view class="price">{{activityDetail.price}}/</view>
<view class="tips acea-row">
<view v-for="(item, index) in activityDetail.flag" :key="index" :class="activityDetail.status == 3 ? 'default-btn' : 'tip-item'">{{item}}</view>
</view>
</view>
<!-- <view class="step-box">
<wux-steps current="{{ current }}">
<wux-step title="筹备中" content="{{activityDetail.time1}}"></wux-step>
<wux-step title="报名中" content="{{activityDetail.time2}}"></wux-step>
<wux-step title="待举办" content="{{activityDetail.time3}}"></wux-step>
<wux-step title="已结束" content="{{activityDetail.time4}}"></wux-step>
</wux-steps>
</view> -->
<view class="activity-info">
<view class="info-item">
<view class="label">活动举办时间:</view>
<view class="info">{{activityDetail.activityStartTime}} {{activityDetail.activityEndTime}}</view>
</view>
<view class="info-item">
<view class="label">报名截止时间:</view>
<view class="info">{{activityDetail.applyEndTime}}</view>
</view>
<view class="info-item" @tap="openMap">
<view class="label">活动举办地址:</view>
<view class="info">{{activityDetail.address}}</view>
</view>
<view class="info-item">
<view class="label">参加人数限制:</view>
<view class="info">{{activityDetail.users.length}}/{{activityDetail.limit}}</view>
</view>
</view>
</view>
<!-- <view class="company-info-box acea-row row-middle">
<view class="company-logo">
<image src="{{activityDetail.publisherVo.image}}"></image>
</view>
<view class="company-info">
<view class="company-name">{{activityDetail.publisherVo.name}}</view>
<view class="company-des line2">{{activityDetail.publisherVo.desc}}</view>
</view>
</view> -->
<view class="activity-des-box">
<view class="title2">活动简介</view>
<text class="line2">{{activityDetail.desc}}</text>
<view class="see-detail acea-row row-center-wrapper" @tap="toDescribe">查看详情 <image src="/static/images/arror-r-s.png"></image></view>
</view>
<view class="info-item join-box">
<view class="label" style="margin-right:0;">最近参与人:</view>
<view class="info headerImg-info" v-if="activityDetail.users.length > 0">
<image v-for="(item, index) in activityDetail.users" :key="index" :src="item.avatar"></image>
</view>
<view class="info headerImg-info" v-else>快分享给好友一起报名参与吧</view>
</view>
<view class="handle-box acea-row row-middle row-between">
<view class="acea-row">
<view class="call-box acea-row row-middle" @tap="call">
<image src="/static/images/phone.png"></image>
<text>拨号</text>
</view>
<view class="call-box acea-row row-middle" @tap="collect">
<image src="/static/images/collect.png"></image>
<text>{{activityDetail.collect ? '已收藏':'收藏'}}</text>
</view>
</view>
<view class="handle-btn-box">
<!-- <view class="cancel-btn">取消报名</view> -->
<view class="cancel-btn" v-if="activityDetail.status == 2">报名截止</view>
<view class="cancel-btn" v-if="activityDetail.status == 3">活动结束</view>
<view class="cancel-btn" v-if="activityDetail.status == 0">等待报名</view>
<view class="cancel-btn signIn-btn" @tap="toSignPage" v-if="activityDetail.status == 1">立即报名</view>
</view>
</view>
</view>
</template>
<script>
// pages/activity/detail/index.js
const app = getApp();
import util from '../../../utils/util';
// import wuxSteps from "../../../dist/steps/index";
// import wuxStep from "../../../dist/step/index";
export default {
data() {
return {
activityId: '',
activityDetail: {},
current: 1
};
},
components: {
// wuxSteps,
// wuxStep
},
props: {},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let erCodeId = uni.getStorageSync('activityId');
if (options.id) {
this.setData({
activityId: options.id
});
this.getDetail();
}
if (erCodeId && !options.id) {
//扫码进来
console.log('扫码进来');
this.setData({
activityId: erCodeId
});
this.getDetail();
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {},
methods: {
getDetail() {
app.http('GET', 'activity/activityInfo/' + this.activityId).then(res => {
if (res.data.success) {
let detail = res.data.data;
detail.time1 = util.setTime(detail.createTime).split(' ')[0];
detail.time2 = util.setTime(detail.applyStartTime).split(' ')[0];
detail.time3 = util.setTime(detail.applyEndTime).split(' ')[0];
detail.time4 = util.setTime(detail.activityEndTime).split(' ')[0];
detail.flag = detail.flag.split(',');
detail.activityStartTime = util.setTime(detail.activityStartTime);
detail.activityEndTime = util.setTime(detail.activityEndTime);
detail.applyStartTime = util.setTime(detail.applyStartTime);
detail.applyEndTime = util.setTime(detail.applyEndTime);
this.setData({
activityDetail: detail,
current: detail.status
});
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
});
}
});
},
openMap() {
const latitude = this.activityDetail.latitude;
const longitude = this.activityDetail.longitude;
uni.openLocation({
latitude,
longitude,
scale: 18
});
},
shareClick() {
uni.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
});
},
call() {
uni.makePhoneCall({
phoneNumber: this.activityDetail.publisherVo.phone,
fail: function () {
console.log('取消');
}
});
},
collect() {
let data = {};
data.id = this.activityDetail.id;
data.type = 'collect';
data.status = this.activityDetail.collect ? false : true;
if (uni.getStorageSync('userInfo') != '') {
this.requestCollect(data);
} else {
uni.getUserProfile({
desc: '展示用户信息',
// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: res => {
console.log(res);
var iv = res.iv;
var encryptedData = res.encryptedData;
var userInfo = res.userInfo;
uni.login({
success: request => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
app.http('POST', 'wxapp/auth', {
code: request.code,
iv: iv,
encryptedData: encryptedData
}).then(response => {
if (response.data.success) {
uni.setStorageSync('token', 'Bearer ' + response.data.data.token);
uni.setStorageSync('userInfo', userInfo);
this.requestCollect(data);
} else {
uni.showToast({
title: response.data.msg,
icon: 'none'
});
}
});
}
});
}
});
}
},
requestCollect(data) {
app.http('POST', 'activity/collect', data).then(res => {
if (res.data.success) {
uni.showToast({
title: '操作成功!'
});
this.getDetail();
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
});
}
});
},
toSignPage() {
if (uni.getStorageSync('userInfo') != '') {
uni.navigateTo({
url: '../signIn/index?id=' + this.activityId
});
} else {
this.getUserProfile();
}
},
toDescribe() {
uni.navigateTo({
url: '../describe/index?id=' + this.activityDetail.id
});
},
getUserProfile() {
uni.getUserProfile({
desc: '展示用户信息',
// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: res => {
console.log(res);
var iv = res.iv;
var encryptedData = res.encryptedData;
var userInfo = res.userInfo;
uni.login({
success: request => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
app.http('POST', 'wxapp/auth', {
code: request.code,
iv: iv,
encryptedData: encryptedData
}).then(response => {
if (response.data.success) {
uni.setStorageSync('token', 'Bearer ' + response.data.data.token);
uni.setStorageSync('userInfo', userInfo);
uni.navigateTo({
url: '../signIn/index?id=' + this.activityId
});
} else {
uni.showToast({
title: response.data.msg,
icon: 'none'
});
}
});
}
});
}
});
}
}
};
</script>
<style>
/* pages/activity/detail/index.wxss */
.activityDetail-page{
background: #f2f2f2;
min-height: 100%;
padding-bottom: 240rpx;
}
.activity-info-box,.company-info-box,.activity-des-box,.join-box{
width: 100%;
box-sizing: border-box;
padding: 0 32rpx 40rpx;
background: #fff;
font-size: 32rpx;
}
.activity-banner{
width: 100%;
height: 404rpx;
border-radius: 12rpx;
overflow: hidden;
}
image{
width: 100%;
}
.activity-title{
color: #333333;
font-weight: 600;
line-height: 44rpx;
margin: 32rpx 0 10rpx;
}
.price{
min-width: 200rpx;
color: #EBB672;
font-weight: 600;
margin-right: 28rpx;
}
.tips{
width: 74%;
flex-wrap: wrap;
margin-top: 12rpx;
}
.tip-item{
height: 36rpx;
margin-bottom: 6rpx;
line-height: 36rpx;
text-align: center;
padding: 0rpx 16rpx;
color: #fff;
font-size: 20rpx;
background: #C93535;
margin-right: 24rpx;
}
.default-btn{
height: 36rpx;
margin-bottom: 6rpx;
line-height: 36rpx;
text-align: center;
padding: 0rpx 16rpx;
color: #fff;
font-size: 20rpx;
background: #A29E9E;
margin-right: 24rpx;
}
.join-box{
height: 100rpx;
padding: 26rpx 32rpx;
box-sizing: border-box;
color: #727272;
}
.step-box{
margin-top: 32rpx;
}
.wux-step--process .wux-step__icon {
background: #FFC985 !important;
border-color: #FFC985 !important;
}
.wux-step__title {
color: #B5B5B5 !important;
font-size: 20rpx !important;
font-weight: 400 !important;
}
.wux-step--process .wux-step__title{
color: #FFC985 !important;
}
.wux-step__content{
font-size: 20rpx !important;
margin-top: 0 !important;
}
.wux-step--process .wux-step__content{
color: #FFC985 !important;
}
.wux-step__bd {
margin-top: 10rpx !important;
}
.info-item{
display: flex;
justify-content: start;
align-items: center;
margin-top: 40rpx;
color: #353535;
font-size: 28rpx;
}
.label{
width: 180rpx;
text-align: left;
margin-right: 20rpx;
color: #868686;
}
.headerImg-info{
width: calc(100% - 180rpx);
color: #333333;
overflow-x: scroll;
white-space: nowrap;
}
.info image{
width: 68rpx;
height: 68rpx;
margin-left: 16rpx;
display: inline-block;
border-radius: 50%;
}
.company-info-box,.activity-des-box{
margin-top: 32rpx;
padding-top: 32rpx;
font-size: 24rpx;
}
.company-logo image{
width: 132rpx;
height: 132rpx;
margin-right: 24rpx;
border-radius: 50%;
}
.company-name{
color: #333333;
font-size: 28rpx;
margin-bottom: 16rpx;
}
.activity-des-box{
color: #727272;
}
.title2{
color: #333;
font-size: 32rpx;
margin-bottom: 24rpx;
}
.see-detail{
color: #333;
text-align: center;
margin-top: 12rpx;
}
.see-detail image{
width: 24rpx;
height: 24rpx;
}
.handle-box {
width: 100%;
box-sizing: border-box;
position: fixed;
bottom: 0;
left: 0;
background: #fff;
padding: 42rpx 32rpx 80rpx;
box-shadow: 0px -2px 8px 0px rgba(0,0,0,0.1);
}
.call-box{
margin-right: 54rpx;
}
.call-box image{
width: 37rpx;
height: 37rpx;
font-size: 28rpx;
color: #333333;
margin-right: 12rpx;
}
.cancel-btn{
width: 234rpx;
height: 60rpx;
text-align: center;
line-height: 60rpx;
background: #F4F4F4;
border-radius: 30rpx;
color: #868686;
font-size: 32rpx;
}
.signIn-btn{
background: #EBB672;
color: #fff;
}
</style>