add-resource.vue 9.8 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. uni.showToast({
  229. title: '提交成功',
  230. icon: 'success'
  231. })
  232. setTimeout(() => {
  233. uni.navigateBack()
  234. }, 1500)
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="scss" scoped>
  240. .add-resource {
  241. min-height: 100vh;
  242. background: #FFF9F9;
  243. display: flex;
  244. flex-direction: column;
  245. }
  246. /* 顶部导航栏 */
  247. .header {
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. padding: 20rpx 30rpx;
  252. padding-top: calc(20rpx + env(safe-area-inset-top));
  253. background: #FFF9F9;
  254. border-bottom: 1rpx solid #F0F0F0;
  255. .back-btn {
  256. width: 50rpx;
  257. height: 50rpx;
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. .back-icon {
  262. font-size: 40rpx;
  263. color: #9C27B0;
  264. }
  265. }
  266. .header-title {
  267. font-size: 32rpx;
  268. font-weight: bold;
  269. color: #333;
  270. flex: 1;
  271. text-align: center;
  272. }
  273. .header-right {
  274. display: flex;
  275. align-items: center;
  276. gap: 15rpx;
  277. .more-icon,
  278. .info-icon {
  279. font-size: 28rpx;
  280. color: #999;
  281. }
  282. }
  283. }
  284. .content {
  285. flex: 1;
  286. overflow-y: auto;
  287. padding: 20rpx;
  288. }
  289. /* 表单区域 */
  290. .section {
  291. background: #FFFFFF;
  292. border-radius: 16rpx;
  293. padding: 20rpx;
  294. margin-bottom: 20rpx;
  295. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  296. .section-title {
  297. margin-bottom: 20rpx;
  298. .section-label {
  299. display: inline-block;
  300. background: #FFEBEE;
  301. color: #E91E63;
  302. font-size: 24rpx;
  303. font-weight: bold;
  304. padding: 6rpx 14rpx;
  305. border-radius: 8rpx;
  306. border: 2rpx solid #E91E63;
  307. }
  308. }
  309. }
  310. /* 表单组 */
  311. .form-group {
  312. margin-bottom: 20rpx;
  313. &:last-child {
  314. margin-bottom: 0;
  315. }
  316. .label {
  317. display: block;
  318. font-size: 26rpx;
  319. color: #666;
  320. margin-bottom: 10rpx;
  321. &.required::after {
  322. content: ' *';
  323. color: #E91E63;
  324. }
  325. }
  326. .text-input {
  327. width: 100%;
  328. padding: 12rpx 16rpx;
  329. border: 1rpx solid #E0E0E0;
  330. border-radius: 8rpx;
  331. font-size: 26rpx;
  332. color: #333;
  333. background: #F8F8F8;
  334. &::placeholder {
  335. color: #999;
  336. }
  337. }
  338. .select-wrapper {
  339. .select-input {
  340. display: flex;
  341. align-items: center;
  342. justify-content: space-between;
  343. padding: 12rpx 16rpx;
  344. border: 1rpx solid #E0E0E0;
  345. border-radius: 8rpx;
  346. font-size: 26rpx;
  347. color: #333;
  348. background: #F8F8F8;
  349. .arrow {
  350. font-size: 20rpx;
  351. color: #999;
  352. }
  353. }
  354. }
  355. .checkbox-group {
  356. display: flex;
  357. flex-wrap: wrap;
  358. gap: 15rpx;
  359. .checkbox-item {
  360. display: flex;
  361. align-items: center;
  362. gap: 8rpx;
  363. .checkbox {
  364. width: 24rpx;
  365. height: 24rpx;
  366. border: 2rpx solid #E0E0E0;
  367. border-radius: 4rpx;
  368. background: #FFFFFF;
  369. &.checked {
  370. background: #E91E63;
  371. border-color: #E91E63;
  372. }
  373. }
  374. text {
  375. font-size: 26rpx;
  376. color: #333;
  377. }
  378. }
  379. }
  380. }
  381. /* 按钮组 */
  382. .button-group {
  383. display: flex;
  384. gap: 15rpx;
  385. margin: 30rpx 0;
  386. .reset-btn,
  387. .submit-btn {
  388. flex: 1;
  389. padding: 16rpx;
  390. border-radius: 12rpx;
  391. font-size: 28rpx;
  392. font-weight: bold;
  393. text-align: center;
  394. }
  395. .reset-btn {
  396. background: #F5F5F5;
  397. color: #666;
  398. border: 1rpx solid #E0E0E0;
  399. }
  400. .submit-btn {
  401. background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
  402. color: #FFFFFF;
  403. }
  404. }
  405. </style>