main-zkx.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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:"/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. let [error, res] = response;
  52. if (res.data.code == 200&&res.data.result) {
  53. var token = res ? res.data.data.token : '';
  54. this.carhelp.setPersonInfo(res.data.data.memberInfo );
  55. this.carhelp.setToken(token);
  56. setTimeout(()=>{
  57. uni.switchTab({
  58. url: '/pages/index/index'
  59. });
  60. },1000)
  61. } else{
  62. this.bottonShow=true
  63. }
  64. }).catch(error => {
  65. this.bottonShow=true
  66. })
  67. }
  68. },
  69. onReady() {
  70. this.findByOpenId()
  71. }
  72. }
  73. </script>
  74. <style>
  75. </style>