mySet.vue 12 KB

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