mySet.vue 14 KB

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