mySet.vue 14 KB

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