123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- <template>
- <view class="login-container">
- <view class="login-nav-bar">
- <image class="arrow-back" @tap="backLogin" src="@/static/theme/default/nav_icon_back_black.png" mode="">
- </image>
- </view>
- <!-- <view class="login-title">注册用户</view> -->
- <view class="login-logo">
- <image src="@/static/login/logo.png" alt=""></image>
- </view>
- <view class="login-form">
- <view class="form-item">
- <text class="item-lable">用户名</text>
- <input class="item-input" v-model="form.username" placeholder="请输入用户名/手机号码" />
- </view>
- <view class="form-item">
- <text class="item-lable">输入密码</text>
- <input class="item-input" v-if="close_icon" type="password" v-model="form.password"
- placeholder="请输入密码" />
- <input class="item-input" v-else type="text" v-model="form.password" placeholder="请输入密码" />
- <view class="login-icon" @tap="close_icon = !close_icon">
- <image v-if="close_icon" src="@/static/login/close.png" mode=""></image>
- <image v-else src="@/static/login/open.png" mode=""></image>
- </view>
- </view>
- <!-- <view class="form-item" v-show="form.code_coerce">
- <text class="item-lable">邀请码</text>
- <input class="item-input" v-model="form.code" placeholder="请输入邀请码" />
- </view> -->
- <view class="form-item" >
- <text class="item-lable">验证码</text>
- <input class="item-input" v-model="form.sms_code" placeholder="请输入验证码" />
- <view class="" @click="showText?getCode():''">
- {{showText?'获取验证码':second}}
- </view>
- </view>
- <navigator url="./login" open-type='navigateBack' hover-class="none" class="zai-label">已有账号,点此去登录.
- </navigator>
- <button :class="['landing',checkIn ? 'landing_true' : 'landing_false']" :disabled="checkIn ? false : true"
- class="zai-btn" @tap="subReg">注册</button>
- <view class="login-bottom">
- <text class="tips" @tap="goTerms">《服务协议》</text><text class="tips" @tap="goPrivacy">《隐私协议》</text>
- </view>
- </view>
- <uni-popup ref="popup" type="confirm">
- <uni-popup-confirm title="温馨提示" :beforeClose="true" @close="close" :content="popuMsg" @confirm="confirm">
- </uni-popup-confirm>
- </uni-popup>
- </view>
- </template>
- <script>
- import uniPopup from '../../components/uni-popup/uni-popup.vue';
- import uniPopupConfirm from '../../components/uni-popup/uni-popup-confirm.vue';
- import _get from "../../common/_get";
- import _data from "../../common/_data";
- export default {
- data() {
- return {
- miaoqiang: 'tests',
- popuMsg: '恭喜您注册成功,是否立即更改资料?',
- showPassword: true,
- showText: true,
- second: 60,
- form: {
- mobileCode: 1,
- username: '',
- password: '',
- code: '',
- code_coerce:1,
- client_id: '',
- sms_code: '',
- type: 'REGISTER',
- },
- close_icon: true
- }
- },
- components: {
- uniPopup,
- uniPopupConfirm
- },
- onLoad() {
- },
- onShow() {
- console.log(this.form.mobileCode);
- let _this = this;
- _get.getSysConfig({}, function(res) {
- // console.log('111111111111111111111',res.user_regiter_code_status)
- if (res.user_regiter_sms_status == 1) {
- _this.form.mobileCode = 1
- } else {
- _this.form.mobileCode = 0
- }
- if(res.user_regiter_code_status == 1){
- _this.form.code_coerce = 1
- }else {
- _this.form.code_coerce = 0
- }
- })
- // #ifdef APP-PLUS
- // plus.push.getClientInfoAsync(function(info) {
- // _this.form.client_id = info.clientid;
- // }, function(e) {
- // console.log('Failed');
- // console.log(JSON.stringify(e));
- // });
- // #endif
- },
- computed: {
- checkIn() {
- return this.form.password != '' && this.form.username != '' && this.form.password.length > 5 && this.form
- .username.length > 5;
- }
- },
- methods: {
- backLogin() {
- uni.navigateBack({
- })
- },
- goTerms() {
- uni.navigateTo({
- 'url': '/pages/in/terms'
- })
- },
- goPrivacy() {
- uni.navigateTo({
- 'url': '/pages/in/privacy'
- })
- },
- goPath() {
- uni.navigateTo({
- 'url': '/pages/in/web'
- })
- },
- close() {
- let _this = this;
- uni.reLaunch({
- url: '../chat/index',
- success: function() {
- _this.$refs.popup.close();
- }
- });
- },
- confirm(e) {
- let _this = this;
- uni.redirectTo({
- url: '/pages/my/details',
- success: function() {
- _this.$refs.popup.close();
- }
- });
- },
- isPoneAvailable($poneInput) {
- let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
- if (!myreg.test($poneInput)) {
- return false;
- } else {
- return true;
- }
- },
- getCode() {
- let _this = this;
- if (this.form.username.trim() == '') {
- uni.showToast({
- title: '请输入手机号',
- icon: 'none'
- });
- return false;
- }
- if (!this.isPoneAvailable(this.form.username.trim())) {
- uni.showToast({
- title: '请输入正确的手机号',
- icon: 'none'
- });
- return false;
- }
- _get.getSms({
- mobile: this.form.username,
- type: 'REGISTER'
- }, function(res) {
- console.log(22222)
- _this.cutDown();
- }, function(res) {
- console.log(1111)
- uni.showToast({
- title: res.msg,
- duration: 2000,
- icon: 'none'
- });
- })
- },
- cutDown(val) { //倒计时
- //获取验证码
- this.showText = false;
- var interval = setInterval(() => {
- let times = --this.second;
- times = times < 0 ? 0 : times;
- this.second = times < 10 ? '0' + times : times //小于10秒补 0
- }, 1000)
- setTimeout(() => {
- clearInterval(interval)
- this.second = 60
- this.showText = true
- }, 60000)
- },
- changePassword() {
- this.showPassword = !this.showPassword;
- },
- delInputUsernameText() {
- this.form.username = ''
- },
- delInputPasswordText() {
- this.form.password = ''
- },
- subReg() {
- let _this = this;
- if (!_this.checkIn) {
- return;
- }
- if (!(/^\w{1,20}$/.test(this.form.username))) {
- uni.showModal({
- content: '密聊号只能包括下划线、数字、字母,并且不能超过20个',
- });
- return;
- }
- if (!(/^\w{1,20}$/.test(this.form.password))) {
- uni.showModal({
- content: '密码只能包括下划线、数字、字母,长度6-20位',
- });
- return;
- }
- let channelCode = _data.localData('xInstallChannelCode');
- if (channelCode) {
- _this.form.channel = channelCode;
- }
- /* uni.showModal({
- content: "xxx2:"+channelCode,
- showCancel: false,
- }); */
- uni.navigateTo({
- url: './finish?username=' + _this.form.username + "&password=" + _this.form.password + "&code=" + _this.form.code + "&sms_code=" + _this.form.sms_code
- })
- return
- uni.showLoading({
- title: '注册中'
- })
- _this.$httpSend({
- path: '/im/in/reg',
- data: _this.form,
- success: (data) => {
- uni.setStorage({
- key: 'token',
- data: data.token,
- fail: () => {
- uni.showModal({
- content: '本地存储数据不可用!',
- });
- },
- success() {
- _this.$socketSend({
- action: 'checkToken',
- data: data.token,
- }, function() {
- uni.hideLoading();
- _this.$refs.popup.open();
- // uni.reLaunch({
- // url: '../chat/index',
- // });
- })
- },
- });
- }
- });
- },
- go_forget() {
- uni.navigateTo({
- url: '../../pages/in/forget'
- })
- },
- go_register() {
- uni.navigateTo({
- url: '../../pages/in/reg'
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .uni-input-placeholder {
- color: #ccc !important;
- }
- input[type="password"]::-ms-reveal {
- display: none;
- }
- .login-icon {
- image {
- width: 40rpx;
- height: 40rpx;
- }
- }
- .login-nav-bar {
- height: 44px;
- display: flex;
- align-items: center;
- position: absolute;
- justify-content: flex-start;
- left: 0;
- top: 0;
- /* #ifdef APP-PLUS */
- top: var(--status-bar-height);
- /* #endif */
- .arrow-back {
- width: 44rpx;
- height: 44rpx;
- margin-left: 20rpx;
- }
- }
- .login-container {
- background-color: #ffffff;
- height: 100vh;
- width: 100vw;
- padding: 0 60rpx;
- position: relative;
- box-sizing: border-box;
- // background-image: url(@/static/login/bg.png);
- background-repeat: no-repeat;
- background-size: 100% auto;
- .login-form {
- display: flex;
- flex-direction: column;
- .login-bottom {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100rpx;
- .login-random {
- text-decoration: none;
- color: #999;
- font-size: 14px;
- }
- .tips {
- font-size: 12px;
- color: #b5746c;
- height: 60rpx;
- line-height: 60rpx;
- text-align: center;
- // width: 100%;
- }
- }
- .login-btn {
- width: 100%;
- height: 100rpx;
- border-radius: 50px;
- background-color: #2da2fd;
- color: #fff;
- font-size: 16px;
- display: flex;
- justify-content: center;
- align-items: center;
- margin-top: 100rpx;
- }
- .form-item {
- display: flex;
- height: 100rpx;
- align-items: center;
- border-bottom: 1px solid #eee;
- .item-lable {
- font-size: 16px;
- color: #333;
- width: 180rpx;
- }
- .item-input {
- border: none;
- outline: none;
- background: none;
- font-size: 16px;
- color: #000;
- height: 100%;
- flex: 1;
- }
- }
- }
- .login-title {
- padding-top: 250rpx;
- font-size: 24px;
- font-weight: bold;
- padding-bottom: 150rpx;
- }
- .login-logo{
- padding-top: 200rpx;
- padding-bottom: 80rpx;
- text-align: center;
- }
- .login-logo image{
- width: 150rpx;
- height: 150rpx;
- }
- }
- .zai-viewl {
- width: 100%;
- display: flex;
- justify-content: center;
- }
- .zai-box {
- padding: 0 100upx;
- position: relative;
- }
- .zai-logo {
- width: 160upx;
- width: 160upx;
- height: 160upx;
- margin-top: 114upx;
- }
- .zai-title {
- position: absolute;
- top: 0;
- line-height: 360upx;
- font-size: 68upx;
- color: #fff;
- text-align: center;
- width: 100%;
- margin-left: -100upx;
- }
- .zai-form {
- margin-top: 150upx;
- }
- .form-code {
- margin-top: 30upx;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100%;
- }
- .form-code .code {
- height: 100%;
- border-radius: 50px;
- text-align: center;
- font-size: 14px;
- background: #ff65a3;
- color: #ffffff;
- }
- .zai-input {
- background: #e2f5fc;
- margin-top: 30upx;
- border-radius: 100upx;
- padding: 20upx 40upx;
- font-size: 36upx;
- }
- .code-input {
- background: #e2f5fc;
- border-radius: 100upx;
- padding: 20upx 40upx;
- font-size: 36upx;
- width: 40%;
- }
- .input-placeholder,
- .zai-input {
- color: #94afce;
- }
- .zai-label {
- text-align: center;
- font-size: 30upx;
- color: #666;
- height: 120rpx;
- display: flex;
- align-items: center;
- text-align: left;
- }
- .zai-btn {
- background: #2da2fd;
- border: 0;
- border-radius: 50rpx;
- font-size: 16px;
- color: #fff;
- width: 100%;
- height: 100rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .zai-btn:after {
- border: 0;
- }
- /*按钮点击效果*/
- .zai-btn.button-hover {
- transform: translate(1upx, 1upx);
- }
- .zai-footer {
- display: flex;
- justify-content: center;
- align-items: center;
- color: #a7b6d0;
- padding-top: 10px;
- }
- </style>
|