index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view class="container">
  3. <navBar title="首页" :back="false" color="white" background="green" />
  4. <u-button text="测试网络请求" @click="testReq" type="primary"></u-button>
  5. <u-button text="测试vuex仓库" @click="testStore" type="primary"></u-button>
  6. <u-button text="测试登录-vuex仓库" @click="testLogin" type="primary"></u-button>
  7. <u-button text="测试登录退出登录" @click="testLogout" type="primary"></u-button>
  8. </view>
  9. </template>
  10. <script>
  11. import {
  12. getValidateCode
  13. } from '@/api/index/index.js'
  14. export default {
  15. data() {
  16. return {
  17. }
  18. },
  19. methods: {
  20. async testReq() {
  21. console.log('testStore()111111', this.$store.getters['user/testInfo']);
  22. console.log('testStore()111111', this.$store.getters['user/testInfo2']);
  23. // let res = await getValidateCode({
  24. // phone: '15609038521',
  25. // event: 'register'
  26. // })
  27. // uni.showToast({
  28. // title: res.msg,
  29. // icon: 'none'
  30. // })
  31. // console.log('发送短信验证码返回值', res);
  32. // if (res.code == 0) {}
  33. },
  34. testStore() {
  35. this.$store.dispatch('user/testAct', '6666666')
  36. console.log('testStore()', this.$store.getters['user/testInfo']);
  37. // this.$store.dispatch('testAct', '66666');
  38. // console.log('存入仓库后', this.$store.getters.testInfo);
  39. },
  40. async testLogin() {
  41. let res = await this.$store.dispatch('user/testAct2', {
  42. phone: '15609038533',
  43. event: 'register'
  44. })
  45. console.log('测试登录返回值:', res);
  46. },
  47. testLogout() {
  48. this.$store.dispatch('user/testAct3')
  49. console.log('测试退出登录返回值:', this.$store.getters['user/testInfo3']);
  50. },
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. @import "./index.scss";
  56. </style>