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.

317 lines
6.8 KiB

<template>
<view class='wrap'>
<view class="formwrap">
<view class='logintitle'>
<image src="@/static/index_logo.png" class="logo" alt="" />
<image src="@/static/logo3.png" class="words" alt="" />
<view class="subtitle">
排查身边灾害隐患</view>
<view class='logintitletext'>
<span>答题时间</span>
<span>{{startTime}}{{endTime}}</span>
</view>
</view>
<view class="loginform">
<view>
<u-input :placeholderStyle="'color:#999;font-size:30rpx'"
:custom-style="{'background':'#fff','padding':'15rpx 30rpx','border-radius':'80rpx'}"
v-model="form.name" placeholder="请输入姓名" :border="false" shape="circle" clearable></u-input>
</view>
<view>
<u-input :placeholderStyle="'color:#999;font-size:30rpx'"
:custom-style="{'background':'#fff','padding':'15rpx 30rpx','border-radius':'80rpx'}"
v-model="form.mobile" placeholder="请输入手机号" :border="false" shape="circle" clearable></u-input>
</view>
</view>
<view class="loginbtn">
<u-button size="mini" :throttle-time="2000" shape="circle" type="default" :custom-style="parStyle"
@click="submit">提交</u-button>
<image src="@/static/logintip.png" class="logintips" alt="" @click="showtips=true" />
</view>
</view>
<!-- 活动须知 -->
<u-popup v-model="showtips" mode="center">
<view class="tipwrap">
<view class="tiptitle">
活动须知
</view>
<view class="tipcenter">
<view>
<view v-html="active_tip"></view>
</view>
</view>
<view class="answerBtn">
<view @click="showtips=false">知道了</view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
import {
isNull,toast
} from "@/common/util.js"
export default {
data() {
return {
parStyle: {
'background': 'linear-gradient(to right, #2754a5, #2b83bb)',
'color': '#fff',
'font-size': '28rpx',
'padding': '20rpx 30rpx',
'margin-left': '15rpx',
'margin-top': '80rpx',
'width': '100%',
'height': '80rpx'
},
tip: '',
form: {
name: '',
mobile: '',
},
isEnd: true,
showtips: false,
tiptitle: '',
active_tip: '',
maskHeight: 0,
windowHeight: 0,
activeConfig: {},
startTime: '',
endTime: '',
}
},
onShow() {
let user = this.vuex_user
if (user) {
if (!isNull(user.mobile)) {
uni.redirectTo({
url: '/pages/me/me'
})
}
}
},
onLoad() {
this.isEnd = uni.getStorageSync('isEnd')
this.active_tip = uni.getStorageSync('active_tip')
console.log("uni.getStorageSync('active_tip')",uni.getStorageSync('active_tip'))
this.activeConfig = uni.getStorageSync('activeConfig')
if (this.activeConfig.start_time) {
this.startTime = this.formatDateToMonthDay(this.activeConfig.start_time)
}
if (this.activeConfig.end_time) {
this.endTime = this.formatDateToMonthDay(this.activeConfig.end_time)
}
},
methods: {
formatDateToMonthDay(dateString) {
const month = this.$moment(dateString).format('MM')
const day = this.$moment(dateString).format('DD')
return `${month}月${day}日`;
},
openTips() {
const query = uni.createSelectorQuery().in(this);
query.select('.wrap').boundingClientRect(({
height
}) => {
console.log("height", height);
if (this.windowHeight > height) {
this.maskHeight = this.windowHeight;
} else {
this.maskHeight = height;
}
}).exec();
this.showtips = true
// this.showSucess = true
},
isOnlyChinese(str) {
const chineseRegex = /^[\u4e00-\u9fa5]+$/;
return chineseRegex.test(str);
},
submit() {
if (!this.isEnd) {
toast("活动已结束")
return
}
if (isNull(this.form.name) || isNull(this.form.mobile)) {
toast("请填写所有信息")
return
}
if (!this.isOnlyChinese(this.form.name)) {
toast("请输入中文姓名")
return
}
if (!isNull(this.form.mobile) && !uni.$u.test.mobile(this.form.mobile)) {
toast("请输入正确的手机号")
return
}
this.$u.api.saveUser({
...this.form
}).then(res => {
this.$u.vuex('vuex_user', res);
uni.showToast({
title: '注册成功',
icon: 'none',
duration: 1500,
success() {
uni.redirectTo({
url: '/pages/me/me'
})
}
})
})
}
}
}
</script>
<style scoped lang="scss">
.wrap {
height: 100vh;
width: 100vw;
background-image: url('../../static/bg.jpg');
background-size: 100% 100%;
background-repeat: no-repeat;
overflow: scroll;
.formwrap {
width: 90%;
padding-top: 100rpx;
margin: 0 auto;
padding-bottom: 120rpx
}
.logintitle {
.logo {
width: 293rpx;
height: 294rpx;
margin: 0 auto;
display: block;
}
.words {
width: 702rpx;
height: 88rpx;
margin: 0 auto;
display: block;
}
.subtitle {
color: #2754a5;
text-align: center;
font-size: 28rpx;
margin: 0 auto;
margin-top: 20rpx;
}
.logintitletext {
margin-top: 40rpx;
text-align: center;
}
.logintitletext span {
font-size: 28rpx;
color: #999999;
border-radius: 0 60rpx 60rpx 0;
background-color: #fff;
padding: 10rpx 20rpx
}
.logintitletext span:first-child {
background-color: #0095e5;
color: #fff;
border-radius: 60rpx 0 0 60rpx;
}
}
.loginbtn {
padding: 20rpx 30rpx;
padding-top: 0;
.logintips {
width: 141rpx;
height: 28rpx;
margin: 20rpx auto;
display: block;
}
}
}
.tipwrap {
width: 650rpx;
// background: #fff;
font-size: 28rpx;
padding:30rpx;
.tiptitle {
width: 100%;
text-align: center;
font-size: 36rpx;
}
.tipcenter {
background-color: #fff;
min-height: 200rpx;
line-height: 1.8;
width: 100%;
box-sizing: content-box;
margin-top: -5rpx;
&>view {
padding: 20px;
padding-bottom: 0;
}
}
.answerBtn {
text-align: center;
padding-bottom: 40rpx;
background-color: #fff;
width: 100%;
text-align: center;
margin-top: -5rpx;
padding-top: 40rpx;
position: relative;
top: 0;
left: 0;
&>view {
box-shadow: 1rpx 7rpx 18rpx 0rpx #2754a5;
color: #333;
padding: 16rpx 70rpx;
margin: 10rpx;
font-size: 28rpx;
border-radius: 10rpx;
display: inline-block;
}
&>view:last-child {
color: #fff;
background: linear-gradient(90deg, #2754a5, #2b83bb);
}
}
}
.loginform {
padding: 30rpx 20rpx;
margin-top: 30rpx
}
.loginform>view {
margin-bottom: 40rpx;
}
</style>