choosePlot.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view>
  3. <view class="cu-bar bg-white search search " >
  4. <view class="search-form round">
  5. <text class="cuIcon-search"></text>
  6. <input @input="nameInputSearch" placeholder="输入小区名称" placeholder-style="font-size: 28rpx"></input>
  7. </view>
  8. </view>
  9. <view class="bg-gray" style="padding: 12rpx 30rpx;">
  10. <text >当前选择城市:</text>
  11. </view>
  12. <view class="cf city" >
  13. <view class="text-blue fl">
  14. <text class="cuIcon-locationfill padding-right-10"></text>
  15. <text class="">{{city}}{{county}}</text>
  16. </view>
  17. <view class="cu-btn line-blue sm round fr" @tap="switchCity">
  18. <text class="cuIcon-refresh padding-right-10"></text>
  19. <text>切换城市</text>
  20. </view>
  21. </view>
  22. <view class="bg-gray" style="padding: 12rpx 30rpx;">
  23. <text >选择小区:</text>
  24. </view>
  25. <u-cell-group v-if="!$isEmpty(residential_list)">
  26. <u-cell-item @click="jump(item)" v-for="(item, index) in residential_list" :key="index" :title="item.name" :arrow="false"></u-cell-item>
  27. </u-cell-group>
  28. <u-divider bg-color="#ffffff" v-if="residential_list.length>=10" height="80">没有更多了</u-divider>
  29. <u-empty marginTop="200" icon-size="260" v-if="$isEmpty(residential_list)&&!loading" text="暂无小区信息" src="http://139.9.103.171:1888/miniofile/xlyq/empty/empty.png"></u-empty>
  30. <u-back-top :scroll-top="scrollTop"></u-back-top>
  31. </view>
  32. </template>
  33. <script>
  34. const config = require("../../utils/config.js");
  35. var app = getApp();
  36. export default {
  37. data() {
  38. return {
  39. //location: app.defaultCity,
  40. //county: app.defaultCounty,
  41. //市的名字
  42. city: '',
  43. //区的名字
  44. county: '',
  45. currentCityCode: null,
  46. //选择的当前城市所在的区编号,
  47. residential_list: null,
  48. //小区数据列表
  49. sign: false,
  50. loading:true,
  51. scrollTop:0,
  52. };
  53. },
  54. onPageScroll(e) {
  55. this.scrollTop = e.scrollTop;
  56. },
  57. /**
  58. * 生命周期函数--监听页面加载
  59. */
  60. onLoad: function (options) {
  61. console.log(options)
  62. if(!this.$isEmpty(options.city)&&!this.$isEmpty(options.county)&&!this.$isEmpty(options.currentCityCode)){
  63. this.currentCityCode=options.currentCityCode
  64. this.city=options.city
  65. this.county=options.county
  66. this.getCommunity();
  67. }else{
  68. uni.showLoading({
  69. mask: true,
  70. title: '定位中'
  71. });
  72. this.getLocation();
  73. }
  74. if (options.from_index == 'index') {
  75. this.setData({
  76. sign: true
  77. });
  78. } else {
  79. this.setData({
  80. sign: false
  81. });
  82. }
  83. },
  84. onShow() {
  85. if (this.canReset) {
  86. this.getCommunity()
  87. }
  88. this.canReset=true
  89. },
  90. methods: {
  91. jump(item) {
  92. let that=this
  93. let id = item.id;
  94. app.globalData.residentialId=id
  95. let name = item.name;
  96. if (this.sign) {
  97. //清空全局list
  98. app.globalData.room_list = null;
  99. app.globalData.device_list = null;
  100. uni.setStorageSync('plotName', name);
  101. uni.navigateTo({
  102. url: '/pages/index/index?residential_id=' + id + '&residential_name=' + name
  103. });
  104. }else {
  105. let params={
  106. residential_name:name,
  107. residential_id:id
  108. }
  109. uni.navigateTo({
  110. url:"./chooseBuilding/chooseBuilding"+this.$u.queryParams(params)
  111. })
  112. }
  113. },
  114. //切换城市
  115. switchCity: function () {
  116. //兼容地图插件
  117. app.globalData.city = this.city;
  118. app.globalData.currentCityCode = this.currentCityCode;
  119. app.globalData.county = this.county;
  120. uni.navigateTo({
  121. url: '/pages/switchcity/switchcity'
  122. });
  123. },
  124. getLocation: function () {
  125. //console.log("正在定位城市");
  126. this.setData({
  127. county: ''
  128. });
  129. const that = this;
  130. uni.getLocation({
  131. type: 'wgs84',
  132. success: function (res) {
  133. let latitude = res.latitude;
  134. let longitude = res.longitude;
  135. let params={
  136. location:latitude+","+longitude,
  137. key:config.key,
  138. }
  139. let operation = 'miniprogram/ws/geocoder/v1/location';
  140. getApp().globalData.postRequest(params, operation, function (res) {
  141. uni.hideLoading(); // console.log(res)
  142. let info=res.data.result.result.ad_info
  143. that.setData({
  144. city: info.city,
  145. currentCityCode: info.adcode,
  146. //区code 如,越秀区--440104
  147. county: info.district
  148. }); //兼容地图插件
  149. app.globalData.city = info.city;
  150. app.globalData.currentCityCode = info.adcode;
  151. app.globalData.county = info.district; //拉取小区信息
  152. that.getCommunity();
  153. });
  154. }
  155. });
  156. },
  157. //根据区编号获取小区列表
  158. getCommunity: function (residential_name) {
  159. uni.showLoading({
  160. title:"加载中.."
  161. })
  162. let that = this;
  163. let params = {};
  164. params['region_area'] = this.currentCityCode;
  165. params['residential_name'] = residential_name;
  166. let operation = 'estate/getByRegionArea';
  167. app.globalData.postRequest(params, operation, function (res) {
  168. //获取成功
  169. if (res.data.result_code == 1) {
  170. that.setData({
  171. residential_list: res.data.list
  172. });
  173. } else {
  174. app.globalData.oneFailHint(res.data.result_msg);
  175. }
  176. that.loading=false
  177. uni.hideLoading()
  178. });
  179. },
  180. //输入小区名字联想搜索
  181. nameInputSearch: function (e) {
  182. let residential_name = e.detail.value;
  183. this.getCommunity(residential_name);
  184. }
  185. }
  186. };
  187. </script>
  188. <style>
  189. page{
  190. overflow-y: scroll;
  191. background-color:#FFFFFF
  192. }
  193. .city{
  194. padding:30rpx 30rpx 20rpx 30rpx;
  195. border-bottom: 1rpx solid #efefef;
  196. z-index: 99;
  197. }
  198. input {
  199. text-align: center;
  200. font-size: 32rpx;
  201. padding: 5px;
  202. border-radius:10rpx;
  203. background-color: #fff;
  204. }
  205. .input {
  206. padding: 16rpx;
  207. border-bottom: 1rpx solid #e2e2e2;
  208. }
  209. .nav_section {
  210. width: 100%;
  211. background-color: #FFFFFF;
  212. }
  213. .nav_section_items {
  214. display: flex;
  215. flex-direction: row;
  216. justify-content: space-between;
  217. padding: 30rpx;
  218. border-bottom: 2rpx solid #efefef;
  219. position: relative;
  220. }
  221. .nav_section_items:active {
  222. background: #ddd;
  223. }
  224. .nav_section_items .section_cont view {
  225. overflow: hidden;
  226. text-overflow: ellipsis;
  227. white-space: nowrap;
  228. display: block;
  229. }
  230. .nav_section_items .section_cont .section_cont_sub {
  231. font-size: 30rpx;
  232. line-height: 50rpx;
  233. color: #000;
  234. margin-bottom: 10rpx;
  235. }
  236. .section_cont_tel .info{
  237. width: 500rpx;
  238. overflow: hidden;
  239. white-space: nowrap;
  240. text-overflow: ellipsis;
  241. display: inline-block;
  242. }
  243. .local_city{
  244. padding: 30rpx;
  245. position:relative;
  246. background: #fff;
  247. }
  248. .local_city .changeCity{
  249. padding: 30rpx;
  250. position: absolute;
  251. right: 0rpx;
  252. top: 0;
  253. }
  254. .local_city .icon{
  255. padding: 20rpx;
  256. position: absolute;
  257. left: -36rpx;
  258. top: 50%;
  259. transform: translate(0,-50%);
  260. font-size: 40rpx;
  261. }
  262. </style>