123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- import { $wuxKeyBoard } from '../../dist/index'
- import ad from '../index/ad'
- ad({
- data: {},
- onLoad() {},
- open() {
- $wuxKeyBoard().show({
- callback(value) {
- console.log(`输入的密码是:${value}`)
- return true
- },
- })
- },
- openWitdhDisorder() {
- $wuxKeyBoard().show({
- disorder: true,
- callback(value) {
- console.log(`输入的密码是:${value}`)
- return false
- },
- })
- },
- openWithPromiseCallback() {
- const http = (obj) => {
- return new Promise((resolve, reject) => {
- obj.success = (res) => resolve(res)
- obj.fail = (res) => reject(res)
- wx.request(obj)
- })
- }
- $wuxKeyBoard().show({
- callback(value) {
- console.log(`输入的密码是:${value}`)
- wx.showLoading({
- title: '验证支付密码',
- })
- return http({
- url: 'your_server_address/api/xxx',
- method: 'POST',
- data: {
- username: 'admin',
- password: value,
- },
- })
- .then(res => {
- const data = res.data
- console.log(data)
- wx.hideLoading()
- wx.showToast({
- title: data.meta.message,
- duration: 3000,
- })
- if (data.meta.code !== 0) {
- return Promise.reject(data.meta.message)
- }
- })
- },
- })
- },
- openPlain() {
- const fn = (title) => {
- wx.hideLoading()
- wx.showToast({
- title,
- duration: 3000,
- })
- }
- $wuxKeyBoard().show({
- className: 'className',
- titleText: '安全键盘',
- cancelText: '取消',
- inputText: '输入数字密码',
- showCancel: true,
- disorder: false,
- maxlength: 4,
- closeOnReject: false,
- callback(value) {
- console.log(`输入的密码是:${value}`)
- wx.showLoading({
- title: '验证支付密码',
- })
- return new Promise((resolve, reject) => {
- setTimeout(() => Math.ceil(Math.random() * 10) >= 6 ? resolve(fn('密码正确')) : reject(fn('密码错误')), 3000)
- })
- },
- })
- },
- openTimed() {
- clearTimeout(this.timeout)
- const hide = $wuxKeyBoard().show({
- password: false,
- maxlength: -1,
- onChange(value) {
- console.log(`输入的密码是:${value}`)
- },
- onClose(value) {
- return false
- },
- })
- this.timeout = setTimeout(hide, 3000)
- },
- })
|