| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <template>
- <view>
- <image class="syslogo" mode="widthFix" :src="param.syslogo"></image>
- <view class="formbox">
- <view class="finput">
- <input placeholder="请输入姓名..." @input="bindInput" data-val="realname" :value="userinfo.realname" />
- </view>
- <view class="finput">
- <input type="number" maxlength="11" placeholder="请输入手机号..." @input="bindInput" data-val="mobile" :value="userinfo.mobile" />
- </view>
- <view class="finput codebox">
- <input type="number" maxlength="6" placeholder="请输入短信验证码..." @input="bindInput" data-val="smscode" :value="userinfo.smscode" />
- <view class="codeimg" @tap="getSmsCode">{{smsbtn.text}}</view>
- </view>
- <view class="finput">
- <input placeholder="请输入登录密码(至少8位)..." @input="bindInput" data-val="password" :value="userinfo.password" />
- </view>
- <button class="registerbtn" type="primary" @click="goRegister"> {{ loading ? "注册中...":"立即注册"}} </button>
- <view class="pagetip">
- <view class="left">
- <navigator open-type="switchTab" url="/pages/index/index">返回首页</navigator>
- </view>
- <view class="right"><text>已有账号,</text>
- <navigator open-type="redirect" url="/pages/login/login">立即登录</navigator>
- </view>
- </view>
- <view class="registertip">
- <text>注册即表示同意</text>
- <navigator open-type="navigate" url="/pages/sinpage/sinpage?op=register">《用户协议》</navigator>
- </view>
- </view>
- </view>
- </template>
- <script>
- var that;
- export default {
- data() {
- return {
- param: {},
- loading: false,
- userinfo: {
- workerid: 0,
- parentid: 0,
- realname: "",
- mobile: "",
- smscode: "",
- password: ""
- },
- smsbtn: {
- text: '获取验证码',
- status: false,
- codeTime: 60
- },
- smscodemd5: "",
- timerId: null
- }
- },
- onLoad: function(option) {
- that = this;
- that.smscodemd5 = uni.getStorageSync('smscodemd5') || "";
- that.$req.ajax({
- data: {
- do: 'register',
- op: 'display'
- },
- }).then((data) => {
- that.param = data.param;
- }).catch((err) => {
- console.log("err: " + JSON.stringify(err));
- });
-
- // #ifdef H5
- that.userinfo.workerid = workerid;
- that.userinfo.parentid = parentid;
- // #endif
- },
- onShareAppMessage: function(res) {
- return {
- title: that.param.sharetitle,
- path: '/pages/index/index'
- }
- },
- onNavigationBarButtonTap: function(e) {
- uni.switchTab({
- url: '/pages/index/index'
- });
- },
- methods: {
- getSmsCode: function() {
- if (that.smsbtn.status == true) {
- return true;
- }
- var myreg = /^((1)+\d{10})$/;
- if (!myreg.test(that.userinfo.mobile)) {
- uni.showModal({
- title: '温馨提示',
- content: '手机号格式不对。',
- showCancel: false
- });
- return;
- }
- that.smsbtn.status = true;
- that.$req.ajax({
- data: {
- do: 'register',
- op: 'getsmscode',
- mobile: that.userinfo.mobile
- }
- }).then((data) => {
- uni.setStorageSync('smscodemd5', data.smscodemd5);
- that.smscodemd5 = data.smscodemd5;
- that.timerId = setInterval(() => {
- var codeTime = that.smsbtn.codeTime;
- codeTime--;
- that.smsbtn.codeTime = codeTime;
- that.smsbtn.text = codeTime + "S";
- if (codeTime < 1) {
- clearInterval(that.timerId);
- that.smsbtn.text = "重新获取";
- that.smsbtn.codeTime = 60;
- that.smsbtn.status = false;
- }
- }, 1000);
- }).catch((err) => {
- uni.showModal({
- title: '温馨提示',
- content: err,
- showCancel: false
- });
- that.smsbtn.status = false;
- });
- return false;
- },
- goRegister: function() {
- that.loading = true;
- that.$req.ajax({
- data: {
- do: 'register',
- op: 'goregister',
- workerid: that.userinfo.workerid,
- parentid: that.userinfo.parentid,
- realname: that.userinfo.realname,
- mobile: that.userinfo.mobile,
- smscode: that.userinfo.smscode,
- password: that.userinfo.password,
- smscodemd5: that.smscodemd5
- }
- }).then((data) => {
- if (data.regstatus == 2) {
- uni.setStorageSync('userinfo', data.user);
- uni.showModal({
- title: '温馨提示',
- content: '注册成功,请尽快完善个人信息。',
- showCancel: false,
- success: function(res) {
- if (res.confirm) {
- uni.reLaunch({
- url: "/pages/my/my"
- })
- }
- }
- });
- } else if (data.regstatus == 1) {
- uni.showModal({
- title: '温馨提示',
- content: '注册成功,请耐心等待审核。',
- showCancel: false,
- success: function(res) {
- if (res.confirm) {
- uni.reLaunch({
- url: "/pages/login/login"
- })
- }
- }
- });
- }
- uni.removeStorageSync('smscodemd5');
- that.loading = false;
- }).catch((err) => {
- uni.showModal({
- title: '温馨提示',
- content: err,
- showCancel: false
- });
- that.loading = false;
- });
- },
- bindInput: function(e) {
- const that = this;
- var dataval = e.currentTarget.dataset.val;
- that.userinfo[dataval] = e.detail.value;
- }
- }
- }
- </script>
- <style>
- page {
- background-color: #FFFFFF;
- }
- .syslogo {
- width: 750rpx;
- }
- .formbox {
- width: 80%;
- margin: 0 auto;
- }
- .finput {
- padding-bottom: 30rpx;
- }
- .finput input {
- height: 72rpx;
- font-size: 32rpx;
- border: 1rpx solid #DDDDDD;
- padding: 5rpx 30rpx;
- border-radius: 40rpx;
- }
- .codebox {
- position: relative;
- }
- .codebox .codeimg {
- position: absolute;
- right: 0rpx;
- top: 0rpx;
- line-height: 80rpx;
- width: 200rpx;
- text-align: center;
- z-index: 999;
- }
- .registerbtn {
- border-radius: 50rpx;
- margin-top: 20rpx;
- }
- .pagetip {
- display: flex;
- justify-content: space-between;
- padding-top: 30rpx;
- color: #888888;
- }
- .pagetip>view.left {
- display: flex;
- justify-content: flex-start;
- }
- .pagetip>view.right {
- display: flex;
- justify-content: flex-end;
- }
- .pagetip navigator {
- color: #007AFF;
- }
- .registertip {
- display: flex;
- justify-content: center;
- padding-top: 40rpx;
- padding-bottom: 80rpx;
- color: #888888;
- font-size: 32rpx;
- }
- .registertip navigator {
- color: #007AFF;
- }
- </style>
|