mixin.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. },
  24. onLoad(options) {
  25. },
  26. onShow() {
  27. let currentPage = this.$util.getCurrentRoute()
  28. if (LOGIN_LIST.includes(currentPage)) {
  29. this.login()
  30. }
  31. },
  32. methods: {
  33. init(){
  34. console.log("登录成功,初始化数");
  35. },
  36. // 登录 begin
  37. showLogin() {
  38. this.$refs.login.show()
  39. },
  40. signIn(resp) {
  41. //获取数据
  42. this.init()
  43. },
  44. async login(e) {
  45. if (this.$isEmpty(this.vuex_userId)) {
  46. this.showLogin()
  47. return
  48. }
  49. //获取数据
  50. this.init()
  51. //获取手机号
  52. if (this.$isEmpty(this.vuex_phone)&&this.$config.isAuthPhone) {
  53. this.$refs.login.showPhoneModal()
  54. }
  55. },
  56. async checkIsCmcc(){
  57. if (this.$isEmpty(this.vuex_phone)) {
  58. return
  59. }
  60. let params={
  61. phone:this.vuex_phone
  62. }
  63. let res=await this.$api.CMCC.isCMCC(params)
  64. this.$u.vuex('vuex_isCMCC',!res.data.data)
  65. if (this.vuex_isCMCC) {
  66. uni.navigateTo({
  67. url:"/pages/auth/auth?mobile="+this.vuex_phone
  68. })
  69. }
  70. },
  71. phoneSuccess(){
  72. console.log('手机号获取成功>>>>>>>>');
  73. },
  74. // 登录 end
  75. },
  76. }
  77. export default page