newCard.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="content">
  3. <view class="content1">
  4. <view class="left">
  5. <image src="../../static/c3.png" mode="widthFix" class="img"></image>
  6. </view>
  7. <view class="right">
  8. <view class="row1">
  9. 姓名|职务
  10. </view>
  11. <view class="">
  12. 公司名称
  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="userInfo.cardBusiness" borderBottom>
  34. <text>名片-{{cardInfo.cardBusiness}}</text>
  35. </u-form-item>
  36. <u-form-item label="姓名" prop="userInfo.name" borderBottom>
  37. <u--input v-model="cardInfo.name" border="none" placeholder="输入姓名"></u--input>
  38. </u-form-item>
  39. <u-form-item label="职务" prop="userInfo.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="userInfo.companyName" borderBottom>
  43. <u--input v-model="cardInfo.companyName" border="none" placholder="输入公司/机构名称"></u--input>
  44. </u-form-item>
  45. <u-form-item label="定位" prop="userInfo.name" borderBottom @click="placeSelect();hideKeyboard()">
  46. <text>选择定位> </text>
  47. </u-form-item>
  48. <u-form-item label="详细地址" prop="userInfo.name" borderBottom>
  49. <u--input v-model="cardInfo.name" border="none" placeholder="输入地址,不超过15个字"></u--input>
  50. </u-form-item>
  51. <u-form-item label="联系电话" prop="userInfo.name" borderBottom>
  52. <u--input v-model="cardInfo.name" border="none" placeholder="输入联系电话"></u--input>
  53. </u-form-item>
  54. </u--form>
  55. </view>
  56. <view class="content3">
  57. <view class="left">
  58. 上传企业logo或个人头像
  59. </view>
  60. <view class="right">
  61. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  62. :maxCount="10"></u-upload>
  63. </view>
  64. </view>
  65. <view class="bottom">
  66. <button>提交</button>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import uploadImage from '@/components/ossutil/uploadFile.js';
  72. export default {
  73. data() {
  74. return {
  75. fileList1: [],
  76. cardInfo: {
  77. commonId:'',
  78. cardBusiness:'',
  79. name:'',
  80. post:'',
  81. companyName:'',
  82. location:'',
  83. detailedAddress:'',
  84. phone:'',
  85. headSculpture:''
  86. }
  87. };
  88. },
  89. methods: {
  90. placeSelect() {
  91. uni.chooseLocation({
  92. success: function(res) {
  93. console.log(res);
  94. 111
  95. // console.log('位置名称:' + res.name);
  96. // console.log('详细地址:' + res.address);
  97. // console.log('纬度:' + res.latitude);
  98. // console.log('经度:' + res.longitude);
  99. this.cardInfo.location = res.latitude+','+res.longitude
  100. this.
  101. console.log('----------------------------')
  102. // that.addressInfo.latitude = res.latitude
  103. // that.addressInfo.longitude = res.longitude
  104. // that.addressInfo.detailedAddress = _address.Village
  105. // that.addressInfo.province = _address.Province
  106. // that.addressInfo.city = _address.City
  107. // that.addressInfo.area = _address.Country
  108. // that.addressInfo.commonId = that.userInfo.id
  109. // that.$forceUpdate()
  110. }
  111. });
  112. },
  113. hideKeyboard() {
  114. uni.hideKeyboard()
  115. },
  116. // 删除图片
  117. deletePic(event) {
  118. this[`fileList${event.name}`].splice(event.index, 1)
  119. },
  120. // 新增图片
  121. async afterRead(event) {
  122. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  123. let lists = [].concat(event.file)
  124. let fileListLen = this[`fileList${event.name}`].length
  125. lists.map((item) => {
  126. this[`fileList${event.name}`].push({
  127. ...item,
  128. status: 'uploading',
  129. message: '上传中'
  130. })
  131. })
  132. for (let i = 0; i < lists.length; i++) {
  133. const result = await this.uploadFilePromise(lists[i].url)
  134. let item = this[`fileList${event.name}`][fileListLen]
  135. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  136. status: 'success',
  137. message: '',
  138. url: result
  139. }))
  140. fileListLen++
  141. }
  142. },
  143. uploadFilePromise(url) {
  144. return new Promise((resolve, reject) => {
  145. // uploadImage(res.tempFilePaths[0], 'cardImages/',
  146. // result => {
  147. // // this.trainImg = result
  148. // uni.hideLoading();
  149. // }
  150. // )
  151. // let a = uni.uploadFile({
  152. // url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
  153. // filePath: url,
  154. // name: 'file',
  155. // formData: {
  156. // user: 'test'
  157. // },
  158. // success: (res) => {
  159. // setTimeout(() => {
  160. // resolve(res.data.data)
  161. // }, 1000)
  162. // }
  163. // });
  164. })
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss">
  170. .img {
  171. width: 100rpx;
  172. }
  173. </style>