add-resource.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <view class="add-resource">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <view class="back-btn" @click="goBack">
  6. <text class="back-icon">‹</text>
  7. </view>
  8. <text class="header-title">信息录入</text>
  9. <view class="header-right">
  10. <text class="more-icon">⋯</text>
  11. <text class="info-icon">ⓘ</text>
  12. </view>
  13. </view>
  14. <scroll-view scroll-y class="content">
  15. <!-- 社会属性 -->
  16. <view class="section">
  17. <view class="section-title">
  18. <text class="section-label">社会属性</text>
  19. </view>
  20. <!-- 婚况 -->
  21. <view class="form-group">
  22. <text class="label">婚况</text>
  23. <view class="select-wrapper">
  24. <picker @change="onMarriageChange" :value="formData.marriageIndex" :range="marriageOptions">
  25. <view class="select-input">
  26. <text>{{ formData.marriage || '请选择婚况' }}</text>
  27. <text class="arrow">▼</text>
  28. </view>
  29. </picker>
  30. </view>
  31. </view>
  32. <!-- 学历 -->
  33. <view class="form-group">
  34. <text class="label">学历</text>
  35. <view class="select-wrapper">
  36. <picker @change="onEducationChange" :value="formData.educationIndex" :range="educationOptions">
  37. <view class="select-input">
  38. <text>{{ formData.education || '请选择学历' }}</text>
  39. <text class="arrow">▼</text>
  40. </view>
  41. </picker>
  42. </view>
  43. </view>
  44. <!-- 年收入 -->
  45. <view class="form-group">
  46. <text class="label">年收入(万元)</text>
  47. <input type="text" class="text-input" placeholder="请输入年收入" v-model="formData.income" />
  48. </view>
  49. <!-- 住址 -->
  50. <view class="form-group">
  51. <text class="label">住址</text>
  52. <input type="text" class="text-input" placeholder="请输入住址" v-model="formData.address" />
  53. </view>
  54. <!-- 户籍地 -->
  55. <view class="form-group">
  56. <text class="label">户籍地</text>
  57. <input type="text" class="text-input" placeholder="请输入户籍地" v-model="formData.hometown" />
  58. </view>
  59. <!-- 职业 -->
  60. <view class="form-group">
  61. <text class="label">职业</text>
  62. <input type="text" class="text-input" placeholder="请输入职业" v-model="formData.occupation" />
  63. </view>
  64. <!-- 购房 -->
  65. <view class="form-group">
  66. <text class="label">购房</text>
  67. <view class="checkbox-group">
  68. <view class="checkbox-item" @click="toggleCheckbox('hasHouse')">
  69. <view class="checkbox" :class="{ checked: formData.hasHouse }"></view>
  70. <text>有房</text>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 购车 -->
  75. <view class="form-group">
  76. <text class="label">购车</text>
  77. <view class="checkbox-group">
  78. <view class="checkbox-item" @click="toggleCheckbox('hasCar')">
  79. <view class="checkbox" :class="{ checked: formData.hasCar }"></view>
  80. <text>有车</text>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <!-- 基本信息 -->
  86. <view class="section">
  87. <view class="section-title">
  88. <text class="section-label">基本信息</text>
  89. </view>
  90. <!-- 姓名 -->
  91. <view class="form-group">
  92. <text class="label required">姓名</text>
  93. <input type="text" class="text-input" placeholder="请输入姓名" v-model="formData.name" />
  94. </view>
  95. <!-- 年龄 -->
  96. <view class="form-group">
  97. <text class="label">年龄</text>
  98. <input type="number" class="text-input" placeholder="请输入年龄" v-model="formData.age" />
  99. </view>
  100. <!-- 性别 -->
  101. <view class="form-group">
  102. <text class="label">性别</text>
  103. <view class="select-wrapper">
  104. <picker @change="onGenderChange" :value="formData.genderIndex" :range="genderOptions">
  105. <view class="select-input">
  106. <text>{{ formData.gender || '请选择性别' }}</text>
  107. <text class="arrow">▼</text>
  108. </view>
  109. </picker>
  110. </view>
  111. </view>
  112. <!-- 星座 -->
  113. <view class="form-group">
  114. <text class="label">星座</text>
  115. <view class="select-wrapper">
  116. <picker @change="onZodiacChange" :value="formData.zodiacIndex" :range="zodiacOptions">
  117. <view class="select-input">
  118. <text>{{ formData.zodiac || '请选择星座' }}</text>
  119. <text class="arrow">▼</text>
  120. </view>
  121. </picker>
  122. </view>
  123. </view>
  124. <!-- 身高 -->
  125. <view class="form-group">
  126. <text class="label">身高 (cm)</text>
  127. <input type="number" class="text-input" placeholder="请输入身高" v-model="formData.height" />
  128. </view>
  129. <!-- 体重 -->
  130. <view class="form-group">
  131. <text class="label">体重 (kg)</text>
  132. <input type="number" class="text-input" placeholder="请输入体重" v-model="formData.weight" />
  133. </view>
  134. </view>
  135. <!-- 底部按钮 -->
  136. <view class="button-group">
  137. <view class="reset-btn" @click="resetForm">重置</view>
  138. <view class="submit-btn" @click="submitForm">提交</view>
  139. </view>
  140. </scroll-view>
  141. </view>
  142. </template>
  143. <script>
  144. export default {
  145. data() {
  146. return {
  147. formData: {
  148. // 社会属性
  149. marriage: '',
  150. marriageIndex: 0,
  151. education: '',
  152. educationIndex: 0,
  153. income: '',
  154. address: '',
  155. hometown: '',
  156. occupation: '',
  157. hasHouse: false,
  158. hasCar: false,
  159. // 基本信息
  160. name: '',
  161. age: '',
  162. gender: '',
  163. genderIndex: 0,
  164. zodiac: '',
  165. zodiacIndex: 0,
  166. height: '',
  167. weight: ''
  168. },
  169. marriageOptions: ['未婚', '已婚', '离异', '丧偶'],
  170. educationOptions: ['初中', '高中', '大专', '本科', '硕士', '博士'],
  171. genderOptions: ['男', '女'],
  172. zodiacOptions: ['白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座', '水瓶座', '双鱼座']
  173. }
  174. },
  175. methods: {
  176. goBack() {
  177. uni.navigateBack()
  178. },
  179. onMarriageChange(e) {
  180. this.formData.marriageIndex = e.detail.value
  181. this.formData.marriage = this.marriageOptions[e.detail.value]
  182. },
  183. onEducationChange(e) {
  184. this.formData.educationIndex = e.detail.value
  185. this.formData.education = this.educationOptions[e.detail.value]
  186. },
  187. onGenderChange(e) {
  188. this.formData.genderIndex = e.detail.value
  189. this.formData.gender = this.genderOptions[e.detail.value]
  190. },
  191. onZodiacChange(e) {
  192. this.formData.zodiacIndex = e.detail.value
  193. this.formData.zodiac = this.zodiacOptions[e.detail.value]
  194. },
  195. toggleCheckbox(field) {
  196. this.formData[field] = !this.formData[field]
  197. },
  198. resetForm() {
  199. this.formData = {
  200. marriage: '',
  201. marriageIndex: 0,
  202. education: '',
  203. educationIndex: 0,
  204. income: '',
  205. address: '',
  206. hometown: '',
  207. occupation: '',
  208. hasHouse: false,
  209. hasCar: false,
  210. name: '',
  211. age: '',
  212. gender: '',
  213. genderIndex: 0,
  214. zodiac: '',
  215. zodiacIndex: 0,
  216. height: '',
  217. weight: ''
  218. }
  219. },
  220. submitForm() {
  221. if (!this.formData.name) {
  222. uni.showToast({
  223. title: '请输入姓名',
  224. icon: 'none'
  225. })
  226. return
  227. }
  228. console.log('提交表单:', this.formData)
  229. uni.showToast({
  230. title: '提交成功',
  231. icon: 'success'
  232. })
  233. setTimeout(() => {
  234. uni.navigateBack()
  235. }, 1500)
  236. }
  237. }
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. .add-resource {
  242. min-height: 100vh;
  243. background: #FFF9F9;
  244. display: flex;
  245. flex-direction: column;
  246. }
  247. /* 顶部导航栏 */
  248. .header {
  249. display: flex;
  250. align-items: center;
  251. justify-content: space-between;
  252. padding: 20rpx 30rpx;
  253. padding-top: calc(20rpx + env(safe-area-inset-top));
  254. background: #FFF9F9;
  255. border-bottom: 1rpx solid #F0F0F0;
  256. .back-btn {
  257. width: 50rpx;
  258. height: 50rpx;
  259. display: flex;
  260. align-items: center;
  261. justify-content: center;
  262. .back-icon {
  263. font-size: 40rpx;
  264. color: #9C27B0;
  265. }
  266. }
  267. .header-title {
  268. font-size: 32rpx;
  269. font-weight: bold;
  270. color: #333;
  271. flex: 1;
  272. text-align: center;
  273. }
  274. .header-right {
  275. display: flex;
  276. align-items: center;
  277. gap: 15rpx;
  278. .more-icon,
  279. .info-icon {
  280. font-size: 28rpx;
  281. color: #999;
  282. }
  283. }
  284. }
  285. .content {
  286. flex: 1;
  287. overflow-y: auto;
  288. padding: 20rpx;
  289. }
  290. /* 表单区域 */
  291. .section {
  292. background: #FFFFFF;
  293. border-radius: 16rpx;
  294. padding: 20rpx;
  295. margin-bottom: 20rpx;
  296. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  297. .section-title {
  298. margin-bottom: 20rpx;
  299. .section-label {
  300. display: inline-block;
  301. background: #FFEBEE;
  302. color: #E91E63;
  303. font-size: 24rpx;
  304. font-weight: bold;
  305. padding: 6rpx 14rpx;
  306. border-radius: 8rpx;
  307. border: 2rpx solid #E91E63;
  308. }
  309. }
  310. }
  311. /* 表单组 */
  312. .form-group {
  313. margin-bottom: 20rpx;
  314. &:last-child {
  315. margin-bottom: 0;
  316. }
  317. .label {
  318. display: block;
  319. font-size: 26rpx;
  320. color: #666;
  321. margin-bottom: 10rpx;
  322. &.required::after {
  323. content: ' *';
  324. color: #E91E63;
  325. }
  326. }
  327. .text-input {
  328. width: 100%;
  329. padding: 12rpx 16rpx;
  330. border: 1rpx solid #E0E0E0;
  331. border-radius: 8rpx;
  332. font-size: 26rpx;
  333. color: #333;
  334. background: #F8F8F8;
  335. &::placeholder {
  336. color: #999;
  337. }
  338. }
  339. .select-wrapper {
  340. .select-input {
  341. display: flex;
  342. align-items: center;
  343. justify-content: space-between;
  344. padding: 12rpx 16rpx;
  345. border: 1rpx solid #E0E0E0;
  346. border-radius: 8rpx;
  347. font-size: 26rpx;
  348. color: #333;
  349. background: #F8F8F8;
  350. .arrow {
  351. font-size: 20rpx;
  352. color: #999;
  353. }
  354. }
  355. }
  356. .checkbox-group {
  357. display: flex;
  358. flex-wrap: wrap;
  359. gap: 15rpx;
  360. .checkbox-item {
  361. display: flex;
  362. align-items: center;
  363. gap: 8rpx;
  364. .checkbox {
  365. width: 24rpx;
  366. height: 24rpx;
  367. border: 2rpx solid #E0E0E0;
  368. border-radius: 4rpx;
  369. background: #FFFFFF;
  370. &.checked {
  371. background: #E91E63;
  372. border-color: #E91E63;
  373. }
  374. }
  375. text {
  376. font-size: 26rpx;
  377. color: #333;
  378. }
  379. }
  380. }
  381. }
  382. /* 按钮组 */
  383. .button-group {
  384. display: flex;
  385. gap: 15rpx;
  386. margin: 30rpx 0;
  387. .reset-btn,
  388. .submit-btn {
  389. flex: 1;
  390. padding: 16rpx;
  391. border-radius: 12rpx;
  392. font-size: 28rpx;
  393. font-weight: bold;
  394. text-align: center;
  395. }
  396. .reset-btn {
  397. background: #F5F5F5;
  398. color: #666;
  399. border: 1rpx solid #E0E0E0;
  400. }
  401. .submit-btn {
  402. background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
  403. color: #FFFFFF;
  404. }
  405. }
  406. </style>