用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

355 lines
9.9 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <!-- 个人 -->
  3. <view>
  4. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="80">
  5. <view class="se-p-20">
  6. <view class="se-p-20 se-bgc-white se-br-10 se-fs-20">
  7. <u-form-item label="姓名" prop="name">
  8. <u--input v-model="form.name" class="se-bgc-f5" placeholder="请输入姓名名称"></u--input>
  9. </u-form-item>
  10. <!-- <u-form-item label="密码" prop="password">
  11. <u--input v-model="form.password" class="se-bgc-f5" placeholder="请输入您的密码"></u--input>
  12. </u-form-item> -->
  13. <u-form-item label="联系电话" prop="mobile">
  14. <u--input v-model="form.mobile" class="se-bgc-f5" placeholder="请输入联系方式"></u--input>
  15. </u-form-item>
  16. <u-form-item label="居住地址" prop="address">
  17. <u--input v-model="form.address" class="se-bgc-f5" placeholder="请输入详细地址"></u--input>
  18. </u-form-item>
  19. <u-form-item label="行业" prop="industryId" @click="handleIndChange()">
  20. <u--input readonly v-model="form.industryName" placeholder="请选择行业" border="bottom"></u--input>
  21. <u-icon slot="right" name="arrow-right"></u-icon>
  22. </u-form-item>
  23. </view>
  24. </view>
  25. <view class="se-p-20">
  26. <view class="se-px-20 se-pb-20 se-bgc-white se-br-10 se-fs-20">
  27. <u-form-item prop="file" labelWidth="2">
  28. <view class="se-flex se-flex-v-sa">
  29. <view class="se-py-20 se-w-p-100 se-flex">
  30. <view class="line-orange"></view>
  31. <view class="se-ml-10">
  32. 个人照片
  33. </view>
  34. </view>
  35. <view class="se-py-20 se-w-p-100">
  36. <u-upload :fileList="form.imageFile" @afterRead="afterImageFileRead" @delete="deleteImageFilePic" name="1"
  37. multiple :maxCount="10"></u-upload>
  38. </view>
  39. </view>
  40. </u-form-item>
  41. </view>
  42. </view>
  43. <view class="se-p-20">
  44. <view class="se-px-20 se-pb-20 se-bgc-white se-br-10 se-fs-20">
  45. <u-form-item prop="file" labelWidth="2">
  46. <view class="se-flex se-flex-v-sa">
  47. <view class="se-py-20 se-w-p-100 se-flex">
  48. <view class="line-orange"></view>
  49. <view class="se-ml-10">
  50. 身份证上传(正面)
  51. </view>
  52. </view>
  53. <view class="se-py-20 se-w-p-100">
  54. <u-upload :fileList="form.cerImageBackFile" @afterRead="afterCerImageBackFileRead" @delete="deleteCerImageBackFilePic" name="1"
  55. multiple :maxCount="10"></u-upload>
  56. </view>
  57. </view>
  58. </u-form-item>
  59. </view>
  60. </view>
  61. <view class="se-p-20">
  62. <view class="se-px-20 se-pb-20 se-bgc-white se-br-10 se-fs-20">
  63. <u-form-item prop="file" labelWidth="2">
  64. <view class="se-flex se-flex-v-sa">
  65. <view class="se-py-20 se-w-p-100 se-flex">
  66. <view class="line-orange"></view>
  67. <view class="se-ml-10">
  68. 身份证上传(反面)
  69. </view>
  70. </view>
  71. <view class="se-py-20 se-w-p-100">
  72. <u-upload :fileList="form.cerImageFrontFile" @afterRead="afterCerImageFrontRead" @delete="deleteCerImageFrontReadPic" name="1"
  73. multiple :maxCount="10"></u-upload>
  74. </view>
  75. </view>
  76. </u-form-item>
  77. </view>
  78. </view>
  79. <view class="se-px-20 se-pt-20">
  80. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  81. <view @click="submit"
  82. class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-60 se-lh-60 se-ta-c se-fs-28 se-c-white se-bgc-orange">
  83. <text>{{form.id?'保存':'提交审核'}}</text>
  84. </view>
  85. <!-- <view class="se-mx-10 se-flex-1 se-b se-br-40 se-flex-h-c se-h-60 se-lh-60 se-ta-c se-fs-28 se-c-66 se-bgc-f5">
  86. <text>联系我们</text>
  87. </view> -->
  88. </view>
  89. </view>
  90. </u--form>
  91. <u-action-sheet :actions="indList" @select="selectIndClick" title="行业" :show="show" @close="show=false"></u-action-sheet>
  92. </view>
  93. </template>
  94. <script>
  95. import {roleBoss,industryList,updateRoleBoss,queryCategoryList,addAuthenticationPerson,getAuthenticationPerson} from "@/common/api.js"
  96. export default{
  97. data(){
  98. return{
  99. show:false,
  100. indList: [],
  101. fileList: [],
  102. form: {
  103. id:'',
  104. role:0,
  105. name: '',
  106. password: '',
  107. mobile: '',
  108. address:'',
  109. industryId:'',
  110. industryName:'',
  111. cerImageBackFile:[],
  112. cerImageFrontFile:[],
  113. imageFile:[]
  114. },
  115. rules: {
  116. name: [{
  117. type: 'string',
  118. required: true,
  119. message: '请输入姓名名称',
  120. trigger: ['blur', 'change']
  121. }],
  122. password: [{
  123. type: 'string',
  124. required: true,
  125. message: '请输入您的密码',
  126. trigger: ['blur', 'change']
  127. }],
  128. mobile: [
  129. {
  130. required: true,
  131. message: '请输入手机号',
  132. trigger: ['change','blur'],
  133. },
  134. {
  135. validator: (rule, value, callback) => {
  136. return uni.$u.test.mobile(value);
  137. },
  138. message: '手机号码不正确',
  139. trigger: ['change','blur'],
  140. },
  141. ],
  142. address: [{
  143. type: 'string',
  144. required: true,
  145. message: '请输入居住地址',
  146. trigger: ['blur', 'change']
  147. }],
  148. industryId: [{
  149. type: 'string',
  150. required: true,
  151. message: '请选择行业',
  152. trigger: ['blur', 'change']
  153. }],
  154. cerImageBackFile:[
  155. {
  156. validator: (rule, value, callback) => {
  157. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  158. callback(new Error('请选择身份证'));
  159. } else {
  160. callback();
  161. }
  162. },
  163. trigger: 'blur'
  164. }
  165. ],
  166. cerImageFrontFile:[
  167. {
  168. validator: (rule, value, callback) => {
  169. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  170. callback(new Error('请选择身份证'));
  171. } else {
  172. callback();
  173. }
  174. },
  175. trigger: 'blur'
  176. }
  177. ],
  178. imageFile:[
  179. {
  180. validator: (rule, value, callback) => {
  181. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  182. callback(new Error('请选择个人照片'));
  183. } else {
  184. callback();
  185. }
  186. },
  187. trigger: 'blur'
  188. }
  189. ],
  190. },
  191. }
  192. },
  193. watch: {
  194. },
  195. onReady() {
  196. this.onAuthenticationPerson()
  197. this.onQueryCategoryList()
  198. this.$refs.uForm.setRules(this.rules)
  199. },
  200. mounted() {
  201. },
  202. methods: {
  203. onAuthenticationPerson(){
  204. let params={}
  205. getAuthenticationPerson(params).then(response=>{
  206. let person = response.result
  207. if(response.result){
  208. this.form.id = person.id
  209. this.form.name = person.name
  210. this.form.mobile = person.phone
  211. this.form.address = person.address
  212. this.form.industryId = person.industry
  213. this.form.industryName = person.industryName
  214. this.form.cerImageBackFile = this.stringToKeyValueArray(person.cerImageBack)
  215. this.form.cerImageFrontFile = this.stringToKeyValueArray(person.cerImageFront)
  216. this.form.imageFile = this.stringToKeyValueArray(person.image)
  217. }
  218. }).catch(error=>{
  219. })
  220. },
  221. onQueryCategoryList(){
  222. queryCategoryList({}).then(response=>{
  223. console.info(response)
  224. this.indList = response.result
  225. }).catch(error=>{
  226. })
  227. },
  228. stringToKeyValueArray(str, delimiter1 = ',') {
  229. if(str){
  230. let arro = str.split(delimiter1);
  231. let arr = [];
  232. arro.forEach(items=>{
  233. let obj = {};
  234. obj["url"] = items
  235. arr.push(obj)
  236. })
  237. console.info(arr)
  238. return arr
  239. }else{
  240. return []
  241. }
  242. },
  243. handleIndChange(){
  244. this.show = true
  245. },
  246. selectIndClick(event){
  247. console.info("selectIndClick",event)
  248. this.form.industryId = event.id
  249. this.form.industryName = event.name
  250. this.show = false
  251. },
  252. submit() {
  253. let that = this
  254. that.$refs.uForm.validate().then(res => {
  255. that.onRoleBoss()
  256. }).catch(errors => {
  257. console.info(errors)
  258. uni.$u.toast('校验失败')
  259. })
  260. },
  261. onRoleBoss(){
  262. let that = this
  263. let params={
  264. id:that.form.id,
  265. name:that.form.name,
  266. role:that.form.role,
  267. phone:that.form.mobile,
  268. address:that.form.address,
  269. industry:that.form.industryId,
  270. // categoryTwo:that.form.industryName,
  271. cerImageBack:that.form.cerImageBackFile.map(item => item.url).join(','),
  272. cerImageFront:that.form.cerImageFrontFile.map(item => item.url).join(','),
  273. image:that.form.imageFile.map(item => item.url).join(','),
  274. }
  275. // if(that.form.id){
  276. // updateRoleBoss(params).then(response=>{
  277. // uni.$u.toast("保存成功!")
  278. // setTimeout(()=>{
  279. // uni.navigateBack({
  280. // delta:1
  281. // })
  282. // },1500)
  283. // }).catch(error=>{
  284. // })
  285. // }else{
  286. addAuthenticationPerson(params).then(response=>{
  287. uni.$u.toast("提交成功,等待申请")
  288. setTimeout(()=>{
  289. uni.switchTab({
  290. url:"/pages/home/index"
  291. })
  292. },1500)
  293. }).catch(error=>{
  294. })
  295. // }
  296. },
  297. deleteCerImageBackFilePic(event) {
  298. this.form.cerImageBackFile.splice(e.index, 1)
  299. },
  300. async afterCerImageBackFileRead(e) {
  301. let self = this
  302. e.file.forEach(file => {
  303. self.$Oss.ossUpload(file.url).then(url => {
  304. self.form.cerImageBackFile.push({
  305. url
  306. })
  307. })
  308. })
  309. },
  310. deleteCerImageFrontReadPic(event) {
  311. this.form.cerImageFrontFile.splice(e.index, 1)
  312. },
  313. async afterCerImageFrontRead(e) {
  314. let self = this
  315. e.file.forEach(file => {
  316. self.$Oss.ossUpload(file.url).then(url => {
  317. self.form.cerImageFrontFile.push({
  318. url
  319. })
  320. })
  321. })
  322. },
  323. async afterImageFileRead(e) {
  324. let self = this
  325. e.file.forEach(file => {
  326. self.$Oss.ossUpload(file.url).then(url => {
  327. self.form.imageFile.push({
  328. url
  329. })
  330. })
  331. })
  332. },
  333. deleteImageFilePic(event) {
  334. this.form.imageFile.splice(e.index, 1)
  335. },
  336. }
  337. }
  338. </script>
  339. <style lang="scss" scoped>
  340. .line-orange {
  341. width: 8rpx;
  342. height: 32rpx;
  343. background: #ff7a31;
  344. border-radius: 4rpx;
  345. }
  346. </style>