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 @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. index:0,
  60. selectCode: '',
  61. show: false,
  62. clicknum: 0,
  63. popupshow: false,
  64. show1: false,
  65. isShowCode: false,
  66. menuList: [{
  67. name: "我的名片",
  68. type: 'myInfo',
  69. src: '../../static/imgs/mySet/card.png'
  70. },
  71. {
  72. name: "我的主页",
  73. type: 'myHome',
  74. src: '../../static/imgs/mySet/home.png'
  75. },
  76. {
  77. name: "名片分类",
  78. type: "cardType",
  79. src: '../../static/imgs/mySet/type.png'
  80. },
  81. {
  82. name: "我的证件",
  83. type: "myCard",
  84. src: '../../static/imgs/mySet/card1.png'
  85. },
  86. {
  87. name: "帮助说明",
  88. type: "help",
  89. src: '../../static/imgs/mySet/help.png'
  90. },
  91. {
  92. name: "联系客服",
  93. type: "contactCustomer",
  94. src: '../../static/imgs/mySet/kf.png'
  95. },
  96. {
  97. name: "设置",
  98. type: 'set',
  99. src: '../../static/imgs/mySet/set.png'
  100. },
  101. ]
  102. };
  103. },
  104. onShow() {
  105. if (uni.getStorageSync("userInfo").phone) {
  106. this.userInfo = uni.getStorageSync("userInfo")
  107. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
  108. commonId: uni.getStorageSync("userInfo").id
  109. }, failres => {
  110. this.$refs.uToast.show({
  111. type: 'error',
  112. message: failres.errmsg,
  113. })
  114. uni.hideLoading()
  115. }).then(res => {
  116. this.list=res.data.items
  117. this.cardList = [res.data.items]
  118. })
  119. } else {
  120. uni.switchTab({
  121. url: "/pages/cardHolder/cardHolder"
  122. })
  123. }
  124. },
  125. onShareAppMessage(res) {
  126. this.popupshow = false
  127. console.log(res, this.popupshow)
  128. let that = this;
  129. //生成名片图片
  130. let imageUrl = this.poster
  131. console.log("imageUrl", imageUrl)
  132. if (res.from === 'button') {
  133. let path = `/pages/cardHolder/scanCodeAddCard?id=${that.currectData.id}`
  134. return {
  135. title: `${that.currectData.name}分享的名片~`,
  136. path: path,
  137. imageUrl: imageUrl,
  138. };
  139. }
  140. if (res.from === 'menu') {
  141. return {
  142. title: '名片Box',
  143. path: '/pages/cardHolder/cardHolder',
  144. imageUrl:''
  145. };
  146. }
  147. },
  148. methods: {
  149. handleHiddenShare() {
  150. this.popupshow = false
  151. },
  152. selectCard() {
  153. if(this.cardList[0].length>0){
  154. this.index=0
  155. this.cardChange({
  156. value: this.cardList[[0]]
  157. })
  158. }else if(this.list.length==0){
  159. this.$refs.uToast.show({
  160. type: 'error',
  161. message: '您还未创建名片',
  162. })
  163. }
  164. },
  165. selectCard1() {
  166. if(this.list.length>1){
  167. this.show1 = true
  168. }else if(this.list.length>0){
  169. this.cardConfirm({value:this.cardList[[0]]})
  170. }
  171. },
  172. cardConfirm(e) {
  173. console.log(e)
  174. this.currectData = e.value[0]
  175. this.selectCode = e.value[0].qrCodeMyself
  176. this.show1 = false
  177. this.isShowCode = true
  178. },
  179. cardChange(e) {
  180. console.log(e)
  181. this.currectData = e.value[0]
  182. uni.showLoading({
  183. title: '加载中',
  184. mask: true
  185. })
  186. var data = [{
  187. type: 'image',
  188. path: this.currectData.currentBackground,
  189. use: 'bg',
  190. x: -10,
  191. y: 0,
  192. width: 530,
  193. height: 325
  194. },
  195. {
  196. type: 'image',
  197. path: this.currectData.headSculpture?this.currectData.headSculpture:'../../static/imgs/card/defaulthead.png',
  198. shape: 'circle',
  199. use: 'head',
  200. imageType:this.currectData.headSculpture?'wl':'bd',
  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. if(this.index==0){
  451. this.show=true
  452. }
  453. // this.show=false
  454. uni.hideLoading()
  455. },
  456. menuClick(typeName) {
  457. if (typeName == "contactCustomer") return
  458. let _url = '/pages/mySet/' + typeName
  459. uni.navigateTo({
  460. url: _url
  461. })
  462. }
  463. }
  464. }
  465. </script>
  466. <style lang="scss" scoped>
  467. .content1 {
  468. background: #112253;
  469. padding: 0rpx 20rpx 160rpx 20rpx;
  470. box-sizing: border-box;
  471. border-radius: 0px 0px 20rpx 20rpx;
  472. .user {
  473. color: #fff;
  474. .name {
  475. font-weight: 700;
  476. }
  477. }
  478. .img {
  479. width: 124rpx;
  480. border-radius: 50%;
  481. margin-right: 32rpx;
  482. }
  483. .position {
  484. display:flex;
  485. .right-img {
  486. width: 44rpx;
  487. margin-left: 40rpx;
  488. }
  489. }
  490. }
  491. .content2 {
  492. background: #fff;
  493. margin: 20rpx;
  494. padding: 0 40rpx;
  495. position: relative;
  496. top: -100rpx;
  497. border-radius: 20rpx;
  498. .nav-img {
  499. width: 32rpx;
  500. margin-right: 20rpx;
  501. }
  502. .row {
  503. border-bottom: 1px solid #E6E6E6;
  504. padding: 35rpx 0;
  505. .row-right-img {
  506. width: 12rpx;
  507. }
  508. }
  509. .row:last-child {
  510. border: none;
  511. }
  512. .left-btn {
  513. background: #fff;
  514. padding: 0;
  515. margin: 0;
  516. font-size: 32rpx;
  517. height: 42rpx;
  518. display: flex;
  519. align-items: center;
  520. }
  521. .left-btn:after {
  522. border: none !important;
  523. }
  524. }
  525. .shareBtn{
  526. background:transparent;
  527. line-height: 1;
  528. padding:0;
  529. }
  530. .shareBtn::after{
  531. border:none;
  532. }
  533. </style>