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

223 lines
6.0 KiB

  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.idCardFile" @afterRead="afterRead" @delete="deletePic" name="1"
  37. multiple :maxCount="10"></u-upload>
  38. </view>
  39. </view>
  40. </u-form-item>
  41. </view>
  42. </view>
  43. <view class="se-px-20 se-pt-20">
  44. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  45. <view @click="submit"
  46. 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">
  47. <text>提交审核</text>
  48. </view>
  49. <!-- <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">
  50. <text>联系我们</text>
  51. </view> -->
  52. </view>
  53. </view>
  54. </u--form>
  55. <u-action-sheet :actions="indList" @select="selectIndClick" title="行业" :show="show" @close="show=false"></u-action-sheet>
  56. </view>
  57. </template>
  58. <script>
  59. import {roleBoss,industryList} from "@/common/api.js"
  60. export default{
  61. data(){
  62. return{
  63. show:false,
  64. indList: [],
  65. fileList: [],
  66. form: {
  67. role:0,
  68. name: 'jerryxiao',
  69. password: '',
  70. mobile: '13189698114',
  71. address:'湖南长沙岳麓区',
  72. industryId:'1865294357074157570',
  73. industryName:'建筑',
  74. idCard:'',
  75. idCardFile:[
  76. {
  77. url:"https://tennis-oss.xzaiyp.top/2024-12-22/cf84422d-dcf7-4efa-82e7-371454eafbee.png"
  78. }
  79. ]
  80. },
  81. rules: {
  82. name: [{
  83. type: 'string',
  84. required: true,
  85. message: '请输入姓名名称',
  86. trigger: ['blur', 'change']
  87. }],
  88. password: [{
  89. type: 'string',
  90. required: true,
  91. message: '请输入您的密码',
  92. trigger: ['blur', 'change']
  93. }],
  94. mobile: [
  95. {
  96. required: true,
  97. message: '请输入手机号',
  98. trigger: ['change','blur'],
  99. },
  100. {
  101. validator: (rule, value, callback) => {
  102. return uni.$u.test.mobile(value);
  103. },
  104. message: '手机号码不正确',
  105. trigger: ['change','blur'],
  106. },
  107. ],
  108. address: [{
  109. type: 'string',
  110. required: true,
  111. message: '请输入公司地址',
  112. trigger: ['blur', 'change']
  113. }],
  114. industryId: [{
  115. type: 'string',
  116. required: true,
  117. message: '请选择行业',
  118. trigger: ['blur', 'change']
  119. }],
  120. idCardFile:[
  121. {
  122. validator: (rule, value, callback) => {
  123. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  124. callback(new Error('请选择身份证'));
  125. } else {
  126. callback();
  127. }
  128. },
  129. trigger: 'blur'
  130. }
  131. ]
  132. },
  133. }
  134. },
  135. watch: {
  136. fileList(newValue, oldValue) {
  137. if (newValue.length > 0) {
  138. this.form.file = '有'
  139. } else {
  140. this.form.file = ''
  141. }
  142. }
  143. },
  144. onReady() {
  145. this.onIndustryList()
  146. this.$refs.uForm.setRules(this.rules)
  147. },
  148. methods: {
  149. handleIndChange(){
  150. this.show = true
  151. },
  152. selectIndClick(event){
  153. console.info("selectIndClick",event)
  154. this.form.industryId = event.id
  155. this.form.industryName = event.name
  156. this.show = false
  157. },
  158. onIndustryList(){
  159. industryList({}).then(response=>{
  160. console.info(response)
  161. this.indList = response.result
  162. }).catch(error=>{
  163. })
  164. },
  165. submit() {
  166. let that = this
  167. that.$refs.uForm.validate().then(res => {
  168. that.onRoleBoss()
  169. }).catch(errors => {
  170. uni.$u.toast('校验失败')
  171. })
  172. },
  173. onRoleBoss(){
  174. let that = this
  175. let params={
  176. userName:that.form.name,
  177. role:that.form.role,
  178. phone:that.form.mobile,
  179. industryId:that.form.industryId,
  180. industryName:that.form.industryName,
  181. idCard:that.form.idCardFile.map(item => item.url).join(','),
  182. }
  183. roleBoss(params).then(response=>{
  184. uni.$u.toast("提交成功,等待申请")
  185. setTimeout(()=>{
  186. uni.switchTab({
  187. url:"/pages/home/index"
  188. })
  189. },1500)
  190. }).catch(error=>{
  191. setTimeout(()=>{
  192. uni.switchTab({
  193. url:"/pages/home/index"
  194. })
  195. },1500)
  196. })
  197. },
  198. deletePic(event) {
  199. this.form.idCardFile.splice(e.index, 1)
  200. },
  201. async afterRead(e) {
  202. let self = this
  203. e.file.forEach(file => {
  204. self.$Oss.ossUpload(file.url).then(url => {
  205. self.form.idCardFile.push({
  206. url
  207. })
  208. })
  209. })
  210. }
  211. }
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. .line-orange {
  216. width: 8rpx;
  217. height: 32rpx;
  218. background: #ff7a31;
  219. border-radius: 4rpx;
  220. }
  221. </style>