editCard.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="content">
  3. <view class="content1">
  4. <view class="left">
  5. <image :src="cardInfo.headSculpture" mode="widthFix" class="img"></image>
  6. </view>
  7. <view class="right">
  8. <view class="row1">
  9. {{cardInfo.name}}|{{cardInfo.post}}
  10. </view>
  11. <view class="">
  12. {{cardInfo.companyName}}
  13. </view>
  14. <view class="">
  15. 地址
  16. </view>
  17. <view class="">
  18. 联系电话
  19. </view>
  20. <view class="">
  21. 备注
  22. </view>
  23. </view>
  24. </view>
  25. <view class="change-template">
  26. 切换模板
  27. </view>
  28. <view class="content2">
  29. <view class="">
  30. 名片信息
  31. </view>
  32. <u--form labelPosition="left" :model="cardInfo" ref="uForm">
  33. <u-form-item label="名片标识" prop="cardInfo.cardBusiness" borderBottom>
  34. <u--input v-model="cardInfo.cardBusiness" border="none" placeholder="输入名片标识"></u--input>
  35. </u-form-item>
  36. <u-form-item label="姓名" prop="cardInfo.name" borderBottom>
  37. <u--input v-model="cardInfo.name" border="none" placeholder="输入姓名"></u--input>
  38. </u-form-item>
  39. <u-form-item label="职务" prop="cardInfo.post" borderBottom>
  40. <u--input v-model="cardInfo.post" border="none" placeholder="输入职务,不超过8个字符"></u--input>
  41. </u-form-item>
  42. <u-form-item label="公司/机构名称" prop="cardInfo.companyName" borderBottom>
  43. <u--input v-model="cardInfo.companyName" border="none" placholder="输入公司/机构名称"></u--input>
  44. </u-form-item>
  45. </u-form-item>
  46. <!-- <u-form-item label="地址" prop="userInfo.name" borderBottom>
  47. <view @click="showPicker">选择地址</view>
  48. <view>{{ province }}{{ city }}{{ area }}</view>
  49. </u-form-item> -->
  50. <u-form-item label="定位" prop="cardInfo.name" borderBottom @click="placeSelect();hideKeyboard()">
  51. <text>选择地址> </text>
  52. </u-form-item>
  53. <u-form-item label="详细地址" prop="cardInfo.name" borderBottom>
  54. <u--input v-model="cardInfo.detailedAddress" border="none" placeholder="输入地址,不超过15个字"></u--input>
  55. </u-form-item>
  56. <u-form-item label="联系电话" prop="cardInfo.name" borderBottom>
  57. <u--input v-model="cardInfo.phone" border="none" placeholder="输入联系电话"></u--input>
  58. </u-form-item>
  59. </u--form>
  60. </view>
  61. <view class="content3">
  62. <view class="left">
  63. 上传企业logo或个人头像
  64. </view>
  65. <view class="right">
  66. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  67. :maxCount="1"></u-upload>
  68. </view>
  69. </view>
  70. <view class="bottom">
  71. <button @click="submit">提交</button>
  72. </view>
  73. <city-picker ref="picker" mode="multiSelector" :list="areaData" :level="3" @confirm="finishSelectAddress">
  74. </city-picker>
  75. <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  76. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  77. <u-toast ref="uToast"></u-toast>
  78. </view>
  79. </template>
  80. <script>
  81. export default {
  82. data() {
  83. return {
  84. isSubmit: false,
  85. content: '确定修改名片信息?',
  86. cardInfo:{},
  87. fileList1: [],
  88. };
  89. },
  90. onLoad(options) {
  91. this.cardInfo = JSON.parse(options.itemVal)
  92. console.log(this.cardInfo)
  93. this.fileList1 = [
  94. {
  95. url:this.cardInfo.headSculpture
  96. }
  97. ]
  98. },
  99. methods:{
  100. confirmSubmit() {
  101. console.log(123434343)
  102. console.log(123434343)
  103. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'update', {
  104. cardManagementInfo: JSON.stringify(this.cardInfo)
  105. }, failres => {
  106. this.$refs.uToast.show({
  107. type: 'error',
  108. message: failres.errmsg,
  109. })
  110. uni.hideLoading()
  111. }).then(res => {
  112. this.isSubmit = false
  113. this.$refs.uToast.show({
  114. type: 'success',
  115. message: '修改成功!',
  116. })
  117. })
  118. },
  119. submit() {
  120. this.isSubmit = true
  121. },
  122. deletePic(event) {
  123. this[`fileList${event.name}`].splice(event.index, 1)
  124. },
  125. // 新增图片
  126. async afterRead(event) {
  127. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  128. let lists = [].concat(event.file)
  129. let fileListLen = this[`fileList${event.name}`].length
  130. lists.map((item) => {
  131. this[`fileList${event.name}`].push({
  132. ...item,
  133. status: 'uploading',
  134. message: '上传中'
  135. })
  136. })
  137. for (let i = 0; i < lists.length; i++) {
  138. const result = await this.uploadFilePromise(lists[i].url)
  139. let item = this[`fileList${event.name}`][fileListLen]
  140. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  141. status: 'success',
  142. message: '',
  143. url: result
  144. }))
  145. fileListLen++
  146. }
  147. },
  148. uploadFilePromise(res) {
  149. return new Promise((resolve, reject) => {
  150. uploadImage(res, 'cardImages/',
  151. result => {
  152. that.cardInfo.headSculpture = result
  153. resolve(res)
  154. }
  155. )
  156. })
  157. },
  158. }
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. .img {
  163. width: 100rpx;
  164. }
  165. </style>