环卫车小程序前端代码
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.

177 lines
4.5 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <template>
  2. <view>
  3. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="80">
  4. <view class="se-p-20">
  5. <view class="se-p-20 se-bgc-white se-br-10 se-fs-20">
  6. <u-form-item label="公司名称" prop="company">
  7. <u--input v-model="form.company" placeholder="请输入公司名称"></u--input>
  8. </u-form-item>
  9. <u-form-item label="联系人" prop="name">
  10. <u--input v-model="form.name" placeholder="请输入姓名名称"></u--input>
  11. </u-form-item>
  12. <u-form-item label="联系电话" prop="mobile">
  13. <u--input v-model="form.mobile" placeholder="请输入联系方式"></u--input>
  14. </u-form-item>
  15. <u-form-item label="公司地址" prop="address">
  16. <u--input v-model="form.address" placeholder="请输入公司地址"></u--input>
  17. </u-form-item>
  18. </view>
  19. </view>
  20. <view class="se-p-20">
  21. <view class="se-px-20 se-pb-20 se-bgc-white se-br-10 se-fs-20">
  22. <u-form-item prop="file" labelWidth="0">
  23. <view class="se-flex se-flex-v-sa">
  24. <view class="se-py-20 se-w-p-100 se-flex">
  25. <view class="line-green"></view>
  26. <view class="se-ml-10">
  27. 营业执照上传
  28. </view>
  29. </view>
  30. <view class="se-py-20 se-w-p-100">
  31. <u-upload :fileList="form.fileList" @afterRead="afterRead" @delete="deletePic" name="1"
  32. multiple :maxCount="10"></u-upload>
  33. </view>
  34. </view>
  35. </u-form-item>
  36. </view>
  37. </view>
  38. <view class="se-px-20 se-pt-20">
  39. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  40. <view @click="submit"
  41. class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-28 se-c-white se-bgc-green">
  42. <text>确认</text>
  43. </view>
  44. </view>
  45. </view>
  46. </u--form>
  47. </view>
  48. </template>
  49. <script>
  50. import { addCompany } from "@/common/api.js"
  51. export default{
  52. data(){
  53. return{
  54. form: {
  55. name: 'jerryxiao',
  56. mobile: '13189698114',
  57. company:'小肖公司',
  58. address:'湖南长沙市岳麓区',
  59. file: '1',
  60. fileList:[
  61. {
  62. url:"https://tennis-oss.xzaiyp.top/2024-12-14/7e98056b-e0b9-496f-89f8-88026ce9426e.png"
  63. },
  64. {
  65. url:"https://tennis-oss.xzaiyp.top/2024-12-14/499fcd8a-3d4b-42f3-b023-61bac6b1c020.png"
  66. }
  67. ],
  68. },
  69. rules: {
  70. name: [{
  71. type: 'string',
  72. required: true,
  73. message: '请输入姓名名称',
  74. trigger: ['blur', 'change']
  75. }],
  76. mobile: [
  77. {
  78. required: true,
  79. message: '请输入手机号',
  80. trigger: ['change','blur'],
  81. },
  82. {
  83. validator: (rule, value, callback) => {
  84. return uni.$u.test.mobile(value);
  85. },
  86. message: '手机号码不正确',
  87. trigger: ['change','blur'],
  88. },
  89. ],
  90. company: [{
  91. type: 'string',
  92. required: true,
  93. message: '请输入公司名称',
  94. trigger: ['blur', 'change']
  95. }],
  96. address: [{
  97. type: 'string',
  98. required: true,
  99. message: '请输入公司地址',
  100. trigger: ['blur', 'change']
  101. }],
  102. file: [{
  103. type: 'string',
  104. required: true,
  105. message: '请选择营业执照',
  106. trigger: ['blur', 'change']
  107. }]
  108. },
  109. }
  110. },
  111. watch: {
  112. 'form.fileList'(newValue, oldValue) {
  113. if (newValue.length > 0) {
  114. this.form.file = '有'
  115. } else {
  116. this.form.file = ''
  117. }
  118. }
  119. },
  120. onReady() {
  121. this.$refs.uForm.setRules(this.rules)
  122. },
  123. methods: {
  124. submit() {
  125. let that = this;
  126. that.$refs.uForm.validate().then(res => {
  127. // uni.$u.toast('校验通过')
  128. that.onAddCompany()
  129. }).catch(errors => {
  130. // uni.$u.toast('校验失败')
  131. })
  132. },
  133. onAddCompany(){
  134. let that = this
  135. let params={
  136. companyName:that.form.company,
  137. userName:that.form.name,
  138. phone:that.form.mobile,
  139. address:that.form.address,
  140. businessLicense:that.form.fileList.map(item => item.url).join(','),
  141. }
  142. addCompany(params).then(response=>{
  143. uni.$u.toast(response.result)
  144. setTimeout(()=>{
  145. uni.switchTab({
  146. url:"/pages/home/index"
  147. })
  148. },1500)
  149. }).catch(error=>{
  150. })
  151. },
  152. deletePic(event) {
  153. this.form.fileList.splice(event.index, 1)
  154. },
  155. async afterRead(e) {
  156. let self = this
  157. e.file.forEach(file => {
  158. self.$Oss.ossUpload(file.url).then(url => {
  159. self.form.fileList.push({
  160. url
  161. })
  162. })
  163. })
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="scss" scoped>
  169. .line-green {
  170. width: 8rpx;
  171. height: 32rpx;
  172. background: #669A32;
  173. border-radius: 4rpx;
  174. }
  175. </style>