const app = getApp()
import {
    exchangemobile,
} from '~/api/user'
import {
    registerSale
} from '~/api/sale'
Page({
    data: {
        menuTop: app.globalData.menuTop,
        username: '',
        mobile: '',
        isSubmit: false
    },
    bindblur(e) {
        this.setData({
            username: e.detail.value.trim()
        })
    },
    async getmobileNumber({
        detail
    }) {
        let mobile = await exchangemobile({
            code: detail.code
        })
        this.setData({
            mobile
        })
    },
    black() {
        wx.navigateBack()
    },
    async submit() {
        let {
            mobile,
            username
        } = this.data
        this.setData({
            isSubmit: true
        })
        if (mobile && username) {
            let res = await registerSale({
                mobile,
                name: username
            })
            wx.redirectTo({
              url: '/salesperson/pages/saleOffice/index',
            })
        }
    }
})