index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="zxbox">
  3. <view class="zxtop">
  4. <view class="navbox">
  5. <uni-nav-bar color="#ffffff" leftWidth='110rpx' rightWidth="48rpx" :background-color="backgroundColor" :border="false" statusBar='true'>
  6. <block slot="left">
  7. <view class="topl flexc">
  8. <view class="over">客户</view>
  9. </view>
  10. </block>
  11. <view class="topc flexc">
  12. <image :src="secimg"></image>
  13. <input placeholder="输入关键字进行查询" confirm-type="search" v-model="usename" @confirm="getConfirm"/>
  14. </view>
  15. <block slot="right">
  16. <view class="topr" @click='getNoticeFn'>
  17. <image :src="noticeimg"></image>
  18. <view class="cir"></view>
  19. <!-- <block v-if="noticenum>99">99+</block>
  20. <block v-else>{{noticenum}}</block> -->
  21. </view>
  22. </block>
  23. </uni-nav-bar>
  24. </view>
  25. <image :src="bgimg" class="bgimg"></image>
  26. <view class="zxmain" :style="'margin-top:-'+marTop+'rpx;'">
  27. <!-- list -->
  28. <bus-list :datalist="list" :wtdt="wtdt" :type="type" @getDetail="getDetail"></bus-list>
  29. </view>
  30. </view>
  31. <footers v-if="isfootflag" :footerindex="footerindex" :isHomeIndex="true"></footers>
  32. </view>
  33. </template>
  34. <script>
  35. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  36. let { calendar } = require("@/components/lunc-calendar/calendar.js");
  37. import {getIdCardList,} from "@/api/mine/card.js"
  38. import {getDictionaryFn} from "@/api/mine/register.js"
  39. import busList from "@/work/components/business/list.vue"
  40. import footers from '@/components/footer/footer.vue'
  41. export default {
  42. components:{footers,busList},
  43. data(){
  44. return{
  45. footerindex:'custom',
  46. isfootflag:true,
  47. backgroundColor:'transparent',
  48. bgimg:require("@/static/images/bg.png"),
  49. noticeimg:require("@/static/images/home/notice.png"),
  50. secimg:require("@/static/images/home/search.png"),
  51. list:[],
  52. pageSize: 10,
  53. pageNum: 1,
  54. reachflag: true,
  55. wtdt:'加载更多',
  56. nvaHeight:44,
  57. marTop:0,//距离顶部的距离
  58. stubarHeight:0,//
  59. scroflag:false,
  60. type:'custom',
  61. usename:'',
  62. }
  63. },
  64. onPageScroll(e) {
  65. var scrollTop = Number(e.scrollTop);
  66. // var listTop=Number(this.listTop)-Number(this.nvaHeight)
  67. if (scrollTop <=this.nvaHeight) {
  68. const opacity = scrollTop / 100 // 计算透明度值
  69. const color = `rgba(4, 145, 253, ${opacity})`
  70. this.backgroundColor = color // 更新盒子背景颜色
  71. } else {
  72. this.backgroundColor = '#00A9F0'
  73. }
  74. },
  75. onUnload() {
  76. uni.$off('refreshdatalist')
  77. },
  78. onLoad: function(e) {
  79. if(e.name){
  80. this.usename=e.name
  81. }
  82. // uni.$on('refreshdatalist',(e) => {
  83. // this.reachflag=false;
  84. // this.pageNum=1;
  85. // this.list=[];
  86. // this.getDataFn();
  87. // })
  88. // this.init()
  89. this.getDataFn()
  90. uni.getSystemInfo({
  91. success: (e) => {
  92. this.stubarHeight=Number(e.statusBarHeight);
  93. this.nvaHeight = Number(e.statusBarHeight)+44;
  94. }
  95. })
  96. },
  97. onShow() {
  98. },
  99. mounted() {
  100. this.getHeightFn()
  101. },
  102. // 上拉触底加载更多触发事件
  103. onReachBottom() {
  104. if (this.reachflag) {
  105. this.pageNum++
  106. this.getDataFn()
  107. }
  108. },
  109. methods:{
  110. checkPermi, checkRole,
  111. getConfirm(){
  112. this.getrefreshData()
  113. },
  114. getNoticeFn(){
  115. this.$tab.navigateTo("/pages/index/notice")
  116. },
  117. getrefreshData(){
  118. this.pageNum=1;
  119. this.list=[];
  120. this.reachflag=true;
  121. this.getDataFn()
  122. },
  123. getHeightFn(){
  124. let query = uni.createSelectorQuery().in(this);
  125. //需要给黄色区域设置一个id标识,在这里是demo
  126. query.select('.navbox').boundingClientRect(data => {
  127. var top=data.top<0 ? -data.top : data.top;
  128. var stubarHeight=Number(this.stubarHeight);
  129. this.marTop =stubarHeight > 0?420 - Number(data.height)*2 : 420 - Number(data.height)*2 + 40 //赋值,待会要用
  130. if (top <=this.nvaHeight) {
  131. const opacity = top / 100 // 计算透明度值
  132. const color = `rgba(4, 145, 253, ${opacity})`
  133. this.backgroundColor = color // 更新盒子背景颜色
  134. } else {
  135. this.backgroundColor = '#00A9F0'
  136. }
  137. }).exec();
  138. },
  139. init(){
  140. // 记录来源
  141. getDictionaryFn('jluly').then(res=>{
  142. if(res.code==200){
  143. this.adrlist = res.data.map(v => {
  144. return {
  145. lLabel: v.dictLabel,
  146. value: v.dictValue
  147. }
  148. })
  149. }
  150. })
  151. },
  152. getDetail(e){
  153. this.$tab.navigateTo("/work/pages/custom/details?id="+e)
  154. },
  155. getDataFn(){
  156. var params={
  157. pageSize:this.pageSize,
  158. pageNum: this.pageNum,
  159. }
  160. if(this.usename){
  161. params.realName=this.usename
  162. }
  163. getIdCardList(params).then(res=>{
  164. if(res.code==200){
  165. if (res.rows.length < this.pageSize) {
  166. this.reachflag = false
  167. this.wtdt = '到底了~';
  168. } else {
  169. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  170. if (num < res.total) {
  171. this.reachflag = true
  172. this.wtdt = '上拉加载更多'
  173. } else {
  174. this.reachflag = false
  175. this.wtdt = '到底了~';
  176. }
  177. }
  178. if (this.pageNum == 1) {
  179. this.list = res.rows;
  180. } else {
  181. this.list = this.list.concat(res.rows)
  182. }
  183. }else{
  184. this.$toast(res.msg)
  185. }
  186. })
  187. },
  188. },
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. page{background-color: #f6f6f6;}
  193. .navbox /deep/ .uni-navbar__header-container {align-items: center;padding-left: 0;}
  194. .navbox /deep/ uni-picker{flex: 1;}
  195. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;
  196. .topl{padding-left: 16rpx;overflow: hidden;
  197. image{width: 30rpx;height: 38rpx;margin-right: 18rpx;flex: 0 0 auto;}
  198. view{font-weight: bold;font-size: 30rpx;color: #FFFFFF;}
  199. }
  200. .topc{border-radius: 34rpx;height:68rpx;box-sizing: border-box;padding:0 32rpx 0 32rpx ;position: relative;flex:1;background-color: #FFFFFF;
  201. input{font-weight: 500;font-size: 26rpx;color: #222327;}
  202. image{width: 30rpx;height: 30rpx;margin-right: 24rpx;}
  203. }
  204. .topr{width: 48rpx;height: 38rpx;position: relative;margin-right: 10rpx;
  205. image{width: 32rpx;height: 38rpx;margin: 0 auto;}
  206. // .cir{background: #FF4747;font-size: 14rpx;color: #FFFFFF;border-radius: 50%;border: 2rpx solid #FFFFFF;min-width: 20rpx;height: 20rpx;
  207. // position: absolute;right: -5rpx;top: -5rpx;text-align: center;line-height: 16rpx;
  208. // }
  209. .cir{width: 14rpx;height: 14rpx;background: #DF0024;border-radius: 50%;position: absolute;right: -7rpx;top: -7rpx;}
  210. }
  211. }
  212. .zxbox{
  213. .bgimg{width: 100%;height: 420rpx;}
  214. .zxmain{position: relative;padding: 48rpx 36rpx 0;
  215. }
  216. }
  217. </style>