index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <view>
  3. <u-select v-model="memberQyshow"
  4. @confirm="confirm" :default-value="defaultvalue"
  5. :list="memberQyColumns"></u-select>
  6. <u-navbar :is-back="false" :border-bottom="false" height="84" >
  7. <view class="home-head" style="width: 100%;">
  8. <view class="" >
  9. <img class="homeLogo" :src="homeLogo" alt="">
  10. </view>
  11. <view>
  12. <view class="homeTab" style="
  13. float: left;
  14. ">
  15. <u-tabs :list="tabList" :current="current" @change="change" :show-bar="false" active-color="#333" inactive-color="#c4c0c0"></u-tabs>
  16. </view>
  17. <view class="homeAdd" style="
  18. float: right;
  19. height: 34px;
  20. line-height: 34px;
  21. " >
  22. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  23. <span @click="memberQyshowBtn">{{memberQyObj.name}}</span>
  24. </view>
  25. </view>
  26. </view>
  27. </u-navbar>
  28. <view class="homeWrap">
  29. <u-swiper v-if="wrapList.length" :list="wrapList" @click="clickBanner" :img-mode="'aspectFit'" :name="'picUrl'" height="294" border-radius="24"></u-swiper>
  30. </view>
  31. <view class="homeUser">
  32. <u-divider color="#19be6b" style="margin-bottom:10px;" font-size="28rpx" ><span @click="changeList" v-show="timeOut" >点击刷新</span><span style="margin-left:20px" @click="onHideMethod" v-show="timeOut" >暂停</span><span style="margin-left:20px" v-show="!timeOut" @click="changeList" >自动刷新</span></u-divider>
  33. <view class="homeUser-item"
  34. @click="gotoUrl('pages/friend/personal?id='+item.id)"
  35. v-for="(item ,index) in list" :key="item.id" >
  36. <view class="homeUser-add">
  37. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  38. <span>{{item.orgAreaName}}</span>
  39. </view>
  40. <view class="homeUser-text">
  41. <view class="homeUser-name">
  42. <span>{{showName(item.realName)}}</span>
  43. <u-icon custom-prefix="custom-icon" :name="(item.gender?'women-line':'men-line')" :color="item.gender?'#FF695B':'#1677FF'"></u-icon>
  44. </view>
  45. <view class="homeUser-info">
  46. {{item.age}}岁 {{item.height?'· '+item.height+'cm':''}} {{item.weight?'· '+item.weight+'kg':''}}
  47. </view>
  48. </view>
  49. <u-image class="homeUser-img" :src="(item.faceImage?item.faceImage:'./static/img/head.png')+'?x-oss-process=image/resize,m_fill,w_256,h_256'" height="330" mode="aspectFill"></u-image>
  50. </view>
  51. </view>
  52. <u-divider color="#19be6b" style="margin-bottom:20px;" font-size="28rpx" ><span @click="changeList" v-show="timeOut" >点击刷新</span><span style="margin-left:20px" @click="onHideMethod" v-show="timeOut" >暂停</span><span style="margin-left:20px" v-show="!timeOut" @click="changeList" >自动刷新</span></u-divider>
  53. </view>
  54. </template>
  55. <script>
  56. import * as Api from '@/apis/index.js'
  57. import * as Api_common from '@/apis/common.js'
  58. var homeLogo=require('@/static/img/homeLogo.png')
  59. export default {
  60. data() {
  61. return {
  62. homeLogo:homeLogo,
  63. memberQyshow:false,
  64. memberQy:0,
  65. memberQyColumns:[],
  66. listQy:[],
  67. list:[],
  68. pageIndex: 1,
  69. recordsTotal:0,
  70. tabList: [{
  71. name: '最新'
  72. }, {
  73. name: '最热'
  74. }],
  75. current: 0,
  76. wrapList: [
  77. ],
  78. timeOut: false,
  79. totalPage: 1,
  80. uuid:'',
  81. }
  82. },
  83. // onReachBottom() {
  84. // if (this.list.length < this.recordsTotal) {
  85. // this.myLoadmore();
  86. // }
  87. // },
  88. computed:{
  89. defaultvalue(){
  90. for(var i in this.listQy){
  91. if(this.listQy[i].value==this.memberQy){
  92. return [i]
  93. }
  94. }
  95. return [0]
  96. },
  97. memberQyObj(){
  98. for(var i in this.listQy){
  99. if(this.listQy[i].value==this.memberQy){
  100. return this.listQy[i]
  101. }
  102. }
  103. return {
  104. id: 0,
  105. name:"荆州市"
  106. }
  107. }
  108. },
  109. methods: {
  110. memberQyshowBtn(){
  111. this.memberQyshow = true;
  112. },
  113. // 回调参数为包含columnIndex、value、values
  114. confirm(e) {
  115. this.memberQy=e[0].value;
  116. console.log(this.memberQy)
  117. // var info= this.carhelp.getPersonInfo();
  118. // if(info){
  119. // this.carhelp.set("index-defaultvalue-memberQy",this.memberQy);
  120. // }
  121. this.memberQyshow = false;
  122. this.list = [];
  123. this.homePage();
  124. },
  125. changeList() {
  126. this.list = [];
  127. this.pageIndex += 1;
  128. if(this.pageIndex == this.totalPage+1) {
  129. this.pageIndex = 1;
  130. }
  131. this.homePage()
  132. if(this.uuid){
  133. clearInterval(this.uuid)
  134. }
  135. this.uuid='';
  136. if(!this.uuid){
  137. this.timeOut=true;
  138. this.uuid=setInterval(()=>{
  139. if(this.timeOut){
  140. this.timingchangeList();
  141. }
  142. },10*1000)
  143. }
  144. },
  145. timingchangeList() {
  146. this.list = [];
  147. this.pageIndex += 1;
  148. if(this.pageIndex == this.totalPage+1) {
  149. this.pageIndex = 1;
  150. }
  151. this.homePage()
  152. },
  153. change(index) {
  154. this.current = index;
  155. this.pageIndex= 1;
  156. this.list = [];
  157. this.homePage()
  158. },
  159. getBaseDictionary(){
  160. this.memberQyColumns=[];
  161. var indexdefaultvaluememberQy=false;// this.carhelp.get("index-defaultvalue-memberQy");
  162. var info= this.carhelp.getPersonInfoPlus();
  163. if(info){
  164. //this.memberQy=info.memberQy
  165. this.listQy = info.qyList;
  166. for(var i in this.listQy){
  167. this.memberQyColumns.push({
  168. label: this.listQy[i].name,
  169. value: this.listQy[i].value
  170. })
  171. }
  172. // if(indexdefaultvaluememberQy){
  173. // this.memberQy=indexdefaultvaluememberQy;
  174. // }
  175. }else{
  176. Api.getBaseDictionary({
  177. }).then((res) => {
  178. this.listQy = res.data.qyList;
  179. for(var i in this.listQy){
  180. this.memberQyColumns.push({
  181. label: this.listQy[i].name,
  182. value: this.listQy[i].value
  183. })
  184. }
  185. }).catch(error => {
  186. uni.showToast({
  187. title: error,icon: "none"
  188. })
  189. })
  190. }
  191. },
  192. homePage(){
  193. //var indexdefaultvaluememberQy=false// this.carhelp.get("index-defaultvalue-memberQy");
  194. // var info= this.carhelp.getPersonInfoPlus();
  195. // if(info){
  196. // this.memberQy=info.memberQy
  197. // if(indexdefaultvaluememberQy){
  198. // this.memberQy=indexdefaultvaluememberQy;
  199. // }
  200. // }
  201. uni.showLoading({
  202. title: "加载中",
  203. mask: true,
  204. })
  205. var memberId=undefined;
  206. if(this.carhelp.getPersonInfo()){
  207. memberId=this.carhelp.getPersonInfo().id;
  208. }
  209. Api.homePage({
  210. pageSize:8,
  211. pageIndex:this.pageIndex,
  212. type:this.current,
  213. qy: this.memberQy,
  214. memberId:memberId
  215. }).then((res) => {
  216. if(this.pageIndex==1){
  217. this.list=[]
  218. }
  219. this.list = [
  220. ...this.list,
  221. ...res.data.data
  222. ];
  223. this.recordsTotal = res.data.recordsTotal
  224. this.totalPage = res.data.totalPage
  225. uni.hideLoading()
  226. }).catch(error => {
  227. uni.showToast({
  228. title: error,icon: "none"
  229. })
  230. })
  231. },getBannerInfo(){
  232. Api_common.getBannerInfo("HOMEPAGE").then((res) => {
  233. this.wrapList =res.data;
  234. }).catch(error => {
  235. uni.showToast({
  236. title: error,icon: "none"
  237. })
  238. })
  239. },clickBanner(index){
  240. var obj= this.wrapList[index]
  241. uni.navigateTo({
  242. url:obj.linkUrl
  243. })
  244. },
  245. onHideMethod(){
  246. this.timeOut = false;
  247. if(this.uuid){
  248. clearInterval(this.uuid)
  249. this.uuid='';
  250. }
  251. },
  252. onShowMethod(){
  253. this.timeOut=true
  254. if(!this.uuid){
  255. this.uuid=setInterval(()=>{
  256. if(this.timeOut){
  257. this.timingchangeList();
  258. }
  259. },10*1000)
  260. }
  261. }
  262. },
  263. onUnload() {
  264. if(this.uuid){
  265. clearInterval(this.uuid)
  266. }
  267. },
  268. onHide() {
  269. console.log("onHide")
  270. this.onHideMethod()
  271. },
  272. onShow() {
  273. this.onShowMethod()
  274. },
  275. onLoad() {
  276. var logo=this.carhelp.getConfig().logo
  277. if(logo){
  278. this.homeLogo=logo
  279. }
  280. },
  281. onReady() {
  282. this.getBaseDictionary()
  283. this.getBannerInfo()
  284. this.homePage()
  285. }
  286. }
  287. </script>
  288. <style>
  289. /deep/.u-slot-content{
  290. flex-direction: column;
  291. align-items: flex-start;
  292. }
  293. </style>
  294. <style lang="scss" scoped>
  295. .homeLogo{
  296. margin-left: 15px;
  297. height: 28px;
  298. width: 148px;
  299. }
  300. .home-head{
  301. padding-right: 15px;
  302. background-color: #fff;
  303. z-index: 99;
  304. .homeAdd{
  305. // position: absolute;
  306. // right: -55px;
  307. // top:45px;
  308. color: #FF5E5E;
  309. span{
  310. margin-left: 3px;
  311. }
  312. }
  313. }
  314. .homeWrap{
  315. padding:0 15px;
  316. }
  317. .homeUser{
  318. display: flex;
  319. justify-content: space-between;
  320. flex-wrap: wrap;
  321. padding: 15px;
  322. .homeUser-item{
  323. width: 48%;
  324. height: 165px;
  325. margin-bottom: 15px;
  326. position: relative;
  327. color: #fff;
  328. border-radius: 12px;
  329. overflow: hidden;
  330. .homeUser-add{
  331. position: absolute;
  332. z-index: 9;
  333. right: 10px;
  334. top: 10px;
  335. background: rgba(0,0,0,0.5);
  336. padding:2px 5px;
  337. border-radius: 12px;
  338. span{
  339. margin-left: 3px;
  340. font-size: 14px;
  341. }
  342. }
  343. .homeUser-text{
  344. position: absolute;
  345. z-index: 9;
  346. left:0px ;
  347. bottom: 0px;
  348. right: 0;
  349. padding: 10px;
  350. background: linear-gradient( 180deg,rgba(0,0,0,0),rgba(0,0,0,0.5));
  351. }
  352. .homeUser-name{
  353. display: flex;
  354. align-items: center;
  355. span{
  356. margin-right: 3px;
  357. }
  358. }
  359. .homeUser-info{
  360. margin-top: 3px;
  361. }
  362. .homeUser-img{
  363. position: relative;
  364. z-index: 0;
  365. }
  366. }
  367. }
  368. </style>