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

184 lines
4.6 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 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: '',
  56. mobile: '',
  57. company:'',
  58. address:'',
  59. file: '',
  60. fileList:[],
  61. // name: 'jerryxiao',
  62. // mobile: '13189698114',
  63. // company:'小肖公司',
  64. // address:'湖南长沙市岳麓区',
  65. // file: '1',
  66. // fileList:[
  67. // {
  68. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/7e98056b-e0b9-496f-89f8-88026ce9426e.png"
  69. // },
  70. // {
  71. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/499fcd8a-3d4b-42f3-b023-61bac6b1c020.png"
  72. // }
  73. // ],
  74. },
  75. rules: {
  76. name: [{
  77. type: 'string',
  78. required: true,
  79. message: '请输入姓名名称',
  80. trigger: ['blur', 'change']
  81. }],
  82. mobile: [
  83. {
  84. required: true,
  85. message: '请输入手机号',
  86. trigger: ['change','blur'],
  87. },
  88. {
  89. validator: (rule, value, callback) => {
  90. return uni.$u.test.mobile(value);
  91. },
  92. message: '手机号码不正确',
  93. trigger: ['change','blur'],
  94. },
  95. ],
  96. company: [{
  97. type: 'string',
  98. required: true,
  99. message: '请输入公司名称',
  100. trigger: ['blur', 'change']
  101. }],
  102. address: [{
  103. type: 'string',
  104. required: true,
  105. message: '请输入公司地址',
  106. trigger: ['blur', 'change']
  107. }],
  108. file: [{
  109. type: 'string',
  110. required: true,
  111. message: '请选择营业执照',
  112. trigger: ['blur', 'change']
  113. }]
  114. },
  115. }
  116. },
  117. watch: {
  118. 'form.fileList'(newValue, oldValue) {
  119. if (newValue.length > 0) {
  120. this.form.file = '有'
  121. } else {
  122. this.form.file = ''
  123. }
  124. }
  125. },
  126. onReady() {
  127. this.$refs.uForm.setRules(this.rules)
  128. },
  129. methods: {
  130. submit() {
  131. let that = this;
  132. that.$refs.uForm.validate().then(res => {
  133. // uni.$u.toast('校验通过')
  134. that.onAddCompany()
  135. }).catch(errors => {
  136. // uni.$u.toast('校验失败')
  137. })
  138. },
  139. onAddCompany(){
  140. let that = this
  141. let params={
  142. companyName:that.form.company,
  143. userName:that.form.name,
  144. phone:that.form.mobile,
  145. address:that.form.address,
  146. businessLicense:that.form.fileList.map(item => item.url).join(','),
  147. }
  148. addCompany(params).then(response=>{
  149. uni.$u.toast(response.result)
  150. setTimeout(()=>{
  151. uni.switchTab({
  152. url:"/pages/home/index"
  153. })
  154. },1500)
  155. }).catch(error=>{
  156. })
  157. },
  158. deletePic(event) {
  159. this.form.fileList.splice(event.index, 1)
  160. },
  161. async afterRead(e) {
  162. let self = this
  163. e.file.forEach(file => {
  164. self.$Oss.ossUpload(file.url).then(url => {
  165. self.form.fileList.push({
  166. url
  167. })
  168. })
  169. })
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .line-green {
  176. width: 8rpx;
  177. height: 32rpx;
  178. background: #669A32;
  179. border-radius: 4rpx;
  180. }
  181. </style>