mySet.vue 13 KB

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