list.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <template>
  2. <view class="container">
  3. <view class="dataList">
  4. <view class="search">
  5. <view class="tui-rolling-search">
  6. <tui-icon @tap="onChangePosition" name="position-fill" color="#333" :size="30" unit="rpx">
  7. </tui-icon>
  8. <view @tap="onChangePosition" class="tui-city-name">{{cityName}}</view>
  9. <tui-icon @tap="onChangePosition" name="turningdown" :size="32" unit="rpx"></tui-icon>
  10. <view class="tui-city-line">|</view>
  11. <tui-icon name="search-2" :size="32" unit="rpx"></tui-icon>
  12. <form @submit="searchSubmit">
  13. <input class="searchinput" placeholder="搜索" placeholder-class="placeholder"
  14. @confirm="searchSubmit" confirm-type="search" name="search"
  15. :value="where.keyword">
  16. </form>
  17. </view>
  18. </view>
  19. <view class="list acea-row row-between-wrapper">
  20. <block v-for="(item, index) in dataList" :key="index">
  21. <view @tap="selectTap" :data-item="item" class="item">
  22. <view :class="'pictrue on'">
  23. <image :src="item.image || '/static/images/default_img.png'"></image>
  24. </view>
  25. <view class="text">
  26. <view class="nametitle">{{item.title}}</view>
  27. <view class="tztitle">{{item.community_title}} 站长: {{item.tz_title}}</view>
  28. <view class="indicators">
  29. <text class="indctext">地址: {{item.area_name}}{{item.house_number}}</text>
  30. </view>
  31. </view>
  32. <view class="buttonbox">
  33. <view class="distance">
  34. <tui-icon name="position-fill" :size="16" color="#ff1e02"></tui-icon><text
  35. v-if="item.distance" class="kmclass">{{item.distance}}km</text>
  36. </view>
  37. <button class="itembutton">选择</button>
  38. </view>
  39. </view>
  40. </block>
  41. <view class="loadingicon acea-row row-center-wrapper" v-if="dataList.length > 0">
  42. <text class="loading iconfont icon-jiazai" :hidden="loading==false"></text>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="noCommodity" v-if="dataList.length==0 && where.page > 1">
  47. <view class="pictrue">
  48. </view>
  49. </view>
  50. <tui-tabbar :current="current">
  51. </tui-tabbar>
  52. </view>
  53. </template>
  54. <script>
  55. var app = getApp();
  56. export default {
  57. data() {
  58. return {
  59. current: '',
  60. dataList: [],
  61. cityName: '',
  62. navH: "",
  63. goodsid: '',
  64. where: {
  65. keyword: '',
  66. priceOrder: '',
  67. salesOrder: '',
  68. news: 0,
  69. page: 1,
  70. limit: 10,
  71. cid: 0,
  72. latitude: "",
  73. longitude: ""
  74. },
  75. price: 0,
  76. stock: 0,
  77. nows: false,
  78. loadend: false,
  79. loading: false,
  80. bottommenulist: [],
  81. host_product: "",
  82. title: "",
  83. position: "",
  84. latitude: "",
  85. longitude: "",
  86. cid: ""
  87. };
  88. },
  89. components: {},
  90. props: {},
  91. /**
  92. * 生命周期函数--监听页面加载
  93. */
  94. onLoad: function(options) {
  95. const _this = this;
  96. this.where.cid = options.cid || ''
  97. this.goodsid = options.goodsid || ''
  98. // #ifdef MP-WEIXIN
  99. this.current = "/" + this.__route__;
  100. // #endif
  101. //#ifdef H5
  102. this.current = this.$route.path;
  103. //#endif
  104. _this.title = options.title || '';
  105. _this.where.keyword = options.searchValue || '';
  106. },
  107. /**
  108. * 生命周期函数--监听页面显示
  109. */
  110. onShow: function() {
  111. const _this = this;
  112. //获取地置位置
  113. _this.sam.getCityPosition().then(res => {
  114. _this.cityName = res.cityName;
  115. _this.getPosition();
  116. });
  117. },
  118. /**
  119. * 页面相关事件处理函数--监听用户下拉动作
  120. */
  121. onPullDownRefresh: function() {
  122. this.where.page = 1;
  123. this.loadend = false;
  124. this.dataList = [];
  125. this.get_data_list();
  126. uni.stopPullDownRefresh();
  127. },
  128. /**
  129. * 页面上拉触底事件的处理函数
  130. */
  131. onReachBottom: function() {
  132. this.get_data_list();
  133. },
  134. methods: {
  135. //获取定位信息
  136. getPosition() {
  137. const _this = this;
  138. // #ifdef MP-WEIXIN
  139. wx.authorize({
  140. scope: 'scope.userFuzzyLocation',
  141. success: res => {
  142. //console.log(res)
  143. wx.getFuzzyLocation({
  144. type: 'wgs84',
  145. success(res) {
  146. _this.position = res.address;
  147. _this.where.latitude = res.latitude;
  148. _this.where.longitude = res.longitude;
  149. _this.loadend = false;
  150. _this.get_data_list();
  151. }
  152. });
  153. },
  154. fail: res => {
  155. //console.log('失败:', res);
  156. }
  157. });
  158. // #endif
  159. //#ifdef H5 || APP-PLUS
  160. uni.getLocation({
  161. type: 'wgs84',
  162. success: function(lb) {
  163. _this.where.latitude = lb.latitude;
  164. _this.where.longitude = lb.longitude;
  165. _this.get_data_list();
  166. console.log(lb.longitude, lb.latitude);
  167. },
  168. })
  169. //#endif
  170. },
  171. selectTap: function(e) {
  172. const _this = this;
  173. var item = e.currentTarget.dataset.item;
  174. _this.$request.post('operatingcity.getcity', {
  175. samkey: (new Date()).valueOf(),
  176. he_id:item.id
  177. }).then(res => {
  178. uni.navigateBack({});
  179. });
  180. },
  181. onChangePosition: function(e) {
  182. const _this = this;
  183. uni.chooseLocation({
  184. success(res) {
  185. _this.cityName = res.name;
  186. uni.setStorageSync('cityName', _this.cityName);
  187. _this.position = res.address;
  188. _this.where.latitude = res.latitude;
  189. _this.where.longitude = res.longitude;
  190. _this.loadend = false;
  191. _this.latitude = res.latitude;
  192. _this.longitude = res.longitude;
  193. _this.get_data_list(true);
  194. }
  195. });
  196. },
  197. searchSubmit: function(e) {
  198. var that = this;
  199. that.where.keyword = e.detail.value;
  200. that.where.page = 1;
  201. that.loadend = false;
  202. this.get_data_list(true);
  203. },
  204. //点击事件处理
  205. set_where: function(e) {
  206. this.cid = e.currentTarget.dataset.cid;
  207. this.loadend = false;
  208. this.where.page = 1;
  209. this.get_data_list(true);
  210. },
  211. //设置where条件
  212. setWhere: function() {
  213. this.where.salesOrder = 'asc';
  214. if (this.cid) {
  215. this.where.cid = this.cid;
  216. }
  217. },
  218. //查找
  219. get_data_list: function(isPage) {
  220. var that = this;
  221. this.setWhere();
  222. if (that.loadend) return;
  223. if (that.loading) return;
  224. if (isPage === true) {
  225. that.dataList = [];
  226. that.where.page =1;
  227. }
  228. that.where.samkey= (new Date()).valueOf()
  229. //console.log(that.where);
  230. that.$request.post('housingestate.list', that.where).then(res => {
  231. var dataList = res.data.data;
  232. var loadend = dataList.length < that.where.limit;
  233. that.where.page = that.where.page + 1;
  234. that.loadend = loadend;
  235. that.loading = false;
  236. that.dataList = dataList;
  237. });
  238. }
  239. }
  240. };
  241. </script>
  242. <style>
  243. page {
  244. font-size: 28rpx;
  245. background-color: #f5f5f5;
  246. color: #333;
  247. }
  248. .container {
  249. padding-bottom: 228rpx;
  250. color: #333;
  251. }
  252. .dataList .search {
  253. width: 100%;
  254. padding-top: 13rpx;
  255. padding-bottom: 13rpx;
  256. padding-left: 15rpx;
  257. padding-right: 15rpx;
  258. box-sizing: border-box;
  259. align-items: center;
  260. background-color: #f5f5f5;
  261. position: fixed;
  262. display: flex;
  263. left: 0;
  264. z-index: 99999;
  265. }
  266. .searchinput {
  267. padding-left: 10rpx;
  268. }
  269. .tui-rolling-search {
  270. width: 100%;
  271. height: 66rpx;
  272. border-radius: 35rpx;
  273. padding: 0 40rpx 0 30rpx;
  274. box-sizing: border-box;
  275. background-color: #fff;
  276. display: flex;
  277. align-items: center;
  278. flex-wrap: nowrap;
  279. color: #999;
  280. }
  281. .tui-city-name {
  282. padding-left: 6rpx;
  283. padding-right: 0rpx;
  284. color: #333;
  285. font-size: 24rpx;
  286. line-height: 24rpx;
  287. }
  288. .tui-city-line {
  289. color: #d3d3d3;
  290. padding-left: 16rpx;
  291. padding-right: 20rpx;
  292. font-size: 24rpx;
  293. line-height: 24rpx;
  294. }
  295. .dataList .bg-color {
  296. background-color: #f5f5f5;
  297. }
  298. .dataList .search .location {
  299. color: #333;
  300. font-size: 28rpx;
  301. flex: 1;
  302. display: flex;
  303. margin-top: 22rpx;
  304. line-height: 40rpx;
  305. }
  306. .dataList .nav {
  307. width: 1000rpx;
  308. display: flex;
  309. color: #454545;
  310. font-size: 28rpx;
  311. background-color: #fff;
  312. }
  313. .dataList .nav .item {
  314. text-align: center;
  315. height: 100%;
  316. padding: 25rpx;
  317. }
  318. .dataList .nav .item.font-color {
  319. font-weight: bold;
  320. }
  321. .dataList .nav .item image {
  322. width: 88rpx;
  323. height: 88rpx;
  324. margin-left: 10rpx;
  325. }
  326. .dataList .list {
  327. padding: 20rpx;
  328. padding-top: 80rpx;
  329. margin-top: 6rpx;
  330. }
  331. .kmclass {
  332. padding-left: 5rpx;
  333. color: #333333;
  334. }
  335. .dataList .list .item {
  336. background-color: #fff;
  337. display: flex;
  338. margin-top: 20rpx;
  339. padding: 20rpx;
  340. border-radius: 18rpx;
  341. }
  342. .dataList .list .item .pictrue {
  343. width: 180rpx;
  344. height: 180rpx;
  345. }
  346. .dataList .list .item .pictrue image {
  347. width: 100%;
  348. height: 100%;
  349. border-radius: 28rpx;
  350. }
  351. .dataList .list .item .text {
  352. width: 308rpx;
  353. padding: 0 0 0 22rpx;
  354. font-size: 28rpx;
  355. color: #373333;
  356. }
  357. .dataList .list .item .text .money {
  358. font-size: 23rpx;
  359. margin-top: 50rpx;
  360. }
  361. .dataList .list .item .text .money .num {
  362. font-size: 32rpx;
  363. }
  364. .dataList .list .item .text .vip {
  365. font-size: 22rpx;
  366. color: #aaa;
  367. margin-top: 12rpx;
  368. }
  369. .dataList .list .item .text .vip .vip-money {
  370. font-size: 24rpx;
  371. color: #282828;
  372. font-weight: bold;
  373. }
  374. .dataList .list .item .text .vip .vip-money image {
  375. width: 46rpx;
  376. height: 21rpx;
  377. margin-left: 4rpx;
  378. }
  379. .dataList .list .item .buttonbox {
  380. margin-top: 40rpx;
  381. width: 200rpx;
  382. padding: 0 0 0 22rpx;
  383. font-size: 28rpx;
  384. color: #373333;
  385. }
  386. .nametitle {
  387. font-size: 32rpx;
  388. padding-top: 2rpx;
  389. word-break: break-all;
  390. font-weight: bold;
  391. overflow: hidden;
  392. text-overflow: ellipsis;
  393. display: -webkit-box;
  394. -webkit-box-orient: vertical;
  395. -webkit-line-clamp: 2;
  396. }
  397. .tztitle {
  398. font-size: 28rpx;
  399. margin-top: 10rpx;
  400. padding-top: 2rpx;
  401. word-break: break-all;
  402. overflow: hidden;
  403. text-overflow: ellipsis;
  404. display: -webkit-box;
  405. -webkit-box-orient: vertical;
  406. -webkit-line-clamp: 2;
  407. }
  408. .distance {
  409. text-align: center;
  410. }
  411. .itembutton {
  412. margin-top: 10rpx;
  413. font-size: 24rpx;
  414. color: #ffffff;
  415. align-items: center;
  416. background-color: #52c276;
  417. }
  418. .noCommodity {
  419. background-color: #fff;
  420. }
  421. .indicators {
  422. color: #909090;
  423. margin-top: 10rpx;
  424. }
  425. .belong {
  426. color: #909090;
  427. margin-top: 20rpx;
  428. }
  429. .indctext {
  430. padding-left: 3rpx;
  431. padding-right: 15rpx;
  432. }
  433. </style>