mySet.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <template>
  2. <view class="content">
  3. <view class="content1 flex-between relative flex">
  4. <view class="user flex">
  5. <image :src="userInfo.head" mode="widthFix" class="img"></image>
  6. <view class="name">
  7. {{userInfo.nickname}}
  8. </view>
  9. </view>
  10. <view class="position">
  11. <image v-if='list.length>1||list.length==0' @click='selectCard' src="../../static/imgs/mySet/share.png" mode="widthFix" class="right-img">
  12. </image>
  13. <button v-if='list.length==1' class="shareBtn" type="default" data-name="shareBtn" open-type="share">
  14. <image src="../../static/imgs/mySet/share.png" mode="widthFix" class="right-img">
  15. </image>
  16. </button>
  17. <image @click='selectCard1' src="../../static/imgs/mySet/ewm.png" mode="widthFix" class="right-img">
  18. </image>
  19. </view>
  20. </view>
  21. <view class="content2">
  22. <view class="row flex flex-between" v-for="(item,index) in menuList" :key='index'
  23. @click="menuClick(item.type)">
  24. <view class="flex">
  25. <image :src="item.src" mode="widthFix" class="nav-img"></image>
  26. <button class="left-btn" v-if='item.type=="contactCustomer"'
  27. open-type='contact'>{{item.name}}</button>
  28. <span class="left" v-else>{{item.name}}</span>
  29. </view>
  30. <span class="right">
  31. <image src="../../static/imgs/mySet/yjt.png" mode="widthFix" class="row-right-img"></image>
  32. </span>
  33. </view>
  34. </view>
  35. <u-popup :show="isShowCode" @close="isShowCode=false" mode="center" :round='10'>
  36. <image style='margin:10px;' :src="selectCode" mode="widthFix"></image>
  37. </u-popup>
  38. <u-picker keyName="cardBusiness" :confirmType='"share"' :confirmText='"分享"' title="选择名片" @cancel="show=false"
  39. closeOnClickOverlay @change="cardChange" :show="show" :columns="cardList"></u-picker>
  40. <u-picker keyName="cardBusiness" confirmText='确定' title="选择名片" @cancel="show1=false" closeOnClickOverlay
  41. @confirm="cardConfirm" :show="show1" :columns="cardList"></u-picker>
  42. <poster :data="canvasData" background-color="#FFF" :width='750' :height='420' @on-success="posterSuccess"
  43. ref="poster" @on-error="posterError"></poster>
  44. <u-toast ref="uToast"></u-toast>
  45. </view>
  46. </template>
  47. <script>
  48. import Poster from '../../components/zhangyuhao-poster/Poster.vue'
  49. export default {
  50. components: {
  51. Poster
  52. },
  53. data() {
  54. return {
  55. userInfo: {},
  56. cardList: [],
  57. canvasData: {},
  58. currectData: {},
  59. list:[],
  60. selectCode: '',
  61. show: false,
  62. clicknum: 0,
  63. popupshow: false,
  64. show1: false,
  65. isShowCode: false,
  66. menuList: [{
  67. name: "我的名片",
  68. type: 'myInfo',
  69. src: '../../static/imgs/mySet/card.png'
  70. },
  71. {
  72. name: "我的主页",
  73. type: 'myHome',
  74. src: '../../static/imgs/mySet/home.png'
  75. },
  76. {
  77. name: "名片分类",
  78. type: "cardType",
  79. src: '../../static/imgs/mySet/type.png'
  80. },
  81. {
  82. name: "我的证件",
  83. type: "myCard",
  84. src: '../../static/imgs/mySet/card1.png'
  85. },
  86. {
  87. name: "帮助说明",
  88. type: "help",
  89. src: '../../static/imgs/mySet/help.png'
  90. },
  91. {
  92. name: "联系客服",
  93. type: "contactCustomer",
  94. src: '../../static/imgs/mySet/kf.png'
  95. },
  96. {
  97. name: "设置",
  98. type: 'set',
  99. src: '../../static/imgs/mySet/set.png'
  100. },
  101. ]
  102. };
  103. },
  104. onShow() {
  105. if (uni.getStorageSync("userInfo").phone) {
  106. this.userInfo = uni.getStorageSync("userInfo")
  107. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
  108. commonId: uni.getStorageSync("userInfo").id
  109. }, failres => {
  110. this.$refs.uToast.show({
  111. type: 'error',
  112. message: failres.errmsg,
  113. })
  114. uni.hideLoading()
  115. }).then(res => {
  116. this.list=res.data.items
  117. this.cardList = [res.data.items]
  118. if(res.data.items.length>0){
  119. this.cardChange({
  120. value: this.cardList[[0]]
  121. })
  122. }
  123. })
  124. } else {
  125. uni.switchTab({
  126. url: "/pages/cardHolder/cardHolder"
  127. })
  128. }
  129. },
  130. onShareAppMessage(res) {
  131. this.popupshow = false
  132. console.log(res, this.popupshow)
  133. let that = this;
  134. //生成名片图片
  135. let imageUrl = this.poster
  136. console.log("imageUrl", imageUrl)
  137. if (res.from === 'button') {
  138. let path = `/pages/mySet/lookCard?id=${that.currectData.id}`
  139. return {
  140. title: `${that.currectData.name}分享的名片~`,
  141. path: path,
  142. imageUrl: imageUrl,
  143. };
  144. }
  145. if (res.from === 'menu') {
  146. return {
  147. title: '我的',
  148. path: '/pages/tabBarPro/index/index',
  149. imageUrl: this.popupshow ? imageUrl : ''
  150. };
  151. }
  152. },
  153. methods: {
  154. handleHiddenShare() {
  155. this.popupshow = false
  156. },
  157. selectCard() {
  158. if(this.cardList[0].length>0){
  159. this.show = true
  160. }else if(this.cardList[0].length==0){
  161. this.$refs.uToast.show({
  162. type: 'error',
  163. message: '您还未创建名片',
  164. })
  165. }
  166. },
  167. selectCard1() {
  168. console.log(this.cardList[0])
  169. if(this.cardList[0].length>1){
  170. this.show1 = true
  171. }else if(this.cardList[0].length>0){
  172. this.cardConfirm({value:this.cardList[[0]]})
  173. }
  174. },
  175. cardConfirm(e) {
  176. console.log(e)
  177. this.currectData = e.value[0]
  178. this.selectCode = e.value[0].qrCodeMyself
  179. this.show1 = false
  180. this.isShowCode = true
  181. },
  182. cardChange(e) {
  183. this.currectData = e.value[0]
  184. uni.showLoading({
  185. title: '加载中',
  186. mask: true
  187. })
  188. var data = [{
  189. type: 'image',
  190. path: this.currectData.currentBackground,
  191. use: 'bg',
  192. x: -10,
  193. y: 0,
  194. width: 530,
  195. height: 325
  196. },
  197. {
  198. type: 'image',
  199. path: this.currectData.headSculpture,
  200. shape: 'circle',
  201. use: 'head',
  202. x: 30,
  203. y: 30,
  204. width: 100,
  205. height: 100
  206. },
  207. {
  208. type: 'text',
  209. text: this.currectData.name,
  210. use: 'name',
  211. x: 150,
  212. y: 50,
  213. size: 24,
  214. color: '#000'
  215. },
  216. {
  217. type: 'text',
  218. text: this.currectData.post,
  219. use: 'post',
  220. x: 240,
  221. y: 55,
  222. size: 18,
  223. color: '#666666'
  224. },
  225. {
  226. type: 'text',
  227. text: this.currectData.companyName,
  228. use: 'companyName',
  229. x: 150,
  230. y: 95,
  231. size: 18,
  232. color: '#000'
  233. },
  234. {
  235. type: 'image',
  236. path: '../../static/imgs/card/address1.png',
  237. use: 'address-icon',
  238. x: 145,
  239. y: 130,
  240. width: 15,
  241. height: 20
  242. },
  243. {
  244. type: 'textarea',
  245. text: this.currectData.province + this.currectData.city + this.currectData.area + this
  246. .currectData.detailedAddress,
  247. lineSpace: 1,
  248. width: 320,
  249. use: 'address',
  250. x: 175,
  251. y: 135,
  252. size: 14,
  253. color: '#000'
  254. },
  255. {
  256. type: 'image',
  257. path: '../../static/imgs/card/phone1.png',
  258. use: 'phone-icon',
  259. x: 145,
  260. y: 163,
  261. width: 16,
  262. height: 16
  263. },
  264. {
  265. type: 'text',
  266. text: this.currectData.phone,
  267. use: 'phone',
  268. x: 175,
  269. y: 167,
  270. size: 14,
  271. color: '#000'
  272. },
  273. {
  274. type: 'image',
  275. path: '../../static/imgs/card/remark1.png',
  276. use: 'remark-icon',
  277. x: 145,
  278. y: 197,
  279. width: 13,
  280. height: 16
  281. },
  282. {
  283. type: 'textarea',
  284. text: this.currectData.remark ? this.currectData.remark : '单击添加备注',
  285. use: 'remark',
  286. lineSpace: 2,
  287. width: 200,
  288. x: 175,
  289. y: 200,
  290. size: 13,
  291. color: '#000'
  292. },
  293. {
  294. type: 'image',
  295. path: '../../static/imgs/card/bgc1.png',
  296. use: 'bg1',
  297. x: 3,
  298. y: 243,
  299. width: 240,
  300. height: 67
  301. },
  302. {
  303. type: 'image',
  304. path: '../../static/imgs/card/bgc2.png',
  305. use: 'bg2',
  306. x: 225,
  307. y: 243,
  308. width: 278,
  309. height: 67
  310. },
  311. {
  312. type: 'image',
  313. path: '../../static/imgs/card/home.png',
  314. use: 'home',
  315. x: 30,
  316. y: 260,
  317. width: 33,
  318. height: 33
  319. },
  320. {
  321. type: 'image',
  322. path: '../../static/imgs/card/share.png',
  323. use: 'share',
  324. x: 90,
  325. y: 263,
  326. width: 33,
  327. height: 28
  328. },
  329. {
  330. type: 'image',
  331. path: '../../static/imgs/card/ewm.png',
  332. use: 'code',
  333. x: 150,
  334. y: 263,
  335. width: 32,
  336. height: 32
  337. },
  338. {
  339. type: 'text',
  340. text: '置顶',
  341. use: 'top',
  342. x: 280,
  343. y: 265,
  344. size: 24,
  345. color: '#fff'
  346. },
  347. {
  348. type: 'text',
  349. text: '删除',
  350. use: 'del',
  351. x: 350,
  352. y: 265,
  353. size: 24,
  354. color: '#fff'
  355. },
  356. {
  357. type: 'text',
  358. text: '编辑',
  359. use: 'edit',
  360. x: 420,
  361. y: 265,
  362. size: 24,
  363. color: '#fff'
  364. },
  365. ]
  366. console.log(this.currectData.cuttentTemplate, 111111)
  367. for (var i = 0; i < data.length; i++) {
  368. switch (this.currectData.cuttentTemplate) {
  369. case '2':
  370. if (data[i].use === 'name' ||
  371. data[i].use === 'companyName' ||
  372. data[i].use === 'address-icon' ||
  373. data[i].use === 'phone-icon' ||
  374. data[i].use === 'remark-icon') {
  375. data[i].x = 30
  376. }
  377. if (data[i].use === 'address-icon') {
  378. data[i].path = '../../static/imgs/card/address3.png'
  379. }
  380. if (data[i].use === 'phone-icon') {
  381. data[i].path = '../../static/imgs/card/phone3.png'
  382. }
  383. if (data[i].use === 'remark-icon') {
  384. data[i].path = '../../static/imgs/card/remark3.png'
  385. }
  386. if (data[i].use === 'post') {
  387. data[i].x = 100
  388. }
  389. if (data[i].use === 'address' ||
  390. data[i].use === 'phone' ||
  391. data[i].use === 'remark') {
  392. data[i].x = 60
  393. }
  394. if (data[i].use == 'head') {
  395. data[i].x = 370
  396. }
  397. break;
  398. case '3':
  399. if (data[i].use === 'name') {
  400. data[i].x = 30
  401. data[i].y = 150
  402. }
  403. if (data[i].use === 'companyName') {
  404. data[i].x = 30
  405. data[i].y = 180
  406. }
  407. if (data[i].use === 'post') {
  408. data[i].x = 100
  409. data[i].y = 153
  410. }
  411. if (data[i].use === 'address-icon' ||
  412. data[i].use === 'phone-icon' ||
  413. data[i].use === 'remark-icon') {
  414. data[i].x = 170
  415. }
  416. if (data[i].use === 'address-icon') {
  417. data[i].y = 150
  418. }
  419. if (data[i].use === 'address') {
  420. data[i].y = 155;
  421. data[i].width = 300
  422. }
  423. if (data[i].use === 'phone-icon') {
  424. data[i].y = 180
  425. }
  426. if (data[i].use === 'phone') {
  427. data[i].y = 183
  428. }
  429. if (data[i].use === 'remark-icon') {
  430. data[i].y = 210
  431. }
  432. if (data[i].use === 'remark') {
  433. data[i].y = 212
  434. }
  435. if (data[i].use === 'address' ||
  436. data[i].use === 'phone' ||
  437. data[i].use === 'remark') {
  438. data[i].x = 190
  439. }
  440. break;
  441. case '4':
  442. if (data[i].use === 'name' ||
  443. data[i].use === 'companyName') {
  444. data[i].x = 30
  445. }
  446. if (data[i].use === 'companyName') {
  447. data[i].y = 90
  448. }
  449. if (data[i].use === 'post') {
  450. data[i].x = 100
  451. }
  452. if (data[i].use == 'head') {
  453. data[i].x = 25
  454. data[i].y = 120
  455. }
  456. if (data[i].use === 'address-icon') {
  457. data[i].path = '../../static/imgs/card/address2.png'
  458. }
  459. if (data[i].use === 'phone-icon') {
  460. data[i].path = '../../static/imgs/card/phone2.png'
  461. }
  462. if (data[i].use === 'remark-icon') {
  463. data[i].path = '../../static/imgs/card/remark2.png'
  464. }
  465. if (data[i].use === 'address-icon' ||
  466. data[i].use === 'phone-icon' ||
  467. data[i].use === 'remark-icon') {
  468. data[i].x = 170
  469. }
  470. if (data[i].use === 'address') {
  471. data[i].width = 300
  472. }
  473. if (data[i].use === 'address' ||
  474. data[i].use === 'phone' ||
  475. data[i].use === 'remark') {
  476. data[i].x = 190
  477. }
  478. break;
  479. default:
  480. }
  481. }
  482. this.canvasData = {
  483. clicknum: this.clicknum++,
  484. list: data,
  485. page:'myInfo'
  486. }
  487. },
  488. posterError(err) {
  489. console.log(err)
  490. uni.hideLoading()
  491. },
  492. posterSuccess(url) {
  493. console.log("hahahah", url)
  494. // 生成成功,会把临时路径在这里返回
  495. this.poster = url;
  496. console.log(url)
  497. // this.show=false
  498. uni.hideLoading()
  499. },
  500. menuClick(typeName) {
  501. if (typeName == "contactCustomer") return
  502. let _url = '/pages/mySet/' + typeName
  503. uni.navigateTo({
  504. url: _url
  505. })
  506. }
  507. }
  508. }
  509. </script>
  510. <style lang="scss" scoped>
  511. .content1 {
  512. background: #112253;
  513. padding: 0rpx 20rpx 160rpx 20rpx;
  514. box-sizing: border-box;
  515. border-radius: 0px 0px 20rpx 20rpx;
  516. .user {
  517. color: #fff;
  518. .name {
  519. font-weight: 700;
  520. }
  521. }
  522. .img {
  523. width: 124rpx;
  524. border-radius: 50%;
  525. margin-right: 32rpx;
  526. }
  527. .position {
  528. display:flex;
  529. .right-img {
  530. width: 44rpx;
  531. margin-left: 40rpx;
  532. }
  533. }
  534. }
  535. .content2 {
  536. background: #fff;
  537. margin: 20rpx;
  538. padding: 0 40rpx;
  539. position: relative;
  540. top: -100rpx;
  541. border-radius: 20rpx;
  542. .nav-img {
  543. width: 32rpx;
  544. margin-right: 20rpx;
  545. }
  546. .row {
  547. border-bottom: 1px solid #E6E6E6;
  548. padding: 35rpx 0;
  549. .row-right-img {
  550. width: 12rpx;
  551. }
  552. }
  553. .row:last-child {
  554. border: none;
  555. }
  556. .left-btn {
  557. background: #fff;
  558. padding: 0;
  559. margin: 0;
  560. font-size: 32rpx;
  561. height: 42rpx;
  562. display: flex;
  563. align-items: center;
  564. }
  565. .left-btn:after {
  566. border: none !important;
  567. }
  568. }
  569. .shareBtn{
  570. background:transparent;
  571. line-height: 1;
  572. padding:0;
  573. }
  574. .shareBtn::after{
  575. border:none;
  576. }
  577. </style>