bindPhone.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view>
  3. <view class="app" v-if="isFirst && isInput">
  4. <view class="info-line" >
  5. <view class="il-top">
  6. <text>请收入手机号码</text>
  7. </view>
  8. <view class="il-bot">
  9. <input placeholder="输入手机号码" type="number" v-model="form.mobile"/>
  10. </view>
  11. </view>
  12. <view class="info-line">
  13. <view class="il-top">
  14. <text>验证码</text>
  15. </view>
  16. <view class="il-code">
  17. <input placeholder="验证码" type="number" v-model="form.verify" />
  18. <view class="ilc-btn" v-if="verifyCount == 0" @click="getverifyPhone">获取验证码</view>
  19. <view class="ilc-no-show" v-else>{{verifyCount}} s</view>
  20. </view>
  21. </view>
  22. <view class="update-btn" @click="tapBind">
  23. <text>绑定手机</text>
  24. </view>
  25. </view>
  26. <view v-else>
  27. <view class="top-bg">
  28. <view class="nav-top fx-h fx-bc">
  29. <image mode="widthFix" src="/static/img/subproof_success.png" style="width: 40vw;height: 30vw;"></image>
  30. <view class="title">已经绑定</view>
  31. </view>
  32. <view class="fx-h fx-bc fx-ac" style="height: calc(100vh - 350px);">
  33. <view class="btn" @tap="utils.navigateBack()">返回上一页</view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. mapState,
  42. mapMutations
  43. } from 'vuex'
  44. export default {
  45. computed: mapState(['user']),
  46. data() {
  47. return {
  48. form:{},
  49. verifyCount: 0,
  50. isInput : false,
  51. isFirst : false
  52. }
  53. },
  54. onLoad(options) {
  55. this.initView();
  56. },
  57. methods: {
  58. initView:function(){
  59. if(this.user.mobile != '') {
  60. this.isInput = false;
  61. } else {
  62. this.isInput = true;
  63. }
  64. this.isFirst = true;
  65. },
  66. getverifyPhone: function() {
  67. if (this.verifyCount > 0) return;
  68. uni.showLoading({
  69. title: "获取中..."
  70. });
  71. if(!this.utils.isPoneAvailable(this.form.mobile)) {
  72. uni.showToast({title: "请输入正确的手机号码",mask: true,icon: 'none'});
  73. return;
  74. }
  75. this
  76. .request
  77. .post("bindYzm", { mobile : this.form.mobile })
  78. .then(res => {
  79. uni.hideLoading();
  80. if (res.code == 200) {
  81. if (res.data.status == 2) {
  82. this.utils.CountDowm(res.data.time, (e, s) => {
  83. this.verifyCount = e;
  84. });
  85. }
  86. if (res.data.status == 1) {
  87. this.utils.CountDowm(120, (e, s) => {
  88. this.verifyCount = e;
  89. });
  90. }
  91. } else {
  92. uni.showToast({
  93. title: res.msg,
  94. mask: true,
  95. icon: 'none'
  96. });
  97. }
  98. })
  99. .catch(err => {
  100. uni.showToast({
  101. title: '获取失败',
  102. mask: true,
  103. icon: 'none'
  104. });
  105. uni.hideLoading();
  106. });
  107. },
  108. /**
  109. * 提交数据
  110. */
  111. tapBind:function(){
  112. if(this.form.mobile == ''){
  113. this.utils.Tip("请输入手机号码");
  114. return;
  115. }
  116. if(!this.utils.isPoneAvailable(this.form.mobile)) {
  117. uni.showToast({title: "请输入正确的手机号码",mask: true,icon: 'none'});
  118. return;
  119. }
  120. if(this.form.verify == ''){
  121. this.utils.Tip("请输入验证码");
  122. return;
  123. }
  124. this.utils.loadIng("提交中..");
  125. this
  126. .request
  127. .post("bindPhone",this.form)
  128. .then(res=>{
  129. uni.hideLoading();
  130. if(res.code == 200) {
  131. this.utils.Tip(res.msg,()=>{
  132. uni.navigateBack();
  133. });
  134. }else{
  135. this.utils.Tip(res.msg);
  136. }
  137. }).catch(function(){
  138. uni.hideLoading();
  139. this.utils.Tip("网络错误,请稍后尝试");
  140. });
  141. },
  142. },
  143. }
  144. </script>
  145. <style>
  146. page {
  147. background: #F5F5F5;
  148. }
  149. #box {
  150. padding-top: 90px;
  151. z-index: -1;
  152. }
  153. .info-line {
  154. height: 80px;
  155. padding: 0 15px;
  156. background-color: #fff;
  157. border-top: 1px #f5f5f5 solid;
  158. }
  159. .il-top {
  160. color: #333;
  161. font-size: 14px;
  162. margin-top: 10px;
  163. }
  164. .il-bot {
  165. margin-top: 10px;
  166. }
  167. .il-bot input {
  168. width: 100%;
  169. height: 100%;
  170. font-size: 13px;
  171. }
  172. .update-btn {
  173. width: 90%;
  174. height: 40px;
  175. text-align: center;
  176. line-height: 40px;
  177. margin: 30px auto;
  178. background: #db292b;
  179. color: #fff;
  180. border-radius: 100px;
  181. font-size: 16px;
  182. }
  183. .il-code {
  184. display: flex;
  185. align-items: center;
  186. margin-top: 10px;
  187. }
  188. .il-code input {
  189. width: 50%;
  190. height: 100%;
  191. font-size: 13px;
  192. }
  193. .ilc-btn {
  194. width: 90px;
  195. height: 30px;
  196. text-align: center;
  197. line-height: 30px;
  198. margin-left: auto;
  199. font-size: 12px;
  200. background: #db292b;
  201. color: #fff;
  202. border-radius: 100px;
  203. }
  204. .ilc-no-show {
  205. width: 90px;
  206. height: 30px;
  207. text-align: center;
  208. line-height: 30px;
  209. margin-left: auto;
  210. font-size: 12px;
  211. background: #eee;
  212. color: #999;
  213. border-radius: 100px;
  214. }
  215. .top-bg{position: relative;margin-top: 50px;}
  216. .nav-top{color: #e02e22;padding-top: 20px;}
  217. .nav-top .title{font-size: 40rpx;margin-top: 20px;}
  218. .nav-top .title-tag{font-size: 24rpx;color: #ffffff;margin-top: 24rpx;}
  219. .top-bg .btn{width: 290rpx;height:90rpx;border: solid 2px #e02e22;font-size: 32rpx;color: #e02e22;border-radius: 40px;text-align: center;line-height: 90rpx;}
  220. </style>