AddressSelect.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <view>
  3. <view class="fixed">
  4. <cu-custom bgColor="bg-gradual-earkblue" :isBack="true">
  5. <block slot="backText">
  6. <view style="height: 80rpx;line-height: 80rpx;">返回</view>
  7. </block>
  8. <block slot="content">
  9. <text :class="'cuIcon-locationfill'"></text>
  10. </block>
  11. <block slot="content">{{address}}</block>
  12. <block slot="content">
  13. <image style="width: 15px;height: 15px;margin-left: 4px;" src="../../static/picture/SanJiao.png">
  14. </block>
  15. </cu-custom>
  16. </view>
  17. <view class="VerticalBox">
  18. <scroll-view class="VerticalNav nav " scroll-y scroll-with-animation :scroll-top="verticalNavTop" style="height:100vh;">
  19. <view class="cu-item" :class="index==tabCur?'text-green cur':''" v-for="(item,index) in adresslist" :key="index" @tap="TabSelect"
  20. :data-id="index" :style="{'height':leftHeight}">
  21. {{item.name}}
  22. </view>
  23. </scroll-view>
  24. <!-- 右侧菜单 -->
  25. <scroll-view class="VerticalMain" scroll-y scroll-with-animation style="height:100vh;padding-top:100upx"
  26. :scroll-into-view="'main-'+mainCur" @scroll="VerticalMain">
  27. <view class="padding-top padding-lr" v-for="(item,index) in adresslist" :key="index" :id="'main-'+index">
  28. <div v-if="(item.name=='吉林')">
  29. <view class="cu-bar bg-white">
  30. <view class="action" >
  31. <text class="cuIcon-title text-green" style="margin-left:-10px"></text> {{item.name}}</view>
  32. </view>
  33. <view class="cu-list menu-avatar " >
  34. <!--item-->
  35. <view class="cu-item" :style="{height:item.height+'upx'}" style="padding-bottom: 560px;">
  36. <view class="row">
  37. <view class="col-8" :style="{'width':nameWidth}" v-for="(val,key) in (item.item)" :key="key" @tap="pushWindPowerStationNameToSessionStorage(val.title,val.windPowerStationId);" >
  38. <a style="margin-left: 20px;">{{val.address}}</a>
  39. <a style=" float: right ">{{val.title}}</a>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </div>
  45. <div v-if="(item.name!='吉林')">
  46. <view class="cu-bar bg-white">
  47. <view class="action" >
  48. <text class="cuIcon-title text-green" style="margin-left:-10px"></text> {{item.name}}</view>
  49. </view>
  50. <view class="cu-list menu-avatar " >
  51. <!--item-->
  52. <view class="cu-item" :style="{height:item.height+'upx'}" >
  53. <view class="row">
  54. <view class="col-8" :style="{'width':nameWidth}" v-for="(val,key) in (item.item)" :key="key" @tap="pushWindPowerStationNameToSessionStorage(val.title,val.windPowerStationId);" >
  55. <a style="margin-left: 20px;">{{val.address}}</a>
  56. <a style=" float: right ">{{val.title}}</a></br>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </div>
  62. </view>
  63. </scroll-view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. adresslist: [],
  72. tabCur: 0,
  73. mainCur: 0,
  74. adressObject:[],
  75. heBeiList:[],
  76. verticalNavTop: 0,
  77. load: true,
  78. address:'',
  79. windpowerstationIds:[],
  80. province:[],
  81. provinceAdressList:[],
  82. windpowerstationAdressList:[],
  83. provinceFlag:false,
  84. windowWidth:"",
  85. windowHeight:"",
  86. leftHeight:'',
  87. nameWidth:'',
  88. };
  89. },
  90. created:function(){
  91. this.windowWidth=uni.getSystemInfoSync().windowWidth;
  92. this.windowHeight=uni.getSystemInfoSync().windowHeight;
  93. if(this.windowWidth>=768){
  94. this.leftHeight="100px";
  95. this.nameWidth="500px"
  96. }else{
  97. this.leftHeight="50px";
  98. this.nameWidth="253px";
  99. }
  100. },
  101. onLoad(option) {
  102. this.windpowerstationIds=JSON.parse(uni.getStorageSync('windpowerstationNames'));
  103. console.log(this.windpowerstationIds);
  104. this.address = option.option;
  105. uni.showLoading({
  106. title: '加载中...',
  107. mask: true,
  108. });
  109. this.selectWindPowerStation();
  110. // let heBeiList = [
  111. // {
  112. // id:2,
  113. // name:'河北',
  114. // item:[
  115. // {id:1,title:'崇礼',address:"河北省张家口崇礼市四台嘴乡"},
  116. // {id:2,title:'康保',address:"河北省张家口市照阳河镇郝家营村"},
  117. // {id:3,title:'雁门关',address:"山西省忻州市代县雁门关乡"}
  118. // ]
  119. // }
  120. // ];
  121. // this.heBeiList = heBeiList;
  122. // this.heBeiListCur = heBeiList[0];
  123. // this.mainHeBeiList = this.heBeiList[this.tabCur];
  124. },
  125. onReady() {
  126. uni.hideLoading()
  127. },
  128. methods: {
  129. TabSelect(e) {
  130. this.tabCur = e.currentTarget.dataset.id;
  131. //this.adressObject = this.adresslist[this.tabCur]
  132. this.mainCur = e.currentTarget.dataset.id;
  133. this.verticalNavTop = (e.currentTarget.dataset.id + 1) * 50
  134. //this.verticalNavTop = 700;
  135. // this.mainHeBeiList=this.heBeiList[this.tabCur]
  136. // this.mainCur = e.currentTarget.dataset.id;
  137. // this.verticalNavTop = (e.currentTarget.dataset.id - 1) * 50
  138. },
  139. pushWindPowerStationNameToSessionStorage(windpowerstationName,windPowerStationId){
  140. uni.setStorageSync('windpowerstationName',windpowerstationName);
  141. uni.setStorageSync('windPowerStationId',windPowerStationId);
  142. this.common.goback('/pages/index/Index');
  143. },
  144. getWindPowerStationNamesToSessionStorage() {
  145. uni.getStorageSync('windpowerstationNames');
  146. console.log(uni.getStorageSync('windpowerstationNames'));
  147. return uni.getStorageSync('windpowerstationNames');
  148. },
  149. VerticalMain(e) {
  150. // #ifdef MP-ALIPAY
  151. return false //支付宝小程序暂时不支持双向联动
  152. // #endif
  153. let that = this;
  154. let tabHeight = 0;
  155. if (this.load) {
  156. for (let i = 0; i < this.adresslist.length; i++) {
  157. let view = uni.createSelectorQuery().select("#main-" + this.adresslist[i].id);
  158. view.fields({
  159. size: true
  160. }, data => {
  161. this.adresslist[i].top = tabHeight;
  162. tabHeight = tabHeight + data.height;
  163. this.adresslist[i].bottom = tabHeight;
  164. }).exec();
  165. }
  166. this.load = false
  167. }
  168. let scrollTop = e.detail.scrollTop + 10;
  169. for (let i = 0; i < this.adresslist.length; i++) {
  170. if (scrollTop > this.adresslist[i].top && scrollTop < this.adresslist[i].bottom) {
  171. this.verticalNavTop = (this.adresslist[i].id - 1) * 50
  172. this.tabCur = this.adresslist[i].id
  173. console.log(scrollTop)
  174. return false
  175. }
  176. }
  177. },
  178. selectWindPowerStation:function(){
  179. let adresslist = [
  180. {
  181. id:0,
  182. name:'宁夏' ,
  183. height:455,
  184. item:[
  185. {id:1,title:'牛首山',address:"宁夏省吴忠市青铜峡市",windPowerStationId:"NSS_FDC"},
  186. {id:2,title:'香山',address:"宁夏省中卫市沙坡头区",windPowerStationId:"XS_FDC"},
  187. {id:3,title:'石板泉',address:"宁夏省吴忠市利通区",windPowerStationId:"SBQ_FDC"},
  188. {id:4,title:'青山',address:"宁夏省吴忠市盐池县",windPowerStationId:"QS_FDC"},
  189. {id:5,title:'麻黄山',address:"宁夏省吴忠市盐池县",windPowerStationId:"MHS_FDC"}
  190. ]
  191. },
  192. {
  193. id:1,
  194. name:'河北',
  195. height:300,
  196. item:[
  197. {id:1,title:'崇礼',address:"河北省崇礼市四台嘴乡",windPowerStationId:"CL_FDC"},
  198. {id:2,title:'康保',address:"河北省照阳河镇郝家营村",windPowerStationId:"KB_FDC"},
  199. {id:3,title:'雁门关',address:"山西省忻州市代县",windPowerStationId:"YMG_FDC"}
  200. ]
  201. },
  202. {
  203. id:2,
  204. name:'内蒙',
  205. height:200,
  206. item:[
  207. {id:1,title:'天源',address:"内蒙古省突泉县太平乡",windPowerStationId:"TY_FDC"},
  208. {id:2,title:'熬伦',address:"内蒙古省通辽市库伦旗",windPowerStationId:"AL_FDC"},
  209. ]
  210. },
  211. {
  212. id:3,
  213. name:'辽宁',
  214. height:600,
  215. item:[
  216. {id:1,title:'调兵山',address:"辽宁省铁岭调兵山市",windPowerStationId:"DBS_FDC"},
  217. {id:2,title:'北镇',address:"辽宁省北镇市广宁乡",windPowerStationId:"BZ_FDC"},
  218. {id:3,title:'兴城',address:"辽宁省葫芦岛兴城市",windPowerStationId:"XC_FDC"},
  219. {id:4,title:'芳山',address:"辽宁省锦州市芳山镇",windPowerStationId:"FS_FDC"},
  220. {id:5,title:'凌海',address:"辽宁省锦州市青松村",windPowerStationId:"LH_FDC"},
  221. {id:6,title:'西八千',address:"辽宁省西八千乡南圈河村",windPowerStationId:"XBQ_FDC"},
  222. {id:7,title:'台子山',address:"辽宁省铁岭市官台工业园区",windPowerStationId:"TZS_FDC"}
  223. ]
  224. },
  225. {
  226. id:4,
  227. name:'吉林',
  228. height:1350,
  229. item:[
  230. {id:1,title:'永茂',address:"吉林省洮南市永茂乡",windPowerStationId:"YM_FDC"},
  231. {id:2,title:'万发',address:"吉林省大安市红岗子乡",windPowerStationId:"WF_FDC"}
  232. ]
  233. },
  234. ];
  235. // for (let i = 0; i < 26; i++) {
  236. // list[i] = {};
  237. // list[i].name = String.fromCharCode(65 + i);
  238. // list[i].id = i;
  239. // }
  240. //判断省份
  241. for(let i=0;i<adresslist.length;i++){
  242. for(let j=0;j<adresslist[i].item.length;j++){
  243. for(let k=0;k<this.windpowerstationIds.length;k++){
  244. if(adresslist[i].item[j].windPowerStationId==this.windpowerstationIds[k]){
  245. if(this.province.length==0){
  246. this.province.push(adresslist[i].name);
  247. }else{
  248. this.provinceFlag=false;
  249. for(let l=0;l<this.province.length;l++){
  250. if(this.province[l]==adresslist[i].name){
  251. this.provinceFlag=true;
  252. }
  253. }
  254. if(this.provinceFlag==false){
  255. this.province.push(adresslist[i].name);
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. for(let i1=0;i1<this.province.length;i1++){
  263. for(let j1=0;j1<adresslist.length;j1++){
  264. if(this.province[i1]==adresslist[j1].name){
  265. this.provinceAdressList.push(adresslist[j1]);
  266. }
  267. }
  268. }
  269. //windpowerstationAdressList=this.provinceAdressList;
  270. // for(let i3=0;i3<this.provinceAdressList.length;i3++){
  271. // this.$set(this.windpowerstationAdressList,i3,this.provinceAdressList[i3]);
  272. // }
  273. this.windpowerstationAdressList=JSON.parse(JSON.stringify(this.provinceAdressList));
  274. //判断风电场
  275. for(let i2=0;i2<this.provinceAdressList.length;i2++){
  276. this.windpowerstationAdressList[i2].item=[];
  277. console.log(this.provinceAdressList);
  278. for(let j2=0;j2<this.provinceAdressList[i2].item.length;j2++){
  279. for(let k2=0;k2<this.windpowerstationIds.length;k2++){
  280. if(this.windpowerstationIds[k2]==this.provinceAdressList[i2].item[j2].windPowerStationId){
  281. this.windpowerstationAdressList[i2].item.push(this.provinceAdressList[i2].item[j2]);
  282. }
  283. }
  284. }
  285. }
  286. //调整高度
  287. for(let i3=0;i3<this.windpowerstationAdressList.length;i3++){
  288. this.windpowerstationAdressList[i3].height=90*this.windpowerstationAdressList[i3].item.length;
  289. }
  290. this.adresslist = this.windpowerstationAdressList;
  291. this.listCur = adresslist[0];
  292. this.adressObject = this.adresslist[this.tabCur];
  293. }
  294. },
  295. }
  296. </script>
  297. <style>
  298. .fixed {
  299. position: fixed;
  300. z-index: 99;
  301. }
  302. .VerticalNav.nav {
  303. width: 200upx;
  304. padding-top: 150upx;
  305. background-color: white;
  306. /* background-color: #64A0D6; */
  307. white-space: initial;
  308. }
  309. .VerticalNav.nav .cu-item {
  310. width: 100%;
  311. text-align: center;
  312. background-color: #fff;
  313. /* background-color: #64A0D6; */
  314. margin: 0;
  315. border: none;
  316. height: 50px;
  317. position: relative;
  318. }
  319. .VerticalNav.nav .cu-item.cur {
  320. background-color: #f1f1f1;
  321. /* background-color: #64A0D6; */
  322. }
  323. .VerticalNav.nav .cu-item.cur::after {
  324. content: "";
  325. width: 8upx;
  326. height: 30upx;
  327. border-radius: 10upx 0 0 10upx;
  328. position: absolute;
  329. background-color: currentColor;
  330. /* background-color: #64A0D6; */
  331. top: 0;
  332. right: 0upx;
  333. bottom: 0;
  334. margin: auto;
  335. }
  336. .VerticalBox {
  337. display: flex;
  338. margin-top: 25px;
  339. }
  340. .VerticalMain {
  341. background-color: #f1f1f1;
  342. /* background-color: #64A0D6; */
  343. flex: 1;
  344. }
  345. .col-8{
  346. /* margin-right: 10upx;
  347. display: flex;
  348. flex-direction: row;
  349. justify-content: space-between; */
  350. width: 253px;
  351. padding-top: 30upx;
  352. padding-bottom: 10px;
  353. border-bottom: 1upx solid lightgray
  354. /* background-color: #64A0D6; */
  355. }
  356. </style>