| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <template>
- <view class="login-form">
- <u-form>
- <view class="form-header">
- <text>{{lang.register}}</text>
- </view>
- <u-form-item :label-position="labelPosition" :label="lang.account" label-width="120">
- <u-input :password-icon="true" v-model="username" :border="border" type="text"
- :placeholder="lang.input_account">
- </u-input>
- </u-form-item>
- <u-form-item :label-position="labelPosition" :label="lang.pwd" label-width="120">
- <u-input :border="border" v-model="upwd" type="password" :placeholder="lang.password"></u-input>
- </u-form-item>
- <u-form-item :label-position="labelPosition" :label="lang.pwd" label-width="120">
- <u-input :border="border" v-model="upwd2" type="password" :placeholder="lang.input_confirm_password">
- </u-input>
- </u-form-item>
- <u-form-item :label-position="labelPosition" :label="lang.verify_code" prop="code" label-width="120">
- <u-input :border="border" v-model="code" :placeholder="lang.verify_code" type="text"></u-input>
- <u-toast ref="uToast"></u-toast>
- <u-verification-code :keep-running="true" :seconds="seconds" @end="end" @start="start" ref="uCode"
- @change="codeChange" :startText="startText" :changeText="changeText" :endText="endText">
- </u-verification-code>
- <u-button slot="right" class="send-code" type="success" size="mini" @click="getCode">{{tips}}</u-button>
- </u-form-item>
- <!-- <u-form-item :label-position="labelPosition" right-icon="scan" label="邀请码" label-width="120">
- <u-input :border="border" v-model="oid" type="text" placeholder="请输入邀请码"></u-input>
- </u-form-item> -->
- <view class="form-btn" @click="reg()">
- {{lang.go_reg}}
- </view>
- <view class="agreement">
- <u-checkbox v-model="check" @change="checkboxChange"></u-checkbox>
- <view class="agreement-text">
- {{lang.protocl}}<text @click="gotoPage('/pages/agreement/register')"
- class="agree">{{lang.service_agree}}</text>
- </view>
- </view>
- </u-form>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- check: false,
- labelPosition: 'left',
- border: false,
- codeTips: '',
- tips: '',
- seconds: 60,
- refCode: null,
- startText: '获取',
- changeText: 'X秒获取',
- endText: '重新获取',
- username: '',
- upwd: '',
- upwd2: '',
- code: '',
- oid: ''
- };
- },
- methods: {
- // 获取验证码
- codeChange(text) {
- this.tips = text;
- },
- checkboxChange() {
- },
- start() {
- console.log('开始')
- },
- end() {
- console.log('结束')
- },
- // 发送验证码
- getCode() {
- if (this.$refs.uCode.canGetCode) {
- // 模拟向后端请求验证码
- uni.showLoading({
- title: '正在获取验证码'
- })
- setTimeout(() => {
- uni.hideLoading();
- // 通知验证码组件内部开始倒计时
- this.$refs.uCode.start();
- this.$request.send('/api/sendmsm', {
- username: this.username,
- }, 'POST').then(res => {
- // 打印调用成功回调
- console.log(res)
- //提示是否发送成功
- this.$u.toast(res.msg);
- })
- }, 2000);
- } else {
- this.$u.toast('请不要频繁发送');
- }
- },
- secondsChange(index) {
- this.seconds = index == 0 ? 60 : index == 1 ? 10 : 5;
- },
- textChange(index) {
- if (index == 0) {
- this.startText = '点一下获取',
- this.changeText = '重新获取Xs',
- this.endText = '再次获取'
- } else {
- this.startText = '获取',
- this.changeText = 'X秒获取',
- this.endText = '重新获取'
- }
- },
- // 注册账户
- reg() {
- var _this = this;
- if (_this.username == '') {
- this.$u.toast('请填写邮箱或手机号');
- return false;
- }
- if (_this.upwd == '') {
- this.$u.toast('请填写登录密码');
- return false;
- }
- if (_this.upwd1 == '') {
- this.$u.toast('请确认登录密码');
- return false;
- }
- if (_this.code == '') {
- this.$u.toast('请填写验证码');
- return false;
- }
- if (_this.upwd != _this.upwd2) {
- this.$u.toast('确认密码不正确');
- return false;
- }
- if (!_this.check) {
- this.$u.toast('请先勾选平台服务条款');
- return false;
- }
- // 调用注册
- this.$request.send('/api/register', {
- username: _this.username,
- password: _this.upwd,
- oid: _this.oid,
- code: _this.code,
- }, 'POST').then(res => {
- // 打印调用成功回调
- if (res.success == true) {
- this.$u.toast(res.msg);
- setTimeout(function() {
- uni.reLaunch({
- url: '/pages/login/login'
- });
- }, 2000)
- } else {
- this.$u.toast(res.msg);
- }
- })
- },
- //返回登录页面
- back() {
- uni.reLaunch({
- url: '/pages/login/login'
- });
- }
- }
- }
- </script>
- <style lang="scss">
- .login-form {
- .u-form {
- padding: 100upx;
- .form-header {
- color: #FFFFFF;
- font-size: 50upx;
- font-weight: bold;
- margin-bottom: 120upx;
- text-align: center;
- text {
- padding: 10upx 30upx;
- }
- }
- .u-form-item {
- background-color: #FFFFFF;
- padding: 10upx 50upx;
- border-radius: 50upx;
- border-width: 0;
- margin-bottom: 40upx;
- }
- .u-border-bottom::after {
- border-width: 0;
- }
- .u-form-item--left__content__label {
- color: #060518;
- }
- .send-code {
- background: linear-gradient(90deg, #F0D8A6 0%, #EBC181 100%);
- color: #060518;
- border-radius: 30upx;
- padding: 10upx 30upx;
- }
- .form-btn {
- background: linear-gradient(90deg, #F0D8A6 0%, #EBC181 100%);
- text-align: center;
- padding: 25upx 30upx;
- border-radius: 50upx;
- margin-top: 60rpx;
- }
- .agreement {
- display: flex;
- align-items: center;
- margin: 40rpx 20rpx;
- .agreement-text {
- padding-left: 8rpx;
- color: $u-tips-color;
- }
- .agree {
- color: #EBC181;
- }
- }
- .u-checkbox__icon-wrap--checked {
- background-color: #EECF98;
- border-color: #EECF98;
- }
- .u-checkbox {
- display: inline-block;
- }
- }
- }
- </style>
|