record-browse.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="browse">
  3. <view class="list" v-if="browse.length > 0">
  4. <view class="item" v-for="(item,index) in browse" :key="index" @click="click(item)">
  5. <view class="img">
  6. <view v-if="item.img">
  7. <image :src="item.img" mode="aspectFill"></image>
  8. </view>
  9. <view v-if="!item.img">
  10. <view class="img_tip" :style="{backgroundColor:bgColor[index]}">
  11. {{item.name}}
  12. </view>
  13. </view>
  14. </view>
  15. <view class="name">{{item.name}}</view>
  16. </view>
  17. </view>
  18. <uni-popup ref="popup" type="center">
  19. <view class="popup_box">
  20. <view class="img">
  21. <view v-if="user.img">
  22. <image :src="user.img" mode="aspectFill"></image>
  23. </view>
  24. <view v-if="!user.img">
  25. <view class="img_tip" :style="{backgroundColor:bgColor[Math.ceil(Math.random()*10)]}">
  26. {{user.name}}
  27. </view>
  28. </view>
  29. </view>
  30. <view class="name">姓名:{{user.name}}</view>
  31. <view class="section">部门:{{user.department}}</view>
  32. <view class="time">最近浏览时间:{{user.createDate}}</view>
  33. </view>
  34. </uni-popup>
  35. </view>
  36. </template>
  37. <script>
  38. import {set_base_url} from '@/common/set_base_url.js'
  39. export default {
  40. data() {
  41. return {
  42. mine_code: "",
  43. base_url: "",
  44. // 二维码ID
  45. pageId: '',
  46. bgColor: [],
  47. browse: [],
  48. user:{}
  49. };
  50. },
  51. onLoad(option) {
  52. // console.log(option)
  53. this.mine_code = option.mine_code
  54. // 根据矿编码切换首页接口不同的请求基础路径
  55. this.base_url = set_base_url(this.mine_code)
  56. // 获取二维码ID
  57. this.pageId = option.pageId
  58. // 获取浏览记录
  59. this.get_browse()
  60. },
  61. methods: {
  62. // 获取浏览记录
  63. get_browse() {
  64. uni.request({
  65. url: this.base_url + "/swagger/api/pageuser/v1/getPageUserByPageId/" + this.pageId,
  66. header:{
  67. 'accesskey': "b364b449a18af327867f7edc3431b541"
  68. },
  69. success: (res) => {
  70. // console.log(res.data.data)
  71. this.browse = res.data.data
  72. for (let i = 0; i < this.browse.length; i++) {
  73. // 获取随机色
  74. let r = parseInt(Math.random() * 256)
  75. let g = parseInt(Math.random() * 256)
  76. let b = parseInt(Math.random() * 256)
  77. // ES6 字符串拼接
  78. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  79. let color = "rgba(" + r + "," + g + "," + b + "," + 0.3 + ")"
  80. // console.log(color)
  81. this.bgColor.push(color)
  82. }
  83. this.$forceUpdate
  84. this.$set(this.browse)
  85. }
  86. })
  87. },
  88. click(item) {
  89. // console.log(item)
  90. this.user = item
  91. this.$refs.popup.open()
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. .browse {
  98. margin-top: 20rpx;
  99. margin-bottom: 40rpx;
  100. .list {
  101. overflow: hidden;
  102. .item {
  103. float: left;
  104. width: 140rpx;
  105. text-align: center;
  106. margin-right: 12rpx;
  107. margin-bottom: 20rpx;
  108. font-size: 30rpx;
  109. .img {
  110. margin: 0 auto;
  111. width: 120rpx;
  112. height: 120rpx;
  113. border-radius: 50%;
  114. overflow: hidden;
  115. image {
  116. width: 120rpx;
  117. height: 120rpx;
  118. }
  119. .img_tip {
  120. width: 120rpx;
  121. height: 120rpx;
  122. text-align: center;
  123. line-height: 120rpx;
  124. color: #FFFFFF;
  125. }
  126. }
  127. .name {
  128. margin-top: 20rpx;
  129. width: 140rpx;
  130. white-space: nowrap;
  131. overflow: hidden;
  132. text-overflow: ellipsis;
  133. }
  134. }
  135. .item:nth-child(5n) {
  136. margin-right: 0;
  137. }
  138. }
  139. }
  140. .popup_box{
  141. background-color: #FFFFFF;
  142. border-radius: 12rpx;
  143. box-sizing: border-box;
  144. padding: 50rpx 30rpx;
  145. text-align: center;
  146. font-size: 30rpx;
  147. .img {
  148. margin: 0 auto;
  149. width: 120rpx;
  150. height: 120rpx;
  151. border-radius: 50%;
  152. overflow: hidden;
  153. image {
  154. width: 120rpx;
  155. height: 120rpx;
  156. }
  157. .img_tip {
  158. width: 120rpx;
  159. height: 120rpx;
  160. text-align: center;
  161. line-height: 120rpx;
  162. color: #FFFFFF;
  163. }
  164. }
  165. .name{
  166. margin-top: 20rpx;
  167. line-height: 60rpx;
  168. }
  169. .section{
  170. line-height: 60rpx;
  171. }
  172. .time{
  173. line-height: 60rpx;
  174. color: #888888;
  175. }
  176. }
  177. </style>