mySet.vue 12 KB

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