mixin.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. },
  40. onShow() {
  41. let currentPage = this.$util.getCurrentRoute()
  42. if (LOGIN_LIST.includes(currentPage)) {
  43. this.login()
  44. }
  45. },
  46. methods: {
  47. init(){
  48. console.log("登录成功,初始化数");
  49. },
  50. // 登录 begin
  51. showLogin(notToast=false) {
  52. this.$refs.login.show(notToast)
  53. },
  54. signIn(resp) {
  55. //获取数据
  56. this.init()
  57. },
  58. async login(e) {
  59. if (this.$isEmpty(this.vuex_userId)) {
  60. this.showLogin()
  61. return
  62. }
  63. //获取数据
  64. this.init()
  65. //获取手机号
  66. if (this.$isEmpty(this.vuex_phone)&&this.$config.isAuthPhone) {
  67. this.$refs.login.showPhoneModal()
  68. }
  69. },
  70. async checkIsCmcc(){
  71. if (this.$isEmpty(this.vuex_phone)) {
  72. return
  73. }
  74. let params={
  75. phone:this.vuex_phone
  76. }
  77. let res=await this.$api.CMCC.isCMCC(params)
  78. console.log(res,"res....");
  79. return res.data.data
  80. },
  81. phoneSuccess(){
  82. console.log('手机号获取成功>>>>>>>>');
  83. },
  84. // 登录 end
  85. },
  86. }
  87. export default page