123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- // 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);
- }
- }
- })
|