mySet.vue 12 KB

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