reg.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <template>
  2. <view class="login-container">
  3. <view class="login-nav-bar">
  4. <image class="arrow-back" @tap="backLogin" src="@/static/theme/default/nav_icon_back_black.png" mode="">
  5. </image>
  6. </view>
  7. <!-- <view class="login-title">注册用户</view> -->
  8. <view class="login-logo">
  9. <image src="@/static/login/logo.png" alt=""></image>
  10. </view>
  11. <view class="login-form">
  12. <view class="form-item">
  13. <text class="item-lable">用户名</text>
  14. <input class="item-input" v-model="form.username" placeholder="请输入用户名/手机号码" />
  15. </view>
  16. <view class="form-item">
  17. <text class="item-lable">输入密码</text>
  18. <input class="item-input" v-if="close_icon" type="password" v-model="form.password"
  19. placeholder="请输入密码" />
  20. <input class="item-input" v-else type="text" v-model="form.password" placeholder="请输入密码" />
  21. <view class="login-icon" @tap="close_icon = !close_icon">
  22. <image v-if="close_icon" src="@/static/login/close.png" mode=""></image>
  23. <image v-else src="@/static/login/open.png" mode=""></image>
  24. </view>
  25. </view>
  26. <!-- <view class="form-item" v-show="form.code_coerce">
  27. <text class="item-lable">邀请码</text>
  28. <input class="item-input" v-model="form.code" placeholder="请输入邀请码" />
  29. </view> -->
  30. <view class="form-item" >
  31. <text class="item-lable">验证码</text>
  32. <input class="item-input" v-model="form.sms_code" placeholder="请输入验证码" />
  33. <view class="" @click="showText?getCode():''">
  34. {{showText?'获取验证码':second}}
  35. </view>
  36. </view>
  37. <navigator url="./login" open-type='navigateBack' hover-class="none" class="zai-label">已有账号,点此去登录.
  38. </navigator>
  39. <button :class="['landing',checkIn ? 'landing_true' : 'landing_false']" :disabled="checkIn ? false : true"
  40. class="zai-btn" @tap="subReg">注册</button>
  41. <view class="login-bottom">
  42. <text class="tips" @tap="goTerms">《服务协议》</text><text class="tips" @tap="goPrivacy">《隐私协议》</text>
  43. </view>
  44. </view>
  45. <uni-popup ref="popup" type="confirm">
  46. <uni-popup-confirm title="温馨提示" :beforeClose="true" @close="close" :content="popuMsg" @confirm="confirm">
  47. </uni-popup-confirm>
  48. </uni-popup>
  49. </view>
  50. </template>
  51. <script>
  52. import uniPopup from '../../components/uni-popup/uni-popup.vue';
  53. import uniPopupConfirm from '../../components/uni-popup/uni-popup-confirm.vue';
  54. import _get from "../../common/_get";
  55. import _data from "../../common/_data";
  56. export default {
  57. data() {
  58. return {
  59. miaoqiang: 'tests',
  60. popuMsg: '恭喜您注册成功,是否立即更改资料?',
  61. showPassword: true,
  62. showText: true,
  63. second: 60,
  64. form: {
  65. mobileCode: 1,
  66. username: '',
  67. password: '',
  68. code: '',
  69. code_coerce:1,
  70. client_id: '',
  71. sms_code: '',
  72. type: 'REGISTER',
  73. },
  74. close_icon: true
  75. }
  76. },
  77. components: {
  78. uniPopup,
  79. uniPopupConfirm
  80. },
  81. onLoad() {
  82. },
  83. onShow() {
  84. console.log(this.form.mobileCode);
  85. let _this = this;
  86. _get.getSysConfig({}, function(res) {
  87. // console.log('111111111111111111111',res.user_regiter_code_status)
  88. if (res.user_regiter_sms_status == 1) {
  89. _this.form.mobileCode = 1
  90. } else {
  91. _this.form.mobileCode = 0
  92. }
  93. if(res.user_regiter_code_status == 1){
  94. _this.form.code_coerce = 1
  95. }else {
  96. _this.form.code_coerce = 0
  97. }
  98. })
  99. // #ifdef APP-PLUS
  100. // plus.push.getClientInfoAsync(function(info) {
  101. // _this.form.client_id = info.clientid;
  102. // }, function(e) {
  103. // console.log('Failed');
  104. // console.log(JSON.stringify(e));
  105. // });
  106. // #endif
  107. },
  108. computed: {
  109. checkIn() {
  110. return this.form.password != '' && this.form.username != '' && this.form.password.length > 5 && this.form
  111. .username.length > 5;
  112. }
  113. },
  114. methods: {
  115. backLogin() {
  116. uni.navigateBack({
  117. })
  118. },
  119. goTerms() {
  120. uni.navigateTo({
  121. 'url': '/pages/in/terms'
  122. })
  123. },
  124. goPrivacy() {
  125. uni.navigateTo({
  126. 'url': '/pages/in/privacy'
  127. })
  128. },
  129. goPath() {
  130. uni.navigateTo({
  131. 'url': '/pages/in/web'
  132. })
  133. },
  134. close() {
  135. let _this = this;
  136. uni.reLaunch({
  137. url: '../chat/index',
  138. success: function() {
  139. _this.$refs.popup.close();
  140. }
  141. });
  142. },
  143. confirm(e) {
  144. let _this = this;
  145. uni.redirectTo({
  146. url: '/pages/my/details',
  147. success: function() {
  148. _this.$refs.popup.close();
  149. }
  150. });
  151. },
  152. isPoneAvailable($poneInput) {
  153. let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  154. if (!myreg.test($poneInput)) {
  155. return false;
  156. } else {
  157. return true;
  158. }
  159. },
  160. getCode() {
  161. let _this = this;
  162. if (this.form.username.trim() == '') {
  163. uni.showToast({
  164. title: '请输入手机号',
  165. icon: 'none'
  166. });
  167. return false;
  168. }
  169. if (!this.isPoneAvailable(this.form.username.trim())) {
  170. uni.showToast({
  171. title: '请输入正确的手机号',
  172. icon: 'none'
  173. });
  174. return false;
  175. }
  176. _get.getSms({
  177. mobile: this.form.username,
  178. type: 'REGISTER'
  179. }, function(res) {
  180. console.log(22222)
  181. _this.cutDown();
  182. }, function(res) {
  183. console.log(1111)
  184. uni.showToast({
  185. title: res.msg,
  186. duration: 2000,
  187. icon: 'none'
  188. });
  189. })
  190. },
  191. cutDown(val) { //倒计时
  192. //获取验证码
  193. this.showText = false;
  194. var interval = setInterval(() => {
  195. let times = --this.second;
  196. times = times < 0 ? 0 : times;
  197. this.second = times < 10 ? '0' + times : times //小于10秒补 0
  198. }, 1000)
  199. setTimeout(() => {
  200. clearInterval(interval)
  201. this.second = 60
  202. this.showText = true
  203. }, 60000)
  204. },
  205. changePassword() {
  206. this.showPassword = !this.showPassword;
  207. },
  208. delInputUsernameText() {
  209. this.form.username = ''
  210. },
  211. delInputPasswordText() {
  212. this.form.password = ''
  213. },
  214. subReg() {
  215. let _this = this;
  216. if (!_this.checkIn) {
  217. return;
  218. }
  219. if (!(/^\w{1,20}$/.test(this.form.username))) {
  220. uni.showModal({
  221. content: '密聊号只能包括下划线、数字、字母,并且不能超过20个',
  222. });
  223. return;
  224. }
  225. if (!(/^\w{1,20}$/.test(this.form.password))) {
  226. uni.showModal({
  227. content: '密码只能包括下划线、数字、字母,长度6-20位',
  228. });
  229. return;
  230. }
  231. let channelCode = _data.localData('xInstallChannelCode');
  232. if (channelCode) {
  233. _this.form.channel = channelCode;
  234. }
  235. /* uni.showModal({
  236. content: "xxx2:"+channelCode,
  237. showCancel: false,
  238. }); */
  239. uni.navigateTo({
  240. url: './finish?username=' + _this.form.username + "&password=" + _this.form.password + "&code=" + _this.form.code + "&sms_code=" + _this.form.sms_code
  241. })
  242. return
  243. uni.showLoading({
  244. title: '注册中'
  245. })
  246. _this.$httpSend({
  247. path: '/im/in/reg',
  248. data: _this.form,
  249. success: (data) => {
  250. uni.setStorage({
  251. key: 'token',
  252. data: data.token,
  253. fail: () => {
  254. uni.showModal({
  255. content: '本地存储数据不可用!',
  256. });
  257. },
  258. success() {
  259. _this.$socketSend({
  260. action: 'checkToken',
  261. data: data.token,
  262. }, function() {
  263. uni.hideLoading();
  264. _this.$refs.popup.open();
  265. // uni.reLaunch({
  266. // url: '../chat/index',
  267. // });
  268. })
  269. },
  270. });
  271. }
  272. });
  273. },
  274. go_forget() {
  275. uni.navigateTo({
  276. url: '../../pages/in/forget'
  277. })
  278. },
  279. go_register() {
  280. uni.navigateTo({
  281. url: '../../pages/in/reg'
  282. })
  283. }
  284. }
  285. }
  286. </script>
  287. <style scoped lang="scss">
  288. .uni-input-placeholder {
  289. color: #ccc !important;
  290. }
  291. input[type="password"]::-ms-reveal {
  292. display: none;
  293. }
  294. .login-icon {
  295. image {
  296. width: 40rpx;
  297. height: 40rpx;
  298. }
  299. }
  300. .login-nav-bar {
  301. height: 44px;
  302. display: flex;
  303. align-items: center;
  304. position: absolute;
  305. justify-content: flex-start;
  306. left: 0;
  307. top: 0;
  308. /* #ifdef APP-PLUS */
  309. top: var(--status-bar-height);
  310. /* #endif */
  311. .arrow-back {
  312. width: 44rpx;
  313. height: 44rpx;
  314. margin-left: 20rpx;
  315. }
  316. }
  317. .login-container {
  318. background-color: #ffffff;
  319. height: 100vh;
  320. width: 100vw;
  321. padding: 0 60rpx;
  322. position: relative;
  323. box-sizing: border-box;
  324. // background-image: url(@/static/login/bg.png);
  325. background-repeat: no-repeat;
  326. background-size: 100% auto;
  327. .login-form {
  328. display: flex;
  329. flex-direction: column;
  330. .login-bottom {
  331. display: flex;
  332. justify-content: center;
  333. align-items: center;
  334. height: 100rpx;
  335. .login-random {
  336. text-decoration: none;
  337. color: #999;
  338. font-size: 14px;
  339. }
  340. .tips {
  341. font-size: 12px;
  342. color: #b5746c;
  343. height: 60rpx;
  344. line-height: 60rpx;
  345. text-align: center;
  346. // width: 100%;
  347. }
  348. }
  349. .login-btn {
  350. width: 100%;
  351. height: 100rpx;
  352. border-radius: 50px;
  353. background-color: #2da2fd;
  354. color: #fff;
  355. font-size: 16px;
  356. display: flex;
  357. justify-content: center;
  358. align-items: center;
  359. margin-top: 100rpx;
  360. }
  361. .form-item {
  362. display: flex;
  363. height: 100rpx;
  364. align-items: center;
  365. border-bottom: 1px solid #eee;
  366. .item-lable {
  367. font-size: 16px;
  368. color: #333;
  369. width: 180rpx;
  370. }
  371. .item-input {
  372. border: none;
  373. outline: none;
  374. background: none;
  375. font-size: 16px;
  376. color: #000;
  377. height: 100%;
  378. flex: 1;
  379. }
  380. }
  381. }
  382. .login-title {
  383. padding-top: 250rpx;
  384. font-size: 24px;
  385. font-weight: bold;
  386. padding-bottom: 150rpx;
  387. }
  388. .login-logo{
  389. padding-top: 200rpx;
  390. padding-bottom: 80rpx;
  391. text-align: center;
  392. }
  393. .login-logo image{
  394. width: 150rpx;
  395. height: 150rpx;
  396. }
  397. }
  398. .zai-viewl {
  399. width: 100%;
  400. display: flex;
  401. justify-content: center;
  402. }
  403. .zai-box {
  404. padding: 0 100upx;
  405. position: relative;
  406. }
  407. .zai-logo {
  408. width: 160upx;
  409. width: 160upx;
  410. height: 160upx;
  411. margin-top: 114upx;
  412. }
  413. .zai-title {
  414. position: absolute;
  415. top: 0;
  416. line-height: 360upx;
  417. font-size: 68upx;
  418. color: #fff;
  419. text-align: center;
  420. width: 100%;
  421. margin-left: -100upx;
  422. }
  423. .zai-form {
  424. margin-top: 150upx;
  425. }
  426. .form-code {
  427. margin-top: 30upx;
  428. display: flex;
  429. justify-content: center;
  430. align-items: center;
  431. height: 100%;
  432. }
  433. .form-code .code {
  434. height: 100%;
  435. border-radius: 50px;
  436. text-align: center;
  437. font-size: 14px;
  438. background: #ff65a3;
  439. color: #ffffff;
  440. }
  441. .zai-input {
  442. background: #e2f5fc;
  443. margin-top: 30upx;
  444. border-radius: 100upx;
  445. padding: 20upx 40upx;
  446. font-size: 36upx;
  447. }
  448. .code-input {
  449. background: #e2f5fc;
  450. border-radius: 100upx;
  451. padding: 20upx 40upx;
  452. font-size: 36upx;
  453. width: 40%;
  454. }
  455. .input-placeholder,
  456. .zai-input {
  457. color: #94afce;
  458. }
  459. .zai-label {
  460. text-align: center;
  461. font-size: 30upx;
  462. color: #666;
  463. height: 120rpx;
  464. display: flex;
  465. align-items: center;
  466. text-align: left;
  467. }
  468. .zai-btn {
  469. background: #2da2fd;
  470. border: 0;
  471. border-radius: 50rpx;
  472. font-size: 16px;
  473. color: #fff;
  474. width: 100%;
  475. height: 100rpx;
  476. display: flex;
  477. align-items: center;
  478. justify-content: center;
  479. }
  480. .zai-btn:after {
  481. border: 0;
  482. }
  483. /*按钮点击效果*/
  484. .zai-btn.button-hover {
  485. transform: translate(1upx, 1upx);
  486. }
  487. .zai-footer {
  488. display: flex;
  489. justify-content: center;
  490. align-items: center;
  491. color: #a7b6d0;
  492. padding-top: 10px;
  493. }
  494. </style>