mySet.vue 13 KB

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