register.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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.username" 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.username&&datainfo.password?'btn2':'btn'" @click="getRegisterFn">注册</button>
  43. <button v-else type="primary" class=" rbtn" :class="datainfo.username&&datainfo.password?'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 {getRegisterFn,sendSmszcOnly} from "@/api/login.js"
  62. import { getToken } from '@/utils/auth'
  63. export default {
  64. components:{
  65. },
  66. data(){
  67. return{
  68. lbg:require('@/static/images/mine/lbg.png'),
  69. fbg:require('@/static/images/mine/fbg.png'),
  70. ldicon:require('@/static/images/mine/ldicon.png'),
  71. checkimg:require('@/static/images/mine/lcicon.png'),
  72. rimg:require('@/static/images/mine/rimg.png'),
  73. pnicon:require('@/static/images/mine/pnicon.png'),
  74. checkflag:true,
  75. captchaEnabled: false,
  76. duancode:'',//短信验证码
  77. checkeye:false,
  78. tucode:'',
  79. codeUrl:'',
  80. time:'',
  81. timefalg:'',
  82. datainfo: {
  83. username: "",
  84. code: "",
  85. password:'',
  86. },
  87. timer:""
  88. }
  89. },
  90. methods:{
  91. getlogin(){
  92. this.$tab.redirectTo(`/pages/tlogin`)
  93. },
  94. handlePrivacy(){
  95. this.$tab.navigateTo(`/pages/agreement`)
  96. },
  97. // 获取短信验证码
  98. getsendCode(){
  99. var that=this;
  100. if (!this.datainfo.username ) {
  101. that.$toast("请输入手机号")
  102. return
  103. }
  104. 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}$/
  105. // 座机号
  106. let reg1=/^(0\d{2,3})-?(\d{7,8})$/
  107. if (this.datainfo.username && !regphone.test(this.datainfo.username)) {
  108. that.$toast("请输入正确的手机号")
  109. return
  110. }
  111. var params={
  112. 'username':this.datainfo.username
  113. }
  114. // getSMS();
  115. return
  116. sendSmszcOnly(params).then(res=>{
  117. if (res.code == 200) {
  118. // 发送验证码
  119. that.$toast("发送成功")
  120. that.time=60;
  121. that.timefalg=true;
  122. that.setTimein()
  123. } else {
  124. that.$toast(res.msg)
  125. }
  126. })
  127. },
  128. // 验证码倒计时
  129. setTimein(){
  130. var that=this;
  131. clearInterval(that.timer)
  132. that.timer=setInterval(()=>{
  133. if(that.time<=1){
  134. that.timefalg=false;
  135. that.time=60;
  136. clearInterval(that.timer)
  137. }
  138. that.time=that.time-1;
  139. },1000)
  140. },
  141. getRegisterFn(){
  142. var that=this;
  143. var params=this.datainfo;
  144. // if(!params.nickName){
  145. // this.$toast("请输入用户名")
  146. // return
  147. // }
  148. if(!params.phonenumber){
  149. this.$toast("请输入手机号")
  150. return
  151. }
  152. // 验证手机号
  153. 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}$/;
  154. if(!regphone.test(params.phonenumber)){
  155. this.$toast('请输入正确的手机号')
  156. return
  157. }
  158. if(!params.password){
  159. this.$toast("请输入密码")
  160. return
  161. }
  162. params.userName=params.phonenumber;
  163. getRegisterFn(params).then(res=>{
  164. if(res.code==200){
  165. that.$toast("注册成功")
  166. setTimeout(function(){
  167. that.$tab.reLaunch(`/pages/login`)
  168. },1200)
  169. }
  170. })
  171. },
  172. },
  173. onLoad: function() {
  174. },
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .navbg{width: 100%;height: 100vh;}
  179. .fbg{width: 100%;height: 750rpx;position: absolute;bottom: 0;left: 0;}
  180. .wymain{z-index: 2;position: relative;padding: 70rpx 60rpx;}
  181. .headimg{width: 136rpx;height: 136rpx;margin:0 auto 36rpx;}
  182. .titico{font-weight: 500;font-size: 24rpx;color: #FF6969;margin-top: 20rpx;}
  183. .head{margin-bottom: 64rpx;
  184. .htit{font-weight: bold;font-size: 48rpx;color: #0156FE;line-height: 60rpx;}
  185. .htxt{font-weight: 500;font-size: 24rpx;color: #666666;margin-top: 30rpx;
  186. text{color: #0156FE;}
  187. }
  188. }
  189. .mzimg{width: 100rpx;height: 44rpx;margin: 0 auto ;}
  190. .regbox /deep/ .uni-easyinput__content{background-color: transparent !important;}
  191. .regbox /deep/ .uni-easyinput__content-input{font-size: 30rpx !important;padding-left: 0 !important;line-height: 80rpx;height: 80rpx;}
  192. .regbox /deep/ .uni-input-placeholder{font-size: 30rpx !important;padding-left: 0 !important;color: #808080;}
  193. .rtxt{font-size: 30rpx;font-weight: 500;
  194. color: $com-cd3;text-align: center;}
  195. .bbcode{position: absolute;width: 100%;text-align: center;left: 0;bottom: -80rpx;font-size: 24rpx;color: #666666;}
  196. .lread{
  197. display: flex;align-items: flex-start;justify-content: center;
  198. .lreadl{padding-top: 4rpx;
  199. image{width: 22rpx;height: 22rpx;margin-right: 12rpx;}
  200. }
  201. .tit{font-size: 26rpx;font-weight: 500;color: #666666;
  202. text{color:#4888FA;padding: 0 6rpx;font-weight: 500;}
  203. }
  204. }
  205. .tab{
  206. .tabtit{font-size: 30rpx;font-weight: 500;color: #666666;padding: 0 24rpx;position: relative;
  207. &.act{color: $com-cd3;font-weight: bold;}
  208. &::before{content: '';position: absolute;left: 0;top: 50%;margin-top: -10rpx;width: 2rpx;height: 20rpx;background: #DADADA;}
  209. &:first-child::before{display: none;}
  210. }
  211. }
  212. .rbtn {height: 84rpx;margin: 120rpx 0 24rpx;font-weight: bold;font-size: 28rpx;color: #FFFFFF;line-height: 84rpx;
  213. &.btn{background: #9a9c9e;color: #ffffff;}
  214. &.btn2{background: $com-cd3;color: #ffffff;}
  215. }
  216. .login-form-content {
  217. margin: 0 auto;
  218. width: 100%;
  219. .input-item {
  220. // margin-bottom:48rpx;
  221. border-bottom: 2rpx solid #CDCDCD;
  222. padding: 40rpx 0 0rpx;
  223. .icon {
  224. font-size: 40rpx;
  225. margin-left: 10px;
  226. color: #999;
  227. }
  228. .login_tit{
  229. font-size: 30rpx;
  230. font-weight: bold;
  231. color: #343434;margin-bottom: 8rpx;
  232. }
  233. .login_box{display: flex;align-items: center;
  234. .rimgs{width: 18rpx;height: 30rpx;flex: 0 0 auto;margin-left: 20rpx;}
  235. }
  236. .input {
  237. width: 100%;
  238. font-size: 30rpx;
  239. height: 80rpx;
  240. line-height: 80rpx;
  241. }
  242. }
  243. .login-code {
  244. height: 38px;
  245. float: right;
  246. .login-code-img {
  247. height: 38px;
  248. position: absolute;
  249. margin-left: 10px;
  250. width: 200rpx;
  251. }
  252. }
  253. }
  254. // .image{width: 30rpx;height: 30rpx;margin-right: 14rpx;}
  255. .input_ye image{width: 34rpx;height: 18rpx;}
  256. .codess{font-size: 28rpx;color: $com-cd3;flex: 0 0 auto;min-width: 200rpx;text-align: center;border-left: 2rpx solid #CDCDCD;}
  257. .codes{background: none;font-size: 28rpx;flex: 0 0 auto;width: 180rpx;text-align: center;border-left: 2rpx solid #CDCDCD;}
  258. .login_box{display: flex;align-items: center;}
  259. .login_boxl{width:130rpx;font-size: 34rpx;color: #343434;border-right: 2rpx solid #CDCDCD;}
  260. .login_txt{text-align: right;flex: 0 0 auto; padding:0 24rpx;
  261. text{font-size: 30rrpx;color:#666666;}
  262. }
  263. .line{width: 2rpx;height: 24rpx;background: #CDCDCD;margin: 0 10rpx;}
  264. .login_jz{display: flex;align-items: center;justify-content: flex-end;flex: 0 0 auto;
  265. image{width: 30rpx;height: 30rpx;margin-right: 12rpx;}
  266. view{color: #666666;font-size: 28rpx;}
  267. }
  268. // app
  269. </style>