mySet.vue 13 KB

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