bindPhone.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view>
  3. <navbar ref="navbar" :config="config"></navbar>
  4. <view class="top">
  5. <view class="title">绑定手机号</view>
  6. </view>
  7. <view class="body">
  8. <view class="inpBox">
  9. <image src="/static/czd/phone.png" mode=""></image>
  10. <input class="uni-input" v-model="form.mobile" type="number" maxlength="11" placeholder="输入手机号码" />
  11. </view>
  12. <view class="inpBox">
  13. <image class="yzm" src="/static/czd/yzm.png" mode=""></image>
  14. <view>
  15. <input class="uni-input uni-code" v-model="form.captcha" type="number" maxlength="6" placeholder="输入验证码" />
  16. <view class="reset" @tap="getCode">{{tips}}</view>
  17. </view>
  18. </view>
  19. <view class="btnBox">
  20. <u-button type="primary" hover-class="hoverClass" @click="bind">完成</u-button>
  21. </view>
  22. </view>
  23. <u-verification-code :seconds="seconds" @end="end" @start="start" ref="uCode"
  24. @change="codeChange"></u-verification-code>
  25. </view>
  26. </template>
  27. <script>
  28. import {smsCode} from "@/api/government.js"
  29. export default{
  30. data(){
  31. return{
  32. config: {
  33. back: true, //false是tolbar页面 是则不写
  34. title: '',
  35. color: '#fff',
  36. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  37. backgroundColor: [1, '#F9F9F9'],
  38. },
  39. tips: '',
  40. seconds: 60,
  41. form:{
  42. mobile:"",
  43. captcha:""
  44. }
  45. }
  46. },
  47. onLoad(options){
  48. this.form.thirdType=options.thirdType;
  49. this.form.identityCode=options.identityCode;
  50. },
  51. methods:{
  52. codeChange(text) {
  53. this.tips = text;
  54. },
  55. getCode() {
  56. if (this.$refs.uCode.canGetCode) {
  57. // 模拟向后端请求验证码
  58. uni.showLoading({
  59. title: '正在获取验证码'
  60. })
  61. smsCode({mobile:this.form.mobile}).then(res=>{
  62. this.$u.toast('验证码已发送');
  63. }).finally(e=>{
  64. uni.hideLoading();
  65. // 这里此提示会被this.start()方法中的提示覆盖
  66. this.$refs.uCode.start();
  67. })
  68. } else {
  69. this.$u.toast('倒计时结束后再发送');
  70. }
  71. },
  72. end() {
  73. // this.$u.toast('倒计时结束');
  74. },
  75. start() {
  76. // this.$u.toast('倒计时开始');
  77. },
  78. bind(){
  79. // this.$yghttp.post('/user/login/yige-login',this.form).then(res=>{
  80. // if (res && res.code == 200) {
  81. // this.$u.toast('登录成功');
  82. // uni.setStorageSync('apiToken', res.data.token);
  83. // uni.switchTab({
  84. // url: '/pages/home'
  85. // })
  86. // } else {
  87. // this.$u.toast('验证码错误');
  88. // }
  89. // })
  90. if(!this.form.mobile){
  91. this.$u.toast('请输入手机号!');
  92. return
  93. }else if(!this.$u.test.mobile(this.form.mobile)){
  94. this.$u.toast('请输入正确手机号!');
  95. return
  96. }else if(!this.form.captcha){
  97. this.$u.toast('请输入验证码!');
  98. return
  99. }
  100. this.$yghttp.post('/user/login/third/register',this.form).then(res=>{
  101. if (res && res.code == 200) {
  102. uni.showToast({
  103. title: '登录成功!',
  104. icon: 'success',
  105. duration: 1500
  106. })
  107. uni.setStorageSync('apiToken', res.data.token);
  108. uni.switchTab({
  109. url: '/pages/home'
  110. })
  111. } else {
  112. this.$u.toast('验证码错误');
  113. }
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style>
  120. page {
  121. background-color: #F9F9F9;
  122. }
  123. </style>
  124. <style lang="scss" scoped>
  125. /deep/ .hx-navbar__icon {
  126. color: #303133 !important;
  127. }
  128. /deep/ .u-char-item{
  129. width: 120rpx !important;
  130. height: 120rpx !important;
  131. background: #ffffff;
  132. border-radius: 20rpx;
  133. border:none !important;
  134. }
  135. .top {
  136. text-align: center;
  137. padding: 50rpx 0 100rpx;
  138. font-size: 28rpx;
  139. .title {
  140. font-size: 60rpx;
  141. margin-bottom: 10rpx;
  142. font-weight: 700;
  143. }
  144. }
  145. .body {
  146. margin: auto;
  147. width: 615rpx;
  148. margin-bottom: 30rpx;
  149. .inpBox {
  150. background: #fff;
  151. border-radius: 20rpx;
  152. padding: 20rpx 30rpx;
  153. display: flex;
  154. margin-top: 30rpx;
  155. .uni-code{
  156. width: 200rpx;
  157. }
  158. >view{
  159. width: 100%;
  160. display: flex;
  161. justify-content: space-between;
  162. align-items: center;
  163. }
  164. }
  165. image{
  166. width: 36rpx;
  167. height: 44rpx;
  168. margin-right: 30rpx;
  169. }
  170. .yzm{
  171. width: 40rpx;
  172. height: 45rpx;
  173. }
  174. .uni-input {
  175. height: 40rpx;
  176. .uni-input-placeholder {
  177. color: #BEBEBE;
  178. }
  179. }
  180. .login-btn {
  181. background-color: #4095E5;
  182. color: #fff;
  183. margin-top: 100rpx;
  184. }
  185. }
  186. .btnBox{
  187. width: 100%;
  188. margin-top: 60rpx;
  189. }
  190. .u-btn{
  191. width: 615rpx;
  192. border-radius: 10rpx;
  193. background: rgb(64,149,229);
  194. font-size: 30rpx;
  195. font-weight: 700;
  196. margin: auto;
  197. font-family: Microsoft YaHei, Microsoft YaHei-Bold;
  198. background: linear-gradient(6deg,#56d9ee 0%, #3ebcd0 100%) #3c66d9;
  199. }
  200. .hoverClass{
  201. background: linear-gradient(6deg,#56d9ee 0%, #3ebcd0 100%) #3c66d9;
  202. }
  203. .reset{
  204. font-size: 30rpx;
  205. color: #4AC2D4;
  206. }
  207. </style>