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

241 lines
6.3 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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.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. id:'',
  68. role:0,
  69. name: '',
  70. password: '',
  71. mobile: '',
  72. address:'',
  73. industryId:'',
  74. industryName:'',
  75. idCardFile:[]
  76. },
  77. rules: {
  78. name: [{
  79. type: 'string',
  80. required: true,
  81. message: '请输入姓名名称',
  82. trigger: ['blur', 'change']
  83. }],
  84. password: [{
  85. type: 'string',
  86. required: true,
  87. message: '请输入您的密码',
  88. trigger: ['blur', 'change']
  89. }],
  90. mobile: [
  91. {
  92. required: true,
  93. message: '请输入手机号',
  94. trigger: ['change','blur'],
  95. },
  96. {
  97. validator: (rule, value, callback) => {
  98. return uni.$u.test.mobile(value);
  99. },
  100. message: '手机号码不正确',
  101. trigger: ['change','blur'],
  102. },
  103. ],
  104. address: [{
  105. type: 'string',
  106. required: true,
  107. message: '请输入居住地址',
  108. trigger: ['blur', 'change']
  109. }],
  110. industryId: [{
  111. type: 'string',
  112. required: true,
  113. message: '请选择行业',
  114. trigger: ['blur', 'change']
  115. }],
  116. idCardFile:[
  117. {
  118. validator: (rule, value, callback) => {
  119. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  120. callback(new Error('请选择身份证'));
  121. } else {
  122. callback();
  123. }
  124. },
  125. trigger: 'blur'
  126. }
  127. ]
  128. },
  129. }
  130. },
  131. watch: {
  132. },
  133. onReady() {
  134. this.onIndustryList()
  135. this.$refs.uForm.setRules(this.rules)
  136. },
  137. mounted() {
  138. let worker = uni.getStorageSync("worker")
  139. if(worker){
  140. this.form.id = worker.id
  141. this.form.name = worker.userName
  142. this.form.mobile = worker.phone
  143. this.form.industryId = worker.industryId
  144. this.form.industryName = worker.industryName
  145. this.form.idCardFile = this.stringToKeyValueArray(worker.idCard)
  146. }
  147. },
  148. methods: {
  149. stringToKeyValueArray(str, delimiter1 = ',') {
  150. if(str){
  151. let arro = str.split(delimiter1);
  152. let arr = [];
  153. arro.forEach(items=>{
  154. let obj = {};
  155. obj["url"] = items
  156. arr.push(obj)
  157. })
  158. console.info(arr)
  159. return arr
  160. }else{
  161. return []
  162. }
  163. },
  164. handleIndChange(){
  165. this.show = true
  166. },
  167. selectIndClick(event){
  168. console.info("selectIndClick",event)
  169. this.form.industryId = event.id
  170. this.form.industryName = event.name
  171. this.show = false
  172. },
  173. onIndustryList(){
  174. industryList({}).then(response=>{
  175. console.info(response)
  176. this.indList = response.result
  177. }).catch(error=>{
  178. })
  179. },
  180. submit() {
  181. let that = this
  182. that.$refs.uForm.validate().then(res => {
  183. that.onRoleBoss()
  184. }).catch(errors => {
  185. console.info(errors)
  186. uni.$u.toast('校验失败')
  187. })
  188. },
  189. onRoleBoss(){
  190. let that = this
  191. let params={
  192. userName:that.form.name,
  193. role:that.form.role,
  194. phone:that.form.mobile,
  195. industryId:that.form.industryId,
  196. industryName:that.form.industryName,
  197. idCard:that.form.idCardFile.map(item => item.url).join(','),
  198. }
  199. roleBoss(params).then(response=>{
  200. uni.$u.toast("提交成功,等待申请")
  201. setTimeout(()=>{
  202. uni.switchTab({
  203. url:"/pages/home/index"
  204. })
  205. },1500)
  206. }).catch(error=>{
  207. setTimeout(()=>{
  208. uni.switchTab({
  209. url:"/pages/home/index"
  210. })
  211. },1500)
  212. })
  213. },
  214. deletePic(event) {
  215. this.form.idCardFile.splice(e.index, 1)
  216. },
  217. async afterRead(e) {
  218. let self = this
  219. e.file.forEach(file => {
  220. self.$Oss.ossUpload(file.url).then(url => {
  221. self.form.idCardFile.push({
  222. url
  223. })
  224. })
  225. })
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="scss" scoped>
  231. .line-orange {
  232. width: 8rpx;
  233. height: 32rpx;
  234. background: #ff7a31;
  235. border-radius: 4rpx;
  236. }
  237. </style>