用工小程序前端代码
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.

309 lines
8.5 KiB

3 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
3 months ago
3 months ago
3 months ago
4 months ago
3 months ago
4 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.cerImageBackFile" @afterRead="afterCerImageBackFileRead" @delete="deleteCerImageBackFilePic" 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.cerImageFrontFile" @afterRead="afterCerImageFrontRead" @delete="deleteCerImageFrontReadPic" name="1"
  55. multiple :maxCount="10"></u-upload>
  56. </view>
  57. </view>
  58. </u-form-item>
  59. </view>
  60. </view>
  61. <view class="se-px-20 se-pt-20">
  62. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  63. <view @click="submit"
  64. 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">
  65. <text>{{form.id?'保存':'提交审核'}}</text>
  66. </view>
  67. <!-- <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">
  68. <text>联系我们</text>
  69. </view> -->
  70. </view>
  71. </view>
  72. </u--form>
  73. <u-action-sheet :actions="indList" @select="selectIndClick" title="行业" :show="show" @close="show=false"></u-action-sheet>
  74. </view>
  75. </template>
  76. <script>
  77. import {roleBoss,industryList,updateRoleBoss,queryCategoryList,addAuthenticationPerson,getAuthenticationPerson} from "@/common/api.js"
  78. export default{
  79. data(){
  80. return{
  81. show:false,
  82. indList: [],
  83. fileList: [],
  84. form: {
  85. id:'',
  86. role:0,
  87. name: '',
  88. password: '',
  89. mobile: '',
  90. address:'',
  91. industryId:'',
  92. industryName:'',
  93. cerImageBackFile:[],
  94. cerImageFrontFile:[]
  95. },
  96. rules: {
  97. name: [{
  98. type: 'string',
  99. required: true,
  100. message: '请输入姓名名称',
  101. trigger: ['blur', 'change']
  102. }],
  103. password: [{
  104. type: 'string',
  105. required: true,
  106. message: '请输入您的密码',
  107. trigger: ['blur', 'change']
  108. }],
  109. mobile: [
  110. {
  111. required: true,
  112. message: '请输入手机号',
  113. trigger: ['change','blur'],
  114. },
  115. {
  116. validator: (rule, value, callback) => {
  117. return uni.$u.test.mobile(value);
  118. },
  119. message: '手机号码不正确',
  120. trigger: ['change','blur'],
  121. },
  122. ],
  123. address: [{
  124. type: 'string',
  125. required: true,
  126. message: '请输入居住地址',
  127. trigger: ['blur', 'change']
  128. }],
  129. industryId: [{
  130. type: 'string',
  131. required: true,
  132. message: '请选择行业',
  133. trigger: ['blur', 'change']
  134. }],
  135. cerImageBackFile:[
  136. {
  137. validator: (rule, value, callback) => {
  138. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  139. callback(new Error('请选择身份证'));
  140. } else {
  141. callback();
  142. }
  143. },
  144. trigger: 'blur'
  145. }
  146. ],
  147. cerImageFrontFile:[
  148. {
  149. validator: (rule, value, callback) => {
  150. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  151. callback(new Error('请选择身份证'));
  152. } else {
  153. callback();
  154. }
  155. },
  156. trigger: 'blur'
  157. }
  158. ]
  159. },
  160. }
  161. },
  162. watch: {
  163. },
  164. onReady() {
  165. this.onAuthenticationPerson()
  166. this.onQueryCategoryList()
  167. this.$refs.uForm.setRules(this.rules)
  168. },
  169. mounted() {
  170. },
  171. methods: {
  172. onAuthenticationPerson(){
  173. let params={}
  174. getAuthenticationPerson(params).then(response=>{
  175. let person = response.result
  176. if(response.result){
  177. this.form.id = person.id
  178. this.form.name = person.name
  179. this.form.mobile = person.phone
  180. this.form.address = person.address
  181. this.form.industryId = person.industry
  182. this.form.industryName = person.industryName
  183. this.form.cerImageBackFile = this.stringToKeyValueArray(person.cerImageBack)
  184. this.form.cerImageFrontFile = this.stringToKeyValueArray(person.cerImageFront)
  185. }
  186. }).catch(error=>{
  187. })
  188. },
  189. onQueryCategoryList(){
  190. queryCategoryList({}).then(response=>{
  191. console.info(response)
  192. this.indList = response.result
  193. }).catch(error=>{
  194. })
  195. },
  196. stringToKeyValueArray(str, delimiter1 = ',') {
  197. if(str){
  198. let arro = str.split(delimiter1);
  199. let arr = [];
  200. arro.forEach(items=>{
  201. let obj = {};
  202. obj["url"] = items
  203. arr.push(obj)
  204. })
  205. console.info(arr)
  206. return arr
  207. }else{
  208. return []
  209. }
  210. },
  211. handleIndChange(){
  212. this.show = true
  213. },
  214. selectIndClick(event){
  215. console.info("selectIndClick",event)
  216. this.form.industryId = event.id
  217. this.form.industryName = event.name
  218. this.show = false
  219. },
  220. submit() {
  221. let that = this
  222. that.$refs.uForm.validate().then(res => {
  223. that.onRoleBoss()
  224. }).catch(errors => {
  225. console.info(errors)
  226. uni.$u.toast('校验失败')
  227. })
  228. },
  229. onRoleBoss(){
  230. let that = this
  231. let params={
  232. id:that.form.id,
  233. name:that.form.name,
  234. role:that.form.role,
  235. phone:that.form.mobile,
  236. address:that.form.address,
  237. categoryOne:that.form.industryId,
  238. categoryTwo:that.form.industryName,
  239. cerImageBack:that.form.cerImageBackFile.map(item => item.url).join(','),
  240. cerImageFront:that.form.cerImageFrontFile.map(item => item.url).join(','),
  241. }
  242. // if(that.form.id){
  243. // updateRoleBoss(params).then(response=>{
  244. // uni.$u.toast("保存成功!")
  245. // setTimeout(()=>{
  246. // uni.navigateBack({
  247. // delta:1
  248. // })
  249. // },1500)
  250. // }).catch(error=>{
  251. // })
  252. // }else{
  253. addAuthenticationPerson(params).then(response=>{
  254. uni.$u.toast("提交成功,等待申请")
  255. setTimeout(()=>{
  256. uni.switchTab({
  257. url:"/pages/home/index"
  258. })
  259. },1500)
  260. }).catch(error=>{
  261. })
  262. // }
  263. },
  264. deleteCerImageBackFilePic(event) {
  265. this.form.cerImageBackFile.splice(e.index, 1)
  266. },
  267. async afterCerImageBackFileRead(e) {
  268. let self = this
  269. e.file.forEach(file => {
  270. self.$Oss.ossUpload(file.url).then(url => {
  271. self.form.cerImageBackFile.push({
  272. url
  273. })
  274. })
  275. })
  276. },
  277. deleteCerImageFrontReadPic(event) {
  278. this.form.cerImageFrontFile.splice(e.index, 1)
  279. },
  280. async afterCerImageFrontRead(e) {
  281. let self = this
  282. e.file.forEach(file => {
  283. self.$Oss.ossUpload(file.url).then(url => {
  284. self.form.cerImageFrontFile.push({
  285. url
  286. })
  287. })
  288. })
  289. }
  290. }
  291. }
  292. </script>
  293. <style lang="scss" scoped>
  294. .line-orange {
  295. width: 8rpx;
  296. height: 32rpx;
  297. background: #ff7a31;
  298. border-radius: 4rpx;
  299. }
  300. </style>