mySet.vue 14 KB

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