index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <template>
  2. <view class="content">
  3. <view class="content-box">
  4. <view class="top-main-box">
  5. <view class="zzbg">
  6. <image class="mpimg" src="/static/images/mpbg1.jpg" mode="widthFix"></image>
  7. </view>
  8. <view class="topmain">
  9. <view class="leftimg">
  10. <u-avatar size="60" :src="cardObj.head_img" shape="square"></u-avatar>
  11. </view>
  12. <view class="rightcont">
  13. <view class="name">{{cardObj.name}}</view>
  14. <view class="tip">{{cardObj.job}}</view>
  15. <view class="tipa">{{cardObj.company}}</view>
  16. </view>
  17. </view>
  18. <view class="btnmain">
  19. <u-icon name="map-fill"></u-icon><text>{{cardObj.address}}</text>
  20. </view>
  21. </view>
  22. <view class="top-mainb">
  23. <view class="conta">
  24. <view class="cont" v-if="cardObj.phone" @click="onPhone()">
  25. <view class="box">
  26. <u-icon name="phone-fill" color="#007AFF" size="40"> </u-icon>
  27. <view class="right">
  28. <text class="tit">拨打电话</text>
  29. <text>{{cardObj.phone}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="cont" v-if="cardObj.wechat" @click="onCopy(cardObj.wechat)">
  34. <view class="box">
  35. <u-icon name="weixin-fill" color="#007AFF" size="40"> </u-icon>
  36. <view class="right">
  37. <text class="tit">加微信</text>
  38. <text>{{cardObj.wechat}}</text>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="cont" v-if="cardObj.qq" @click="onCopy(cardObj.qq)">
  43. <view class="box">
  44. <u-icon name="qq-fill" color="#007AFF" size="40"> </u-icon>
  45. <view class="right">
  46. <text class="tit">QQ</text>
  47. <text>{{cardObj.qq}}</text>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="cont" v-if="cardObj.email" @click="onCopy(cardObj.email)">
  52. <view class="box">
  53. <u-icon name="email-fill" color="#007AFF" size="40"> </u-icon>
  54. <view class="right">
  55. <text class="tit">邮箱</text>
  56. <text>{{cardObj.email}}</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="top-maina">
  63. <button class="left" @click="onAdd()">
  64. 同步到通讯录
  65. </button>
  66. <button class="right" open-type="share">
  67. 分享名片
  68. </button>
  69. </view>
  70. <view class="top-mainc">
  71. <view class="left">
  72. <u-avatar-group :urls="headerList" size="35" gap="0.4" :default-url="headerImg" randomBgColor>
  73. </u-avatar-group>
  74. <text>{{visitorCount}}人浏览</text>
  75. </view>
  76. </view>
  77. <view class="top-main-tit">
  78. <u-icon name="file-text-fill" color="#007AFF" size="40"> </u-icon>
  79. <text>业务介绍</text>
  80. </view>
  81. <view class="top-maind">
  82. <view class="topmain">
  83. <view class="leftimg">
  84. <u-avatar size="60" :src="cardObj.head_img" shape="square"></u-avatar>
  85. </view>
  86. <view class="rightcont">
  87. <view class="name" v-if="!cardObj.intro">Hi~欢迎访问我的名片,了解更多内容请直接咨询我。</view>
  88. <view class="name" v-if="cardObj.intro">{{cardObj.intro}}</view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="bottom-block"></view>
  94. <view class="bottombtn" type="primary" @click="gotoEdit">编辑我的名片</view>
  95. </view>
  96. </template>
  97. <script>
  98. import {
  99. request
  100. } from '@/common/js/request'
  101. export default {
  102. data() {
  103. return {
  104. id: "",
  105. headerImg: "/static/images/userimg.png",
  106. cardObj: {},
  107. visitorList: [],
  108. visitorCount: 0,
  109. headerList: []
  110. }
  111. },
  112. async onShow(options) {
  113. console.log("onLoad options", options);
  114. const logged = uni.getStorageSync('logged');
  115. if (logged) {
  116. var id = uni.getStorageSync('id');
  117. var user = uni.getStorageSync('userInfo');
  118. if (id != null && id != "") {
  119. this.id = id;
  120. const card = await request('uni-card', 'getCard', {
  121. id: id,
  122. uid: user.id
  123. }, {
  124. showloading: true
  125. });
  126. if (card._id == "") {
  127. this.getDefault();
  128. } else {
  129. const visitorList = await request('uni-card', 'getVisitorList', {
  130. card_id: id,
  131. skip: 0,
  132. limit: 8
  133. }, {
  134. showloading: true
  135. });
  136. this.cardObj = card;
  137. this.visitorCount = visitorList.total;
  138. visitorList.items.forEach((arr, index) => {
  139. if (arr.head_img)
  140. this.headerList.push(arr.head_img)
  141. else
  142. this.headerList.push("/static/images/userimg.png")
  143. })
  144. }
  145. } else {
  146. const mycard = await request('uni-card', 'getMyCard', {
  147. uid: user.id
  148. }, {
  149. showloading: true
  150. });
  151. if (mycard._id == "") {
  152. this.getDefault();
  153. } else {
  154. const myVisitorList = await request('uni-card', 'getMyVisitorList', {
  155. uid: user.id,
  156. skip: 0,
  157. limit: 8
  158. }, {
  159. showloading: true
  160. });
  161. this.cardObj = mycard;
  162. this.visitorCount = myVisitorList.total;
  163. myVisitorList.items.forEach((arr, index) => {
  164. if (arr.head_img)
  165. this.headerList.push(arr.head_img)
  166. else
  167. this.headerList.push("/static/images/userimg.png")
  168. })
  169. }
  170. }
  171. }
  172. },
  173. onShareAppMessage(res) {
  174. if (this.id == "" || this.id == null) {
  175. this.id = "61b30b8091a7500001dea375"
  176. }
  177. return {
  178. title: '您好,这是我的名片,望惠存',
  179. path: '/pages/index?id=' + this.id
  180. }
  181. },
  182. methods: {
  183. async getDefault() {
  184. const card = await request('uni-card', 'getCard', {
  185. id: "61b30b8091a7500001dea375",
  186. uid: "61b30b4e7964120001e32f41"
  187. }, {
  188. showloading: true
  189. });
  190. if (card._id == "") {
  191. this.gotoEdit();
  192. }
  193. const visitorList = await request('uni-card', 'getVisitorList', {
  194. card_id: "61b30b8091a7500001dea375",
  195. skip: 0,
  196. limit: 8
  197. }, {
  198. showloading: true
  199. });
  200. this.cardObj = card;
  201. this.visitorCount = visitorList.total;
  202. visitorList.items.forEach((arr, index) => {
  203. if (arr.head_img)
  204. this.headerList.push(arr.head_img)
  205. else
  206. this.headerList.push("/static/images/userimg.png")
  207. })
  208. },
  209. onAdd() {
  210. uni.addPhoneContact({
  211. organization: this.cardObj.company,
  212. firstName: this.cardObj.name,
  213. title: this.cardObj.job,
  214. email: this.cardObj.email,
  215. mobilePhoneNumber: this.cardObj.phone,
  216. weChatNumber: this.cardObj.wechat,
  217. remark: this.cardObj.address,
  218. success: function() {
  219. console.log('success');
  220. },
  221. fail: function() {
  222. console.log('fail');
  223. }
  224. });
  225. },
  226. onPhone() {
  227. uni.makePhoneCall({
  228. phoneNumber: this.cardObj.phone,
  229. success: (res) => {
  230. console.log('调用成功!')
  231. },
  232. fail: (res) => {
  233. console.log('调用失败!')
  234. }
  235. })
  236. },
  237. onCopy(data) {
  238. uni.setClipboardData({
  239. data: data, //要被复制的内容
  240. success: function() {
  241. //重点~做笔记
  242. //在success中加入uni.hideToast()可以解决
  243. uni.showToast({
  244. title: '复制成功',
  245. duration: 2000,
  246. icon: 'none'
  247. });
  248. //以下就可自定义操作了~
  249. },
  250. fail: function(err) {
  251. uni.showToast({
  252. title: '复制失败',
  253. duration: 2000,
  254. icon: 'none'
  255. });
  256. }
  257. });
  258. },
  259. gotoEdit() {
  260. uni.navigateTo({
  261. url: "/pages/edit"
  262. })
  263. }
  264. }
  265. }
  266. </script>
  267. <style>
  268. page {
  269. background: #f7f7f7;
  270. }
  271. .content {
  272. display: flex;
  273. flex-direction: column;
  274. align-items: center;
  275. justify-content: center;
  276. }
  277. .content-box {
  278. width: 100%;
  279. box-sizing: border-box;
  280. padding: 0 5%;
  281. }
  282. .content-box .top-main-box {
  283. width: 100%;
  284. box-sizing: border-box;
  285. border-radius: 15rpx;
  286. height: 52vw;
  287. overflow: hidden;
  288. position: relative;
  289. box-shadow: 0px 0px 10px #cccccc;
  290. }
  291. .content-box .top-main-box .zzbg {
  292. width: 100%;
  293. position: absolute;
  294. top: 0;
  295. left: 0;
  296. background: rgba(139, 139, 139, 0.5);
  297. z-index: 1;
  298. }
  299. .content-box .top-main-box .mpimg {
  300. width: 100%;
  301. }
  302. .content-box .top-main-box .topmain {
  303. width: 100%;
  304. box-sizing: border-box;
  305. padding: 40rpx 5%;
  306. display: flex;
  307. align-items: flex-start;
  308. position: relative;
  309. z-index: 4;
  310. }
  311. .content-box .top-main-box .topmain .leftimg {
  312. width: 150rpx;
  313. height: 150rpx;
  314. border-radius: 15rpx;
  315. overflow: hidden;
  316. }
  317. .content-box .top-main-box .topmain .leftimg .tximg {
  318. width: 100%;
  319. }
  320. .content-box .top-main-box .topmain .rightcont {
  321. color: #fff;
  322. flex: 1;
  323. box-sizing: border-box;
  324. padding-left: 25rpx;
  325. }
  326. .content-box .top-main-box .topmain .rightcont .name {
  327. font-size: 42rpx;
  328. padding-bottom: 10rpx;
  329. }
  330. .content-box .top-main-box .topmain .rightcont .tip,
  331. .content-box .top-main-box .topmain .rightcont .tipa {
  332. font-size: 34rpx;
  333. text-shadow: 1px 1px 1px #000;
  334. }
  335. .content-box .top-main-box .btnmain {
  336. width: 100%;
  337. position: absolute;
  338. left: 0;
  339. bottom: 0px;
  340. z-index: 5;
  341. box-sizing: border-box;
  342. padding: 25rpx 5%;
  343. background: #fff;
  344. display: inline;
  345. align-items: center;
  346. justify-content: space-between;
  347. text-align: left;
  348. }
  349. .content-box .top-main-box .btnmain view {
  350. float: left;
  351. }
  352. .content-box .top-main-box .btnmain text {
  353. font-size: 24rpx;
  354. color: #333333;
  355. padding-left: 10rpx;
  356. float: left;
  357. }
  358. .content-box .top-maina {
  359. width: 100%;
  360. box-sizing: border-box;
  361. display: flex;
  362. align-items: center;
  363. justify-content: space-between;
  364. margin: 20rpx auto;
  365. }
  366. .content-box .top-maina view {
  367. width: 48%;
  368. border-radius: 15rpx;
  369. text-align: center;
  370. padding: 25rpx 0;
  371. font-size: 18px;
  372. }
  373. .content-box .top-maina .left {
  374. border: 1px solid #007AFF;
  375. color: #007AFF;
  376. width: 48%;
  377. }
  378. .content-box .top-maina .right {
  379. background: #007AFF;
  380. border: 1px solid #007AFF;
  381. color: #fff;
  382. width: 48%;
  383. }
  384. .content-box .top-mainb {
  385. width: 100%;
  386. overflow: scroll;
  387. padding: 15rpx 0;
  388. overflow-x: hidden;
  389. }
  390. .content-box .top-mainb .conta {
  391. width: 100%;
  392. overflow-x: auto;
  393. word-break: keep-all;
  394. /* 不换行 */
  395. white-space: nowrap;
  396. /* 不换行 */
  397. padding-bottom: 20rpx;
  398. }
  399. .content-box .top-mainb .conta .cont {
  400. display: inline-block;
  401. margin-right: 20rpx;
  402. background: #fff;
  403. box-shadow: 0px 0px 8px #cccccc;
  404. border-radius: 10rpx;
  405. overflow: hidden;
  406. }
  407. .content-box .top-mainb .conta .cont .box {
  408. display: flex;
  409. align-items: center;
  410. justify-content: space-between;
  411. box-sizing: border-box;
  412. padding: 15rpx 20rpx;
  413. }
  414. .content-box .top-mainb .conta .cont .box image {
  415. width: 80rpx;
  416. height: 80rpx;
  417. }
  418. .content-box .top-mainb .conta .cont .box .right {
  419. flex: 1;
  420. box-sizing: border-box;
  421. padding-left: 10rpx;
  422. }
  423. .content-box .top-mainb .conta .cont .box .right text {
  424. display: block;
  425. font-size: 30rpx;
  426. }
  427. .content-box .top-mainb .conta .cont .box .right .tit {
  428. font-size: 34rpx;
  429. }
  430. .content-box .top-mainc {
  431. width: 100%;
  432. box-sizing: border-box;
  433. padding: 20rpx 10rpx;
  434. display: flex;
  435. align-items: center;
  436. justify-content: space-between;
  437. margin: 10rpx auto;
  438. background: #fff;
  439. }
  440. .content-box .top-mainc .left {
  441. flex: 1;
  442. display: flex;
  443. align-items: center;
  444. }
  445. .content-box .top-mainc .left text {
  446. font-size: 28rpx;
  447. color: #555555;
  448. }
  449. .content-box .top-mainc .left image {
  450. width: 60rpx;
  451. height: 60rpx;
  452. margin-right: 5rpx;
  453. border-radius: 10rpx;
  454. }
  455. .content-box .top-mainc .right {
  456. display: flex;
  457. align-items: center;
  458. justify-content: space-between;
  459. }
  460. .content-box .top-mainc .right text {
  461. font-size: 28rpx;
  462. color: #555555;
  463. padding-right: 10rpx;
  464. }
  465. .content-box .top-mainc .right image {
  466. width: 40rpx;
  467. height: 40rpx;
  468. }
  469. .content-box .top-main-tit {
  470. width: 100%;
  471. box-sizing: border-box;
  472. padding: 20rpx 10rpx;
  473. display: flex;
  474. align-items: center;
  475. }
  476. .content-box .top-main-tit image {
  477. width: 60rpx;
  478. height: 60rpx;
  479. }
  480. .content-box .top-main-tit text {
  481. color: #333;
  482. font-size: 18px;
  483. padding-left: 10rpx;
  484. }
  485. .content-box .top-maind {
  486. width: 100%;
  487. box-sizing: border-box;
  488. padding: 40rpx 5%;
  489. background: #fff;
  490. box-shadow: 0px 0px 8px #cccccc;
  491. }
  492. .content-box .top-maind .topmain {
  493. width: 100%;
  494. box-sizing: border-box;
  495. display: flex;
  496. align-items: flex-start;
  497. }
  498. .content-box .top-maind .topmain .leftimg {
  499. width: 120rpx;
  500. height: 120rpx;
  501. border-radius: 15rpx;
  502. overflow: hidden;
  503. }
  504. .content-box .top-maind .topmain .leftimg .tximg {
  505. width: 100%;
  506. }
  507. .content-box .top-maind .topmain .rightcont {
  508. color: #555;
  509. flex: 1;
  510. box-sizing: border-box;
  511. padding-left: 25rpx;
  512. line-height: 42rpx;
  513. font-size: 28rpx;
  514. }
  515. .content-box .top-maind .toptip {
  516. width: 100%;
  517. }
  518. .content-box .top-maind .toptip .box {
  519. display: inline-block;
  520. margin-top: 25rpx;
  521. padding: 10rpx 15rpx;
  522. background: #e6e6e6;
  523. border-radius: 10rpx;
  524. overflow: hidden;
  525. margin-right: 20rpx;
  526. }
  527. .content-box .top-maind .toptip .box image {
  528. width: 30rpx;
  529. height: 30rpx;
  530. }
  531. .content-box .top-maind .toptip .box text {
  532. font-size: 28rpx;
  533. padding-left: 10rpx;
  534. }
  535. .bottombtn {
  536. position: fixed;
  537. bottom: 0;
  538. width: 100%;
  539. height: 60px;
  540. background: #007AFF;
  541. color: #fff;
  542. line-height: 60px;
  543. text-align: center;
  544. }
  545. .bottom-block {
  546. display: block;
  547. width: 100%;
  548. height: 80px;
  549. }
  550. </style>