detail.vue 10 KB

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