bindPhone.vue 9.4 KB

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