index1.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. <u-button text="测试提示弹框" @click="$toast('测试','success')" type="primary"></u-button>
  9. <u-button text="测试自定义弹框" @click="show=true" type="primary"></u-button>
  10. <dpopup :show="show" mode="bottom" :round="10" @close="show=false">
  11. <view slot="content">
  12. <view class="top">
  13. 顶部
  14. </view>
  15. <view class="content" style="height: 300px;">
  16. 内容
  17. </view>
  18. </view>
  19. </dpopup>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. getValidateCode
  25. } from '@/api/index/index.js'
  26. export default {
  27. data() {
  28. return {
  29. show: false
  30. }
  31. },
  32. methods: {
  33. async testReq() {
  34. console.log('testStore()111111', this.$store.getters['user/testInfo']);
  35. console.log('testStore()111111', this.$store.getters['user/testInfo2']);
  36. let res = await getValidateCode({
  37. phone: '15609038521',
  38. event: 'register'
  39. })
  40. uni.showToast({
  41. title: res.msg,
  42. icon: 'none'
  43. })
  44. console.log('发送短信验证码返回值', res);
  45. // if (res.code == 0) {}
  46. },
  47. testStore() {
  48. this.$store.dispatch('user/testAct', '6666666')
  49. console.log('testStore()', this.$store.getters['user/testInfo']);
  50. // this.$store.dispatch('testAct', '66666');
  51. // console.log('存入仓库后', this.$store.getters.testInfo);
  52. },
  53. async testLogin() {
  54. let res = await this.$store.dispatch('user/testAct2', {
  55. phone: '15609038533',
  56. event: 'register'
  57. })
  58. console.log('测试登录返回值:', res);
  59. },
  60. testLogout() {
  61. this.$store.dispatch('user/testAct3')
  62. console.log('测试退出登录返回值:', this.$store.getters['user/testInfo3']);
  63. },
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. @import "./index.scss";
  69. </style>