123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- <template>
- <view>
- <view class="logo">
- <image src="../../static/logo.png" mode="aspectFit"></image>
- </view>
- <view class="form">
- <uni-forms ref="form" :modelValue="formData" :rules="rules" :label-width="90" label-align="right">
- <uni-forms-item label="所在地" name="provinceCode">
- <view class="form-item">
- <uni-data-select :clear="false" v-model="formData.provinceCode" placeholder="请选择您所在的省市"
- :localdata="provinces"></uni-data-select>
- <view class="des-text">省/市</view>
- </view>
- </uni-forms-item>
- <!-- <uni-forms-item label="学校" name="name">
- <uni-easyinput type="text" :clearable="false" v-model="formData.mobile" placeholder="请输入所在学校" />
- </uni-forms-item> -->
- <uni-forms-item label="高考年份" name="enrollYear">
- <view class="form-item">
- <uni-data-select :clear="false" v-model="formData.enrollYear" placeholder="请选择您的高考年份"
- :localdata="years"></uni-data-select>
- <view class="des-text"></view>
- </view>
- </uni-forms-item>
- <uni-forms-item label="姓名" name="name">
- <view class="form-item">
- <uni-easyinput type="text" :clearable="false" v-model="formData.name" placeholder="请输入姓名" />
- <view class="des-text"></view>
- </view>
- </uni-forms-item>
- <uni-forms-item label="性别" name="gender">
- <view class="form-item">
- <uni-data-checkbox v-model="formData.gender" :localdata="genders"></uni-data-checkbox>
- <view class="des-text"></view>
- </view>
- </uni-forms-item>
- </uni-forms>
- <button class="submit" :class="{'submit-disabled': !isDisabled}" @click="submit">提交</button>
- </view>
- </view>
- </template>
- <script lang="ts" setup>
- import { ref, reactive, computed } from 'vue'
- import { onLoad } from '@dcloudio/uni-app'
- import { getFutureYears } from '@/utils/index'
- import { provincesList, registerUser, prefUser } from '@/api/h5.js'
- const unitCode = ref('')
- const isDisabled = computed(() => {
- return formData.enrollYear && formData.gender && formData.name && formData.provinceCode
- })
- const formData = reactive({
- enrollYear: '',
- mobilePhone: '',
- gender: '',
- name: '',
- password: '',
- provinceCode: '',
- })
- const rules = reactive({
- enrollYear: {
- rules: [{
- required: true,
- errorMessage: '请选择您的高考年份',
- }]
- },
- gender: {
- rules: [{
- required: true,
- errorMessage: '请选择性别',
- }]
- },
- name: {
- rules: [{
- required: true,
- errorMessage: '请输入姓名',
- }]
- },
- provinceCode: {
- rules: [{
- required: true,
- errorMessage: '请选择您所在的省市',
- }]
- },
- })
- const genders = ref([
- { "value": '男', "text": "男" },
- { "value": '女', "text": "女" }
- ])
- const years = ref([])
- const provinces = ref([])
- const getProvincesList = async () => {
- const res = await provincesList({})
- if (res.code === 200) {
- provinces.value = Object.keys(res.data)?.map((item, index) => {
- return {
- value: item,
- text: res.data[item]
- }
- })?.filter(item => item.value != '65')
- }
- }
- const handlePrefUser = async () => {
- const res = await prefUser({
- mobilePhone: formData.mobilePhone,
- prefUnitCode: unitCode.value
- })
- if(res.code === 200) {
- // uni.showToast({
- // title: res.message,
- // icon: 'none'
- // })
- setTimeout(() => {
- uni.reLaunch({
- url: `/pages/result/result?provinceCode=${formData.provinceCode}`
- })
- }, 800)
- }
- }
- const form = ref()
- const submit = () => {
- if(isDisabled.value) {
- form.value.validate().then(async data => {
- const res = await registerUser(formData)
- if(res.code === 200) {
- handlePrefUser()
- }
- })
- }
- }
- onLoad((options) => {
- const parameter = JSON.parse(decodeURIComponent(options.parameter));
- unitCode.value = parameter.unitCode
- formData.mobilePhone = parameter.mobilePhone
- formData.password = parameter.password
- years.value = getFutureYears(3)?.map(item => {
- return {
- value: item,
- text: item
- }
- })
- getProvincesList()
- })
- </script>
- <style lang="scss" scoped>
- .form {
- padding: 0 40rpx;
- :deep(.uni-easyinput__content) {
- border: none;
- }
- :deep(.uni-forms-item__label) {
- height: 88rpx;
- font-weight: 500;
- font-size: 32rpx;
- color: #1D2129;
- line-height: 38rpx;
- }
- :deep(.uni-stat__select) {
- height: 88rpx;
- border-radius: 24rpx;
- background: #F1F5FE;
- .uni-stat-box {
- height: 88rpx;
- .uni-select {
- height: 100%;
- border: none;
- .uni-select__input-text {
- font-weight: 500;
- font-size: 32rpx;
- color: #1D2129;
- }
- .uni-select__input-placeholder {
- font-weight: 400;
- font-size: 32rpx;
- color: #86909C;
- line-height: 38rpx;
- }
- .uni-icons {
- font-size: 32rpx !important;
- margin-right: 10rpx;
- }
- }
- }
- }
- :deep(.uni-data-checklist) {
- height: 88rpx;
- display: flex;
- align-items: center;
- .radio__inner {
- width: 32rpx !important;
- height: 32rpx !important;
- }
- .radio__inner-icon {
- width: 16rpx !important;
- height: 16rpx !important;
- }
- .checklist-text {
- font-weight: 400;
- font-size: 36rpx !important;
- color: #1D2129;
- }
- }
- :deep(.uni-easyinput__content-input) {
- background: #F1F5FE;
- height: 88rpx;
- border-radius: 24rpx;
- font-weight: 500;
- font-size: 32rpx;
- color: #1D2129;
- line-height: 38rpx;
- }
- :deep(.uni-input-placeholder) {
- font-weight: 400;
- font-size: 32rpx;
- color: #86909C;
- line-height: 38rpx;
- }
- .form-area {
- width: 100%;
- background: #F1F5FE;
- border-radius: 24rpx;
- height: 88rpx;
- :deep(.input-block) {
- width: calc(100% - 10px);
- height: 88rpx;
- padding-left: 10px;
- }
- }
- .submit {
- height: 112rpx;
- background: #3682EA;
- border-radius: 24rpx;
- font-weight: 500;
- font-size: 36rpx;
- color: #FFFFFF;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: 128rpx;
- }
- .submit-disabled {
- background: #B0CDFF;
- }
- .form-item {
- display: flex;
- align-items: center;
- .des-text {
- width: 80rpx;
- font-weight: 400;
- font-size: 32rpx;
- color: #4E5969;
- margin-left: 20rpx;
- }
- }
- }
- </style>
|