mySet.vue 12 KB

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