customer-info.vue 3.7 KB

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