guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 1 | <template> |
| 2 | <view class="otherPay"> |
| 3 | <u-cell-group> |
| 4 | <u-cell-item title="指纹" :arrow="false"> |
| 5 | <u-icon slot="icon" size="32" name="fingerprint"></u-icon> |
| 6 | <u-switch slot="right-icon" v-model="checked" @change="isOtherPay"></u-switch> |
| 7 | </u-cell-item> |
| 8 | </u-cell-group> |
| 9 | </view> |
| 10 | </template> |
| 11 | |
| 12 | <script> |
| 13 | export default { |
| 14 | data() { |
| 15 | return { |
| 16 | checked: false |
| 17 | } |
| 18 | }, |
| 19 | onLoad() { |
| 20 | let that = this |
| 21 | let openFingerPay = wx.getStorageSync("openFingerPay") |
| 22 | if (openFingerPay) { |
| 23 | that.checked = true |
| 24 | } |
| 25 | }, |
| 26 | methods: { |
| 27 | isOtherPay(e) { |
| 28 | let that = this |
| 29 | if (e) { |
| 30 | uni.showModal({ |
| 31 | title: "提示", |
| 32 | content: "是否开启指纹支付", |
| 33 | complete(res) { |
| 34 | if (res.confirm) { |
| 35 | that.checked = true |
| 36 | uni.setStorageSync("openFingerPay", true) |
| 37 | } else if (res.cancel) { |
| 38 | that.checked = false |
| 39 | } |
| 40 | } |
| 41 | }) |
| 42 | } else { |
| 43 | uni.showModal({ |
| 44 | title: "提示", |
| 45 | content: "是否关闭指纹支付", |
| 46 | complete(res) { |
| 47 | if (res.confirm) { |
| 48 | that.checked = false |
| 49 | uni.removeStorageSync("openFingerPay") |
| 50 | } else if (res.cancel) { |
| 51 | that.checked = true |
| 52 | } |
| 53 | } |
| 54 | }) |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | </script> |
| 60 | |
| 61 | <style scoped lang="scss"> |
| 62 | |
| 63 | </style> |