customer-info.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view>
  3. <view class="box">
  4. <view class="top">
  5. <text class="title">信息管理</text>
  6. </view>
  7. <view class="item">
  8. <view class="l">
  9. <text style="color: red;">*</text>
  10. 企业名称:
  11. </view>
  12. <view class="r">
  13. <u-input v-model="form.name" placeholder="输入企业名称"/>
  14. </view>
  15. </view>
  16. <view class="item">
  17. <view class="l">
  18. <text style="color: red;">*</text>
  19. 联系人:
  20. </view>
  21. <view class="r">
  22. <u-input v-model="form.dutyPeople" placeholder="输入联系人"/>
  23. </view>
  24. </view>
  25. <view class="item">
  26. <view class="l">
  27. <text style="color: red;">*</text>
  28. 联系电话:
  29. </view>
  30. <view class="r">
  31. <u-input maxlength="11" v-model="form.phone" placeholder="输入电话号码"/>
  32. </view>
  33. </view>
  34. <view class="item" v-if="form.type==='0'">
  35. <view class="l">结算方式:</view>
  36. <view class="r">
  37. <radio-group @change="payChange">
  38. <label class="radio">
  39. <radio value="1" :disabled="customerId!=='1'" :checked="form.payType==1"/>
  40. 现结
  41. </label>
  42. <label class="radio" style="margin-left: 20rpx;">
  43. <radio value="2" :disabled="customerId!=='1'" :checked="form.payType==2"/>
  44. 月结
  45. </label>
  46. </radio-group>
  47. </view>
  48. </view>
  49. <view class="item">
  50. <view class="l">营业执照:</view>
  51. <view class="r">
  52. <view class="img">
  53. <uni-file-picker v-model="imageValue" fileMediatype="image" mode="grid" limit="1"
  54. @select="select"
  55. @delete="form.businessLicence=''" :image-styles="imageStyles"/>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="common-btn" @click="confirm">确认</view>
  61. </view>
  62. </template>
  63. <script>
  64. import request from '../../utils/request.js'
  65. export default {
  66. data() {
  67. return {
  68. imgList: [],
  69. imageValue: [],
  70. imageStyles: {
  71. width: 150,
  72. height: 100,
  73. border: {
  74. color: "#eee",
  75. width: 1,
  76. style: 'dashed',
  77. radius: '5px'
  78. }
  79. },
  80. uploadImageUrl: request.server + '/upload/image',
  81. form: {
  82. name: '',
  83. dutyPeople: '',
  84. phone: '',
  85. payType: '1',
  86. businessLicence: ''
  87. },
  88. customerId: ''
  89. }
  90. },
  91. mounted() {
  92. let id = uni.getStorageSync('userInfo').customerId;
  93. this.customerId = id;
  94. this.getCustomerById(id);
  95. },
  96. methods: {
  97. select(e) {
  98. let that = this;
  99. uni.uploadFile({
  100. url: that.uploadImageUrl,
  101. filePath: e.tempFilePaths[0],
  102. name: 'file',
  103. success: (resp => {
  104. console.log(JSON.parse(resp.data).data)
  105. that.form.businessLicence = JSON.parse(resp.data).data;
  106. })
  107. })
  108. },
  109. getCustomerById(id) {
  110. this.$api.getCustomerById({
  111. id: id
  112. }).then(resp => {
  113. this.form = resp.data;
  114. if (this.form.businessLicence) {
  115. this.imageValue = [{
  116. 'name': 'payTicket.png',
  117. 'extname': '.png',
  118. 'url': this.form.businessLicence
  119. }]
  120. }
  121. })
  122. },
  123. payChange(e) {
  124. this.form.payType = e.detail.value
  125. },
  126. check() {
  127. if (!this.form.name) {
  128. this.$common.toast('请录入名称');
  129. return false;
  130. }
  131. if (!this.form.dutyPeople) {
  132. this.$common.toast('请录入联系人');
  133. return false;
  134. }
  135. if (!this.$common.isPhone(this.form.phone)) {
  136. this.$common.toast('联系号码不正确');
  137. return false;
  138. }
  139. return true;
  140. },
  141. confirm() {
  142. if (this.check()) {
  143. this.$api.editCustomer(this.$common.removeNull(this.form)).then(resp => {
  144. if (resp.code == 200) {
  145. this.$common.toast('修改成功');
  146. setTimeout(() => {
  147. this.$common.back();
  148. }, 1000)
  149. }
  150. })
  151. }
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="scss">
  157. page {
  158. background-color: #fff;
  159. }
  160. @import '@/common/common.scss'
  161. </style>