mySet.vue 14 KB

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