mixin.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. const LOGIN_LIST = ['pages/mine/mine']
  2. /*
  3. * 全局注入器
  4. */
  5. let page = {
  6. data() {
  7. return {
  8. }
  9. },
  10. computed: {
  11. //ios底部安全区域
  12. safeAreaBottom() {
  13. let info = uni.getSystemInfoSync()
  14. let safe = 20
  15. if (
  16. info && ['devtools', 'ios'].includes(info.platform) &&
  17. info.statusBarHeight > safe
  18. ) {
  19. return info.statusBarHeight - safe + 'px'
  20. }
  21. return 0
  22. },
  23. formatTime() {
  24. return (data, format = 'yyyy-mm-dd') => {
  25. // yyyy-mm-dd hh:MM:ss
  26. return this.$u.timeFormat(this.$dateTime.getTime(data), format)
  27. }
  28. },
  29. numberNull() {
  30. return data => {
  31. if (data == -1 || this.$isEmpty(data)) {
  32. return 0
  33. }
  34. return data
  35. }
  36. }
  37. },
  38. onLoad(options) {
  39. let currentPage = this.$util.getCurrentRoute()
  40. if (LOGIN_LIST.includes(currentPage)) {
  41. this.login()
  42. }
  43. },
  44. methods: {
  45. init() {
  46. console.log("登录成功,初始化数");
  47. },
  48. // 登录 begin
  49. showLogin(notToast = false) {
  50. // #ifdef MP-WEIXIN
  51. this.$refs.login.show(notToast)
  52. // #endif
  53. // #ifdef H5
  54. setTimeout(() => {
  55. this.$refs.login.show(notToast)
  56. }, 20)
  57. // #endif
  58. },
  59. signIn(resp) {
  60. //获取数据
  61. this.init()
  62. },
  63. async login(e) {
  64. if (this.$isEmpty(this.vuex_userId)) {
  65. this.showLogin()
  66. return
  67. }
  68. //获取数据
  69. this.init()
  70. //获取手机号
  71. if (this.$isEmpty(this.vuex_phone) && this.$config.isAuthPhone) {
  72. this.$refs.login.showPhoneModal()
  73. }
  74. },
  75. phoneSuccess() {
  76. console.log('手机号获取成功>>>>>>>>');
  77. },
  78. // 登录 end
  79. },
  80. }
  81. export default page