register.vue 9.4 KB

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