newCard.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. {{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="userInfo.cardBusiness" borderBottom>
  34. <u--input v-model="cardInfo.cardBusiness" border="none" placeholder="输入名片标识"></u--input>
  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>
  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="userInfo.name" borderBottom @click="placeSelect();hideKeyboard()">
  51. <text>选择地址> </text>
  52. </u-form-item>
  53. <u-form-item label="详细地址" prop="userInfo.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="userInfo.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="10"></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. var that;
  82. import uploadImage from '@/components/ossutil/uploadFile.js';
  83. export default {
  84. onLoad() {
  85. that = this
  86. this.userInfo = uni.getStorageSync("userInfo")
  87. this.cardInfo.commonId = this.userInfo.id
  88. },
  89. data() {
  90. return {
  91. isSubmit: false,
  92. content: '确定提交名片信息?',
  93. userInfo: {},
  94. fileList1: [],
  95. cardInfo: {
  96. commonId: '',
  97. cardBusiness: '名片标识-1',
  98. name: '',
  99. post: '',
  100. companyName: '',
  101. location: '',
  102. detailedAddress: '',
  103. phone: '',
  104. headSculpture: ''
  105. }
  106. };
  107. },
  108. methods: {
  109. placeSelect() {
  110. uni.chooseLocation({
  111. success: function(res) {
  112. console.log(res);
  113. that.cardInfo.location = res.latitude + ',' + res.longitude
  114. let _address = that.$helper.formatLocation(res.address)
  115. that.cardInfo.province = _address.Province
  116. that.cardInfo.city = _address.City
  117. that.cardInfo.area = _address.Country
  118. that.cardInfo.detailedAddress = _address.Village
  119. }
  120. });
  121. },
  122. hideKeyboard() {
  123. uni.hideKeyboard()
  124. },
  125. // 删除图片
  126. deletePic(event) {
  127. this[`fileList${event.name}`].splice(event.index, 1)
  128. },
  129. // 新增图片
  130. async afterRead(event) {
  131. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  132. let lists = [].concat(event.file)
  133. let fileListLen = this[`fileList${event.name}`].length
  134. lists.map((item) => {
  135. this[`fileList${event.name}`].push({
  136. ...item,
  137. status: 'uploading',
  138. message: '上传中'
  139. })
  140. })
  141. for (let i = 0; i < lists.length; i++) {
  142. const result = await this.uploadFilePromise(lists[i].url)
  143. let item = this[`fileList${event.name}`][fileListLen]
  144. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  145. status: 'success',
  146. message: '',
  147. url: result
  148. }))
  149. fileListLen++
  150. }
  151. },
  152. uploadFilePromise(res) {
  153. return new Promise((resolve, reject) => {
  154. uploadImage(res, 'cardImages/',
  155. result => {
  156. that.cardInfo.headSculpture = result
  157. resolve(res)
  158. }
  159. )
  160. })
  161. },
  162. confirmSubmit() {
  163. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'add', {
  164. cardManagementInfo: JSON.stringify(this.cardInfo)
  165. }, failres => {
  166. this.$refs.uToast.show({
  167. type: 'error',
  168. message: failres.errmsg,
  169. })
  170. uni.hideLoading()
  171. }).then(res => {
  172. this.isSubmit = false
  173. this.$refs.uToast.show({
  174. type: 'success',
  175. message: '提交成功!',
  176. })
  177. })
  178. },
  179. submit() {
  180. this.isSubmit = true
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss">
  186. .img {
  187. width: 100rpx;
  188. }
  189. </style>