mySet.vue 12 KB

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