reg.1.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="zai-box">
  3. <image src="/static/theme/default/register.png" mode='aspectFit' class="zai-logo"></image>
  4. <view class="zai-title">密聊</view>
  5. <view class="zai-form">
  6. <input class="zai-input" v-model="form.username" v-if="mobileCode" placeholder="请输入手机号" />
  7. <input class="zai-input" v-model="form.username" v-else placeholder="请输入用户名" />
  8. <view class="form-code" v-if="mobileCode">
  9. <input class="code-input" v-model="form.sms_code" placeholder="请输入验证码" />
  10. <button class="code" @tap="getCode" v-if="showText"> 获取验证码</button>
  11. <button class="code" v-else>{{second}}重新发送</button>
  12. </view>
  13. <!-- <input class="zai-input" placeholder-class password placeholder="请输入密码"/> -->
  14. <input class="zai-input" v-model="form.password" type="password" placeholder="请输入密码"/>
  15. <button :class="['landing',checkIn ? 'landing_true' : 'landing_false']"
  16. :disabled="checkIn ? false : true" class="zai-btn" @tap="subReg">立即注册</button>
  17. <navigator url="./login" open-type='navigateBack' hover-class="none" class="zai-label">已有账号,点此去登录.</navigator>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import _get from "../../common/_get";
  23. export default {
  24. data () {
  25. return {
  26. showPassword: true,
  27. showText:true,
  28. second:60,
  29. mobileCode:1,
  30. form: {
  31. username: '',
  32. password: '',
  33. client_id:'',
  34. sms_code:''
  35. }
  36. }
  37. },
  38. onLoad () {
  39. },
  40. onShow(){
  41. console.log(this.mobileCode);
  42. _get.getSysConfig({},function (res) {
  43. console.log(res)
  44. })
  45. let _this = this;
  46. // #ifdef APP-PLUS
  47. plus.push.getClientInfoAsync(function(info){
  48. _this.form.client_id = info.clientid;
  49. },function(e){
  50. console.log('Failed');
  51. console.log(JSON.stringify(e));
  52. });
  53. // #endif
  54. },
  55. computed: {
  56. checkIn () {
  57. return this.form.password != '' && this.form.username != '' && this.form.password.length > 5 && this.form.username.length > 5;
  58. }
  59. },
  60. methods: {
  61. getCode(){//倒计时
  62. //获取验证码
  63. this.showText = false;
  64. var interval = setInterval(() => {
  65. let times = --this.second;
  66. times = times < 0 ? 0 : times;
  67. this.second = times<10?'0'+times:times //小于10秒补 0
  68. }, 1000)
  69. setTimeout(() => {
  70. clearInterval(interval)
  71. this.second=60
  72. this.showText = true
  73. }, 60000)
  74. },
  75. changePassword () {
  76. this.showPassword = !this.showPassword;
  77. },
  78. delInputUsernameText () {
  79. this.form.username = ''
  80. },
  81. delInputPasswordText () {
  82. this.form.password = ''
  83. },
  84. subReg () {
  85. let _this = this;
  86. if (!_this.checkIn) {
  87. return;
  88. }
  89. if (!(/^\w{1,20}$/.test(this.form.username))) {
  90. uni.showModal({
  91. content: '密聊号只能包括下划线、数字、字母,并且不能超过20个',
  92. });
  93. return;
  94. }
  95. if (!(/^\w{1,20}$/.test(this.form.password))) {
  96. uni.showModal({
  97. content: '密码只能包括下划线、数字、字母,长度6-20位',
  98. });
  99. return;
  100. }
  101. uni.showLoading({title:'注册中'})
  102. _this.$httpSend({
  103. path: '/im/in/reg',
  104. data: _this.form,
  105. success: (data) => {
  106. uni.setStorage({
  107. key: 'token',
  108. data: data.token,
  109. fail: () => {
  110. uni.showModal({
  111. content: '本地存储数据不可用!',
  112. });
  113. },
  114. success () {
  115. _this.$socketSend({
  116. action: 'checkToken',
  117. data: data.token,
  118. },function () {
  119. uni.hideLoading()
  120. uni.reLaunch({
  121. url: '../chat/index',
  122. });
  123. })
  124. },
  125. });
  126. }
  127. });
  128. },
  129. go_forget () {
  130. uni.navigateTo({
  131. url: '../../pages/in/forget'
  132. })
  133. },
  134. go_register () {
  135. uni.navigateTo({
  136. url: '../../pages/in/reg'
  137. })
  138. }
  139. }
  140. }
  141. </script>
  142. <style>
  143. page{
  144. background-color: #FFFFFF;
  145. }
  146. .zai-box{
  147. padding: 0 100upx;
  148. position: relative;
  149. }
  150. .zai-logo{
  151. width: 100%;
  152. width: 100%;
  153. height: 310upx;
  154. }
  155. .zai-title{
  156. position: absolute;
  157. top: 0;
  158. line-height: 360upx;
  159. font-size: 68upx;
  160. color: #fff;
  161. text-align: center;
  162. width: 100%;
  163. margin-left: -100upx;
  164. }
  165. .zai-form{
  166. margin-top: 300upx;
  167. }
  168. .form-code{
  169. margin-top: 30upx;
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. height: 100%;
  174. }
  175. .form-code .code{
  176. height: 100%;
  177. border-radius: 50px;
  178. text-align: center;
  179. font-size: 14px;
  180. background: #ff65a3;
  181. color: #ffffff;
  182. }
  183. .zai-input{
  184. background: #e2f5fc;
  185. margin-top: 30upx;
  186. border-radius: 100upx;
  187. padding: 20upx 40upx;
  188. font-size: 36upx;
  189. }
  190. .code-input{
  191. background: #e2f5fc;
  192. border-radius: 100upx;
  193. padding: 20upx 40upx;
  194. font-size: 36upx;
  195. width: 40%;
  196. }
  197. .input-placeholder, .zai-input{
  198. color: #94afce;
  199. }
  200. .zai-label{
  201. padding: 60upx 0;
  202. text-align: center;
  203. font-size: 30upx;
  204. color: #a7b6d0;
  205. }
  206. .zai-btn{
  207. background: #ff65a3;
  208. color: #fff;
  209. border: 0;
  210. border-radius: 100upx;
  211. font-size: 36upx;
  212. margin-top: 60upx;
  213. }
  214. .zai-btn:after{
  215. border: 0;
  216. }
  217. /*按钮点击效果*/
  218. .zai-btn.button-hover{
  219. transform: translate(1upx, 1upx);
  220. }
  221. </style>