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