mySet.vue 14 KB

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