// components/authorizeBox/authorizeBox.js import { xcxPhoneNumber, xcxsmbd } from "../../apis/index" Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { show: false, animation: '', name: '', idcard: '' }, /** * 组件的方法列表 */ methods: { none() { return }, name(e) { let that = this that.setData({ name: e.detail.value }) }, idcard(e) { let that = this that.setData({ idcard: e.detail.value }) }, getPhoneNumber(e) { let that = this let name = that.data.name let idcard = that.data.idcard let publicId = wx.getStorageSync('PUBLIC_ID') if (!e.detail.code) { wx.showToast({ title: '用户拒绝', icon: "none", duration: 3000 }) that.hide() } else { if (name.length < 2 || idcard.length != 18) { wx.showToast({ title: '请检查姓名或者身份证号码是否填写准确', icon: "none", duration: 5000 }) } else { wx.showLoading({ title: '正在绑定...', }) xcxPhoneNumber({ code: e.detail.code }).then((res) => { if (res.code == 200) { let form = { xcxId: publicId.openid, unionid: publicId.unionid, sfzjhm: idcard, sjh: res.message, xm: name } xcxsmbd(form).then((res) => { wx.hideLoading() if (res.code == 200) { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 3000 }) that.triggerEvent('success', true) that.hide() } else { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 5000 }) } }) } else { wx.hideLoading() wx.showToast({ title: res.msg || res.message, icon: "none", duration: 5000 }) } }) } } }, close() { let that = this that.hide() }, show() { let that = this that.setData({ show: true }) setTimeout(() => { that.setData({ animation: 'showAuthorizeBox' }) }, 50); }, hide() { let that = this that.setData({ animation: '' }) setTimeout(() => { that.setData({ show: false }) }, 350); } } })