record-browse.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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=""></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=""></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. export default {
  39. data() {
  40. return {
  41. mine_code: "",
  42. base_url: "",
  43. // 二维码ID
  44. pageId: '',
  45. bgColor: [],
  46. browse: [],
  47. user:{}
  48. };
  49. },
  50. onLoad(option) {
  51. console.log(option)
  52. this.mine_code = option.mine_code
  53. // 根据矿编码切换首页接口不同的请求基础路径
  54. switch (option.mine_code) {
  55. case 'ningdongyunying':
  56. this.base_url = "http://ningdongyunying.nxjiewei.com:8011/api"
  57. break;
  58. case 'meihuajing':
  59. this.base_url = "http://meihuajing.nxjiewei.com:8011/api"
  60. break;
  61. case 'zaoquan':
  62. this.base_url = "http://zaoquan.nxjiewei.com:8011/api"
  63. break;
  64. default:
  65. this.base_url = ""
  66. }
  67. // 获取二维码ID
  68. this.pageId = option.pageId
  69. // 获取浏览记录
  70. this.get_browse()
  71. },
  72. methods: {
  73. // 获取浏览记录
  74. get_browse() {
  75. uni.request({
  76. url: this.base_url + "/swagger/api/pageuser/v1/getPageUserByPageId/" + this.pageId,
  77. success: (res) => {
  78. console.log(res.data.data)
  79. this.browse = res.data.data
  80. for (let i = 0; i < this.browse.length; i++) {
  81. // 获取随机色
  82. let r = parseInt(Math.random() * 256)
  83. let g = parseInt(Math.random() * 256)
  84. let b = parseInt(Math.random() * 256)
  85. // ES6 字符串拼接
  86. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  87. let color = "rgba(" + r + "," + g + "," + b + "," + 0.3 + ")"
  88. // console.log(color)
  89. this.bgColor.push(color)
  90. }
  91. this.$forceUpdate
  92. this.$set(this.browse)
  93. }
  94. })
  95. },
  96. click(item) {
  97. console.log(item)
  98. this.user = item
  99. this.$refs.popup.open()
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss">
  105. .browse {
  106. margin-top: 20rpx;
  107. margin-bottom: 40rpx;
  108. .list {
  109. overflow: hidden;
  110. .item {
  111. float: left;
  112. width: 140rpx;
  113. text-align: center;
  114. margin-right: 12rpx;
  115. margin-bottom: 20rpx;
  116. font-size: 30rpx;
  117. .img {
  118. margin: 0 auto;
  119. width: 120rpx;
  120. height: 120rpx;
  121. border-radius: 50%;
  122. overflow: hidden;
  123. image {
  124. width: 120rpx;
  125. height: 120rpx;
  126. }
  127. .img_tip {
  128. width: 120rpx;
  129. height: 120rpx;
  130. text-align: center;
  131. line-height: 120rpx;
  132. color: #FFFFFF;
  133. }
  134. }
  135. .name {
  136. margin-top: 20rpx;
  137. width: 140rpx;
  138. white-space: nowrap;
  139. overflow: hidden;
  140. text-overflow: ellipsis;
  141. }
  142. }
  143. .item:nth-child(5n) {
  144. margin-right: 0;
  145. }
  146. }
  147. }
  148. .popup_box{
  149. background-color: #FFFFFF;
  150. border-radius: 12rpx;
  151. box-sizing: border-box;
  152. padding: 50rpx 30rpx;
  153. text-align: center;
  154. font-size: 30rpx;
  155. .img {
  156. margin: 0 auto;
  157. width: 120rpx;
  158. height: 120rpx;
  159. border-radius: 50%;
  160. overflow: hidden;
  161. image {
  162. width: 120rpx;
  163. height: 120rpx;
  164. }
  165. .img_tip {
  166. width: 120rpx;
  167. height: 120rpx;
  168. text-align: center;
  169. line-height: 120rpx;
  170. color: #FFFFFF;
  171. }
  172. }
  173. .name{
  174. margin-top: 20rpx;
  175. line-height: 60rpx;
  176. }
  177. .section{
  178. line-height: 60rpx;
  179. }
  180. .time{
  181. line-height: 60rpx;
  182. color: #888888;
  183. }
  184. }
  185. </style>