index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <view class="pageIndex">
  3. <uni-menubar title="我的名片" />
  4. <view class="pure_top"></view>
  5. <template v-if="user.uid">
  6. <template v-if='user.card_id>0'>
  7. <view>
  8. <tm-sheet :shadow="25">
  9. <view class="visitor-box text-size-s">
  10. <view class="visitor-items">
  11. <view>
  12. <image class="visitor-user-avatar" :src="userInfo.picture"></image>
  13. </view>
  14. <view class="visitor-items-user">
  15. <view class="text-weight-b">{{userInfo.name}}({{userInfo.title}})</view>
  16. <view class="visitor-items-content">{{userInfo.industry}}</view>
  17. <view class="visitor-items-content">{{userInfo.company}}</view>
  18. </view>
  19. </view>
  20. <view>
  21. <image :src="ewm" style="width: 80rpx;height: 80rpx;" mode="" @click="previewImage"></image>
  22. </view>
  23. </view>
  24. <view class="my-20 visitor-items-userInfo">
  25. <tm-icons class="mr-20" name="icon-phone"></tm-icons>{{userInfo.mobile}}
  26. </view>
  27. <view class="visitor-items-userInfo">
  28. <tm-icons class="mr-20" name="icon-mail"></tm-icons>{{userInfo.email}}
  29. </view>
  30. <view class="my-20 visitor-items-userInfo">
  31. <tm-icons class="mr-20" name="icon-aliwangwang"></tm-icons>{{userInfo.wx}}
  32. </view>
  33. <view class="my-20 visitor-items-userInfo">
  34. <tm-icons class="mr-20" name="icon-position-fill"></tm-icons>
  35. {{userInfo.cityAdress || ''}}{{userInfo.address}}
  36. </view>
  37. </tm-sheet>
  38. <view class="mx-32 my-50">
  39. <tm-row>
  40. <tm-col :grid="4">
  41. <tm-badges :offset="[-10,-15]" :dot="false" :label="userInfo.views"></tm-badges>
  42. <view>
  43. <tm-icons name="icon-eye"></tm-icons>
  44. <text class="pl-10"> 人气 </text>
  45. </view>
  46. </tm-col>
  47. <tm-col :grid="4">
  48. <tm-badges v-if="userInfo.collected" :offset="[-10,-15]" :dot="false" :label="userInfo.collected"></tm-badges>
  49. <view>
  50. <tm-icons name="icon-collection"></tm-icons>
  51. <text class="pl-10"> 收藏 </text>
  52. </view>
  53. </tm-col>
  54. <tm-col :grid="4">
  55. <tm-badges v-if="userInfo.recommend" :offset="[-10,-15]" :dot="false" :label="userInfo.recommend"></tm-badges>
  56. <view>
  57. <tm-icons name="icon-like"></tm-icons>
  58. <text class="pl-10"> 点赞 </text>
  59. </view>
  60. </tm-col>
  61. </tm-row>
  62. </view>
  63. <view class="my-20 mx-32">
  64. <tm-button openType="share" :theme="`bg-gradient-${$tm.vx.state().tmVuetify.color}-accent`" :round="24" block>发名片
  65. </tm-button>
  66. </view>
  67. <view class="my-20 mx-32">
  68. <tm-button @click="goDetail()" :text="true" :round="24" block>预览名片
  69. </tm-button>
  70. </view>
  71. <tm-sheet :shadow="25">
  72. <view class="px-32 mb-20 text-weight-b text-overflow-2 text-size-g"
  73. style="width: 100%; box-sizing: border-box;">
  74. 我的
  75. </view>
  76. <tm-grid :grid="4" @change="change" :list="list"></tm-grid>
  77. </tm-sheet>
  78. <view class="px-32 mb-20 text-weight-b text-overflow-2 text-size-g"
  79. style="width: 100%; box-sizing: border-box;">
  80. 最近访客
  81. </view>
  82. <view v-if="visitorList.length>0">
  83. <tm-sheet :shadow="4" v-for="(item,index) in visitorList" :key="index">
  84. <view class="visitor-box text-size-s">
  85. <view class="visitor-items">
  86. <view>
  87. <tm-avatar size="120" :src="item.avatar"></tm-avatar>
  88. </view>
  89. <view class="visitor-items-user">
  90. <view class="text-weight-b">{{item.nickname?item.nickname:'游客'}}</view>
  91. <view class="visitor-items-content">{{item.label}}</view>
  92. </view>
  93. </view>
  94. <view>
  95. <tm-menu @change="menuListClick(item,$event)" direction="top" black
  96. tip-direction="right" :list="['发起聊天','查看轨迹']">
  97. <tm-icons name="icon-gengduo" color="darkgray"></tm-icons>
  98. </tm-menu>
  99. </view>
  100. </view>
  101. </tm-sheet>
  102. <view style="height: 50rpx;"></view>
  103. </view>
  104. <view v-else>
  105. <tm-sheet>
  106. <tm-empty icon="icon-cry-fill" label="您还没有访客"></tm-empty>
  107. </tm-sheet>
  108. </view>
  109. </view>
  110. <!-- <tm-shareSheet @change="onclick" :actions="shareList" v-model="shareShow"></tm-shareSheet> -->
  111. </template>
  112. <view class="mt-50" v-else>
  113. <view style="height: 200rpx;"></view>
  114. <view style="display: flex;justify-content: space-around;">
  115. <tm-button @click="register" :font-size="24" :round="24" theme="bg-gradient-blue-accent" size="g">
  116. 立即注册
  117. </tm-button>
  118. </view>
  119. </view>
  120. </template>
  121. <l-painter ref="painter" style="position:fixed;top:-100000000px" />
  122. <uni-tabBar v-if='user.card_id>0'/>
  123. <uni-suspension v-if='user.card_id>0' />
  124. </view>
  125. </template>
  126. <script>
  127. export default {
  128. data() {
  129. return {
  130. shareShow: false,
  131. shareList: [
  132. [{
  133. name: "发名片",
  134. icon: "icon-terminal",
  135. type: "share"
  136. },
  137. {
  138. name: "扫一扫",
  139. icon: "icon-scan",
  140. type: "scan"
  141. },
  142. ]
  143. ],
  144. value: '',
  145. list: [],
  146. poster: {},
  147. urlImg: "",
  148. userInfo: {},
  149. ewm:''
  150. }
  151. },
  152. computed: {
  153. user() {
  154. return this.$tm.vx.state().user.userInfo || {}
  155. },
  156. visitorList() {
  157. return this.$tm.vx.state().track.trackList || []
  158. }
  159. },
  160. onShareAppMessage(res) {
  161. return {
  162. title: '您好,这是我的名片,请惠存',
  163. path: '/pages/index/detail?card_id=' + this.user.card_id,
  164. imageUrl: this.urlImg
  165. }
  166. },
  167. onLoad() {
  168. uni.$on('onTrack', function(data) {
  169. that.visitorList = data.data
  170. })
  171. },
  172. onPullDownRefresh() {
  173. this.$tm.request.get('card/read').then(res => {
  174. if (res.data.card_id) {
  175. this.userInfo = res.data
  176. this.showCard()
  177. this.$tm.request.post('index/common').then(res => {
  178. this.list = res.data.index_grid
  179. })
  180. }
  181. })
  182. },
  183. async onShow() {
  184. await this.$tm.request.get('card/read').then(res => {
  185. if (res.data.card_id) {
  186. this.userInfo = res.data
  187. this.$tm.request.post('index/common').then(res => {
  188. this.list = res.data.index_grid
  189. this.showCard(res.data.share_thumb)
  190. })
  191. this.$tm.request.post('card/qr', {
  192. page: "/pages/index/index",
  193. scene: "card_id=" + res.data.card_id
  194. }).then(res => {
  195. this.ewm = res.data
  196. })
  197. }
  198. })
  199. },
  200. methods: {
  201. register() {
  202. uni.navigateTo({
  203. url: '/subpages/pages/card/addCard'
  204. })
  205. },
  206. menuListClick(item, e) {
  207. if (e.index === 0) {
  208. uni.navigateTo({
  209. url: "/subpages/pages/card/cardChat?t_uid=" + item.uid + '&name=' + item.nickname +
  210. '&card_id=' + this.userInfo.card_id
  211. })
  212. } else if (e.index === 1) {
  213. uni.navigateTo({
  214. url: "/subpages/pages/radar/drawPage?id=" + item.uid
  215. })
  216. }
  217. },
  218. showCard(share_thumb) {
  219. this.poster = {
  220. css: {
  221. width: '500rpx',
  222. height: '400rpx',
  223. background: share_thumb.bg
  224. },
  225. views: [{
  226. src: this.userInfo.picture,
  227. type: "image",
  228. css: {
  229. objectFit: "cover",
  230. marginLeft: "20rpx",
  231. marginTop: "40rpx",
  232. width: "100rpx",
  233. border: "2rpx solid #fff",
  234. boxSizing: "border-box",
  235. height: "100rpx",
  236. borderRadius: "50%"
  237. }
  238. },
  239. {
  240. type: "view",
  241. css: {
  242. paddingLeft: "10rpx",
  243. display: "inline-block",
  244. marginTop: "50rpx",
  245. marginLeft: "20rpx",
  246. },
  247. views: [{
  248. text: this.userInfo.name,
  249. type: "text",
  250. css: {
  251. display: "block",
  252. color: share_thumb.fontColor,
  253. fontSize: "28rpx",
  254. fontWeight: "bold"
  255. }
  256. },
  257. {
  258. text: this.userInfo.company,
  259. type: "text",
  260. css: {
  261. color: share_thumb.fontColor,
  262. fontSize: "24rpx",
  263. marginTop: "10rpx",
  264. },
  265. }
  266. ],
  267. },
  268. {
  269. css: {
  270. marginLeft: "20rpx",
  271. padding: "12rpx",
  272. boxSizing: "border-box",
  273. width: "500rpx",
  274. height:"400rpx"
  275. },
  276. views: [{
  277. views: [{
  278. type: "view",
  279. css: {
  280. width: "460rpx",
  281. color: share_thumb.fontColor,
  282. display: "inline-block",
  283. fontSize: "24rpx",
  284. },
  285. views: [
  286. {
  287. text: "电话:" + this.userInfo.mobile,
  288. type: "text",
  289. css: {
  290. display: "block",
  291. paddingBottom: "10rpx",
  292. fontWeight: "bold"
  293. }
  294. },
  295. {
  296. text: "微信:" + this.userInfo.wx,
  297. type: "text",
  298. css: {
  299. display: "block",
  300. paddingBottom: "10rpx",
  301. fontWeight: "bold"
  302. }
  303. },
  304. {
  305. text: "地址:" + this.userInfo.cityAdress + this.userInfo.address,
  306. type: "text",
  307. css: {
  308. display: "block",
  309. paddingBottom: "10rpx",
  310. fontWeight: "bold"
  311. },
  312. },
  313. {
  314. text: "邮箱:" + this.userInfo.email,
  315. type: "text",
  316. css: {
  317. display: "block",
  318. paddingBottom: "10rpx",
  319. fontWeight: "bold"
  320. },
  321. }
  322. ],
  323. }, ],
  324. type: "view"
  325. }],
  326. type: "view"
  327. }
  328. ]
  329. }
  330. // 渲染
  331. this.$refs.painter.render(this.poster);
  332. // 生成图片
  333. this.$refs.painter.canvasToTempFilePathSync({
  334. fileType: "jpg",
  335. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  336. pathType: 'url',
  337. quality: 1,
  338. success: (res) => {
  339. this.urlImg = res.tempFilePath
  340. // console.log(res.tempFilePath);
  341. },
  342. });
  343. },
  344. onclick(e) {
  345. if (e.data.type === 'scan') {
  346. uni.scanCode({
  347. scanType: ['barCode'],
  348. });
  349. }
  350. },
  351. goDetail() {
  352. uni.navigateTo({
  353. url: '/pages/cardList/cardDetail?card_id=' + uni.getStorageSync('card_id')
  354. });
  355. },
  356. change(e) {
  357. uni.navigateTo({
  358. url: e.data.page
  359. });
  360. },
  361. previewImage() {
  362. uni.previewImage({
  363. urls: [this.ewm],
  364. longPressActions: {
  365. itemList: ['发送给朋友', '保存图片', '收藏'],
  366. success: function(data) {
  367. },
  368. fail: function(err) {
  369. }
  370. }
  371. });
  372. }
  373. }
  374. }
  375. </script>
  376. <style lang="scss">
  377. .visitor-box {
  378. display: flex;
  379. justify-content: space-between;
  380. align-items: center;
  381. .visitor-items {
  382. display: flex;
  383. align-items: flex-start;
  384. .visitor-items-user {
  385. padding-left: 20rpx;
  386. font-size: 28rpx;
  387. .visitor-items-content {
  388. margin-top: 10rpx;
  389. color: #999999;
  390. }
  391. }
  392. .visitor-user-avatar {
  393. width: 140rpx;
  394. height: 140rpx;
  395. border-radius: 50%;
  396. }
  397. .visitor-items-avatar {
  398. width: 90rpx;
  399. height: 90rpx;
  400. border-radius: 50%;
  401. }
  402. }
  403. }
  404. .tm-menu .tm-menu-block.center {
  405. left: calc(50% - 280rpx) !important;
  406. }
  407. </style>