mySet.vue 14 KB

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