hookehuyr

✨ feat: 联调新建主办方API

...@@ -16,6 +16,15 @@ ...@@ -16,6 +16,15 @@
16 /* 调整下划线的起始位置 左侧是0 上边是1.15em */ 16 /* 调整下划线的起始位置 左侧是0 上边是1.15em */
17 background-position: 0 1.25rem; 17 background-position: 0 1.25rem;
18 } 18 }
19 + .user-type-box, .user-status-box {
20 + padding-top: 1rem;
21 + .title {
22 + font-size: 32rpx; margin-left: 1rem;
23 + }
24 + .border {
25 + margin: 0 1rem; border-bottom: 1px solid #F2F2F2;
26 + }
27 + }
19 .sign-box { 28 .sign-box {
20 width: 100%; 29 width: 100%;
21 display: flex; 30 display: flex;
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-09 11:25:53 4 + * @LastEditTime: 2022-10-10 10:55:06
5 * @FilePath: /swx/src/pages/createProject/index.vue 5 * @FilePath: /swx/src/pages/createProject/index.vue
6 - * @Description: 文件描述 6 + * @Description: 新建主办方页面
7 --> 7 -->
8 <template> 8 <template>
9 <view class="create-project-page"> 9 <view class="create-project-page">
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
12 <text class="bg-gradient" style="font-size: 1.25rem;">主办方信息设置</text> 12 <text class="bg-gradient" style="font-size: 1.25rem;">主办方信息设置</text>
13 </view> 13 </view>
14 </view> 14 </view>
15 - <AtInput :border="true" title="主办方名称" type='text' placeholder='请输入主办方名称' v-model:value="username" /> 15 + <AtInput :border="true" title="主办方名称" type='text' placeholder='请输入主办方名称' v-model:value="name" />
16 - <view style="padding-top: 1rem;"> 16 + <view class="user-type-box">
17 - <text style="font-size: 32rpx; margin-left: 1rem;">用户类型</text> 17 + <text class="title">用户类型</text>
18 <view class="sign-box"> 18 <view class="sign-box">
19 <view @tap="onTapType(item)" @longpress="onLongPressType(item)" v-for="(item, index) in userType" :key="index" 19 <view @tap="onTapType(item)" @longpress="onLongPressType(item)" v-for="(item, index) in userType" :key="index"
20 class="sign-item" :class="{ 'checked': item.checked }"><text>{{ item.label }}</text></view> 20 class="sign-item" :class="{ 'checked': item.checked }"><text>{{ item.label }}</text></view>
...@@ -22,11 +22,10 @@ ...@@ -22,11 +22,10 @@
22 <van-icon name="plus" color="" /> 22 <van-icon name="plus" color="" />
23 </view> 23 </view>
24 </view> 24 </view>
25 - <view style="margin: 0 1rem; border-bottom: 1px solid #F2F2F2;"></view> 25 + <view class="border"></view>
26 </view> 26 </view>
27 - 27 + <view class="user-status-box">
28 - <view style="padding-top: 1rem;"> 28 + <text class="title">用户状态</text>
29 - <text style="font-size: 32rpx; margin-left: 1rem;">用户状态</text>
30 <view class="sign-box"> 29 <view class="sign-box">
31 <view @tap="onTapStatus(item)" @longpress="onLongPressStatus(item)" v-for="(item, index) in userStatus" :key="index" 30 <view @tap="onTapStatus(item)" @longpress="onLongPressStatus(item)" v-for="(item, index) in userStatus" :key="index"
32 class="sign-item" :class="{ 'checked': item.checked }"><text>{{ item.label }}</text></view> 31 class="sign-item" :class="{ 'checked': item.checked }"><text>{{ item.label }}</text></view>
...@@ -34,10 +33,10 @@ ...@@ -34,10 +33,10 @@
34 <van-icon name="plus" color="" /> 33 <van-icon name="plus" color="" />
35 </view> 34 </view>
36 </view> 35 </view>
37 - <view style="margin: 0 1rem; border-bottom: 1px solid #F2F2F2;"></view> 36 + <view class="border"></view>
38 </view> 37 </view>
39 <view style="height: 6rem;"></view> 38 <view style="height: 6rem;"></view>
40 - <bottom-button @on-submit="onSubmit">保存</bottom-button> 39 + <bottom-button @on-submit="onSave">保存</bottom-button>
41 </view> 40 </view>
42 41
43 <!-- 用户类型弹出框 --> 42 <!-- 用户类型弹出框 -->
...@@ -48,9 +47,9 @@ ...@@ -48,9 +47,9 @@
48 <text class="bg-gradient">用户类型</text> 47 <text class="bg-gradient">用户类型</text>
49 </view> 48 </view>
50 <view style="width: 22rem;"> 49 <view style="width: 22rem;">
51 - <van-field :value="message" label-class="label-class" input-class="input-class" rows="1" autosize label="字段名称" 50 + <van-field :value="add_user_type" label-class="label-class" input-class="input-class" rows="1" autosize label="用户类型"
52 - type="textarea" placeholder="请输入字段名称(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" 51 + type="textarea" placeholder="请输入用户类型(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign=""
53 - rightIcon="" :required="true" :maxlength="6" :border="true" @change="onChangeType" /> 52 + rightIcon="" :required="true" :border="true" @change="onChangeType" />
54 <van-row> 53 <van-row>
55 <van-col span="12"> 54 <van-col span="12">
56 <view class="cancel-box"> 55 <view class="cancel-box">
...@@ -76,9 +75,9 @@ ...@@ -76,9 +75,9 @@
76 <text class="bg-gradient">用户状态</text> 75 <text class="bg-gradient">用户状态</text>
77 </view> 76 </view>
78 <view style="width: 22rem;"> 77 <view style="width: 22rem;">
79 - <van-field :value="message" label-class="label-class" input-class="input-class" rows="1" autosize label="字段名称" 78 + <van-field :value="add_user_status" label-class="label-class" input-class="input-class" rows="1" autosize label="用户状态"
80 - type="textarea" placeholder="请输入字段名称(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign="" 79 + type="textarea" placeholder="请输入用户状态(6个字以内)" placeholder-style="color: #999;" customStyle="" inputAlign=""
81 - rightIcon="" :required="true" :maxlength="6" :border="true" @change="onChangeStatus" /> 80 + rightIcon="" :required="true" :border="true" @change="onChangeStatus" />
82 <van-row> 81 <van-row>
83 <van-col span="12"> 82 <van-col span="12">
84 <view class="cancel-box"> 83 <view class="cancel-box">
...@@ -95,6 +94,7 @@ ...@@ -95,6 +94,7 @@
95 </view> 94 </view>
96 </view> 95 </view>
97 </van-overlay> 96 </van-overlay>
97 + <van-toast id="van-toast" />
98 </template> 98 </template>
99 99
100 <script setup> 100 <script setup>
...@@ -103,70 +103,88 @@ import { ref } from "vue"; ...@@ -103,70 +103,88 @@ import { ref } from "vue";
103 import { AtInput } from 'taro-ui-vue3' 103 import { AtInput } from 'taro-ui-vue3'
104 import "taro-ui-vue3/dist/style/components/input.scss"; 104 import "taro-ui-vue3/dist/style/components/input.scss";
105 import bottomButton from "@/components/bottom-button"; 105 import bottomButton from "@/components/bottom-button";
106 - 106 +import request from '../../utils/request';
107 -const username = ref(''); 107 +import Toast from '@/components/vant-weapp/toast/toast';
108 -const onSubmit = (val) => { 108 +
109 - console.warn(val); 109 +const name = ref('');
110 - Taro.showToast({ 110 +const user_type = ref([]);
111 - title: '请检查输入项', 111 +const user_status = ref([]);
112 - icon: 'error', 112 +const add_user_type= ref('');
113 - duration: 2000 113 +const add_user_status = ref('');
114 +
115 +const onSave = () => {
116 + if (!name.value) {
117 + Toast.fail('名称不能为空');
118 + return false;
119 + }
120 + let temp_user_type = userType.value.filter(element => element.checked);
121 + user_type.value = temp_user_type.map(element => element.label);
122 + let temp_user_status = userStatus.value.filter(element => element.checked);
123 + user_status.value = temp_user_status.map(element => element.label);
124 + // 保存主办方信息
125 + request.post('/srv/?a=host_add', {
126 + name: name.value,
127 + user_type: user_type.value,
128 + user_status: user_status.value,
129 + })
130 + .then(res => {
131 + if (res.data.code) {
132 + Toast.success('保存成功');
133 + Taro.navigateBack({
134 + delta: 1
135 + });
136 + } else {
137 + console.warn(res.data.msg);
138 + }
139 + })
140 + .catch(err => {
141 + console.error(err);
114 }); 142 });
115 - // Taro.redirectTo({
116 - // url: '../joinSuccess/index'
117 - // })
118 } 143 }
119 144
120 const userType = ref([{ 145 const userType = ref([{
121 - key: '首次参与',
122 label: '首次参与', 146 label: '首次参与',
123 checked: 1, 147 checked: 1,
124 }, { 148 }, {
125 - key: '老用户',
126 label: '老用户', 149 label: '老用户',
127 checked: 1, 150 checked: 1,
128 }]); 151 }]);
129 const userStatus = ref([{ 152 const userStatus = ref([{
130 - key: '跟踪',
131 label: '跟踪', 153 label: '跟踪',
132 checked: 1, 154 checked: 1,
133 }, { 155 }, {
134 - key: '引导',
135 label: '引导', 156 label: '引导',
136 checked: 1, 157 checked: 1,
137 }]); 158 }]);
138 159
139 160
140 161
141 -// 用户类型 162 +// 用户类型弹框操作
142 const onTapType = (item) => { 163 const onTapType = (item) => {
143 item.checked = !item.checked 164 item.checked = !item.checked
144 } 165 }
145 -
146 const onLongPressType = (item) => { 166 const onLongPressType = (item) => {
147 - console.warn(item);
148 show_edit_type.value = true; 167 show_edit_type.value = true;
149 } 168 }
150 -
151 const show_edit_type = ref(false) 169 const show_edit_type = ref(false)
152 -
153 const onChangeType = ({ detail }) => { 170 const onChangeType = ({ detail }) => {
154 - console.warn(detail); 171 + add_user_type.value = detail;
155 - checked.value = detail;
156 } 172 }
157 -
158 const closeEditType = () => { 173 const closeEditType = () => {
159 show_edit_type.value = false; 174 show_edit_type.value = false;
160 } 175 }
161 const confirmEditType = () => { 176 const confirmEditType = () => {
177 + if (!add_user_type.value) {
178 + Toast.fail('名称不能为空');
179 + } else {
162 show_edit_type.value = false; 180 show_edit_type.value = false;
163 userType.value.push({ 181 userType.value.push({
164 - key: '推荐人', 182 + label: add_user_type.value,
165 - label: '推荐人',
166 checked: 1, 183 checked: 1,
167 - }) 184 + });
185 + add_user_type.value = '';
186 + }
168 } 187 }
169 -
170 const addSign = () => { 188 const addSign = () => {
171 show_edit_type.value = true; 189 show_edit_type.value = true;
172 } 190 }
...@@ -175,31 +193,28 @@ const addSign = () => { ...@@ -175,31 +193,28 @@ const addSign = () => {
175 const onTapStatus = (item) => { 193 const onTapStatus = (item) => {
176 item.checked = !item.checked 194 item.checked = !item.checked
177 } 195 }
178 -
179 const onLongPressStatus = (item) => { 196 const onLongPressStatus = (item) => {
180 - console.warn(item);
181 show_edit_status.value = true; 197 show_edit_status.value = true;
182 } 198 }
183 -
184 const show_edit_status= ref(false) 199 const show_edit_status= ref(false)
185 -
186 const onChangeStatus = ({ detail }) => { 200 const onChangeStatus = ({ detail }) => {
187 - console.warn(detail); 201 + add_user_status.value = detail;
188 - checked.value = detail;
189 } 202 }
190 -
191 const closeEditStatus = () => { 203 const closeEditStatus = () => {
192 show_edit_status.value = false; 204 show_edit_status.value = false;
193 } 205 }
194 const confirmEditStatus = () => { 206 const confirmEditStatus = () => {
207 + if (!add_user_status.value) {
208 + Toast.fail('名称不能为空');
209 + } else {
195 show_edit_status.value = false; 210 show_edit_status.value = false;
196 userStatus.value.push({ 211 userStatus.value.push({
197 - key: '关注', 212 + label: add_user_status.value,
198 - label: '关注',
199 checked: 1, 213 checked: 1,
200 }) 214 })
215 + add_user_status.value = '';
216 + }
201 } 217 }
202 -
203 const addStatus = () => { 218 const addStatus = () => {
204 show_edit_status.value = true; 219 show_edit_status.value = true;
205 } 220 }
......