index.vue 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="page LiJiBaoMing">
  3. <!-- 表单 -->
  4. <view class="Form">
  5. <view class="flex-h">
  6. <text>姓名</text>
  7. <view class="flex-item">
  8. <input type="text" placeholder="请输入" v-model="Name" />
  9. </view>
  10. </view>
  11. <view class="flex-h">
  12. <text>手机号</text>
  13. <view class="flex-item">
  14. <input type="number" placeholder="请输入" v-model="Phone" />
  15. </view>
  16. </view>
  17. <view class="flex-h">
  18. <text>人数</text>
  19. <view class="flex-item">
  20. <input type="number" placeholder="请输入" v-model="Num" />
  21. </view>
  22. </view>
  23. </view>
  24. <text @tap="ToJoin">提交</text>
  25. </view>
  26. </template>
  27. <script>
  28. import { getCurrentInstance } from '@tarojs/taro'
  29. import { createNamespacedHelpers } from 'vuex'
  30. const { mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
  31. export default {
  32. name: 'LiJiBaoMing',
  33. data () {
  34. return {
  35. Name: '',
  36. Phone: '',
  37. Num: '',
  38. CurrnetId: null,
  39. DataLock: false
  40. }
  41. },
  42. computed: {
  43. ...mapUserState({
  44. UserInfo: x => x.UserInfo // 用户信息
  45. })
  46. },
  47. components: {
  48. },
  49. created () {
  50. this.CurrnetId = getCurrentInstance().router.params.id
  51. let _that = this
  52. wx.login({
  53. success (res) {
  54. _that.MainSignIn({ queryData: { code: res.code } }).then((res) => { // 获取用户信息
  55. _that.EditUserInfo({ name: 'PersonId', value: res.data.data.person.personId })
  56. _that.EditUserInfo({ name: 'OpenId', value: res.data.data.person.openId })
  57. _that.EditUserInfo({ name: 'SessionKey', value: res.data.data.extraInfo.sessionKey })
  58. if (res.data.data.person.phone !== undefined && res.data.data.person.phone !== null) {
  59. _that.EditUserInfo({ name: 'Phone', value: res.data.data.person.phone })
  60. }
  61. _that.Init()
  62. })
  63. }
  64. })
  65. },
  66. methods: {
  67. ...mapUserActions([
  68. 'GetUserPhone',
  69. 'PostActivityJoin',
  70. 'MainSignIn' // 获取用户信息
  71. ]),
  72. ...mapUserMutations([
  73. 'EditUserInfo' // 编辑用户信息
  74. ]),
  75. Init () {
  76. },
  77. ToJoin () { // 去报名
  78. if (this.DataLock) return
  79. this.DataLock = true
  80. this.PostActivityJoin({
  81. urlData: { id: this.ActivityInfo.activityId },
  82. data: { data: { enrollName: this.Name, enrollPhone: this.Phone, enrollNum: this.Num } }
  83. }).then((res) => {
  84. this.DataLock = false
  85. wx.showToast({
  86. title: '报名成功',
  87. icon: 'none',
  88. duration: 2000
  89. })
  90. }).catch(() => {
  91. this.DataLock = false
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. @import "page.scss";
  99. </style>