record-browse.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. success: (res) => {
  67. // console.log(res.data.data)
  68. this.browse = res.data.data
  69. for (let i = 0; i < this.browse.length; i++) {
  70. // 获取随机色
  71. let r = parseInt(Math.random() * 256)
  72. let g = parseInt(Math.random() * 256)
  73. let b = parseInt(Math.random() * 256)
  74. // ES6 字符串拼接
  75. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  76. let color = "rgba(" + r + "," + g + "," + b + "," + 0.3 + ")"
  77. // console.log(color)
  78. this.bgColor.push(color)
  79. }
  80. this.$forceUpdate
  81. this.$set(this.browse)
  82. }
  83. })
  84. },
  85. click(item) {
  86. // console.log(item)
  87. this.user = item
  88. this.$refs.popup.open()
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. .browse {
  95. margin-top: 20rpx;
  96. margin-bottom: 40rpx;
  97. .list {
  98. overflow: hidden;
  99. .item {
  100. float: left;
  101. width: 140rpx;
  102. text-align: center;
  103. margin-right: 12rpx;
  104. margin-bottom: 20rpx;
  105. font-size: 30rpx;
  106. .img {
  107. margin: 0 auto;
  108. width: 120rpx;
  109. height: 120rpx;
  110. border-radius: 50%;
  111. overflow: hidden;
  112. image {
  113. width: 120rpx;
  114. height: 120rpx;
  115. }
  116. .img_tip {
  117. width: 120rpx;
  118. height: 120rpx;
  119. text-align: center;
  120. line-height: 120rpx;
  121. color: #FFFFFF;
  122. }
  123. }
  124. .name {
  125. margin-top: 20rpx;
  126. width: 140rpx;
  127. white-space: nowrap;
  128. overflow: hidden;
  129. text-overflow: ellipsis;
  130. }
  131. }
  132. .item:nth-child(5n) {
  133. margin-right: 0;
  134. }
  135. }
  136. }
  137. .popup_box{
  138. background-color: #FFFFFF;
  139. border-radius: 12rpx;
  140. box-sizing: border-box;
  141. padding: 50rpx 30rpx;
  142. text-align: center;
  143. font-size: 30rpx;
  144. .img {
  145. margin: 0 auto;
  146. width: 120rpx;
  147. height: 120rpx;
  148. border-radius: 50%;
  149. overflow: hidden;
  150. image {
  151. width: 120rpx;
  152. height: 120rpx;
  153. }
  154. .img_tip {
  155. width: 120rpx;
  156. height: 120rpx;
  157. text-align: center;
  158. line-height: 120rpx;
  159. color: #FFFFFF;
  160. }
  161. }
  162. .name{
  163. margin-top: 20rpx;
  164. line-height: 60rpx;
  165. }
  166. .section{
  167. line-height: 60rpx;
  168. }
  169. .time{
  170. line-height: 60rpx;
  171. color: #888888;
  172. }
  173. }
  174. </style>