customer-info.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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">企业名称:</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">联系人:</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">联系电话:</view>
  21. <view class="r">
  22. <u-input maxlength="11" v-model="form.phone" placeholder="输入电话号码" />
  23. </view>
  24. </view>
  25. <view class="item">
  26. <view class="l">结算方式:</view>
  27. <view class="r">
  28. <radio-group @change="payChange">
  29. <label class="radio">
  30. <radio value="1" checked />现结
  31. </label>
  32. <label class="radio" style="margin-left: 20rpx;">
  33. <radio value="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. }
  78. },
  79. mounted() {
  80. let id = uni.getStorageSync('info').customerId;
  81. this.getCustomerById(id);
  82. },
  83. methods: {
  84. select(e) {
  85. let that = this;
  86. uni.uploadFile({
  87. url: that.uploadImageUrl,
  88. filePath: e.tempFilePaths[0],
  89. name: 'file',
  90. success: (resp => {
  91. that.form.businessLicence = JSON.parse(resp.data).data;
  92. })
  93. })
  94. },
  95. getCustomerById(id) {
  96. this.$api.getCustomerById({
  97. id: id
  98. }).then(resp => {
  99. this.form = resp.data;
  100. if(this.form.businessLicence){
  101. this.imageValue=[{
  102. 'name':'payTicket.png',
  103. 'extname':'.png',
  104. 'url':this.form.businessLicence
  105. }]
  106. }
  107. })
  108. },
  109. payChange(e) {
  110. this.form.payType = e.detail.value
  111. },
  112. check() {
  113. if (!this.form.name) {
  114. this.$common.toast('请录入名称');
  115. return false;
  116. }
  117. if (!this.form.dutyPeople) {
  118. this.$common.toast('请录入联系人');
  119. return false;
  120. }
  121. if (!this.$common.isPhone(this.form.phone)) {
  122. this.$common.toast('联系号码不正确');
  123. return false;
  124. }
  125. return true;
  126. },
  127. confirm() {
  128. if (this.check()) {
  129. this.$api.editCustomer(this.$common.removeNull(this.form)).then(resp => {
  130. if (resp.code == 200) {
  131. this.$common.toast('修改成功');
  132. setTimeout(()=>{
  133. this.$common.back();
  134. },1000)
  135. }
  136. })
  137. }
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss">
  143. page {
  144. background-color: #fff;
  145. }
  146. @import '@/common/common.scss'
  147. </style>