Showing
4 changed files
with
82 additions
and
36 deletions
| ... | @@ -10,6 +10,7 @@ import { fn, fetch } from '../fn'; | ... | @@ -10,6 +10,7 @@ import { fn, fetch } from '../fn'; |
| 10 | const Api = { | 10 | const Api = { |
| 11 | MY_INFO: '/srv/?a=reg_my_info', | 11 | MY_INFO: '/srv/?a=reg_my_info', |
| 12 | REG_ADD: '/srv/?a=reg_add', | 12 | REG_ADD: '/srv/?a=reg_add', |
| 13 | + REG_EDIT: '/srv/?a=reg_edit', | ||
| 13 | } | 14 | } |
| 14 | 15 | ||
| 15 | /** | 16 | /** |
| ... | @@ -23,3 +24,9 @@ export const myInfoAPI = (params) => fn(fetch.post(Api.MY_INFO, params)); | ... | @@ -23,3 +24,9 @@ export const myInfoAPI = (params) => fn(fetch.post(Api.MY_INFO, params)); |
| 23 | * @returns | 24 | * @returns |
| 24 | */ | 25 | */ |
| 25 | export const addRegAPI = (params) => fn(fetch.post(Api.REG_ADD, params)); | 26 | export const addRegAPI = (params) => fn(fetch.post(Api.REG_ADD, params)); |
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * @description: 修改活动报名 | ||
| 30 | + * @returns | ||
| 31 | + */ | ||
| 32 | +export const editRegAPI = (params) => fn(fetch.post(Api.REG_EDIT, params)); | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-26 16:10:35 | 2 | * @Date: 2022-09-26 16:10:35 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-20 17:38:25 | 4 | + * @LastEditTime: 2022-10-20 18:27:46 |
| 5 | * @FilePath: /swx/src/components/activity-bar.vue | 5 | * @FilePath: /swx/src/components/activity-bar.vue |
| 6 | * @Description: 活动详情页底部导航栏 | 6 | * @Description: 活动详情页底部导航栏 |
| 7 | --> | 7 | --> |
| ... | @@ -72,7 +72,7 @@ const goTo = (type) => { | ... | @@ -72,7 +72,7 @@ const goTo = (type) => { |
| 72 | } else if (type === 'info') { // 报名信息 | 72 | } else if (type === 'info') { // 报名信息 |
| 73 | if (props.memberRole === 'player') { // 普通用户报名详情页 | 73 | if (props.memberRole === 'player') { // 普通用户报名详情页 |
| 74 | Taro.navigateTo({ | 74 | Taro.navigateTo({ |
| 75 | - url: '../joinInfo/index?reg_id=' + props.regId | 75 | + url: '../joinInfo/index?reg_id=' + props.regId + '&id=' + getCurrentPageParam().id |
| 76 | }) | 76 | }) |
| 77 | } else { // 义工报名详情页 | 77 | } else { // 义工报名详情页 |
| 78 | Taro.navigateTo({ | 78 | Taro.navigateTo({ | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-27 17:13:05 | 2 | * @Date: 2022-09-27 17:13:05 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-20 16:48:22 | 4 | + * @LastEditTime: 2022-10-20 18:40:43 |
| 5 | * @FilePath: /swx/src/pages/joinActivity/index.vue | 5 | * @FilePath: /swx/src/pages/joinActivity/index.vue |
| 6 | * @Description: 活动报名 | 6 | * @Description: 活动报名 |
| 7 | --> | 7 | --> |
| ... | @@ -97,9 +97,10 @@ import bottomButton from "@/components/bottom-button"; | ... | @@ -97,9 +97,10 @@ import bottomButton from "@/components/bottom-button"; |
| 97 | import Taro from '@tarojs/taro' | 97 | import Taro from '@tarojs/taro' |
| 98 | import { getCurrentPageParam } from "@/utils/weapp"; | 98 | import { getCurrentPageParam } from "@/utils/weapp"; |
| 99 | import { activityInfoAPI } from '@/api/Host/index'; | 99 | import { activityInfoAPI } from '@/api/Host/index'; |
| 100 | -import { addRegAPI } from '@/api/Reg/index'; | 100 | +import { addRegAPI, editRegAPI } from '@/api/Reg/index'; |
| 101 | import mixin from '@/utils/mixin'; | 101 | import mixin from '@/utils/mixin'; |
| 102 | import Toast from '@/components/vant-weapp/toast/toast'; | 102 | import Toast from '@/components/vant-weapp/toast/toast'; |
| 103 | +import { myInfoAPI } from '@/api/Reg/index'; | ||
| 103 | 104 | ||
| 104 | const username = ref(''); | 105 | const username = ref(''); |
| 105 | const phone = ref(''); | 106 | const phone = ref(''); |
| ... | @@ -115,6 +116,30 @@ onMounted(async () => { | ... | @@ -115,6 +116,30 @@ onMounted(async () => { |
| 115 | item.value = ''; | 116 | item.value = ''; |
| 116 | }); | 117 | }); |
| 117 | } | 118 | } |
| 119 | + // 编辑模式 | ||
| 120 | + if (getCurrentPageParam().type === 'edit') { | ||
| 121 | + // 动态修改标题 | ||
| 122 | + wx.setNavigationBarTitle({ | ||
| 123 | + title: '修改活动报名', | ||
| 124 | + }); | ||
| 125 | + const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id }); | ||
| 126 | + if (code) { | ||
| 127 | + username.value = data.name; | ||
| 128 | + phone.value = data.phone; | ||
| 129 | + age_group.value = data.age_group; | ||
| 130 | + user_sex.value = data.gender; | ||
| 131 | + // 额外信息 | ||
| 132 | + if (data.extend) { | ||
| 133 | + for (const key in data.extend) { | ||
| 134 | + fields.value.forEach(item => { | ||
| 135 | + if (item.field === key) { | ||
| 136 | + item.value = data.extend[key]; | ||
| 137 | + } | ||
| 138 | + }); | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + } | ||
| 118 | }) | 143 | }) |
| 119 | 144 | ||
| 120 | const onSexChange = ({ detail }) => { | 145 | const onSexChange = ({ detail }) => { |
| ... | @@ -148,6 +173,7 @@ const validForm = () => { | ... | @@ -148,6 +173,7 @@ const validForm = () => { |
| 148 | const pattern = /^\d{11}$/; | 173 | const pattern = /^\d{11}$/; |
| 149 | if (!pattern.test(phone.value)) { | 174 | if (!pattern.test(phone.value)) { |
| 150 | Toast('请输入正确手机号'); | 175 | Toast('请输入正确手机号'); |
| 176 | + return false; | ||
| 151 | } | 177 | } |
| 152 | if (!age_group.value) { | 178 | if (!age_group.value) { |
| 153 | Toast('年龄段不能为空'); | 179 | Toast('年龄段不能为空'); |
| ... | @@ -183,11 +209,21 @@ const onSubmit = async (val) => { | ... | @@ -183,11 +209,21 @@ const onSubmit = async (val) => { |
| 183 | post: '', | 209 | post: '', |
| 184 | extend: JSON.stringify(extend) | 210 | extend: JSON.stringify(extend) |
| 185 | } | 211 | } |
| 186 | - const { code } = await addRegAPI(params); | 212 | + if (getCurrentPageParam().type === 'edit') { |
| 187 | - if (code) { | 213 | + params.i = getCurrentPageParam().reg_id; |
| 188 | - Taro.redirectTo({ | 214 | + const { code } = await editRegAPI(params); |
| 189 | - url: '../joinSuccess/index' | 215 | + if (code) { |
| 190 | - }) | 216 | + Taro.redirectTo({ |
| 217 | + url: '../joinSuccess/index' | ||
| 218 | + }) | ||
| 219 | + } | ||
| 220 | + } else { | ||
| 221 | + const { code } = await addRegAPI(params); | ||
| 222 | + if (code) { | ||
| 223 | + Taro.redirectTo({ | ||
| 224 | + url: '../joinSuccess/index' | ||
| 225 | + }) | ||
| 226 | + } | ||
| 191 | } | 227 | } |
| 192 | } | 228 | } |
| 193 | } | 229 | } | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-27 17:13:05 | 2 | * @Date: 2022-09-27 17:13:05 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-20 16:56:34 | 4 | + * @LastEditTime: 2022-10-20 18:50:36 |
| 5 | * @FilePath: /swx/src/pages/joinInfo/index.vue | 5 | * @FilePath: /swx/src/pages/joinInfo/index.vue |
| 6 | * @Description: 活动报名 | 6 | * @Description: 活动报名 |
| 7 | --> | 7 | --> |
| ... | @@ -63,31 +63,6 @@ import Taro from '@tarojs/taro' | ... | @@ -63,31 +63,6 @@ import Taro from '@tarojs/taro' |
| 63 | import { myInfoAPI } from '@/api/Reg/index'; | 63 | import { myInfoAPI } from '@/api/Reg/index'; |
| 64 | import { getCurrentPageParam } from "@/utils/weapp"; | 64 | import { getCurrentPageParam } from "@/utils/weapp"; |
| 65 | 65 | ||
| 66 | -const username = ref(''); | ||
| 67 | -const phone = ref(''); | ||
| 68 | -const age_group = ref(''); | ||
| 69 | -const user_sex = ref(''); | ||
| 70 | -const extend = ref([]); | ||
| 71 | - | ||
| 72 | -onMounted(async () => { | ||
| 73 | - const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id }); | ||
| 74 | - if (code) { | ||
| 75 | - username.value = data.name; | ||
| 76 | - phone.value = data.phone; | ||
| 77 | - age_group.value = data.age_group; | ||
| 78 | - user_sex.value = data.gender === 'man' ? '男士' : '女士'; | ||
| 79 | - // 额外信息 | ||
| 80 | - if (data.extend) { | ||
| 81 | - for (const key in data.extend) { | ||
| 82 | - extend.value.push({ | ||
| 83 | - title: key, | ||
| 84 | - value: data.extend[key], | ||
| 85 | - }); | ||
| 86 | - } | ||
| 87 | - } | ||
| 88 | - } | ||
| 89 | -}) | ||
| 90 | - | ||
| 91 | const cancelJoin = (val) => { | 66 | const cancelJoin = (val) => { |
| 92 | Taro.showToast({ | 67 | Taro.showToast({ |
| 93 | title: '取消成功', | 68 | title: '取消成功', |
| ... | @@ -98,7 +73,7 @@ const cancelJoin = (val) => { | ... | @@ -98,7 +73,7 @@ const cancelJoin = (val) => { |
| 98 | 73 | ||
| 99 | const editJoin = (val) => { | 74 | const editJoin = (val) => { |
| 100 | Taro.navigateTo({ | 75 | Taro.navigateTo({ |
| 101 | - url: '../joinActivity/index' | 76 | + url: '../joinActivity/index?type=edit®_id=' + getCurrentPageParam().reg_id + '&id=' + getCurrentPageParam().id |
| 102 | }) | 77 | }) |
| 103 | } | 78 | } |
| 104 | </script> | 79 | </script> |
| ... | @@ -107,5 +82,33 @@ const editJoin = (val) => { | ... | @@ -107,5 +82,33 @@ const editJoin = (val) => { |
| 107 | import "./index.less"; | 82 | import "./index.less"; |
| 108 | export default { | 83 | export default { |
| 109 | name: "demoPage", | 84 | name: "demoPage", |
| 85 | + data () { | ||
| 86 | + return { | ||
| 87 | + username: '', | ||
| 88 | + phone: '', | ||
| 89 | + age_group: '', | ||
| 90 | + user_sex: '', | ||
| 91 | + extend: [], | ||
| 92 | + } | ||
| 93 | + }, | ||
| 94 | + async onShow () { | ||
| 95 | + const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id }); | ||
| 96 | + if (code) { | ||
| 97 | + this.username = data.name; | ||
| 98 | + this.phone = data.phone; | ||
| 99 | + this.age_group = data.age_group; | ||
| 100 | + this.user_sex = data.gender === 'man' ? '男士' : '女士'; | ||
| 101 | + // 额外信息 | ||
| 102 | + if (data.extend) { | ||
| 103 | + this.extend = []; | ||
| 104 | + for (const key in data.extend) { | ||
| 105 | + this.extend.push({ | ||
| 106 | + title: key, | ||
| 107 | + value: data.extend[key], | ||
| 108 | + }); | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + } | ||
| 110 | }; | 113 | }; |
| 111 | </script> | 114 | </script> | ... | ... |
-
Please register or login to post a comment