apply.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <view class="page-container">
  3. <u-navbar title="提交资料" :autoBack="true" placeholder border></u-navbar>
  4. <view class="form-content">
  5. <u--form ref="uForm"
  6. labelWidth="auto" labelPosition="top"
  7. :labelStyle="{ color: '#333', fontWeight: 500, marginBottom: '10rpx' }"
  8. :model="form" :rules="rules"
  9. >
  10. <view class="section-title">基本信息</view>
  11. <view class="card-box">
  12. <u-form-item label="真实姓名" prop="cName">
  13. <u-input v-model="form.cName" placeholder="请输入真实姓名" border="none" class="custom-input"></u-input>
  14. </u-form-item>
  15. <u-form-item label="性别" prop="nSex">
  16. <u-radio-group v-model="form.nSex" activeColor="#00cba3">
  17. <u-radio label="男" :name="1" customStyle="margin-right: 30px"></u-radio>
  18. <u-radio label="女" :name="0"></u-radio>
  19. </u-radio-group>
  20. </u-form-item>
  21. <u-form-item label="手机号" prop="cPhone">
  22. <u-input v-model="form.cPhone" placeholder="请输入手机号" border="none" class="custom-input"></u-input>
  23. </u-form-item>
  24. <u-form-item label="入驻城市" prop="city" @click="show = true">
  25. <u-input v-model="form.city" readonly placeholder="请选择城市" border="none"
  26. class="custom-input"></u-input>
  27. </u-form-item>
  28. <u-form-item label="近期生活照" prop="cImgList">
  29. <Upload
  30. @fileList="onUpload($event, 'cImgList')"
  31. />
  32. </u-form-item>
  33. </view>
  34. <view class="section-title">详细信息</view>
  35. <view class="card-box">
  36. <u-form-item label="昵称" prop="cNickName">
  37. <u-input v-model="form.cNickName" placeholder="请输入昵称" border="none"
  38. class="custom-input"></u-input>
  39. </u-form-item>
  40. <u-form-item label="头像" prop="cPortrait">
  41. <Upload
  42. :maxCount="1"
  43. @fileList="onUpload($event, 'cPortrait')"
  44. />
  45. </u-form-item>
  46. <u-form-item label="所在位置" prop="address" @click="onSelAddr">
  47. <u-input v-model="address" readonly placeholder="请选择工作所在位置" border="none" class="custom-input"></u-input>
  48. </u-form-item>
  49. <u-form-item label="个人简介" prop="cJianjie">
  50. <u--textarea v-model="form.cJianjie" placeholder="请输入个人简介" border="none"
  51. class="custom-input"></u--textarea>
  52. </u-form-item>
  53. </view>
  54. <view class="section-title">上传身份证正反面 <text class="sub-tip">*最多3张</text></view>
  55. <view class="card-box">
  56. <Upload
  57. :maxCount="3"
  58. @fileList="onUpload($event, 'cSfzImg')"
  59. />
  60. <template v-if="0">
  61. <view class="id-upload-row">
  62. <Upload
  63. name="idCardFront"
  64. width="auto"
  65. height="220rpx"
  66. :maxCount="1"
  67. @fileList="onUpload($event, 'idCardFront')"
  68. >
  69. <view class="upload-block" slot="content">
  70. <view class="icon-bg"><u-icon name="camera-fill" color="#fff" size="20"></u-icon></view>
  71. <text class="up-text">身份证人像面</text>
  72. </view>
  73. </Upload>
  74. <Upload
  75. name="idCardBack"
  76. width="auto"
  77. height="220rpx"
  78. :maxCount="1"
  79. @fileList="onUpload($event, 'idCardBack')"
  80. >
  81. <view class="upload-block" slot="content">
  82. <view class="icon-bg"><u-icon name="camera-fill" color="#fff" size="20"></u-icon></view>
  83. <text class="up-text">身份证国徽面</text>
  84. </view>
  85. </Upload>
  86. </view>
  87. <Upload
  88. name="idCardHand"
  89. width="auto"
  90. height="220rpx"
  91. :maxCount="1"
  92. @fileList="onUpload($event, 'idCardHand')"
  93. >
  94. <view class="upload-block full-width" slot="content">
  95. <view class="icon-bg"><u-icon name="camera-fill" color="#fff" size="20"></u-icon></view>
  96. <text class="up-text">手持身份证照片</text>
  97. </view>
  98. </Upload>
  99. </template>
  100. <!-- 隐藏的表单项,用于校验图片 -->
  101. <u-form-item prop="cSfzImg" style="display: none;"></u-form-item>
  102. </view>
  103. <view class="section-title">
  104. 上传资格证书
  105. </view>
  106. <view class="card-box">
  107. <Upload
  108. :maxCount="1"
  109. @fileList="onUpload($event, 'certification')"
  110. />
  111. <!-- 隐藏的表单项,用于校验图片 -->
  112. <u-form-item prop="certification" style="display: none;"></u-form-item>
  113. </view>
  114. <view class="section-title">上传营业执照</view>
  115. <view class="card-box">
  116. <Upload
  117. :maxCount="1"
  118. @fileList="onUpload($event, 'businessLicense')"
  119. />
  120. <!-- 隐藏的表单项,用于校验图片 -->
  121. <u-form-item prop="businessLicense" style="display: none;"></u-form-item>
  122. </view>
  123. <view class="section-title">上传无犯罪证明</view>
  124. <view class="card-box">
  125. <Upload
  126. :maxCount="1"
  127. @fileList="onUpload($event, 'noCrime')"
  128. />
  129. <!-- 隐藏的表单项,用于校验图片 -->
  130. <u-form-item prop="noCrime" style="display: none;"></u-form-item>
  131. </view>
  132. <view class="section-title">上传承诺书信息</view>
  133. <view class="card-box">
  134. <u-form-item label="承诺书" prop="commitment">
  135. <Upload
  136. accept="file"
  137. :maxSize="10240"
  138. :maxCount="2"
  139. @fileList="onUpload($event, 'commitment')"
  140. />
  141. </u-form-item>
  142. <u-form-item label="承诺录音" prop="recording">
  143. <Upload
  144. accept="file"
  145. :maxSize="10240"
  146. :maxCount="2"
  147. @fileList="onUpload($event, 'recording')"
  148. />
  149. </u-form-item>
  150. <u-form-item label="承诺录像" prop="videoRecording">
  151. <Upload
  152. accept="file"
  153. :maxSize="51200"
  154. :maxCount="2"
  155. @fileList="onUpload($event, 'videoRecording')"
  156. />
  157. </u-form-item>
  158. </view>
  159. </u--form>
  160. <view class="footer-bar">
  161. <u-button text="提交" color="#1BD6CD" shape="circle"
  162. customStyle=""
  163. @click="onSubmit"
  164. ></u-button>
  165. </view>
  166. </view>
  167. <!-- 城市选择 -->
  168. <u-picker :show="show" :columns="[cityList]" keyName="label"
  169. @cancel="show = false" @confirm="onSelect"
  170. ></u-picker>
  171. </view>
  172. </template>
  173. <script>
  174. import {
  175. getCityList,
  176. getProjectList,
  177. getMerchantData,
  178. } from '@/api/index';
  179. import Upload from '@/components/upload/index.vue';
  180. export default {
  181. components: {
  182. Upload
  183. },
  184. data() {
  185. return {
  186. form: {
  187. cName: '',
  188. nSex: 0,
  189. },
  190. rules: {
  191. city: [
  192. {
  193. required: true,
  194. message: '请选择城市',
  195. trigger: ['blur', 'change']
  196. }
  197. ],
  198. cName: [
  199. {
  200. required: true,
  201. message: '请输入您的姓名',
  202. trigger: ['blur', 'change']
  203. }
  204. ],
  205. cNickName: [
  206. {
  207. required: true,
  208. message: '请输入您的昵称',
  209. trigger: ['blur', 'change']
  210. }
  211. ],
  212. cPhone: [
  213. {
  214. required: true,
  215. message: '请输入手机号',
  216. trigger: ['blur', 'change']
  217. },
  218. {
  219. pattern: /^1([3589]\d|4[01456879]|6[0-9]|7[0-8])\d{8}$/,
  220. message: '请输入正确的手机号格式',
  221. trigger: ['blur', 'change']
  222. }
  223. ],
  224. address: [
  225. {
  226. required: true,
  227. message: '请选择位置',
  228. trigger: ['blur', 'change']
  229. }
  230. ],
  231. cJianjie: [
  232. {
  233. required: true,
  234. message: '请填写您的简介',
  235. trigger: ['blur', 'change']
  236. }
  237. ],
  238. cSfzImg: [{ required: true, message: '请上传身份证', trigger: ['change'] }],
  239. cImgList: [{ required: true, message: '最少上传一张生活照片', trigger: ['change'] }],
  240. cPortrait: [{ required: true, message: '请上传头像', trigger: ['change'] }],
  241. // 针对隐藏表单项的校验规则
  242. // idCardBack: [{ required: true, message: '请上传身份证国徽面', trigger: ['change'] }],
  243. },
  244. query: {},
  245. // 城市选择
  246. show: false,
  247. cityList: [],
  248. };
  249. },
  250. computed: {
  251. address() {
  252. return (this.form.address || '') + (this.form.name || '');
  253. }
  254. },
  255. onLoad(query) {
  256. this.query = query;
  257. if (query.id) this.getData();
  258. this.getCity();
  259. },
  260. onReady() {
  261. // 页面加载完成后为表单设置规则
  262. this.$refs.uForm.setRules(this.rules);
  263. },
  264. methods: {
  265. getData() {
  266. let params = {
  267. cOpenId: uni.getStorageSync('wx_copenid')
  268. }
  269. getMerchantData(params).then(res => {
  270. let data = res.data.data;
  271. this.form = data;
  272. });
  273. },
  274. getCity() {
  275. getCityList().then(res => {
  276. this.cityList = res.data.data.map(({
  277. deptId,
  278. deptName
  279. }) => ({
  280. value: deptId,
  281. label: deptName
  282. }))
  283. });
  284. },
  285. onSelAddr() {
  286. uni.chooseLocation({
  287. success: res => {
  288. this.form.name = res.name;
  289. this.form.address = res.address || res.name;
  290. this.form.latitude = res.latitude;
  291. this.form.longitude = res.longitude;
  292. }
  293. });
  294. },
  295. onSelect(e) {
  296. this.form = {
  297. ...this.form,
  298. city: e.value[0].label,
  299. deptId: e.value[0].value,
  300. }
  301. this.show = false;
  302. },
  303. // upload事件
  304. onUpload(e, t) {
  305. this.form[t] = e.map(item => item.url);
  306. },
  307. onSubmit() {
  308. this.$refs.uForm.validate().then(res => {
  309. let api = netStaffAdd;
  310. if (this.query.id) api = netStaffUpdate;
  311. api().then(ares => {
  312. uni.$u.toast(ares.data.msg);
  313. if (ares.data.code == 200) {
  314. setTimeout(() => {
  315. uni.navigateBack();
  316. }, 1000);
  317. }
  318. });
  319. }).catch(errors => {
  320. console.log(errors)
  321. let f = errors.some(item => ['cSfzImg', 'certification', 'businessLicense', 'noCrime'].indexOf(item.field) !== -1);
  322. if (f) uni.$u.toast(errors[0].message);
  323. })
  324. }
  325. }
  326. };
  327. </script>
  328. <style lang="scss" scoped>
  329. .page-container {
  330. min-height: 100vh;
  331. padding-bottom: 130rpx;
  332. background-color: #f8f8f8;
  333. .form-content {
  334. padding: 24rpx;
  335. .section-title {
  336. font-size: 30rpx;
  337. font-weight: bold;
  338. margin: 30rpx 0 20rpx;
  339. display: flex;
  340. align-items: center;
  341. position: relative;
  342. padding-left: 20rpx;
  343. &::before {
  344. content: '';
  345. position: absolute;
  346. left: 0;
  347. top: 6rpx;
  348. bottom: 6rpx;
  349. width: 6rpx;
  350. background-color: #00cba3;
  351. border-radius: 4rpx;
  352. }
  353. .sub-tip {
  354. font-size: 24rpx;
  355. color: #ff5e5e;
  356. font-weight: normal;
  357. margin-left: 10rpx;
  358. }
  359. }
  360. .card-box {
  361. background: #fff;
  362. border-radius: 16rpx;
  363. padding: 20rpx;
  364. margin-bottom: 20rpx;
  365. }
  366. .custom-input {
  367. background-color: #f5f6f8;
  368. border-radius: 8rpx;
  369. padding: 6rpx 20rpx !important;
  370. }
  371. }
  372. }
  373. /* 身份证上传样式 */
  374. .id-upload-row {
  375. gap: 10rpx;
  376. display: flex;
  377. justify-content: space-between;
  378. margin-bottom: 20rpx;
  379. }
  380. .upload-block {
  381. // width: 100%;
  382. height: 220rpx;
  383. background-color: #f9f9f9;
  384. border-radius: 12rpx;
  385. border: 1rpx dashed #eee;
  386. display: flex;
  387. align-items: center;
  388. flex-direction: column;
  389. justify-content: center;
  390. position: relative;
  391. overflow: hidden;
  392. &.full-width {
  393. width: 100%;
  394. height: 240rpx;
  395. }
  396. .icon-bg {
  397. width: 60rpx;
  398. height: 60rpx;
  399. background-color: #00cba3;
  400. border-radius: 50%;
  401. display: flex;
  402. align-items: center;
  403. justify-content: center;
  404. margin-bottom: 16rpx;
  405. }
  406. .up-text {
  407. font-size: 24rpx;
  408. color: #666;
  409. }
  410. }
  411. </style>