register.vue 9.2 KB

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