newCard.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <template>
  2. <view class="content">
  3. <view class="content1 relative">
  4. <view class="relative">
  5. <image :src="imgList[selectIndex].dictLabel" mode="widthFix" style="width: 100%;height: auto;"></image>
  6. </view>
  7. <view class="absolute card-content style1" v-if="imgList[selectIndex].dictSort==1">
  8. <view class="left">
  9. <u--image :showLoading="true" :src="cardInfo.headSculpture" width="66px" height="66px" shape="circle" v-if="cardInfo.headSculpture"></u--image>
  10. <u--image :showLoading="true" src="/static/imgs/card/defaulthead.png" width="66px" height="66px" shape="circle" v-else></u--image>
  11. </view>
  12. <view class="right">
  13. <view class="row1">
  14. <text class="name">{{cardInfo.name}}</text>
  15. <text class="post">{{cardInfo.post}}</text>
  16. </view>
  17. <view class="row2">
  18. {{cardInfo.companyName}}
  19. </view>
  20. <view class="row3 flex">
  21. <u--image :showLoading="true" src="/static/imgs/card/address1.png" width="13px"
  22. height="16px"></u--image>
  23. <view class='icon-text'>{{ cardInfo.province?cardInfo.province:'-' }}{{ cardInfo.city }}{{ cardInfo.area }}</view>
  24. </view>
  25. <view class="row4 flex">
  26. <u--image :showLoading="true" src="/static/imgs/card/phone1.png" width="12px"
  27. height="13px"></u--image>
  28. <view class='icon-text'>{{ cardInfo.phone?cardInfo.phone:'-' }}</view>
  29. </view>
  30. <view class="row4 flex">
  31. <u--image :showLoading="true" src="/static/imgs/card/remark1.png" width="10px"
  32. height="12px"></u--image>
  33. <view class='icon-text'>{{cardInfo.remark?cardInfo.remark:'-'}}</view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="absolute card-content style1 flex-between" v-if="imgList[selectIndex].dictSort==2">
  38. <view class="right">
  39. <view class="row1">
  40. <text class="name">{{cardInfo.name}}</text>
  41. <text class="post">{{cardInfo.post}}</text>
  42. </view>
  43. <view class="row2">
  44. {{cardInfo.companyName}}
  45. </view>
  46. <view class="row3 flex">
  47. <u--image :showLoading="true" src="/static/imgs/card/address3.png" width="13px"
  48. height="16px"></u--image>
  49. <view class='icon-text'>{{ cardInfo.province?cardInfo.province:'-' }}{{ cardInfo.city }}{{ cardInfo.area }}</view>
  50. </view>
  51. <view class="row4 flex">
  52. <u--image :showLoading="true" src="/static/imgs/card/phone3.png" width="12px"
  53. height="13px"></u--image>
  54. <view class='icon-text'>{{ cardInfo.phone?cardInfo.phone:'-' }}</view>
  55. </view>
  56. <view class="row4 flex">
  57. <u--image :showLoading="true" src="/static/imgs/card/remark3.png" width="10px"
  58. height="12px"></u--image>
  59. <view class='icon-text'>{{cardInfo.remark?cardInfo.remark:'-'}}</view>
  60. </view>
  61. </view>
  62. <view class="left">
  63. <u--image :showLoading="true" :src="cardInfo.headSculpture" width="66px" height="66px" shape="circle" v-if="cardInfo.headSculpture"></u--image>
  64. <u--image :showLoading="true" src="/static/imgs/card/defaulthead.png" width="66px" height="66px" shape="circle" v-else></u--image>
  65. </view>
  66. </view>
  67. <view class="absolute card-content style2" v-if="imgList[selectIndex].dictSort==3">
  68. <view class="top">
  69. <u--image :showLoading="true" :src="cardInfo.headSculpture" width="66px" height="66px" shape="circle" v-if="cardInfo.headSculpture"></u--image>
  70. <u--image :showLoading="true" src="/static/imgs/card/defaulthead.png" width="66px" height="66px" shape="circle" v-else></u--image>
  71. </view>
  72. <view class="bottom flex">
  73. <view class="left">
  74. <view class="row1">
  75. <text class="name">{{cardInfo.name}}</text>
  76. <text class="post">{{cardInfo.post}}</text>
  77. </view>
  78. <view class="row2">
  79. {{cardInfo.companyName}}
  80. </view>
  81. </view>
  82. <view class="right">
  83. <view class="row1 flex">
  84. <u--image :showLoading="true" src="/static/imgs/card/address1.png" width="13px"
  85. height="16px"></u--image>
  86. <view class='icon-text'>{{ cardInfo.province?cardInfo.province:'-' }}{{ cardInfo.city }}{{ cardInfo.area }}</view>
  87. </view>
  88. <view class="row2 flex">
  89. <u--image :showLoading="true" src="/static/imgs/card/phone1.png" width="12px"
  90. height="13px"></u--image>
  91. <view class='icon-text'>{{ cardInfo.phone?cardInfo.phone:'-' }}</view>
  92. </view>
  93. <view class="row4 flex">
  94. <u--image :showLoading="true" src="/static/imgs/card/remark1.png" width="10px"
  95. height="12px"></u--image>
  96. <view class='icon-text'>{{cardInfo.remark?cardInfo.remark:'-'}}</view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="absolute card-content style2" v-if="imgList[selectIndex].dictSort==4">
  102. <view class="top">
  103. <view class="row1">
  104. <text class="name">{{cardInfo.name}}</text>
  105. <text class="post">{{cardInfo.post}}</text>
  106. </view>
  107. <view class="row2">
  108. {{cardInfo.companyName}}
  109. </view>
  110. </view>
  111. <view class="bottom flex">
  112. <view class="left">
  113. <u--image :showLoading="true" :src="cardInfo.headSculpture" width="66px" height="66px" shape="circle" v-if="cardInfo.headSculpture"></u--image>
  114. <u--image :showLoading="true" src="/static/imgs/card/defaulthead.png" width="66px" height="66px" shape="circle" v-else></u--image>
  115. </view>
  116. <view class="right">
  117. <view class="row1 flex">
  118. <u--image :showLoading="true" src="/static/imgs/card/address2.png" width="13px"
  119. height="16px"></u--image>
  120. <view class='icon-text'>{{ cardInfo.province?cardInfo.province:'-' }}{{ cardInfo.city }}{{ cardInfo.area }}</view>
  121. </view>
  122. <view class="row2 flex">
  123. <u--image :showLoading="true" src="/static/imgs/card/phone2.png" width="12px"
  124. height="13px"></u--image>
  125. <view class='icon-text'>{{ cardInfo.phone?cardInfo.phone:'-' }}</view>
  126. </view>
  127. <view class="row4 flex">
  128. <u--image :showLoading="true" src="/static/imgs/card/remark2.png" width="10px"
  129. height="12px"></u--image>
  130. <view class='icon-text'>{{cardInfo.remark?cardInfo.remark:'-'}}</view>
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. <view class="change-template">
  137. 切换模板
  138. </view>
  139. <view class="img-list">
  140. <view class="img-item" v-for="(item,index) in imgList" @click="changeTemplate(index)">
  141. <image :src="item.dictValue" class="img-item" :key="index"></image>
  142. <image src="../../static/imgs/card/dh.png" class="dh" v-if="selectIndex==index"></image>
  143. </view>
  144. </view>
  145. <view class="change-template">
  146. 名片信息
  147. </view>
  148. <view class="content2">
  149. <view class="flex flex-between align-item-center row">
  150. <view class="left">
  151. 名片标识
  152. </view>
  153. <u--input v-model="cardInfo.cardBusiness" border="none" placeholder="输入名片标识" inputAlign='right'></u--input>
  154. </view>
  155. <view class="flex flex-between align-item-center row">
  156. <view class="left">
  157. 姓名
  158. </view>
  159. <u--input v-model="cardInfo.name" border="none" placeholder="输入姓名" inputAlign='right'></u--input>
  160. </view>
  161. <view class="flex flex-between align-item-center row">
  162. <view class="left">
  163. 职务
  164. </view>
  165. <u--input v-model="cardInfo.post" border="none" placeholder="输入职务,不超过8个字符" inputAlign='right'></u--input>
  166. </view>
  167. <view class="flex flex-between align-item-center row">
  168. <view class="left">
  169. 公司/机构名称
  170. </view>
  171. <u--input v-model="cardInfo.companyName" border="none" placeholder="输入公司/机构名称" inputAlign='right'></u--input>
  172. </view>
  173. <view class="flex flex-between align-item-center row" @click="placeSelect();hideKeyboard()">
  174. <view class="left">
  175. 地址
  176. </view>
  177. <view v-if="cardInfo.province">{{ cardInfo.province }}{{ cardInfo.city }}{{ cardInfo.area }}</view>
  178. <view class="" v-else>
  179. <text>选择地址 </text>
  180. <image src="../../static/imgs/card/yjt.png" mode="" style="margin-left:10rpx;width:12rpx;height: 21rpx;"></image>
  181. </view>
  182. </view>
  183. <view class="flex flex-between align-item-center row">
  184. <view class="left">
  185. 详细地址
  186. </view>
  187. <u--input v-model="cardInfo.detailedAddress" border="none" placeholder="输入详细地址,不超过15个字" inputAlign='right'></u--input>
  188. </view>
  189. <view class="flex flex-between align-item-center row">
  190. <view class="left">
  191. 联系电话
  192. </view>
  193. <u--input v-model="cardInfo.phone" maxlength='15' border="none" placeholder="输入联系电话" inputAlign='right'></u--input>
  194. </view>
  195. <!-- <u-form-item label="地址" prop="userInfo.name" borderBottom>
  196. <view @click="showPicker">选择地址</view>
  197. <view>{{ province }}{{ city }}{{ area }}</view>
  198. </u-form-item> -->
  199. <view class="flex flex-between align-item-center row">
  200. <view class="left">
  201. 上传企业logo或个人头像
  202. </view>
  203. <view class="right">
  204. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  205. :maxCount="1"></u-upload>
  206. </view>
  207. </view>
  208. </view>
  209. <view class="bottom">
  210. <button @click='$u.debounce(submit, 500)' class='button' type="default">提交</button>
  211. </view>
  212. <city-picker ref="picker" mode="multiSelector" :list="areaData" :level="3" @confirm="finishSelectAddress">
  213. </city-picker>
  214. <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  215. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  216. <u-toast ref="uToast"></u-toast>
  217. </view>
  218. </template>
  219. <script>
  220. var that;
  221. import uploadImage from '@/components/ossutil/uploadFile.js';
  222. export default {
  223. onLoad() {
  224. that = this
  225. this.userInfo = uni.getStorageSync("userInfo")
  226. this.cardInfo.commonId = this.userInfo.id
  227. this.getList()
  228. },
  229. data() {
  230. return {
  231. selectIndex: 0,
  232. imgList:[],
  233. // imgList: [{
  234. // dictLabel: '/./../static/1.jpg',
  235. // dictValue: '/./../static/1.jpg'
  236. // },
  237. // {
  238. // dictLabel: '/./../static/2.jpg',
  239. // dictValue: '/./../static/2.jpg'
  240. // },
  241. // {
  242. // dictLabel: '/./../static/3.jpg',
  243. // dictValue: '/./../static/3.jpg'
  244. // }, {
  245. // dictLabel: '/./../static/4.jpg',
  246. // dictValue: '/./../static/4.jpg'
  247. // }, {
  248. // dictLabel: '/./../static/5.jpg',
  249. // dictValue: '/./../static/5.jpg'
  250. // }
  251. // ],
  252. isSubmit: false,
  253. content: '确定提交名片信息?',
  254. userInfo: {},
  255. fileList1: [],
  256. cardInfo: {
  257. city:'',
  258. area:'',
  259. province:'',
  260. commonId: '',
  261. cardBusiness: '名片标识',
  262. name: '',
  263. post: '',
  264. companyName: '',
  265. location: '',
  266. detailedAddress: '',
  267. phone: '',
  268. headSculpture: '',
  269. currentBackground:'',
  270. cuttentTemplate:''
  271. }
  272. };
  273. },
  274. methods: {
  275. leftClick() {
  276. uni.navigateBack({delta:2})
  277. },
  278. changeTemplate(index) {
  279. this.selectIndex = index
  280. this.cardInfo.currentBackground = this.imgList[index].dictLabel
  281. this.cardInfo.cuttentTemplate = this.imgList[index].dictSort
  282. },
  283. getList() {
  284. this.$request.baseRequest('admin.dictData', 'list', {
  285. dictType: "card_template"
  286. }, failres => {
  287. console.log('res+++++', failres.errmsg)
  288. this.$refs.uToast.show({
  289. type: 'error',
  290. message: failres.errmsg,
  291. })
  292. uni.hideLoading()
  293. }).then(res => {
  294. console.log("img", res)
  295. this.imgList = res.data.items
  296. if(!this.cardInfo.currentBackground&&!this.cardInfo.cuttentTemplate){
  297. this.cardInfo.currentBackground = this.imgList[0].dictLabel
  298. this.cardInfo.cuttentTemplate = this.imgList[0].dictSort
  299. }
  300. })
  301. },
  302. placeSelect() {
  303. uni.chooseLocation({
  304. success: function(res) {
  305. console.log(res);
  306. that.cardInfo.location = res.latitude + ',' + res.longitude
  307. let _address = that.$helper.formatLocation(res.address)
  308. that.cardInfo.province = _address.Province
  309. that.cardInfo.city = _address.City
  310. that.cardInfo.area = _address.Country
  311. that.cardInfo.detailedAddress = _address.Village
  312. }
  313. });
  314. },
  315. hideKeyboard() {
  316. uni.hideKeyboard()
  317. },
  318. // 删除图片
  319. deletePic(event) {
  320. this[`fileList${event.name}`].splice(event.index, 1)
  321. },
  322. // 新增图片
  323. async afterRead(event) {
  324. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  325. let lists = [].concat(event.file)
  326. let fileListLen = this[`fileList${event.name}`].length
  327. lists.map((item) => {
  328. this[`fileList${event.name}`].push({
  329. ...item,
  330. status: 'uploading',
  331. message: '上传中'
  332. })
  333. })
  334. for (let i = 0; i < lists.length; i++) {
  335. const result = await this.uploadFilePromise(lists[i].url)
  336. let item = this[`fileList${event.name}`][fileListLen]
  337. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  338. status: 'success',
  339. message: '',
  340. url: result
  341. }))
  342. fileListLen++
  343. }
  344. },
  345. uploadFilePromise(res) {
  346. return new Promise((resolve, reject) => {
  347. uploadImage(res, 'cardImages/',
  348. result => {
  349. that.cardInfo.headSculpture = result
  350. resolve(res)
  351. }
  352. )
  353. })
  354. },
  355. confirmSubmit() {
  356. uni.showLoading({
  357. title: '加载中',
  358. mask: true
  359. })
  360. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'add', {
  361. cardManagementInfo: JSON.stringify(this.cardInfo)
  362. }, failres => {
  363. this.$refs.uToast.show({
  364. type: 'error',
  365. message: failres.errmsg,
  366. })
  367. uni.hideLoading()
  368. }).then(res => {
  369. this.isSubmit = false
  370. this.$refs.uToast.show({
  371. type: 'success',
  372. message: '提交成功!',
  373. })
  374. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'list', {
  375. page: 1,
  376. limit: 10,
  377. commonId: uni.getStorageSync("userInfo").id
  378. }, failres => {
  379. console.log('res+++++', failres.errmsg)
  380. this.$refs.uToast.show({
  381. type: 'error',
  382. message: failres.errmsg,
  383. })
  384. uni.hideLoading()
  385. }).then(res => {
  386. if (res.data.items.length > 0) {
  387. uni.navigateBack()
  388. } else {
  389. uni.navigateTo({
  390. url: '/pages/mySet/myHome'
  391. })
  392. }
  393. })
  394. })
  395. },
  396. submit() {
  397. this.isSubmit = true
  398. }
  399. }
  400. }
  401. </script>
  402. <style lang="scss" scoped>
  403. .content {
  404. padding: 20rpx;
  405. }
  406. .bgc0 {
  407. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc1.png') no-repeat center;
  408. height: 380rpx;
  409. border-radius: 20rpx;
  410. }
  411. .bgc1 {
  412. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc2.png') no-repeat center;
  413. height: 380rpx;
  414. border-radius: 20rpx;
  415. }
  416. .bgc2 {
  417. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc3.png') no-repeat center;
  418. height: 380rpx;
  419. border-radius: 20rpx;
  420. }
  421. .bgc3 {
  422. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc4.png') no-repeat center;
  423. height: 380rpx;
  424. border-radius: 20rpx;
  425. }
  426. .bgc4 {
  427. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc5.png') no-repeat center;
  428. height: 380rpx;
  429. border-radius: 20rpx;
  430. }
  431. .img {
  432. width: 100rpx;
  433. }
  434. .change-template {
  435. margin: 46rpx 0 30rpx 0;
  436. font-size: 32rpx;
  437. font-weight: bold;
  438. color: #19191A;
  439. }
  440. .img-list {
  441. display: block;
  442. white-space: nowrap;
  443. overflow-x: auto;
  444. .dh {
  445. width: 32rpx;
  446. height: 32rpx;
  447. position: absolute;
  448. right: 8rpx;
  449. bottom: 8rpx;
  450. }
  451. .img-item {
  452. position: relative;
  453. width: 186rpx;
  454. height: 120rpx;
  455. display: inline-block;
  456. margin-right: 2 0rpx;
  457. border-radius: 20rpx;
  458. margin-right: 20rpx;
  459. }
  460. }
  461. .content2 {
  462. background-color: #fff;
  463. border-radius: 20rpx;
  464. padding:0 20rpx 0 20rpx;
  465. .row{
  466. padding: 20rpx;
  467. border-bottom: 1px solid #E6E5E5;
  468. }
  469. }
  470. .button{
  471. color: #fff;
  472. background-color: #112253;
  473. border-radius: 20rpx;
  474. margin: 40rpx 0;
  475. }
  476. .card-content{
  477. top: 20rpx;
  478. left: 20rpx;
  479. }
  480. .content1{
  481. .icon-text{
  482. margin-left:10rpx;
  483. }
  484. .style1{
  485. display: flex;
  486. padding: 20rpx 30rpx;
  487. width: 85%;
  488. .left{
  489. width: 132rpx;
  490. height: 132rpx;
  491. border-radius: 50%;
  492. }
  493. .right{
  494. margin-left: 40rpx;
  495. .row1{
  496. .name{
  497. font-size: 38rpx;
  498. font-weight: bold;
  499. color: #040000;
  500. margin-right: 20rpx;
  501. }
  502. .post{
  503. font-size: 26rpx;
  504. font-weight: 500;
  505. color: #666666;
  506. }
  507. }
  508. .row2{
  509. margin-top: 20rpx;
  510. font-size: 24rpx;
  511. font-weight: bold;
  512. color: #323333;
  513. }
  514. .row3{
  515. margin-top: 30rpx;
  516. font-size: 24rpx;
  517. font-weight: 500;
  518. color: #323333;
  519. }
  520. .row2,.row3,.row4{
  521. margin-top: 20rpx;
  522. }
  523. }
  524. }
  525. .style2{
  526. padding:30rpx;
  527. .top{
  528. .row1{
  529. .name{
  530. font-size: 38rpx;
  531. font-weight: bold;
  532. color: #040000;
  533. margin-right: 20rpx;
  534. }
  535. .post{
  536. font-size: 26rpx;
  537. font-weight: 500;
  538. color: #666666;
  539. }
  540. }
  541. .row2{
  542. margin-top: 20rpx;
  543. font-size: 24rpx;
  544. font-weight: bold;
  545. color: #323333;
  546. }
  547. }
  548. .bottom{
  549. margin-top: 48rpx;
  550. .left{
  551. margin-right: 40rpx;
  552. .row1{
  553. .name{
  554. font-size: 38rpx;
  555. font-weight: bold;
  556. color: #040000;
  557. margin-right: 20rpx;
  558. }
  559. .post{
  560. font-size: 26rpx;
  561. font-weight: 500;
  562. color: #666666;
  563. }
  564. }
  565. .row2{
  566. margin-top: 20rpx;
  567. font-size: 24rpx;
  568. font-weight: bold;
  569. color: #323333;
  570. }
  571. }
  572. .right{
  573. .row1,.row2{
  574. font-size: 24rpx;
  575. font-weight: 500;
  576. color: #323333;
  577. }
  578. .row2,.row3,.row4{
  579. margin-top: 20rpx;
  580. }
  581. }
  582. }
  583. }
  584. }
  585. .content2{
  586. .left{
  587. margin-right:10rpx;
  588. }
  589. }
  590. </style>