index.vue 12 KB

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