main-zkx.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view>
  3. <u-navbar></u-navbar>
  4. 首页图
  5. <view v-if="bottonShow">
  6. <u-button @click="gotoMain(true)" >加入我们</u-button>
  7. <u-button @click="gotoMain(false)">我先逛逛</u-button>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import * as loginApi from '@/apis/login.js'
  13. export default {
  14. data() {
  15. return {
  16. bottonShow:false
  17. }
  18. },
  19. methods: {
  20. gotoMain(k){
  21. if(k){
  22. uni.navigateTo({
  23. url:"/pagesA/pages/login/index"
  24. })
  25. }else{
  26. uni.switchTab({
  27. url: '/pages/index/index'
  28. });
  29. }
  30. },
  31. findByOpenId(){
  32. var openId=this.carhelp.getOpenId()
  33. if(openId==""){
  34. console.log("------------------")
  35. setTimeout(()=>{
  36. this.findByOpenId()
  37. },1000)
  38. return
  39. }
  40. uni.request({
  41. method:'get',
  42. url: process.car.BASE_URL + "/mobile/regUser/findByOpenId",
  43. data: {
  44. openId:openId,
  45. },
  46. header: {
  47. 'Content-Type': 'application/x-www-form-urlencoded',
  48. 'X-Requested-With': 'XMLHttpRequest',
  49. }
  50. }).then((response) => {
  51. console.log('findByOpenId')
  52. let [error, res] = response;
  53. if (res.data.code == 200&&res.data.result) {
  54. var token = res ? res.data.data.token : '';
  55. this.carhelp.setPersonInfo(res.data.data.memberInfo );
  56. this.carhelp.setToken(token);
  57. this.carhelp.setPersonInfoPlus(res.data.data);
  58. setTimeout(()=>{
  59. uni.switchTab({
  60. url: '/pages/index/index'
  61. });
  62. },1000)
  63. } else{
  64. this.bottonShow=true
  65. }
  66. }).catch(error => {
  67. this.bottonShow=true
  68. })
  69. }
  70. },
  71. onReady() {
  72. this.findByOpenId()
  73. }
  74. }
  75. </script>
  76. <style>
  77. </style>