bindNumber.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view style="padding-top: 300rpx;">
  3. <!-- <view v-if="userInfo&&userInfo.mobile" class="phone">{{userInfo.mobile.substring(0,3)}}****{{userInfo.mobile.substring(userInfo.mobile.length-4,userInfo.mobile.length)}}</view> -->
  4. <view class="phone">绑定工号</view>
  5. <view class="input-box" style="margin-bottom: 30rpx;">
  6. <input v-model="saleNo" placeholder-class="input-placeholder" placeholder="请输入工号"/>
  7. </view>
  8. <view class="input-box dflex" style="margin-top: 40rpx;margin-bottom: 40rpx;">
  9. <input v-model="code" type="number" maxlength="6" placeholder="请输入验证码" placeholder-class="input-placeholder"
  10. class="flex" />
  11. <view class="yzm" @click="getCode()" v-text="sendMsg"></view>
  12. </view>
  13. <view style="padding: 0 60rpx;font-size: 26rpx;color: #999;margin-bottom: 40rpx;">
  14. * 该验证码将发送到云助理-小智·湖南
  15. </view>
  16. <view class="btn" @click="submit">确认绑定</view>
  17. </view>
  18. </template>
  19. <script>
  20. import { setTimeout } from "timers";
  21. const app = getApp();
  22. const req = require("../../utils/request.js");
  23. export default {
  24. components: {},
  25. props: {},
  26. data() {
  27. return {
  28. userInfo:{},
  29. systems: {},
  30. isTop:0,
  31. saleNo:'',
  32. code: '', //code
  33. sendMsg: '获取验证码',
  34. isGetCodeDisabled: false,
  35. }
  36. },
  37. onLoad(options) {
  38. this.userInfo = req.getStorage('userInfo')
  39. },
  40. onShow() {
  41. },
  42. methods: {
  43. submit(){
  44. if(!this.saleNo) return req.msg("请输入工号")
  45. if(!this.code) return req.msg("请输入验证码")
  46. req.postRequest('/api/user/isBeBinding',{saleNo:this.saleNo},res=>{
  47. if(res){
  48. uni.showModal({
  49. title:'提示',
  50. content:res,
  51. success: (rres) => {
  52. if(rres.confirm){
  53. this.bindSaleNo()
  54. }else{
  55. }
  56. }
  57. })
  58. }else{
  59. this.bindSaleNo()
  60. }
  61. },true)
  62. },
  63. bindSaleNo(){
  64. req.postRequest('/api/user/bindSaleNo',{saleNo:this.saleNo,yzlCode:this.code},res=>{
  65. req.msg("绑定成功")
  66. req.getRequest('/api/user/info', {}, suc => {
  67. req.setStorage('userInfo', suc);
  68. });
  69. setTimeout(()=>{
  70. uni.navigateBack()
  71. },1000)
  72. },true)
  73. },
  74. getCode() {
  75. if (this.isGetCodeDisabled == true) return false;
  76. if (!this.saleNo) {
  77. req.msg('请输入工号');
  78. return;
  79. }
  80. req.postRequest(
  81. '/api/user/getYzlCode', {
  82. saleNo: this.saleNo,
  83. },
  84. data => {
  85. req.msg('验证码获取成功');
  86. let time = 60;
  87. let interval = setInterval(() => {
  88. time--;
  89. if (time == 0) {
  90. this.isGetCodeDisabled = false;
  91. this.sendMsg = '获取验证码';
  92. clearInterval(interval);
  93. } else {
  94. this.isGetCodeDisabled = true;
  95. this.sendMsg = time + '秒后再获取';
  96. }
  97. }, 1000);
  98. },
  99. true
  100. );
  101. },
  102. },
  103. mounted() {
  104. const systemInfo = uni.getSystemInfoSync();
  105. // px转换到rpx的比例
  106. let pxToRpxScale = 750 / systemInfo.windowWidth;
  107. let systems = {
  108. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  109. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  110. };
  111. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  112. this.systems = systems;
  113. },
  114. onPageScroll: function(e) {
  115. if (e.scrollTop > this.systems.barHeight) {
  116. this.isTop = 1;
  117. } else {
  118. this.isTop = 0;
  119. }
  120. }
  121. }
  122. </script>
  123. <style>
  124. @import "./bindNumber.css";
  125. </style>