mySet.vue 12 KB

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