<template>
	<view>
		<view style="margin-top: 300rpx;">
			<view v-if="userInfo&&userInfo.mobile" class="phone">{{userInfo.mobile.substring(0,3)}}****{{userInfo.mobile.substring(userInfo.mobile.length-4,3)}}</view>
			<input v-model="saleNo" placeholder-class="input-placeholder" placeholder="请输入工号"/>
		</view>
		<view class="btn" @click="submit">确认绑定</view>
	</view>
</template>

<script>
import { setTimeout } from "timers";
	const app = getApp();
	const req = require("../../utils/request.js");

	export default {
		components: {},
		props: {},
		data() {
			return {
				userInfo:{},
				systems: {},
				isTop:0,
				saleNo:''
			}
		},
		onLoad(options) {
			this.userInfo = req.getStorage('userInfo')
		},
		onShow() {
			
		},
		methods: {
			submit(){
				if(!this.saleNo) req.msg("请输入工号")
				req.postRequest('/api/user/bindSaleNo',{saleNo:this.saleNo},res=>{
					req.msg("绑定成功")
					req.getRequest('/api/user/info', {}, suc => {
						req.setStorage('userInfo', data);
					});
					setTimeout(()=>{
						uni.navigateBack()
					},1000)
				})
			}
		},
		mounted() {
			const systemInfo = uni.getSystemInfoSync();
			// px转换到rpx的比例
			let pxToRpxScale = 750 / systemInfo.windowWidth;
			let systems = {
				ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
				navigationHeight: 44 * pxToRpxScale // 导航栏的高度
			};
			systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
			this.systems = systems;
		},
		onPageScroll: function(e) {
			if (e.scrollTop > this.systems.barHeight) {
				this.isTop = 1;
			} else {
				this.isTop = 0;
			}
		}
	}
</script>

<style>
	@import "./bindNumber.css";
</style>