cardDetail.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="cardDetail">
  3. <uni-menubar :title="cardInfo.name" />
  4. <view class="pure_top"></view>
  5. <template>
  6. <tm-sheet :shadow="25">
  7. <view class="visitor-box text-size-s">
  8. <view class="visitor-items">
  9. <view>
  10. <image class="visitor-user-avatar" :src="cardInfo.picture"></image>
  11. <!-- <image class="visitor-user-avatar"></image> -->
  12. </view>
  13. <view class="visitor-items-user">
  14. <view class="text-weight-b">{{cardInfo.name}}</view>
  15. <view class="visitor-items-content">{{cardInfo.industry}}</view>
  16. <view class="visitor-items-content">{{cardInfo.company}}</view>
  17. </view>
  18. </view>
  19. <view>
  20. <image :src="ewm" style="width: 80rpx;height: 80rpx;" mode="" @click="previewImage"></image>
  21. </view>
  22. </view>
  23. <view @click="mobileClick(cardInfo.mobile)" class="my-20 visitor-items-userInfo">
  24. <tm-icons class="mr-20" name="icon-phone"></tm-icons>{{cardInfo.mobile}}
  25. </view>
  26. <view @click="copyWx(cardInfo.wx)" class="my-20 visitor-items-userInfo">
  27. <tm-icons class="mr-20" name="icon-aliwangwang"></tm-icons>{{cardInfo.wx}}
  28. </view>
  29. <view @click="copyEmail(cardInfo.email)" class="my-20 visitor-items-userInfo">
  30. <tm-icons class="mr-20" name="icon-mail"></tm-icons>{{cardInfo.email}}
  31. </view>
  32. <view @click="openAddress" class="my-20 visitor-items-userInfo">
  33. <tm-icons class="mr-20" name="icon-position-fill"></tm-icons>
  34. {{cardInfo.cityAdress || ''}}{{cardInfo.address}}
  35. </view>
  36. </tm-sheet>
  37. <view class="mx-50 mt-40">
  38. <tm-button openType="share" theme="bg-gradient-blue-accent" :round="24" block>介绍ta给朋友
  39. </tm-button>
  40. </view>
  41. <view class="mx-50 mt-30">
  42. <tm-button @click="keepClick" :text="true" :round="24" block>保存到通讯录
  43. </tm-button>
  44. </view>
  45. <tm-sheet :shadow="25" :padding="[0, 0]">
  46. <view class="gray text-size-s text-align-right" style="padding:20rpx 46rpx;">
  47. {{count_str}}
  48. </view>
  49. <tm-grid :grid="4" @change="change" :list="grid"></tm-grid>
  50. </tm-sheet>
  51. <!-- <tm-sheet>
  52. <tm-empty icon="icon-cry-fill" label="还没有访客哦"></tm-empty>
  53. </tm-sheet> -->
  54. <tm-sheet :shadow="25" :padding="[0, 0]">
  55. <view class="mx-32 pt-15 text-weight-b text-overflow-2 text-size-g">
  56. 企业介绍
  57. </view>
  58. <text decode user-select space class="text-size-s pa-24 d-inline-block">
  59. {{introduce}}
  60. </text>
  61. </tm-sheet>
  62. <tm-sheet @click="openAddress" :shadow="25" :padding="[0, 20]">
  63. <view class="mx-32 pt-15 text-weight-b text-overflow-2 text-size-g">
  64. 详细地址
  65. </view>
  66. <view class="my-20 pa-20">
  67. <tm-icons class="mx-10" name="icon-position-fill"></tm-icons>
  68. {{cardInfo.cityAdress || ''}}{{cardInfo.address}}
  69. </view>
  70. <view class="my-20 pa-20">
  71. <map :markers="covers" :latitude="cardInfo.latitude" :longitude="cardInfo.longitude"
  72. style="width: 100%;height: 300rpx;"></map>
  73. </view>
  74. </tm-sheet>
  75. <tm-sheet @click="openAddress" :shadow="25" :padding="[0, 0]">
  76. <view class="mx-32 pt-15 text-weight-b text-overflow-2 text-size-g">
  77. 我的动态
  78. </view>
  79. <tm-empty icon="icon-cry-fill" label="还没有动态"></tm-empty>
  80. </tm-sheet>
  81. </template>
  82. <view class="safe-height"></view>
  83. <l-painter ref="painter" style="position:absolute;top:-1000rpx" />
  84. <!-- <uni-suspension></uni-suspension> -->
  85. <view v-if="userID != card_id" class="suspension">
  86. <tm-button @click="goChat" :width="90" :height="90" fab :icon-size="50" icon="icon-aliwangwang"
  87. theme="blue"></tm-button>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. export default {
  93. data() {
  94. return {
  95. cardInfo: {},
  96. grid: [],
  97. poster: {},
  98. urlImg: "",
  99. card_id: '',
  100. introduce: '',
  101. count_str: '',
  102. covers: [],
  103. userID: uni.getStorageSync('card_id'),
  104. ewm: ''
  105. }
  106. },
  107. onShareAppMessage(res) {
  108. return {
  109. title: '您好,这是我的名片,请惠存',
  110. path: '/pages/index/detail?card_id=' + this.card_id,
  111. imageUrl: this.urlImg,
  112. success: () => {
  113. this.$point.point(9, '', this.card_id)
  114. }
  115. }
  116. },
  117. onLoad(option) {
  118. if (option) {
  119. this.card_id = option.card_id
  120. this.$tm.request.post('card/viewread', {
  121. card_id: option.card_id
  122. }).then(res => {
  123. if (res.data) {
  124. this.cardInfo = res.data.card
  125. this.grid = res.data.grid
  126. this.count_str = res.data.count_str
  127. this.covers = [{
  128. id: 1,
  129. latitude: this.cardInfo.latitude,
  130. longitude: this.cardInfo.longitude,
  131. iconPath: '/static/location.png'
  132. }]
  133. this.introduce = res.data.introduce
  134. this.$tm.request.post('index/common').then(res => {
  135. this.showCard(res.data.share_thumb)
  136. })
  137. this.$tm.request.post('card/qr', {
  138. page: "/pages/index/index",
  139. uid: this.cardInfo.uid,
  140. scene: "card_id=" + this.card_id
  141. }).then(res => {
  142. this.ewm = res.data
  143. })
  144. }
  145. })
  146. // this.$point.ponit()
  147. }
  148. },
  149. methods: {
  150. showCard(share_thumb) {
  151. this.poster = {
  152. css: {
  153. width: '500rpx',
  154. height: '400rpx',
  155. background: share_thumb.bg
  156. },
  157. views: [{
  158. src: this.cardInfo.picture,
  159. type: "image",
  160. css: {
  161. objectFit: "cover",
  162. marginLeft: "20rpx",
  163. marginTop: "40rpx",
  164. width: "100rpx",
  165. border: "2rpx solid #fff",
  166. boxSizing: "border-box",
  167. height: "100rpx",
  168. borderRadius: "50%"
  169. }
  170. },
  171. {
  172. type: "view",
  173. css: {
  174. paddingLeft: "10rpx",
  175. display: "inline-block",
  176. marginTop: "50rpx",
  177. marginLeft: "20rpx",
  178. },
  179. views: [{
  180. text: this.cardInfo.name,
  181. type: "text",
  182. css: {
  183. display: "block",
  184. color: share_thumb.fontColor,
  185. fontSize: "28rpx",
  186. fontWeight: "bold"
  187. }
  188. },
  189. {
  190. text: this.cardInfo.company,
  191. type: "text",
  192. css: {
  193. color: share_thumb.fontColor,
  194. fontSize: "24rpx",
  195. marginTop: "10rpx",
  196. },
  197. }
  198. ],
  199. },
  200. {
  201. css: {
  202. marginLeft: "20rpx",
  203. padding: "12rpx",
  204. boxSizing: "border-box",
  205. width: "500rpx",
  206. height: "400rpx"
  207. },
  208. views: [{
  209. views: [{
  210. type: "view",
  211. css: {
  212. width: "460rpx",
  213. color: share_thumb.fontColor,
  214. display: "inline-block",
  215. fontSize: "24rpx",
  216. },
  217. views: [{
  218. text: "电话:" + this.cardInfo.mobile,
  219. type: "text",
  220. css: {
  221. display: "block",
  222. paddingBottom: "10rpx",
  223. fontWeight: "bold"
  224. }
  225. },
  226. {
  227. text: "微信:" + this.cardInfo.wx,
  228. type: "text",
  229. css: {
  230. display: "block",
  231. paddingBottom: "10rpx",
  232. fontWeight: "bold"
  233. }
  234. },
  235. {
  236. text: "地址:" + this.cardInfo.cityAdress + this
  237. .cardInfo.address,
  238. type: "text",
  239. css: {
  240. display: "block",
  241. paddingBottom: "10rpx",
  242. fontWeight: "bold"
  243. },
  244. },
  245. {
  246. text: "邮箱:" + this.cardInfo.email,
  247. type: "text",
  248. css: {
  249. display: "block",
  250. paddingBottom: "10rpx",
  251. fontWeight: "bold"
  252. },
  253. }
  254. ],
  255. }, ],
  256. type: "view"
  257. }],
  258. type: "view"
  259. }
  260. ]
  261. }
  262. // 渲染
  263. this.$refs.painter.render(this.poster);
  264. // 生成图片
  265. this.$refs.painter.canvasToTempFilePathSync({
  266. fileType: "jpg",
  267. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  268. pathType: 'url',
  269. quality: 1,
  270. success: (res) => {
  271. this.urlImg = res.tempFilePath
  272. // console.log(res.tempFilePath);
  273. },
  274. });
  275. },
  276. goChat() {
  277. let {
  278. id,
  279. name,
  280. uid
  281. } = this.cardInfo
  282. uni.navigateTo({
  283. url: "/subpages/pages/card/cardChat?t_uid=" + uid + '&name=' + name + '&card_id=' + id
  284. })
  285. },
  286. openAddress() {
  287. let that = this
  288. let latitude = that.cardInfo.latitude * 1
  289. let longitude = that.cardInfo.longitude * 1
  290. uni.openLocation({
  291. latitude: latitude,
  292. longitude: longitude,
  293. success: function() {
  294. that.$point.point(15, '', that.card_id)
  295. }
  296. })
  297. },
  298. mobileClick(phone) {
  299. uni.makePhoneCall({
  300. phoneNumber: phone
  301. });
  302. this.$point.point(8, '', this.card_id)
  303. },
  304. copyWx(text, ) {
  305. uni.setClipboardData({
  306. data: text
  307. });
  308. this.$point.point(14, '', this.cardInfo.id)
  309. },
  310. copyEmail(text) {
  311. uni.setClipboardData({
  312. data: text
  313. });
  314. },
  315. keepClick() {
  316. let that = this
  317. uni.addPhoneContact({
  318. firstName: that.cardInfo.name,
  319. mobilePhoneNumber: that.cardInfo.mobile
  320. });
  321. this.$point.point(10, '', this.card_id)
  322. },
  323. change(e) {
  324. if (e.data.appid) {
  325. uni.navigateToMiniProgram({
  326. appId: e.data.appid,
  327. path: e.data.page
  328. })
  329. } else {
  330. uni.navigateTo({
  331. url: e.data.page
  332. })
  333. }
  334. },
  335. previewImage() {
  336. uni.previewImage({
  337. urls: [this.ewm],
  338. longPressActions: {
  339. itemList: ['发送给朋友', '保存图片', '收藏'],
  340. success: function(data) {
  341. },
  342. fail: function(err) {
  343. }
  344. }
  345. });
  346. }
  347. }
  348. }
  349. </script>
  350. <style lang="scss" scoped>
  351. .suspension {
  352. position: fixed;
  353. bottom: 200rpx;
  354. right: 50rpx;
  355. }
  356. .visitor-box {
  357. display: flex;
  358. justify-content: space-between;
  359. align-items: center;
  360. .visitor-items {
  361. display: flex;
  362. align-items: flex-start;
  363. .visitor-items-user {
  364. padding-left: 20rpx;
  365. font-size: 28rpx;
  366. .visitor-items-content {
  367. margin-top: 10rpx;
  368. }
  369. }
  370. .visitor-user-avatar {
  371. width: 140rpx;
  372. height: 140rpx;
  373. border-radius: 50%;
  374. }
  375. .visitor-items-avatar {
  376. width: 90rpx;
  377. height: 90rpx;
  378. border-radius: 50%;
  379. }
  380. }
  381. }
  382. </style>