mySet.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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. </image>
  13. <image @click='selectCard1' src="../../static/imgs/mySet/ewm.png" mode="widthFix" class="right-img">
  14. </image>
  15. </view>
  16. </view>
  17. <view class="content2">
  18. <view class="row flex flex-between" v-for="(item,index) in menuList" :key='index'
  19. @click="menuClick(item.type)">
  20. <view class="flex">
  21. <image :src="item.src" mode="widthFix" class="nav-img"></image>
  22. <button class="left-btn" v-if='item.type=="contactCustomer"'
  23. open-type='contact'>{{item.name}}</button>
  24. <span class="left" v-else>{{item.name}}</span>
  25. </view>
  26. <span class="right">
  27. <image src="../../static/imgs/mySet/yjt.png" mode="widthFix" class="row-right-img"></image>
  28. </span>
  29. </view>
  30. </view>
  31. <u-popup :show="isShowCode" @close="isShowCode=false" mode="center" :round='10'>
  32. <image :src="selectCode" mode="widthFix"></image>
  33. </u-popup>
  34. <u-picker keyName="cardBusiness" :confirmType='"share"' :confirmText='"分享"' title="选择名片" @cancel="show=false"
  35. closeOnClickOverlay @change="cardChange" :show="show" :columns="cardList"></u-picker>
  36. <u-picker keyName="cardBusiness" confirmText='确定' title="选择名片" @cancel="show1=false" closeOnClickOverlay
  37. @confirm="cardConfirm" :show="show1" :columns="cardList"></u-picker>
  38. <poster :data="canvasData" background-color="#FFF" :width='750' :height='420' @on-success="posterSuccess"
  39. ref="poster" @on-error="posterError"></poster>
  40. </view>
  41. </template>
  42. <script>
  43. import Poster from '../../components/zhangyuhao-poster/Poster.vue'
  44. export default {
  45. components: {
  46. Poster
  47. },
  48. data() {
  49. return {
  50. userInfo: {},
  51. cardList: [],
  52. canvasData: {},
  53. currectData: {},
  54. selectCode: '',
  55. show: false,
  56. clicknum: 0,
  57. popupshow: false,
  58. show1: false,
  59. isShowCode: false,
  60. menuList: [{
  61. name: "我的名片",
  62. type: 'myInfo',
  63. src: '../../static/imgs/mySet/card.png'
  64. },
  65. {
  66. name: "我的主页",
  67. type: 'myHome',
  68. src: '../../static/imgs/mySet/home.png'
  69. },
  70. {
  71. name: "名片分类",
  72. type: "cardType",
  73. src: '../../static/imgs/mySet/type.png'
  74. },
  75. {
  76. name: "我的证件",
  77. type: "myCard",
  78. src: '../../static/imgs/mySet/card1.png'
  79. },
  80. {
  81. name: "帮助说明",
  82. type: "help",
  83. src: '../../static/imgs/mySet/help.png'
  84. },
  85. {
  86. name: "联系客服",
  87. type: "contactCustomer",
  88. src: '../../static/imgs/mySet/kf.png'
  89. },
  90. {
  91. name: "设置",
  92. type: 'set',
  93. src: '../../static/imgs/mySet/set.png'
  94. },
  95. ]
  96. };
  97. },
  98. onShow() {
  99. this.userInfo = uni.getStorageSync("userInfo")
  100. console.log(this.userInfo)
  101. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
  102. commonId: uni.getStorageSync("userInfo").id
  103. }, failres => {
  104. this.$refs.uToast.show({
  105. type: 'error',
  106. message: failres.errmsg,
  107. })
  108. uni.hideLoading()
  109. }).then(res => {
  110. this.cardList = [res.data.items]
  111. this.cardChange({
  112. value: this.cardList[[0]]
  113. })
  114. })
  115. },
  116. onShareAppMessage(res) {
  117. this.popupshow = false
  118. console.log(res, this.popupshow)
  119. let that = this;
  120. //生成名片图片
  121. let imageUrl = this.poster
  122. console.log("imageUrl", imageUrl)
  123. if (res.from === 'button') {
  124. let path = `/pages/mySet/lookCard?id=${that.currectData.id}`
  125. return {
  126. title: `${that.currectData.name}分享的名片~`,
  127. path: path,
  128. imageUrl: imageUrl,
  129. };
  130. }
  131. if (res.from === 'menu') {
  132. return {
  133. title: '商通线上商城',
  134. path: '/pages/tabBarPro/index/index',
  135. imageUrl: this.popupshow ? imageUrl : ''
  136. };
  137. }
  138. },
  139. // 分享到朋友圈
  140. onShareTimeline() {
  141. return {
  142. title: '商通线上商城',
  143. path: '/pages/index/index',
  144. imageUrl: 'https://cdn.uviewui.com/uview/swiper/1.jpg'
  145. };
  146. },
  147. methods: {
  148. handleHiddenShare() {
  149. this.popupshow = false
  150. },
  151. selectCard() {
  152. this.show = true
  153. },
  154. selectCard1() {
  155. this.show1 = true
  156. },
  157. cardConfirm(e) {
  158. console.log(e)
  159. this.currectData = e.value[0]
  160. this.selectCode = e.value[0].qrCodeMyself
  161. this.show1 = false
  162. this.isShowCode = true
  163. },
  164. cardChange(e) {
  165. this.currectData = e.value[0]
  166. uni.showLoading({
  167. title: '加载中',
  168. mask: true
  169. })
  170. var data = [{
  171. type: 'image',
  172. path: this.currectData.currentBackground,
  173. use: 'bg',
  174. x: -10,
  175. y: 0,
  176. width: 530,
  177. height: 325
  178. },
  179. {
  180. type: 'image',
  181. path: this.currectData.headSculpture,
  182. shape: 'circle',
  183. use: 'head',
  184. x: 30,
  185. y: 30,
  186. width: 100,
  187. height: 100
  188. },
  189. {
  190. type: 'text',
  191. text: this.currectData.name,
  192. use: 'name',
  193. x: 150,
  194. y: 50,
  195. size: 24,
  196. color: '#000'
  197. },
  198. {
  199. type: 'text',
  200. text: this.currectData.post,
  201. use: 'post',
  202. x: 240,
  203. y: 55,
  204. size: 18,
  205. color: '#666666'
  206. },
  207. {
  208. type: 'text',
  209. text: this.currectData.companyName,
  210. use: 'companyName',
  211. x: 150,
  212. y: 95,
  213. size: 18,
  214. color: '#000'
  215. },
  216. {
  217. type: 'image',
  218. path: '../../static/imgs/card/address1.png',
  219. use: 'address-icon',
  220. x: 145,
  221. y: 130,
  222. width: 15,
  223. height: 20
  224. },
  225. {
  226. type: 'textarea',
  227. text: this.currectData.province + this.currectData.city + this.currectData.area + this
  228. .currectData.detailedAddress,
  229. lineSpace: 1,
  230. width: 320,
  231. use: 'address',
  232. x: 175,
  233. y: 135,
  234. size: 14,
  235. color: '#000'
  236. },
  237. {
  238. type: 'image',
  239. path: '../../static/imgs/card/phone1.png',
  240. use: 'phone-icon',
  241. x: 145,
  242. y: 163,
  243. width: 16,
  244. height: 16
  245. },
  246. {
  247. type: 'text',
  248. text: this.currectData.phone,
  249. use: 'phone',
  250. x: 175,
  251. y: 167,
  252. size: 14,
  253. color: '#000'
  254. },
  255. {
  256. type: 'image',
  257. path: '../../static/imgs/card/remark1.png',
  258. use: 'remark-icon',
  259. x: 145,
  260. y: 197,
  261. width: 13,
  262. height: 16
  263. },
  264. {
  265. type: 'textarea',
  266. text: this.currectData.remark ? this.currectData.remark : '单击添加备注',
  267. use: 'remark',
  268. lineSpace: 2,
  269. width: 200,
  270. x: 175,
  271. y: 200,
  272. size: 13,
  273. color: '#000'
  274. },
  275. {
  276. type: 'image',
  277. path: '../../static/imgs/card/bg3.png',
  278. use: 'bg1',
  279. x: 0,
  280. y: 243,
  281. width: 370,
  282. height: 67
  283. },
  284. {
  285. type: 'image',
  286. path: '../../static/imgs/card/bg4.png',
  287. use: 'bg2',
  288. x: 355,
  289. y: 243,
  290. width: 150,
  291. height: 67
  292. },
  293. {
  294. type: 'image',
  295. path: '../../static/imgs/card/home.png',
  296. use: 'home',
  297. x: 65,
  298. y: 260,
  299. width: 33,
  300. height: 33
  301. },
  302. {
  303. type: 'text',
  304. text: this.currectData.classifyName ? this.currectData.classifyName : '默',
  305. use: 'classify',
  306. x: 145,
  307. y: 263,
  308. size: 34,
  309. color: '#fff'
  310. },
  311. {
  312. type: 'image',
  313. path: '../../static/imgs/card/share.png',
  314. use: 'share',
  315. x: 235,
  316. y: 263,
  317. width: 33,
  318. height: 28
  319. },
  320. ]
  321. console.log(this.currectData.cuttentTemplate, 111111)
  322. for (var i = 0; i < data.length; i++) {
  323. switch (this.currectData.cuttentTemplate) {
  324. case '2':
  325. if (data[i].use === 'name' ||
  326. data[i].use === 'companyName' ||
  327. data[i].use === 'address-icon' ||
  328. data[i].use === 'phone-icon' ||
  329. data[i].use === 'remark-icon') {
  330. data[i].x = 30
  331. }
  332. if (data[i].use === 'post') {
  333. data[i].x = 100
  334. }
  335. if (data[i].use === 'address' ||
  336. data[i].use === 'phone' ||
  337. data[i].use === 'remark') {
  338. data[i].x = 60
  339. }
  340. if (data[i].use == 'head') {
  341. data[i].x = 370
  342. }
  343. break;
  344. case '3':
  345. if (data[i].use === 'name') {
  346. data[i].x = 30
  347. data[i].y = 150
  348. }
  349. if (data[i].use === 'companyName') {
  350. data[i].x = 30
  351. data[i].y = 180
  352. }
  353. if (data[i].use === 'post') {
  354. data[i].x = 100
  355. data[i].y = 153
  356. }
  357. if (data[i].use === 'address-icon' ||
  358. data[i].use === 'phone-icon' ||
  359. data[i].use === 'remark-icon') {
  360. data[i].x = 170
  361. }
  362. if (data[i].use === 'address-icon') {
  363. data[i].y = 150
  364. }
  365. if (data[i].use === 'address') {
  366. data[i].y = 155;
  367. data[i].width = 300
  368. }
  369. if (data[i].use === 'phone-icon') {
  370. data[i].y = 180
  371. }
  372. if (data[i].use === 'phone') {
  373. data[i].y = 183
  374. }
  375. if (data[i].use === 'remark-icon') {
  376. data[i].y = 210
  377. }
  378. if (data[i].use === 'remark') {
  379. data[i].y = 212
  380. }
  381. if (data[i].use === 'address' ||
  382. data[i].use === 'phone' ||
  383. data[i].use === 'remark') {
  384. data[i].x = 190
  385. }
  386. break;
  387. case '4':
  388. if (data[i].use === 'name' ||
  389. data[i].use === 'companyName') {
  390. data[i].x = 30
  391. }
  392. if (data[i].use === 'companyName') {
  393. data[i].y = 90
  394. }
  395. if (data[i].use === 'post') {
  396. data[i].x = 100
  397. }
  398. if (data[i].use == 'head') {
  399. data[i].x = 25
  400. data[i].y = 120
  401. }
  402. if (data[i].use === 'address-icon' ||
  403. data[i].use === 'phone-icon' ||
  404. data[i].use === 'remark-icon') {
  405. data[i].x = 170
  406. }
  407. if (data[i].use === 'address') {
  408. data[i].width = 300
  409. }
  410. if (data[i].use === 'address' ||
  411. data[i].use === 'phone' ||
  412. data[i].use === 'remark') {
  413. data[i].x = 190
  414. }
  415. break;
  416. default:
  417. }
  418. }
  419. this.canvasData = {
  420. clicknum: this.clicknum++,
  421. list: data
  422. }
  423. },
  424. posterError(err) {
  425. console.log(err)
  426. uni.hideLoading()
  427. },
  428. posterSuccess(url) {
  429. console.log("hahahah", url)
  430. // 生成成功,会把临时路径在这里返回
  431. this.poster = url;
  432. console.log(url)
  433. // this.show=false
  434. uni.hideLoading()
  435. },
  436. menuClick(typeName) {
  437. if (typeName == "contactCustomer") return
  438. let _url = '/pages/mySet/' + typeName
  439. uni.navigateTo({
  440. url: _url
  441. })
  442. }
  443. }
  444. }
  445. </script>
  446. <style lang="scss" scoped>
  447. .content1 {
  448. background: #112253;
  449. padding: 0rpx 20rpx 160rpx 20rpx;
  450. box-sizing: border-box;
  451. border-radius: 0px 0px 20rpx 20rpx;
  452. .user {
  453. color: #fff;
  454. .name {
  455. font-weight: 700;
  456. }
  457. }
  458. .img {
  459. width: 124rpx;
  460. border-radius: 50%;
  461. margin-right: 32rpx;
  462. }
  463. .position {
  464. .right-img {
  465. width: 44rpx;
  466. margin-left: 40rpx;
  467. }
  468. }
  469. }
  470. .content2 {
  471. background: #fff;
  472. margin: 20rpx;
  473. padding: 0 40rpx;
  474. position: relative;
  475. top: -100rpx;
  476. border-radius: 20rpx;
  477. .nav-img {
  478. width: 32rpx;
  479. margin-right: 20rpx;
  480. }
  481. .row {
  482. border-bottom: 1px solid #E6E6E6;
  483. padding: 35rpx 0;
  484. .row-right-img {
  485. width: 12rpx;
  486. }
  487. }
  488. .row:last-child {
  489. border: none;
  490. }
  491. .left-btn {
  492. background: #fff;
  493. padding: 0;
  494. margin: 0;
  495. font-size: 32rpx;
  496. height: 42rpx;
  497. display: flex;
  498. align-items: center;
  499. }
  500. .left-btn:after {
  501. border: none !important;
  502. }
  503. }
  504. </style>