newCard.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <view class="content">
  3. <view class="content1 bgc0" v-show="selectIndex==0">
  4. <view class="left">
  5. <image src="../../static/2.jpg" 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="content1 bgc1" v-show="selectIndex==1">
  26. <view class="left">
  27. <image src="../../static/2.jpg" mode="widthFix" class="img"></image>
  28. </view>
  29. <view class="right">
  30. <view class="row1">
  31. {{cardInfo.name}}|{{cardInfo.post}}
  32. </view>
  33. <view class="">
  34. {{cardInfo.companyName}}
  35. </view>
  36. <view class="">
  37. 地址
  38. </view>
  39. <view class="">
  40. 联系电话
  41. </view>
  42. <view class="">
  43. 备注
  44. </view>
  45. </view>
  46. </view>
  47. <view class="content1 bgc2" v-show="selectIndex==2">
  48. <view class="left">
  49. <image src="../../static/2.jpg" mode="widthFix" class="img"></image>
  50. </view>
  51. <view class="right">
  52. <view class="row1">
  53. {{cardInfo.name}}|{{cardInfo.post}}
  54. </view>
  55. <view class="">
  56. {{cardInfo.companyName}}
  57. </view>
  58. <view class="">
  59. 地址
  60. </view>
  61. <view class="">
  62. 联系电话
  63. </view>
  64. <view class="">
  65. 备注
  66. </view>
  67. </view>
  68. </view>
  69. <view class="content1 bgc3" v-show="selectIndex==3">
  70. <view class="left">
  71. <image src="../../static/2.jpg" mode="widthFix" class="img"></image>
  72. </view>
  73. <view class="right">
  74. <view class="row1">
  75. {{cardInfo.name}}|{{cardInfo.post}}
  76. </view>
  77. <view class="">
  78. {{cardInfo.companyName}}
  79. </view>
  80. <view class="">
  81. 地址
  82. </view>
  83. <view class="">
  84. 联系电话
  85. </view>
  86. <view class="">
  87. 备注
  88. </view>
  89. </view>
  90. </view>
  91. <view class="content1 bgc4" v-show="selectIndex==4">
  92. <view class="left">
  93. <image src="../../static/2.jpg" mode="widthFix" class="img"></image>
  94. </view>
  95. <view class="right">
  96. <view class="row1">
  97. {{cardInfo.name}}|{{cardInfo.post}}
  98. </view>
  99. <view class="">
  100. {{cardInfo.companyName}}
  101. </view>
  102. <view class="">
  103. 地址
  104. </view>
  105. <view class="">
  106. 联系电话
  107. </view>
  108. <view class="">
  109. 备注
  110. </view>
  111. </view>
  112. </view>
  113. <view class="change-template">
  114. 切换模板
  115. </view>
  116. <view class="img-list">
  117. <view class="img-item" v-for="(item,index) in imgList" @click="changeTemplate(index)">
  118. <image :src="item.dictValue" class="img-item" :key="index"></image>
  119. <image src="../../static/imgs/card/dh.png" class="dh" v-if="selectIndex==index"></image>
  120. </view>
  121. </view>
  122. <view class="change-template">
  123. 名片信息
  124. </view>
  125. <view class="content2">
  126. <view class="flex flex-between row">
  127. <view class="left">
  128. 名片标识
  129. </view>
  130. <u--input v-model="cardInfo.cardBusiness" border="none" placeholder="输入名片标识" inputAlign='right'></u--input>
  131. </view>
  132. <view class="flex flex-between row">
  133. <view class="left">
  134. 姓名
  135. </view>
  136. <u--input v-model="cardInfo.name" border="none" placeholder="输入姓名" inputAlign='right'></u--input>
  137. </view>
  138. <view class="flex flex-between row">
  139. <view class="left">
  140. 职务
  141. </view>
  142. <u--input v-model="cardInfo.post" border="none" placeholder="输入职务,不超过8个字符" inputAlign='right'></u--input>
  143. </view>
  144. <view class="flex flex-between row">
  145. <view class="left">
  146. 公司/机构名称
  147. </view>
  148. <u--input v-model="cardInfo.companyName" border="none" placeholder="输入公司/机构名称" inputAlign='right'></u--input>
  149. </view>
  150. <view class="flex flex-between row" @click="placeSelect();hideKeyboard()">
  151. <view class="left">
  152. 地址
  153. </view>
  154. <view v-if="cardInfo.province">{{ cardInfo.province }}{{ cardInfo.city }}{{ cardInfo.area }}</view>
  155. <view class="" v-else>
  156. <text>选择地址 </text>
  157. <image src="../../static/imgs/card/yjt.png" mode="" style="margin-left:10rpx;width:12rpx;height: 21rpx;"></image>
  158. </view>
  159. </view>
  160. <view class="flex flex-between row">
  161. <view class="left">
  162. 详细地址
  163. </view>
  164. <u--input v-model="cardInfo.detailedAddress" border="none" placeholder="输入详细地址,不超过15个字" inputAlign='right'></u--input>
  165. </view>
  166. <view class="flex flex-between row">
  167. <view class="left">
  168. 联系电话
  169. </view>
  170. <u--input v-model="cardInfo.phone" border="none" placeholder="输入联系电话" inputAlign='right'></u--input>
  171. </view>
  172. <!-- <u-form-item label="地址" prop="userInfo.name" borderBottom>
  173. <view @click="showPicker">选择地址</view>
  174. <view>{{ province }}{{ city }}{{ area }}</view>
  175. </u-form-item> -->
  176. <view class="flex flex-between row">
  177. <view class="left">
  178. 上传企业logo或个人头像
  179. </view>
  180. <view class="right">
  181. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  182. :maxCount="1"></u-upload>
  183. </view>
  184. </view>
  185. </view>
  186. <view class="bottom">
  187. <button @click='$u.debounce(submit, 500)' class='button' type="default">提交</button>
  188. </view>
  189. <city-picker ref="picker" mode="multiSelector" :list="areaData" :level="3" @confirm="finishSelectAddress">
  190. </city-picker>
  191. <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  192. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  193. <u-toast ref="uToast"></u-toast>
  194. </view>
  195. </template>
  196. <script>
  197. var that;
  198. import uploadImage from '@/components/ossutil/uploadFile.js';
  199. export default {
  200. onLoad() {
  201. that = this
  202. this.userInfo = uni.getStorageSync("userInfo")
  203. this.cardInfo.commonId = this.userInfo.id
  204. // this.getList()
  205. },
  206. data() {
  207. return {
  208. selectIndex: 0,
  209. imgList: [{
  210. dictLabel: '/./../static/1.jpg',
  211. dictValue: '/./../static/1.jpg'
  212. },
  213. {
  214. dictLabel: '/./../static/2.jpg',
  215. dictValue: '/./../static/2.jpg'
  216. },
  217. {
  218. dictLabel: '/./../static/3.jpg',
  219. dictValue: '/./../static/3.jpg'
  220. }, {
  221. dictLabel: '/./../static/4.jpg',
  222. dictValue: '/./../static/4.jpg'
  223. }, {
  224. dictLabel: '/./../static/5.jpg',
  225. dictValue: '/./../static/5.jpg'
  226. }
  227. ],
  228. isSubmit: false,
  229. content: '确定提交名片信息?',
  230. userInfo: {},
  231. fileList1: [],
  232. cardInfo: {
  233. commonId: '',
  234. cardBusiness: '名片标识-1',
  235. name: '',
  236. post: '',
  237. companyName: '',
  238. location: '',
  239. detailedAddress: '',
  240. phone: '',
  241. headSculpture: ''
  242. }
  243. };
  244. },
  245. methods: {
  246. changeTemplate(index) {
  247. this.selectIndex = index
  248. },
  249. getList() {
  250. this.$request.baseRequest('admin.dictData', 'list', {
  251. dictType: "card_template"
  252. }, failres => {
  253. console.log('res+++++', failres.errmsg)
  254. this.$refs.uToast.show({
  255. type: 'error',
  256. message: failres.errmsg,
  257. })
  258. uni.hideLoading()
  259. }).then(res => {
  260. console.log("img", res)
  261. this.imgList = res.data.items
  262. })
  263. },
  264. placeSelect() {
  265. uni.chooseLocation({
  266. success: function(res) {
  267. console.log(res);
  268. that.cardInfo.location = res.latitude + ',' + res.longitude
  269. let _address = that.$helper.formatLocation(res.address)
  270. that.cardInfo.province = _address.Province
  271. that.cardInfo.city = _address.City
  272. that.cardInfo.area = _address.Country
  273. that.cardInfo.detailedAddress = _address.Village
  274. }
  275. });
  276. },
  277. hideKeyboard() {
  278. uni.hideKeyboard()
  279. },
  280. // 删除图片
  281. deletePic(event) {
  282. this[`fileList${event.name}`].splice(event.index, 1)
  283. },
  284. // 新增图片
  285. async afterRead(event) {
  286. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  287. let lists = [].concat(event.file)
  288. let fileListLen = this[`fileList${event.name}`].length
  289. lists.map((item) => {
  290. this[`fileList${event.name}`].push({
  291. ...item,
  292. status: 'uploading',
  293. message: '上传中'
  294. })
  295. })
  296. for (let i = 0; i < lists.length; i++) {
  297. const result = await this.uploadFilePromise(lists[i].url)
  298. let item = this[`fileList${event.name}`][fileListLen]
  299. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  300. status: 'success',
  301. message: '',
  302. url: result
  303. }))
  304. fileListLen++
  305. }
  306. },
  307. uploadFilePromise(res) {
  308. return new Promise((resolve, reject) => {
  309. uploadImage(res, 'cardImages/',
  310. result => {
  311. that.cardInfo.headSculpture = result
  312. resolve(res)
  313. }
  314. )
  315. })
  316. },
  317. confirmSubmit() {
  318. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'add', {
  319. cardManagementInfo: JSON.stringify(this.cardInfo)
  320. }, failres => {
  321. this.$refs.uToast.show({
  322. type: 'error',
  323. message: failres.errmsg,
  324. })
  325. uni.hideLoading()
  326. }).then(res => {
  327. this.isSubmit = false
  328. this.$refs.uToast.show({
  329. type: 'success',
  330. message: '提交成功!',
  331. })
  332. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'list', {
  333. page: 1,
  334. limit: 10,
  335. commonId: uni.getStorageSync("userInfo").id
  336. }, failres => {
  337. console.log('res+++++', failres.errmsg)
  338. this.$refs.uToast.show({
  339. type: 'error',
  340. message: failres.errmsg,
  341. })
  342. uni.hideLoading()
  343. }).then(res => {
  344. if (res.data.items.length > 0) {
  345. uni.navigateBack()
  346. } else {
  347. uni.navigateTo({
  348. url: '/pages/mySet/myHome'
  349. })
  350. }
  351. })
  352. })
  353. },
  354. submit() {
  355. this.isSubmit = true
  356. }
  357. }
  358. }
  359. </script>
  360. <style lang="scss" scoped>
  361. .content {
  362. padding: 20rpx;
  363. }
  364. .bgc0 {
  365. background: url('../../static/1.jpg') no-repeat center;
  366. height: 380rpx;
  367. border-radius: 20rpx;
  368. }
  369. .bgc1 {
  370. background: url('../../static/2.jpg') no-repeat center;
  371. height: 380rpx;
  372. border-radius: 20rpx;
  373. }
  374. .bgc2 {
  375. background: url('../../static/3.jpg') no-repeat center;
  376. height: 380rpx;
  377. border-radius: 20rpx;
  378. }
  379. .bgc3 {
  380. background: url('../../static/4.jpg') no-repeat center;
  381. height: 380rpx;
  382. border-radius: 20rpx;
  383. }
  384. .bgc4 {
  385. background: url('../../static/5.jpg') no-repeat center;
  386. height: 380rpx;
  387. border-radius: 20rpx;
  388. }
  389. .img {
  390. width: 100rpx;
  391. }
  392. .change-template {
  393. margin: 46rpx 0 30rpx 0;
  394. font-size: 32rpx;
  395. font-weight: bold;
  396. color: #19191A;
  397. }
  398. .img-list {
  399. display: block;
  400. white-space: nowrap;
  401. overflow-x: auto;
  402. .dh {
  403. width: 32rpx;
  404. height: 32rpx;
  405. position: absolute;
  406. right: 8rpx;
  407. bottom: 8rpx;
  408. }
  409. .img-item {
  410. position: relative;
  411. width: 186rpx;
  412. height: 120rpx;
  413. display: inline-block;
  414. margin-right: 2 0rpx;
  415. border-radius: 20rpx;
  416. margin-right: 20rpx;
  417. }
  418. }
  419. .content2 {
  420. background-color: #fff;
  421. border-radius: 20rpx;
  422. padding:0 20rpx 0 20rpx;
  423. .row{
  424. padding: 20rpx;
  425. border-bottom: 1px solid #E6E5E5;
  426. }
  427. }
  428. .button{
  429. color: #fff;
  430. background-color: #112253;
  431. border-radius: 20rpx;
  432. margin: 40rpx 0;
  433. }
  434. </style>