index.vue 12 KB

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