Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
swx_weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-10-20 18:51:01 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
baf57cc5de391aa57a2b95a4e1da9bdb3afc9fb0
baf57cc5
1 parent
7c59ba0b
✨ feat: 编辑报名信息API联调
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
31 deletions
src/api/Reg/index.js
src/components/activity-bar.vue
src/pages/joinActivity/index.vue
src/pages/joinInfo/index.vue
src/api/Reg/index.js
View file @
baf57cc
...
...
@@ -10,6 +10,7 @@ import { fn, fetch } from '../fn';
const
Api
=
{
MY_INFO
:
'/srv/?a=reg_my_info'
,
REG_ADD
:
'/srv/?a=reg_add'
,
REG_EDIT
:
'/srv/?a=reg_edit'
,
}
/**
...
...
@@ -23,3 +24,9 @@ export const myInfoAPI = (params) => fn(fetch.post(Api.MY_INFO, params));
* @returns
*/
export
const
addRegAPI
=
(
params
)
=>
fn
(
fetch
.
post
(
Api
.
REG_ADD
,
params
));
/**
* @description: 修改活动报名
* @returns
*/
export
const
editRegAPI
=
(
params
)
=>
fn
(
fetch
.
post
(
Api
.
REG_EDIT
,
params
));
...
...
src/components/activity-bar.vue
View file @
baf57cc
<!--
* @Date: 2022-09-26 16:10:35
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-20 1
7:38:25
* @LastEditTime: 2022-10-20 1
8:27:46
* @FilePath: /swx/src/components/activity-bar.vue
* @Description: 活动详情页底部导航栏
-->
...
...
@@ -72,7 +72,7 @@ const goTo = (type) => {
} else if (type === 'info') { // 报名信息
if (props.memberRole === 'player') { // 普通用户报名详情页
Taro.navigateTo({
url: '../joinInfo/index?reg_id=' + props.regId
url: '../joinInfo/index?reg_id=' + props.regId
+ '&id=' + getCurrentPageParam().id
})
} else { // 义工报名详情页
Taro.navigateTo({
...
...
src/pages/joinActivity/index.vue
View file @
baf57cc
<!--
* @Date: 2022-09-27 17:13:05
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-20 1
6:48:22
* @LastEditTime: 2022-10-20 1
8:40:43
* @FilePath: /swx/src/pages/joinActivity/index.vue
* @Description: 活动报名
-->
...
...
@@ -97,9 +97,10 @@ import bottomButton from "@/components/bottom-button";
import Taro from '@tarojs/taro'
import { getCurrentPageParam } from "@/utils/weapp";
import { activityInfoAPI } from '@/api/Host/index';
import { addRegAPI } from '@/api/Reg/index';
import { addRegAPI
, editRegAPI
} from '@/api/Reg/index';
import mixin from '@/utils/mixin';
import Toast from '@/components/vant-weapp/toast/toast';
import { myInfoAPI } from '@/api/Reg/index';
const username = ref('');
const phone = ref('');
...
...
@@ -115,6 +116,30 @@ onMounted(async () => {
item.value = '';
});
}
// 编辑模式
if (getCurrentPageParam().type === 'edit') {
// 动态修改标题
wx.setNavigationBarTitle({
title: '修改活动报名',
});
const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id });
if (code) {
username.value = data.name;
phone.value = data.phone;
age_group.value = data.age_group;
user_sex.value = data.gender;
// 额外信息
if (data.extend) {
for (const key in data.extend) {
fields.value.forEach(item => {
if (item.field === key) {
item.value = data.extend[key];
}
});
}
}
}
}
})
const onSexChange = ({ detail }) => {
...
...
@@ -148,6 +173,7 @@ const validForm = () => {
const pattern = /^\d{11}$/;
if (!pattern.test(phone.value)) {
Toast('请输入正确手机号');
return false;
}
if (!age_group.value) {
Toast('年龄段不能为空');
...
...
@@ -183,6 +209,15 @@ const onSubmit = async (val) => {
post: '',
extend: JSON.stringify(extend)
}
if (getCurrentPageParam().type === 'edit') {
params.i = getCurrentPageParam().reg_id;
const { code } = await editRegAPI(params);
if (code) {
Taro.redirectTo({
url: '../joinSuccess/index'
})
}
} else {
const { code } = await addRegAPI(params);
if (code) {
Taro.redirectTo({
...
...
@@ -190,6 +225,7 @@ const onSubmit = async (val) => {
})
}
}
}
}
</script>
...
...
src/pages/joinInfo/index.vue
View file @
baf57cc
<!--
* @Date: 2022-09-27 17:13:05
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-20 1
6:56:34
* @LastEditTime: 2022-10-20 1
8:50:36
* @FilePath: /swx/src/pages/joinInfo/index.vue
* @Description: 活动报名
-->
...
...
@@ -63,31 +63,6 @@ import Taro from '@tarojs/taro'
import { myInfoAPI } from '@/api/Reg/index';
import { getCurrentPageParam } from "@/utils/weapp";
const username = ref('');
const phone = ref('');
const age_group = ref('');
const user_sex = ref('');
const extend = ref([]);
onMounted(async () => {
const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id });
if (code) {
username.value = data.name;
phone.value = data.phone;
age_group.value = data.age_group;
user_sex.value = data.gender === 'man' ? '男士' : '女士';
// 额外信息
if (data.extend) {
for (const key in data.extend) {
extend.value.push({
title: key,
value: data.extend[key],
});
}
}
}
})
const cancelJoin = (val) => {
Taro.showToast({
title: '取消成功',
...
...
@@ -98,7 +73,7 @@ const cancelJoin = (val) => {
const editJoin = (val) => {
Taro.navigateTo({
url: '../joinActivity/index
'
url: '../joinActivity/index
?type=edit®_id=' + getCurrentPageParam().reg_id + '&id=' + getCurrentPageParam().id
})
}
</script>
...
...
@@ -107,5 +82,33 @@ const editJoin = (val) => {
import "./index.less";
export default {
name: "demoPage",
data () {
return {
username: '',
phone: '',
age_group: '',
user_sex: '',
extend: [],
}
},
async onShow () {
const { code, data } = await myInfoAPI({ i: getCurrentPageParam().reg_id });
if (code) {
this.username = data.name;
this.phone = data.phone;
this.age_group = data.age_group;
this.user_sex = data.gender === 'man' ? '男士' : '女士';
// 额外信息
if (data.extend) {
this.extend = [];
for (const key in data.extend) {
this.extend.push({
title: key,
value: data.extend[key],
});
}
}
}
}
};
</script>
...
...
Please
register
or
login
to post a comment