1
0

index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view style="padding-top: 200rpx;">
  3. <view @click="getContact" class="list">
  4. 获取通讯录数据
  5. </view>
  6. <view @click="getSms" class="list">
  7. 获取短息
  8. </view>
  9. <view @click="getCallLog" class="list">
  10. 获取通话记录
  11. </view>
  12. <view style="padding: 30px;">
  13. {{datas}}
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import PhoneInfo from './PhoneInfo.js';
  19. const $phoneInfo = new PhoneInfo();
  20. export default {
  21. onLoad() {
  22. $phoneInfo.needPermission((res) => {});
  23. // $phoneInfo.initAll();
  24. },
  25. data() {
  26. return {
  27. datas: ""
  28. };
  29. },
  30. methods: {
  31. getContact() {
  32. const contact = $phoneInfo.readContacts()
  33. contact.then(res => {
  34. this.datas = res
  35. })
  36. },
  37. getSms() {
  38. if (uni.getSystemInfoSync().platform == "ios") {
  39. return
  40. }
  41. $phoneInfo.readSms().then(res => {
  42. this.datas = res
  43. })
  44. },
  45. getCallLog() {
  46. if (uni.getSystemInfoSync().platform == "ios") {
  47. return
  48. }
  49. $phoneInfo.readCallLog().then(res => {
  50. this.datas = res
  51. }).catch(err => {
  52. console.log(err);
  53. })
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss">
  59. .list {
  60. height: 80rpx;
  61. line-height: 80rpx;
  62. font-size: 28rpx;
  63. padding: 0 20rpx 0 20rpx;
  64. color: #333333;
  65. border-bottom: 2rpx solid #adadad;
  66. text-align: center;
  67. }
  68. </style>