main-zkx.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. setTimeout(()=>{
  58. uni.switchTab({
  59. url: '/pages/index/index'
  60. });
  61. },1000)
  62. } else{
  63. this.bottonShow=true
  64. }
  65. }).catch(error => {
  66. this.bottonShow=true
  67. })
  68. }
  69. },
  70. onReady() {
  71. this.findByOpenId()
  72. }
  73. }
  74. </script>
  75. <style>
  76. </style>