bindNumber.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <view>
  3. <view style="margin-top: 300rpx;">
  4. <view v-if="userInfo&&userInfo.mobile" class="phone">{{userInfo.mobile.substring(0,3)}}****{{userInfo.mobile.substring(userInfo.mobile.length-4,3)}}</view>
  5. <input v-model="saleNo" placeholder-class="input-placeholder" placeholder="请输入工号"/>
  6. </view>
  7. <view class="btn" @click="submit">确认绑定</view>
  8. </view>
  9. </template>
  10. <script>
  11. import { setTimeout } from "timers";
  12. const app = getApp();
  13. const req = require("../../utils/request.js");
  14. export default {
  15. components: {},
  16. props: {},
  17. data() {
  18. return {
  19. userInfo:{},
  20. systems: {},
  21. isTop:0,
  22. saleNo:''
  23. }
  24. },
  25. onLoad(options) {
  26. this.userInfo = req.getStorage('userInfo')
  27. },
  28. onShow() {
  29. },
  30. methods: {
  31. submit(){
  32. if(!this.saleNo) req.msg("请输入工号")
  33. req.postRequest('/api/user/bindSaleNo',{saleNo:this.saleNo},res=>{
  34. req.msg("绑定成功")
  35. req.getRequest('/api/user/info', {}, suc => {
  36. req.setStorage('userInfo', data);
  37. });
  38. setTimeout(()=>{
  39. uni.navigateBack()
  40. },1000)
  41. })
  42. }
  43. },
  44. mounted() {
  45. const systemInfo = uni.getSystemInfoSync();
  46. // px转换到rpx的比例
  47. let pxToRpxScale = 750 / systemInfo.windowWidth;
  48. let systems = {
  49. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  50. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  51. };
  52. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  53. this.systems = systems;
  54. },
  55. onPageScroll: function(e) {
  56. if (e.scrollTop > this.systems.barHeight) {
  57. this.isTop = 1;
  58. } else {
  59. this.isTop = 0;
  60. }
  61. }
  62. }
  63. </script>
  64. <style>
  65. @import "./bindNumber.css";
  66. </style>