finish.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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 class="nav-bar-title">
  7. 完善资料
  8. </view>
  9. </view>
  10. <view class="login-title">
  11. <!-- <image :src="show_path" mode="" @click="chooseImage"></image> -->
  12. <!-- <avatar selWidth="600upx" selHeight="600upx" @upload="upload" :avatarSrc="show_path"
  13. avatarStyle="width: 200upx; height: 200upx; border-radius: 50%;">
  14. </avatar> -->
  15. </view>
  16. <view class="login-form">
  17. <view class="form-item">
  18. <input class="item-input" v-model="form.nickname" placeholder="请输入你的昵称(必填)" />
  19. </view>
  20. </view>
  21. <view class="sex-item">
  22. <view class="sex-box" :class="{'sex-active':sex == 0}" @tap="sex = 0">
  23. <text>男</text>
  24. <image src="/static/login/man.png" mode=""></image>
  25. </view>
  26. <view class="sex-box" :class="{'sex-active':sex == 1}" @tap="sex = 1">
  27. <text>女</text>
  28. <image src="/static/login/woman.png" mode=""></image>
  29. </view>
  30. </view>
  31. <button :class="['landing',checkIn ? 'landing_true' : 'landing_false']" :disabled="checkIn ? false : true"
  32. class="zai-btn" @tap="subReg">下一步</button>
  33. </view>
  34. </template>
  35. <script>
  36. import avatar from "@/components/yq-avatar/yq-avatar.vue";
  37. import _get from "../../common/_get";
  38. import _data from "../../common/_data";
  39. export default {
  40. data() {
  41. return {
  42. miaoqiang: 'tests',
  43. popuMsg: '恭喜您注册成功,是否立即更改资料?',
  44. showPassword: true,
  45. showText: true,
  46. second: 60,
  47. form: {
  48. nickname: '',
  49. password: '',
  50. code: '',
  51. client_id: '',
  52. type: 'REGISTER',
  53. sex: 1,
  54. },
  55. sex: 1, // sex 0=男 1=女
  56. show_path: require('@/static/login/avatar.png'),
  57. my_avatar: '',
  58. }
  59. },
  60. components: {
  61. avatar
  62. },
  63. onLoad(option) {
  64. this.form.username = option.username;
  65. this.form.password = option.password;
  66. this.form.code = option.code;
  67. this.form.sms_code = option.sms_code;
  68. },
  69. onShow() {
  70. console.log(this.form.mobileCode);
  71. let _this = this;
  72. _get.getSysConfig({}, function(res) {
  73. if (res.user_regiter_sms_status == 1) {
  74. _this.form.mobileCode = 1
  75. } else {
  76. _this.form.mobileCode = 0
  77. }
  78. })
  79. // #ifdef APP-PLUS
  80. // plus.push.getClientInfoAsync(function(info) {
  81. // _this.form.client_id = info.clientid;
  82. // }, function(e) {
  83. // console.log('Failed');
  84. // console.log(JSON.stringify(e));
  85. // });
  86. // #endif
  87. },
  88. computed: {
  89. checkIn() {
  90. return this.form.password != '' && this.form.username != '' && this.form.password.length > 5 && this.form
  91. .username.length > 5 && this.form.nickname;
  92. }
  93. },
  94. methods: {
  95. chooseImage() {
  96. let _this = this;
  97. uni.chooseImage({
  98. count: 1, //默认9
  99. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  100. sourceType: ['album'], //从相册选择
  101. success: function(res) {
  102. console.log(JSON.stringify(res));
  103. _this.uploadFile(res.tempFilePaths[0]);
  104. }
  105. });
  106. },
  107. backLogin() {
  108. uni.navigateBack({
  109. })
  110. },
  111. goPath() {
  112. uni.navigateTo({
  113. 'url': '/pages/in/web'
  114. })
  115. },
  116. close() {
  117. let _this = this;
  118. uni.reLaunch({
  119. url: '../chat/index',
  120. success: function() {
  121. _this.$refs.popup.close();
  122. }
  123. });
  124. },
  125. confirm(e) {
  126. let _this = this;
  127. uni.redirectTo({
  128. url: '/pages/my/details',
  129. success: function() {
  130. _this.$refs.popup.close();
  131. }
  132. });
  133. },
  134. isPoneAvailable($poneInput) {
  135. let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  136. if (!myreg.test($poneInput)) {
  137. return false;
  138. } else {
  139. return true;
  140. }
  141. },
  142. getCode() {
  143. let _this = this;
  144. if (this.form.username.trim() == '') {
  145. uni.showToast({
  146. title: '请输入手机号',
  147. icon: 'none'
  148. });
  149. return false;
  150. }
  151. if (!this.isPoneAvailable(this.form.username.trim())) {
  152. uni.showToast({
  153. title: '请输入正确的手机号',
  154. icon: 'none'
  155. });
  156. return false;
  157. }
  158. _get.getSms({
  159. mobile: this.form.username,
  160. type: 'REGISTER'
  161. }, function(res) {
  162. console.log(22222)
  163. _this.cutDown();
  164. }, function(res) {
  165. console.log(1111)
  166. uni.showToast({
  167. title: res.msg,
  168. duration: 2000,
  169. icon: 'none'
  170. });
  171. })
  172. },
  173. cutDown(val) { //倒计时
  174. //获取验证码
  175. this.showText = false;
  176. var interval = setInterval(() => {
  177. let times = --this.second;
  178. times = times < 0 ? 0 : times;
  179. this.second = times < 10 ? '0' + times : times //小于10秒补 0
  180. }, 1000)
  181. setTimeout(() => {
  182. clearInterval(interval)
  183. this.second = 60
  184. this.showText = true
  185. }, 60000)
  186. },
  187. changePassword() {
  188. this.showPassword = !this.showPassword;
  189. },
  190. delInputUsernameText() {
  191. this.form.username = ''
  192. },
  193. delInputPasswordText() {
  194. this.form.password = ''
  195. },
  196. subReg() {
  197. let _this = this;
  198. if (!_this.checkIn) {
  199. return;
  200. }
  201. if (!(/^\w{1,20}$/.test(this.form.username))) {
  202. uni.showModal({
  203. content: '密聊号只能包括下划线、数字、字母,并且不能超过20个',
  204. });
  205. return;
  206. }
  207. if (!(/^\w{1,20}$/.test(this.form.password))) {
  208. uni.showModal({
  209. content: '密码只能包括下划线、数字、字母,长度6-20位',
  210. });
  211. return;
  212. }
  213. let channelCode = _data.localData('xInstallChannelCode');
  214. if (channelCode) {
  215. _this.form.channel = channelCode;
  216. }
  217. /* uni.showModal({
  218. content: "xxx2:"+channelCode,
  219. showCancel: false,
  220. }); */
  221. uni.showLoading({
  222. title: '注册中'
  223. })
  224. _this.form.sex = this.sex;
  225. _this.$httpSend({
  226. path: '/im/in/reg',
  227. data: _this.form,
  228. success: (data) => {
  229. console.log("注册成功数据", data)
  230. uni.reLaunch({
  231. url: './login',
  232. });
  233. uni.hideLoading();
  234. return;
  235. uni.setStorage({
  236. key: 'token',
  237. data: data.token,
  238. fail: () => {
  239. uni.showModal({
  240. content: '本地存储数据不可用!',
  241. });
  242. },
  243. success() {
  244. _this.$socketSend({
  245. action: 'checkToken',
  246. data: data.token,
  247. }, function(res) {
  248. console.log("注册成功数据2", res)
  249. uni.hideLoading();
  250. // _this.$refs.popup.open();
  251. uni.reLaunch({
  252. url: '../chat/index',
  253. });
  254. })
  255. },
  256. });
  257. },
  258. fail: (err) => {
  259. uni.hideLoading();
  260. }
  261. });
  262. },
  263. go_forget() {
  264. uni.navigateTo({
  265. url: '../../pages/in/forget'
  266. })
  267. },
  268. go_register() {
  269. uni.navigateTo({
  270. url: '../../pages/in/reg'
  271. })
  272. },
  273. upload(e) {
  274. console.log("e", e);
  275. return
  276. this.show_path = e.path;
  277. this.send();
  278. },
  279. uploadFile(local_url) {
  280. let uploadTask = uni.uploadFile({
  281. url: getApp().globalData.http_url + '/im/in/photo',
  282. filePath: local_url,
  283. name: 'file',
  284. /** formData必须要有值,否则会上传失败 */
  285. formData: {
  286. username: this.form.username
  287. },
  288. success: (res) => {
  289. console.log("res", res);
  290. this.show_path = local_url;
  291. this.my_avatar = local_url;
  292. },
  293. fail(err) {
  294. console.log("err", err);
  295. uni.showToast({
  296. icon: 'none',
  297. title: '上传失败'
  298. })
  299. }
  300. });
  301. },
  302. send() {
  303. let _this = this;
  304. uni.showLoading();
  305. _this.$httpSendFile({
  306. local_url: _this.show_path,
  307. type: 1,
  308. success(data) {
  309. /** 更新头像上传状态 */
  310. _this.$httpSend({
  311. path: '/im/in/photo',
  312. data: {
  313. username: _this.form.username,
  314. },
  315. success(data) {
  316. /** 更改头像后,更新下头像 */
  317. let user_info = _data.data('user_info');
  318. user_info.photo = user_info.photo.replace(/(\?_=)[\d\.]+$/, '$1' + Math
  319. .random());
  320. _data.data('user_info', user_info);
  321. uni.$emit('data_user_info', user_info);
  322. uni.hideLoading();
  323. uni.showToast({
  324. title: '更换成功',
  325. duration: 1000,
  326. });
  327. }
  328. });
  329. },
  330. });
  331. }
  332. }
  333. }
  334. </script>
  335. <style scoped lang="scss">
  336. .uni-input-placeholder {
  337. color: #ccc !important;
  338. }
  339. .sex-item {
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. height: 100rpx;
  344. box-sizing: border-box;
  345. width: 300rpx;
  346. margin: 60rpx auto;
  347. }
  348. .sex-box {
  349. height: 80rpx;
  350. width: 140rpx;
  351. display: flex;
  352. justify-content: center;
  353. align-items: center;
  354. border-radius: 40rpx;
  355. background: #efefef;
  356. text {
  357. font-size: 14px;
  358. color: #aaa;
  359. margin-right: 20rpx;
  360. }
  361. image {
  362. width: 20px;
  363. height: 20px;
  364. }
  365. }
  366. .sex-active {
  367. background-color: #598fef;
  368. text {
  369. color: #fff;
  370. }
  371. }
  372. input[type="password"]::-ms-reveal {
  373. display: none;
  374. }
  375. .login-icon {
  376. image {
  377. width: 40rpx;
  378. height: 40rpx;
  379. }
  380. }
  381. .login-nav-bar {
  382. height: 44px;
  383. display: flex;
  384. align-items: center;
  385. position: absolute;
  386. justify-content: center;
  387. width: 100vw;
  388. left: 0;
  389. top: 0;
  390. /* #ifdef APP-PLUS */
  391. top: var(--status-bar-height);
  392. /* #endif */
  393. .arrow-back {
  394. width: 44rpx;
  395. height: 44rpx;
  396. position: absolute;
  397. left: 20rpx;
  398. top: 50%;
  399. transform: translateY(-50%);
  400. }
  401. .nav-bar-title {
  402. font-size: 20px;
  403. font-weight: bold;
  404. width: 100%;
  405. text-align: center;
  406. line-height: 44px;
  407. height: 100%;
  408. }
  409. }
  410. .login-container {
  411. background-color: #ffffff;
  412. height: 100vh;
  413. width: 100vw;
  414. padding: 0 60rpx;
  415. position: relative;
  416. box-sizing: border-box;
  417. // background-image: url(@/static/login/bg.png);
  418. background-repeat: no-repeat;
  419. background-size: 100% auto;
  420. .login-form {
  421. display: flex;
  422. flex-direction: column;
  423. .login-bottom {
  424. display: flex;
  425. justify-content: space-between;
  426. align-items: center;
  427. height: 100rpx;
  428. .login-random {
  429. text-decoration: none;
  430. color: #999;
  431. font-size: 14px;
  432. }
  433. .tips {
  434. font-size: 12px;
  435. color: #b5746c;
  436. height: 60rpx;
  437. line-height: 60rpx;
  438. text-align: center;
  439. width: 100%;
  440. }
  441. }
  442. .login-btn {
  443. width: 100%;
  444. height: 100rpx;
  445. border-radius: 50px;
  446. background-color: #2da2fd;
  447. color: #fff;
  448. font-size: 16px;
  449. display: flex;
  450. justify-content: center;
  451. align-items: center;
  452. margin-top: 100rpx;
  453. }
  454. .form-item {
  455. display: flex;
  456. height: 100rpx;
  457. align-items: center;
  458. border-bottom: 1px solid #eee;
  459. .item-lable {
  460. font-size: 16px;
  461. color: #333;
  462. width: 180rpx;
  463. }
  464. .item-input {
  465. border: none;
  466. outline: none;
  467. background: none;
  468. flex: 1;
  469. text-align: center;
  470. font-size: 16px;
  471. color: #000;
  472. }
  473. }
  474. }
  475. .login-title {
  476. padding-top: 250rpx;
  477. font-size: 24px;
  478. font-weight: bold;
  479. padding-bottom: 50rpx;
  480. display: flex;
  481. align-items: center;
  482. justify-content: center;
  483. image {
  484. width: 180rpx;
  485. height: 180rpx;
  486. border-radius: 50%;
  487. }
  488. }
  489. }
  490. .zai-viewl {
  491. width: 100%;
  492. display: flex;
  493. justify-content: center;
  494. }
  495. .zai-box {
  496. padding: 0 100upx;
  497. position: relative;
  498. }
  499. .zai-logo {
  500. width: 160upx;
  501. width: 160upx;
  502. height: 160upx;
  503. margin-top: 114upx;
  504. }
  505. .zai-title {
  506. position: absolute;
  507. top: 0;
  508. line-height: 360upx;
  509. font-size: 68upx;
  510. color: #fff;
  511. text-align: center;
  512. width: 100%;
  513. margin-left: -100upx;
  514. }
  515. .zai-form {
  516. margin-top: 150upx;
  517. }
  518. .form-code {
  519. margin-top: 30upx;
  520. display: flex;
  521. justify-content: center;
  522. align-items: center;
  523. height: 100%;
  524. }
  525. .form-code .code {
  526. height: 100%;
  527. border-radius: 50px;
  528. text-align: center;
  529. font-size: 14px;
  530. background: #ff65a3;
  531. color: #ffffff;
  532. }
  533. .zai-input {
  534. background: #e2f5fc;
  535. margin-top: 30upx;
  536. border-radius: 100upx;
  537. padding: 20upx 40upx;
  538. font-size: 36upx;
  539. }
  540. .code-input {
  541. background: #e2f5fc;
  542. border-radius: 100upx;
  543. padding: 20upx 40upx;
  544. font-size: 36upx;
  545. width: 40%;
  546. }
  547. .input-placeholder,
  548. .zai-input {
  549. color: #94afce;
  550. }
  551. .zai-label {
  552. text-align: center;
  553. font-size: 30upx;
  554. color: #666;
  555. height: 100rpx;
  556. display: flex;
  557. align-items: center;
  558. text-align: left;
  559. }
  560. .zai-btn {
  561. background: #598fef;
  562. border: 0;
  563. border-radius: 50rpx;
  564. font-size: 16px;
  565. color: #fff;
  566. width: 100%;
  567. height: 100rpx;
  568. display: flex;
  569. align-items: center;
  570. justify-content: center;
  571. width: 400rpx;
  572. margin: 0 auto;
  573. }
  574. .zai-btn:after {
  575. border: 0;
  576. }
  577. /*按钮点击效果*/
  578. .zai-btn.button-hover {
  579. transform: translate(1upx, 1upx);
  580. }
  581. .zai-footer {
  582. display: flex;
  583. justify-content: center;
  584. align-items: center;
  585. color: #a7b6d0;
  586. padding-top: 10px;
  587. }
  588. </style>