register.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view class="regbox">
  3. <image :src="lbg" class="navbg"></image>
  4. <image :src="fbg" class="fbg"></image>
  5. <view class="wymain">
  6. <view class="head">
  7. <view class="htit">你好,</view>
  8. <view class="htit">欢迎注册智慧社区平台</view>
  9. <view class="htxt" @click="getlogin">已有账号?<text>立即登录</text></view>
  10. </view>
  11. <view class="flex1" style="position: relative;">
  12. <!-- 手机号登录 -->
  13. <view class="login-form-content">
  14. <view class="input-item">
  15. <view class="login_tit">账号</view>
  16. <view class="login_box">
  17. <!-- <view class="login_boxl">+86</view> -->
  18. <input v-model="datainfo.phonenumber" class="input" type="text" placeholder="请输入登录账号" maxlength="30" />
  19. </view>
  20. </view>
  21. <view class="input-item">
  22. <view class="login_tit">验证码</view>
  23. <view style="display: flex;align-items: center;">
  24. <input v-model="duancode" type="code" class="input" placeholder="请输入短信验证码" maxlength="20" />
  25. <view v-if="timefalg" class="codes">重新发送{{time}}s</view>
  26. <view v-else class="codess" @click="getsendCode">发送验证码</view>
  27. </view>
  28. </view>
  29. <!-- <view class="input-item" >
  30. <view class="login_tit">密码</view>
  31. <view class="login_box">
  32. <uni-easyinput :inputBorder="false" type="password" v-model="datainfo.password" placeholder="请输入密码" />
  33. </view>
  34. </view>
  35. <view class="titico">*密码必须包含数字、大小写字母、特殊符号且大于8位</view> -->
  36. <!-- <view class="input-item flex align-center" style="width: 60%;margin: 0px;margin-bottom: 24rpx;" v-if="captchaEnabled">
  37. <input v-model="tucode" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
  38. <view class="login-code">
  39. <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
  40. </view >
  41. </view> -->
  42. <button v-if="captchaEnabled" type="primary" class=" rbtn " :class="tucode&&datainfo.phonenumber?'btn2':'btn'" @click="getRegisterFn">注册</button>
  43. <button v-else type="primary" class=" rbtn" :class="datainfo.phonenumber?'btn2':'btn'" @click="getRegisterFn">注册</button>
  44. </view>
  45. <!-- 账号密码登录 -->
  46. <view class="lread" @click="checkflag=!checkflag">
  47. <view class="lreadl">
  48. <image :src="checkimg" v-if="checkflag"></image>
  49. <image :src="pnicon" v-else></image>
  50. </view>
  51. <view class="tit">我已阅读并同意<text @click.stop="handlePrivacy">服务协议、</text><text @click.stop="handlePrivacy">隐私政策</text></view>
  52. </view>
  53. <!-- <view class="bbcode">版本号:ZXY_YY_1.3</view> -->
  54. </view>
  55. </view>
  56. <loading></loading>
  57. <!-- <view class="rtxt" @click="getregister">还没账号?去申请注册</view> -->
  58. </view>
  59. </template>
  60. <script>
  61. import {register,sendSmsCode} from "@/api/login.js"
  62. import { getToken } from '@/utils/auth'
  63. import config from '@/config'
  64. export default {
  65. components:{
  66. },
  67. //5243
  68. data(){
  69. return{
  70. lbg:require('@/static/images/mine/lbg.png'),
  71. fbg:require('@/static/images/mine/fbg.png'),
  72. checkimg:require('@/static/images/mine/lcicon.png'),
  73. rimg:require('@/static/images/mine/rimg.png'),
  74. pnicon:require('@/static/images/mine/pnicon.png'),
  75. checkflag:true,
  76. captchaEnabled: false,
  77. duancode:'',//短信验证码
  78. checkeye:false,
  79. tucode:'',
  80. codeUrl:'',
  81. time:'',
  82. timefalg:'',
  83. datainfo: {
  84. phonenumber: "",
  85. code: "",
  86. clientId:config.Clientid,
  87. grantType:'sms',
  88. userType:config.userType
  89. },
  90. timer:""
  91. }
  92. },
  93. methods:{
  94. getlogin(){
  95. this.$tab.redirectTo(`/pages/tlogin?type=1`)
  96. },
  97. handlePrivacy(){
  98. this.$tab.navigateTo(`/pages/agreement`)
  99. },
  100. // 获取短信验证码
  101. getsendCode(){
  102. var that=this;
  103. if (!this.datainfo.phonenumber ) {
  104. that.$toast("请输入手机号")
  105. return
  106. }
  107. let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  108. // 座机号
  109. let reg1=/^(0\d{2,3})-?(\d{7,8})$/
  110. if (this.datainfo.phonenumber && !regphone.test(this.datainfo.phonenumber)) {
  111. that.$toast("请输入正确的手机号")
  112. return
  113. }
  114. var params={
  115. 'phonenumber':this.datainfo.phonenumber,
  116. 'type':'2',//1:登录 2:注册 3:修改密码
  117. }
  118. sendSmsCode(params).then(res=>{
  119. if (res.code == 200) {
  120. // 发送验证码
  121. that.$toast("发送成功")
  122. that.time=60;
  123. that.timefalg=true;
  124. that.setTimein()
  125. } else {
  126. that.$toast(res.msg)
  127. }
  128. })
  129. },
  130. // 验证码倒计时
  131. setTimein(){
  132. var that=this;
  133. clearInterval(that.timer)
  134. that.timer=setInterval(()=>{
  135. if(that.time<=1){
  136. that.timefalg=false;
  137. that.time=60;
  138. clearInterval(that.timer)
  139. }
  140. that.time=that.time-1;
  141. },1000)
  142. },
  143. getRegisterFn(){
  144. var that=this;
  145. var params=this.datainfo;
  146. // if(!params.nickName){
  147. // this.$toast("请输入用户名")
  148. // return
  149. // }
  150. if(!params.phonenumber){
  151. this.$toast("请输入手机号")
  152. return
  153. }
  154. // 验证手机号
  155. let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
  156. if(!regphone.test(params.phonenumber)){
  157. this.$toast('请输入正确的手机号')
  158. return
  159. }
  160. // if(!params.password){
  161. // this.$toast("请输入密码")
  162. // return
  163. // }
  164. params.code=this.duancode;
  165. register(params).then(res=>{
  166. if(res.code==200){
  167. that.$toast("注册成功")
  168. setTimeout(function(){
  169. that.$tab.reLaunch(`/pages/login`)
  170. },1200)
  171. }
  172. })
  173. },
  174. },
  175. onLoad: function() {
  176. },
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .navbg{width: 100%;height: 100vh;}
  181. .fbg{width: 100%;height: 750rpx;position: absolute;bottom: 0;left: 0;}
  182. .wymain{z-index: 2;position: relative;padding: 180rpx 60rpx;}
  183. .headimg{width: 136rpx;height: 136rpx;margin:0 auto 36rpx;}
  184. .titico{font-weight: 500;font-size: 24rpx;color: #FF6969;margin-top: 20rpx;}
  185. .head{margin-bottom: 64rpx;
  186. .htit{font-weight: bold;font-size: 48rpx;color: #0156FE;line-height: 60rpx;}
  187. .htxt{font-weight: 500;font-size: 24rpx;color: #666666;margin-top: 30rpx;
  188. text{color: #0156FE;}
  189. }
  190. }
  191. .mzimg{width: 100rpx;height: 44rpx;margin: 0 auto ;}
  192. .regbox /deep/ .uni-easyinput__content{background-color: transparent !important;}
  193. .regbox /deep/ .uni-easyinput__content-input{font-size: 30rpx !important;padding-left: 0 !important;line-height: 80rpx;height: 80rpx;}
  194. .regbox /deep/ .uni-input-placeholder{font-size: 30rpx !important;padding-left: 0 !important;color: #808080;}
  195. .rtxt{font-size: 30rpx;font-weight: 500;
  196. color: $com-cd3;text-align: center;}
  197. .bbcode{position: absolute;width: 100%;text-align: center;left: 0;bottom: -80rpx;font-size: 24rpx;color: #666666;}
  198. .lread{
  199. display: flex;align-items: flex-start;justify-content: center;
  200. .lreadl{padding-top: 4rpx;
  201. image{width: 22rpx;height: 22rpx;margin-right: 12rpx;}
  202. }
  203. .tit{font-size: 26rpx;font-weight: 500;color: #666666;
  204. text{color:#4888FA;padding: 0 6rpx;font-weight: 500;}
  205. }
  206. }
  207. .tab{
  208. .tabtit{font-size: 30rpx;font-weight: 500;color: #666666;padding: 0 24rpx;position: relative;
  209. &.act{color: $com-cd3;font-weight: bold;}
  210. &::before{content: '';position: absolute;left: 0;top: 50%;margin-top: -10rpx;width: 2rpx;height: 20rpx;background: #DADADA;}
  211. &:first-child::before{display: none;}
  212. }
  213. }
  214. .rbtn {height: 84rpx;margin: 120rpx 0 24rpx;font-weight: bold;font-size: 28rpx;color: #FFFFFF;line-height: 84rpx;
  215. &.btn{background: #9a9c9e;color: #ffffff;}
  216. &.btn2{background: $com-cd3;color: #ffffff;}
  217. }
  218. .login-form-content {
  219. margin: 0 auto;
  220. width: 100%;
  221. .input-item {
  222. // margin-bottom:48rpx;
  223. border-bottom: 2rpx solid #CDCDCD;
  224. padding: 40rpx 0 0rpx;
  225. .icon {
  226. font-size: 40rpx;
  227. margin-left: 10px;
  228. color: #999;
  229. }
  230. .login_tit{
  231. font-size: 30rpx;
  232. font-weight: bold;
  233. color: #343434;margin-bottom: 8rpx;
  234. }
  235. .login_box{display: flex;align-items: center;
  236. .rimgs{width: 18rpx;height: 30rpx;flex: 0 0 auto;margin-left: 20rpx;}
  237. }
  238. .input {
  239. width: 100%;
  240. font-size: 30rpx;
  241. height: 80rpx;
  242. line-height: 80rpx;
  243. }
  244. }
  245. .login-code {
  246. height: 38px;
  247. float: right;
  248. .login-code-img {
  249. height: 38px;
  250. position: absolute;
  251. margin-left: 10px;
  252. width: 200rpx;
  253. }
  254. }
  255. }
  256. // .image{width: 30rpx;height: 30rpx;margin-right: 14rpx;}
  257. .input_ye image{width: 34rpx;height: 18rpx;}
  258. .codess{font-size: 28rpx;color: $com-cd3;flex: 0 0 auto;min-width: 200rpx;text-align: center;border-left: 2rpx solid #CDCDCD;}
  259. .codes{background: none;font-size: 28rpx;flex: 0 0 auto;width: 180rpx;text-align: center;border-left: 2rpx solid #CDCDCD;}
  260. .login_box{display: flex;align-items: center;}
  261. .login_boxl{width:130rpx;font-size: 34rpx;color: #343434;border-right: 2rpx solid #CDCDCD;}
  262. .login_txt{text-align: right;flex: 0 0 auto; padding:0 24rpx;
  263. text{font-size: 30rrpx;color:#666666;}
  264. }
  265. .line{width: 2rpx;height: 24rpx;background: #CDCDCD;margin: 0 10rpx;}
  266. .login_jz{display: flex;align-items: center;justify-content: flex-end;flex: 0 0 auto;
  267. image{width: 30rpx;height: 30rpx;margin-right: 12rpx;}
  268. view{color: #666666;font-size: 28rpx;}
  269. }
  270. // app
  271. </style>