bm_page.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class="box">
  3. <u-navbar :title="activityTitle" autoBack :placeholder="true" bgColor="#fee1b9"></u-navbar>
  4. <view class="ban">
  5. <view class="hdjs_box">
  6. <view class="hdjs_tit">活动介绍</view>
  7. <view class="hdjs_xq" style="overflow: scroll">{{activityDesc}}</view>
  8. </view>
  9. <!-- -->
  10. <view class="ld">报名资料填写</view>
  11. <view class="radio_box">
  12. <u-radio-group
  13. v-model="activity_schedule_id"
  14. placement="column"
  15. >
  16. <u-radio
  17. :customStyle="{marginBottom: '8px'}"
  18. v-for="(item, index) in scheduleList"
  19. :key="index"
  20. :label="item.desc"
  21. :name="item.id"
  22. @change="scheduleChange"
  23. >
  24. </u-radio>
  25. </u-radio-group>
  26. </view>
  27. <!-- 动态表单 -->
  28. <block v-for="item in signupParams" :key="item.id">
  29. <!-- @click="getTitle(item)" -->
  30. <view class="" style="margin-top: 30rpx;">
  31. <text >{{ item.title }}</text>
  32. <!-- <text v-if="item.tip" class="tip">{{ item.tip }}</text> -->
  33. <!-- 根据 type 属性决定渲染哪种类型的输入 -->
  34. <u--input v-if="item.type === 'string'"
  35. v-model="item.value"
  36. border="surround"
  37. @change="onInput(item)"
  38. :placeholder="item.tip" />
  39. <u-radio-group v-if="item.type === 'radio'" placement="column">
  40. <u-radio v-for="(fruitName, fruitId) in item.params" :key="fruitId"
  41. :label="fruitName"
  42. :name="item.name + '-' + fruitName"
  43. @change="radioChange"
  44. :customStyle="{ marginBottom: '8px', height: '30px' }"
  45. >
  46. {{ fruitName }}
  47. </u-radio>
  48. </u-radio-group>
  49. <!-- 其他类型可以根据需要添加 -->
  50. </view>
  51. </block>
  52. <view class="bm_btn" @click="tjcyBtn">添加成员</view>
  53. <view class="cy_box" v-for="(item,index) in cyList" :key="index">
  54. <view class="" style="display: flex;">
  55. <view class="icon_box">
  56. <u-icon name="account" color="#000000" size="20"></u-icon>
  57. </view>
  58. <view style="margin-left: 20rpx">
  59. <view class="cy_name">{{item.name}}</view>
  60. <view class="cy_age">年龄:{{item.age}}</view>
  61. </view>
  62. </view>
  63. <view @click="removeMembers(index)" style="width: 60rpx;height: 60rpx;">
  64. <u-icon name="trash" color="#858789" size="20" ></u-icon>
  65. </view>
  66. </view>
  67. <!-- -->
  68. <view class="tjbm_btn" @click="submitActivitySignupInfo">提交报名</view>
  69. <!-- 阅读协议 -->
  70. <view class="ydxy">
  71. <u-checkbox-group @change="xyShow=!xyShow" >
  72. <u-checkbox v-model="xyShow" shape="circle" ></u-checkbox>
  73. </u-checkbox-group>
  74. <view class="" @click="volhow=true">
  75. 阅读并同意《隐私政策》和《用户协议》
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 协议弹层 -->
  80. <u-popup bgColor="#f2c8a2" :show="volhow" mode="center" customStyle="width:600rpx;padding: 30rpx;" round="20rpx">
  81. <view style="text-align: center; font-size: 30rpx">请阅读以下协议</view>
  82. <view style="margin-top: 20rpx"></view>
  83. <view class="bt_box">
  84. <view class="bt2" @click="volhow=false">我已知悉</view>
  85. </view>
  86. </u-popup>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. let that;
  92. export default {
  93. data() {
  94. return {
  95. radioName: '',
  96. signupParams : [],
  97. activityId: 1,
  98. activityDesc: '',
  99. activityTitle: '',
  100. volhow:false,
  101. xyShow:false,
  102. // 家庭成员
  103. cyList:[],
  104. ydxyShow:false,
  105. // 默认选中第一个
  106. activity_schedule_id: 1,
  107. scheduleList: [],
  108. params:{
  109. activity_schedule_id: 1,
  110. }
  111. };
  112. },
  113. onLoad(option) {
  114. console.log(option);
  115. that = this;
  116. that.activityId = option.id;
  117. that.activityDesc = option.desc;
  118. that.activityTitle = option.title;
  119. that.getActivityScheduleList(that.activityId);
  120. that.getActivitySignupParams(that.activityId);
  121. that.params.activity_id = option.id;
  122. },
  123. onShow() {
  124. // console.log(uni.getStorageSync('selectedMembers'), 'selectedMembers');
  125. that.loadMembers();
  126. },
  127. computed: {
  128. // 筛选出 type 为 radio 的数据
  129. radioItems() {
  130. return this.signupParams.filter((item) => item.type === "radio");
  131. },
  132. },
  133. methods: {
  134. //获取活动日程列表
  135. getActivityScheduleList(id) {
  136. this.$api.activityScheduleList(
  137. {
  138. activity_id: id
  139. },
  140. data => {
  141. if (data.code == 0) {
  142. that.$common.errorToShow(data.msg);
  143. return;
  144. } else {
  145. that.scheduleList = data.data;
  146. // console.log(that.scheduleList);
  147. }
  148. }
  149. );
  150. },
  151. //获取活动报名参数
  152. getActivitySignupParams(id) {
  153. this.$api.activitySignupParams(
  154. {
  155. activity_id: id
  156. },
  157. data => {
  158. if (data.code == 0) {
  159. that.$common.errorToShow(data.msg);
  160. return;
  161. } else {
  162. that.signupParams = data.data;
  163. //这边需要把每个参都存到params里面
  164. that.signupParams.forEach((item) => {
  165. that.params[item.name] = '';
  166. });
  167. console.log(that.params,'sparams');
  168. // console.log(that.signupParams,'that.signupParams')
  169. }
  170. }
  171. );
  172. },
  173. submitActivitySignupInfo() {
  174. console.log(that.xyShow);
  175. if (that.xyShow === false) {
  176. that.$common.errorToShow('请阅读并同意协议');
  177. return;
  178. }
  179. let params = that.params;
  180. if (that.cyList.length === 0) {
  181. that.$common.errorToShow('请选择报名成员');
  182. return;
  183. }
  184. params.identities = that.cyList.map(item => item.id).join(",");
  185. console.log(params, 'params');
  186. this.$api.submitActivitySignupInfo(params,
  187. data => {
  188. if (data.code == 0) {
  189. that.$common.errorToShow(data.msg);
  190. return;
  191. } else {
  192. that.$common.successToShow(data.msg);
  193. if (data.code == 1) {
  194. setTimeout(
  195. function(){
  196. uni.navigateBack({
  197. delta: 1
  198. });
  199. }, 1500);
  200. }
  201. }
  202. }
  203. );
  204. },
  205. volhowChange(volhow){
  206. that.volhow = !volhow;
  207. console.log(that.volhow);
  208. },
  209. radioChange(n) {
  210. const [field, value] = n.split("-");
  211. let title = field;
  212. that.params[title] = value;
  213. // console.log(that.params,'that.params');
  214. },
  215. scheduleChange(n) {
  216. that.activity_schedule_id = n;
  217. that.params.activity_schedule_id = n;
  218. // console.log(that.params);
  219. // console.log('scheduleChange',that.activity_schedule_id);
  220. },
  221. onInput(item) {
  222. that.$set(that.params, item.name, item.value); // 使用Vue的$set方法保证响应式
  223. // console.log('this.params:', this.params);
  224. },
  225. tjcyBtn(){
  226. uni.navigateTo({
  227. url: '/index_fenbao/XuanJiangYuan/ck_page'
  228. });
  229. },
  230. // 从本地存储中获取乘客信息
  231. loadMembers() {
  232. const storedSelectedMembers = uni.getStorageSync('selectedMembers');
  233. // console.log(storedSelectedMembers, 'storedSelectedMembers')
  234. if (storedSelectedMembers) {
  235. that.cyList = storedSelectedMembers;
  236. } else {
  237. that.cyList = [];
  238. }
  239. },
  240. removeMembers(index) {
  241. // 移除乘客并更新本地存储
  242. that.cyList.splice(index, 1);
  243. // 更新本地存储中的乘客信息
  244. uni.setStorageSync('selectedMembers', that.cyList);
  245. // 提示删除成功
  246. uni.showToast({
  247. title: '删除成功',
  248. icon: 'success'
  249. });
  250. }
  251. }
  252. };
  253. </script>
  254. <style>
  255. .box {
  256. min-height: 100%;
  257. height: auto;
  258. width: 100%;
  259. padding-bottom: 50rpx;
  260. background-image: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/gj_bg.png');
  261. background-repeat: repeat-y;
  262. background-size: 100%;
  263. }
  264. .ban {
  265. width: 92%;
  266. margin: auto;
  267. }
  268. .top_tit {
  269. width: 100%;
  270. height: 60rpx;
  271. color: black;
  272. line-height: 60rpx;
  273. text-align: center;
  274. font-size: 30rpx;
  275. background-color: #fee1b9;
  276. }
  277. .hdjs_box {
  278. height: 200rpx;
  279. color: black;
  280. margin-top: 10rpx;
  281. border-radius: 10rpx;
  282. padding: 20rpx;
  283. background-color: #fff0e3;
  284. }
  285. .hdjs_box2 {
  286. color: black;
  287. margin-top: 10rpx;
  288. border-radius: 10rpx;
  289. margin-bottom: 30rpx;
  290. padding: 20rpx;
  291. background-color: #fff0e3;
  292. }
  293. .hdjs_tit {
  294. font-size: 30rpx;
  295. }
  296. .hdjs_xq {
  297. margin-top: 10rpx;
  298. font-size: 26rpx;
  299. }
  300. .ld {
  301. font-size: 30rpx;
  302. font-weight: 700;
  303. margin-top: 20rpx;
  304. margin-bottom: 20rpx;
  305. }
  306. .u-input.data-v-113bc24f {
  307. background-color: #fee1b9 !important ;
  308. margin-top: 20rpx;
  309. }
  310. .bm_btn {
  311. width: 100%;
  312. height: 80rpx;
  313. font-size: 30rpx;
  314. line-height: 80rpx;
  315. text-align: center;
  316. color: black;
  317. border-radius: 10rpx;
  318. background-color: #fee1b9;
  319. margin-top: 20rpx;
  320. }.bt2 {
  321. width: 244rpx;
  322. height: 78rpx;
  323. background: #ca5642;
  324. border-radius: 39rpx;
  325. text-align: center;
  326. line-height: 78rpx;
  327. color: #ffffff;
  328. }
  329. .cy_box {
  330. display: flex;
  331. margin-top: 20rpx;
  332. justify-content: space-between;
  333. }
  334. .icon_box {
  335. width: 90rpx;
  336. height: 90rpx;
  337. display: flex;
  338. justify-content: center;
  339. background-color: #fee1b9;
  340. border-radius: 10rpx;
  341. }
  342. .cy_name {
  343. color: black;
  344. font-size: 28rpx;
  345. line-height: 50rpx;
  346. }
  347. .cy_age {
  348. font-size: 24rpx;
  349. color: #858789;
  350. }
  351. .bt_box {
  352. display: flex;
  353. margin-top: 50rpx;
  354. justify-content: space-around;
  355. }
  356. .tjbm_btn {
  357. width: 100%;
  358. height: 80rpx;
  359. font-size: 30rpx;
  360. line-height: 80rpx;
  361. text-align: center;
  362. color: #ffffff;
  363. border-radius: 10rpx;
  364. background-color: #fb5a02;
  365. margin-top: 50rpx;
  366. }
  367. .ydxy{
  368. display: flex;
  369. align-items: center;
  370. margin-top: 20rpx;
  371. height: 50rpx;
  372. font-size: 24rpx;
  373. color:#03A9F4;
  374. }
  375. .radio_box{
  376. background-color: #fee1b9;
  377. padding: 20rpx;
  378. border-radius: 10rpx;
  379. }
  380. </style>