phone.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="container">
  3. <image src="../../static/img/bd-top.png" mode="widthFix" style="width: 750rpx;"></image>
  4. <view class="login_text">
  5. <view class="login_input flex">
  6. <view class="login_img"><image src="/static/icon/phone.png"></image></view>
  7. <view class="login_name"><input class="uni-input" v-model="account" placeholder="请输入手机号" /></view>
  8. </view>
  9. <!-- <view class="login_input flex">
  10. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  11. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder="请输入密码" /></view>
  12. </view> -->
  13. <!-- <view class="login_input flex">
  14. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  15. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus placeholder="请重复输入密码" /></view>
  16. </view>
  17. <view class="login_input flex">
  18. <view class="login_img"><image src="/static/icon/img07.png"></image></view>
  19. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
  20. </view> -->
  21. <view class="login_input flex">
  22. <view class="login_img"><image src="/static/icon//yzm.png"></image></view>
  23. <view class="login_name flex">
  24. <input class="uni-input width" v-model="captcha" placeholder="请输入验证码" />
  25. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="sb-btn" @click="loding ? '' : confirm()">
  30. 确认绑定
  31. </view>
  32. <!-- <view class="row b-b">
  33. <text class="tit">手机号</text>
  34. <input class="input" v-model="account" type="text" placeholder="请填写手机号" placeholder-class="placeholder" />
  35. </view>
  36. <view>
  37. <view class="row b-b">
  38. <text class="tit">验证码</text>
  39. <input class="input" v-model="captcha" type="text" placeholder="请填写验证码" placeholder-class="placeholder" />
  40. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  41. </view>
  42. <button class="add-btn" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">提交</button>
  43. </view> -->
  44. </view>
  45. </template>
  46. <script>
  47. import { verify } from '@/api/login.js';
  48. import { mapState } from 'vuex';
  49. import { registerReset, binding } from '@/api/set.js';
  50. export default {
  51. data() {
  52. return {
  53. time: '', //保存倒计时对象
  54. countDown: 0, //倒计时
  55. account: '', //手机号
  56. captcha: '', //验证码
  57. password: '', //新密码
  58. loding: false //是否载入中
  59. };
  60. },
  61. watch: {
  62. // 监听倒计时
  63. countDown(i) {
  64. if (i == 0) {
  65. clearInterval(this.time);
  66. }
  67. }
  68. },
  69. computed: {
  70. ...mapState(['userInfo'])
  71. },
  72. onLoad() {
  73. if (this.userInfo.phone == null) {
  74. this.account = '';
  75. } else {
  76. this.account = this.userInfo.phone;
  77. this.show = false;
  78. }
  79. },
  80. onBackPress() {
  81. // uni.switchTab({
  82. // url: '/pages/user/user'
  83. // })
  84. return true
  85. },
  86. methods: {
  87. //发送验证码
  88. verification() {
  89. let obj = this;
  90. if (this.account == '') {
  91. this.$api.msg('请输入电话号码');
  92. return;
  93. }
  94. if (!/(^1[2|3|4|5|6|7|8|9][0-9]{9}$)/.test(this.account)) {
  95. this.$api.msg('请输入正确的手机号');
  96. return;
  97. }
  98. // 判断是否在倒计时
  99. if (obj.countDown > 0) {
  100. return false;
  101. } else {
  102. obj.countDown = 60;
  103. obj.time = setInterval(() => {
  104. obj.countDown--;
  105. }, 1000);
  106. //调用验证码接口
  107. verify({
  108. phone: obj.account,
  109. type: 'BDING_CODE'
  110. })
  111. .then(({ data }) => {})
  112. .catch(err => {
  113. console.log(err);
  114. });
  115. }
  116. },
  117. confirm(e) {
  118. let obj = this;
  119. obj.loding = true;
  120. binding({
  121. phone: obj.account,
  122. captcha: obj.captcha
  123. })
  124. .then(({ data }) => {
  125. obj.$api.msg('绑定成功!');
  126. setTimeout(function() {
  127. obj.loding = false;
  128. uni.switchTab({
  129. url: '/pages/user/user'
  130. });
  131. }, 1000);
  132. })
  133. .catch(err => {
  134. obj.loding = false;
  135. console.log(err);
  136. });
  137. }
  138. }
  139. };
  140. </script>
  141. <style lang="scss">
  142. page {
  143. background: #e9f8f2;
  144. min-height: 100%;
  145. height: auto;
  146. }
  147. .row {
  148. display: flex;
  149. align-items: center;
  150. position: relative;
  151. padding: 0 30rpx;
  152. height: 110rpx;
  153. background: #fff;
  154. .tit {
  155. flex-shrink: 0;
  156. width: 120rpx;
  157. font-size: 30rpx;
  158. color: $font-color-dark;
  159. }
  160. .input {
  161. flex: 1;
  162. font-size: 30rpx;
  163. color: $font-color-dark;
  164. }
  165. .iconlocation {
  166. font-size: 36rpx;
  167. color: $font-color-light;
  168. }
  169. }
  170. .add-btn {
  171. display: flex;
  172. align-items: center;
  173. justify-content: center;
  174. width: 690rpx;
  175. height: 80rpx;
  176. margin: 60rpx auto;
  177. font-size: $font-lg;
  178. color: #fff;
  179. background-color: $base-color;
  180. border-radius: 10rpx;
  181. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  182. }
  183. .bg-gray {
  184. background-color: $color-gray;
  185. }
  186. .login_text {
  187. margin: auto 30rpx;
  188. position: relative;
  189. padding: 100rpx 102rpx;
  190. background: #e9f8f2;
  191. // margin-top: -180rpx;
  192. border-radius: 20rpx;
  193. .login_input {
  194. border-bottom: 1px solid #eee;
  195. margin-bottom: 65rpx;
  196. justify-content: flex-start;
  197. .login_img image {
  198. height: 35rpx;
  199. width: 29rpx;
  200. margin-right: 20rpx;
  201. }
  202. .uni-input {
  203. text-align: left;
  204. // width: 470rpx;
  205. max-width: 470rpx;
  206. flex-grow: 1;
  207. font-size: 36rpx !important;
  208. }
  209. .login_name {
  210. color: #333333;
  211. }
  212. }
  213. .other {
  214. margin-top: 60rpx;
  215. .fenge {
  216. width: 30%;
  217. height: 2rpx;
  218. background-color: #eeeeee;
  219. }
  220. .qita {
  221. font-size: 28rpx;
  222. color: #999999;
  223. }
  224. }
  225. .weixin {
  226. width: 75rpx;
  227. height: 75rpx;
  228. margin: 25rpx auto;
  229. }
  230. .weixin image {
  231. width: 100%;
  232. height: 100%;
  233. }
  234. .weixin_text {
  235. text-align: center;
  236. font-size: 28rpx;
  237. color: #999999;
  238. }
  239. .forget {
  240. font-size: 28rpx;
  241. width: 100%;
  242. text-align: right;
  243. color: #999999;
  244. }
  245. .uni-button-green {
  246. color: #ffffff;
  247. background-color: #5dbc7c;
  248. margin: 40rpx 10rpx;
  249. border-radius: 50rpx;
  250. }
  251. .uni-button-green-plain {
  252. border: 1px solid #5dbc7c;
  253. margin: 40rpx 10rpx;
  254. border-radius: 50rpx;
  255. color: #5dbc7c;
  256. background-color: #ffffff;
  257. }
  258. .uni-button {
  259. height: 85rpx;
  260. line-height: 85rpx;
  261. }
  262. }
  263. .code {
  264. color: #5dbc7c;
  265. font-size: 36rpx;
  266. border-left: 1px solid #eeeeee;
  267. width: 150rpx;
  268. flex-shrink: 0;
  269. text-align: center;
  270. }
  271. .sb-btn {
  272. display: flex;
  273. align-items: center;
  274. justify-content: center;
  275. width: 550rpx;
  276. height: 90rpx;
  277. background: #52C696;
  278. border-radius: 10rpx;
  279. font-size: 34rpx;
  280. font-weight: 400;
  281. color: #FFFFFF;
  282. margin: auto;
  283. text-align: center;
  284. }
  285. </style>