with_house.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <view class="content">
  3. <view class="supplyInfo">
  4. <view class="tel flex">
  5. <label>小区名称:</label>
  6. <view class="picker">
  7. <picker
  8. @change="hoodChange"
  9. :value="hoodIndex"
  10. :range="hoodList"
  11. range-key="name"
  12. class="pick"
  13. >
  14. <view class="picker_title">
  15. <view class="pickername">
  16. <view>
  17. {{ hoodList[hoodIndex].name || '请选择小区'}}
  18. </view>
  19. </view>
  20. <view class="triangle-down"></view>
  21. </view>
  22. </picker>
  23. </view>
  24. </view>
  25. <view class="tel flex" style="margin-top:30rpx;">
  26. <label style="text-align: center;">楼栋:</label>
  27. <view class="picker">
  28. <picker
  29. @change="buildingChange"
  30. :value="buildIndex"
  31. :range="buildList"
  32. range-key="name"
  33. class="pick"
  34. >
  35. <view class="picker_title">
  36. <view class="pickername">
  37. <view>
  38. {{ buildList[buildIndex].name || '请选择楼栋'}}
  39. </view>
  40. </view>
  41. <view class="triangle-down"></view>
  42. </view>
  43. </picker>
  44. </view>
  45. </view>
  46. <view class="tel flex">
  47. <label style="text-align: center;">单元:</label>
  48. <view class="picker">
  49. <picker
  50. @change="unitChange"
  51. :value="unitIndex"
  52. :range="unitList"
  53. range-key="name"
  54. class="pick"
  55. >
  56. <view class="picker_title">
  57. <view class="pickername">
  58. <view>
  59. {{ unitList[unitIndex].name || '请选择单元'}}
  60. </view>
  61. </view>
  62. <view class="triangle-down"></view>
  63. </view>
  64. </picker>
  65. </view>
  66. </view>
  67. <view class="tel flex">
  68. <label style="text-align: center;">房号:</label>
  69. <view class="picker">
  70. <picker
  71. @change="numChange"
  72. :value="numIndex"
  73. :range="numList"
  74. range-key="name"
  75. class="pick"
  76. >
  77. <view class="picker_title">
  78. <view class="pickername">
  79. <view>
  80. {{ numList[numIndex].name || '请选择房号'}}
  81. </view>
  82. </view>
  83. <view class="triangle-down"></view>
  84. </view>
  85. </picker>
  86. </view>
  87. </view>
  88. <view class="tel flex" style="margin-top: 100rpx;">
  89. <label>户主姓名:</label>
  90. <input type="text" class="card input" v-model="house.master" disabled/>
  91. </view>
  92. <view class="tel flex">
  93. <label>住宅面积:</label>
  94. <input type="text" class="card input" v-model="house.area" disabled/>
  95. </view>
  96. </view>
  97. <button class="submit" @tap="houseSubmit">提交</button>
  98. <uni-popup ref="popup" :mask-click="false">
  99. <view class="popup-box">
  100. <view>
  101. <view class="popup-title">确认</view>
  102. <view class="popup-content-box">
  103. <view class="popup-content">
  104. <view class="popup-type">
  105. 确定关联此住房信息吗?
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. <view class="popup-footer">
  111. <button class="popup-cancel" @click="closePop">取消</button>
  112. <button class="popup-submit" @click="submitPop">确定</button>
  113. </view>
  114. </view>
  115. </uni-popup>
  116. </view>
  117. </template>
  118. <script>
  119. import md5 from "@/common/md5.js";
  120. export default {
  121. data() {
  122. return {
  123. house: {
  124. name: "",
  125. num: "",
  126. master:'',
  127. area:'',
  128. },
  129. hoodList: [],
  130. buildList: [],
  131. unitList: [],
  132. numList: [],
  133. hoodIndex: 0,
  134. buildIndex:0,
  135. unitIndex:0,
  136. numIndex:0,
  137. };
  138. },
  139. onLoad() {
  140. },
  141. onShow() {
  142. this.searchHood()
  143. },
  144. methods: {
  145. searchHood(){
  146. let that = this;
  147. // let result = e.detail.value;
  148. let md5Sign = md5(
  149. "method=" +
  150. "user" +
  151. "&timestamp=" +
  152. getApp().globalData.globalTimestamp +
  153. "&secret=" +
  154. getApp().globalData.secret
  155. );
  156. let url =
  157. getApp().globalData.shareUrl +
  158. "api/api.php" +
  159. "?method=user&source=user&action=search_estate&timestamp=" +
  160. getApp().globalData.globalTimestamp +
  161. "&sign=" +
  162. md5Sign;
  163. let postData = {
  164. keyword:'',
  165. openId: getApp().globalData.open_id,
  166. };
  167. uni.request({
  168. url: url,
  169. method: "POST",
  170. header: {
  171. "content-type": "application/x-www-form-urlencoded",
  172. },
  173. data: postData,
  174. success: (res) => {
  175. if (res.data.code === 200) {
  176. let obj = res.data.data;
  177. for (let key in obj) {
  178. let child = {
  179. name:obj[key]
  180. }
  181. this.hoodList.push(child)
  182. }
  183. }
  184. },
  185. fail: () => {
  186. console.log("连接失败");
  187. },
  188. });
  189. },
  190. searchDetail(hood,build,unit,room){
  191. let that = this, addressResult,searchType;
  192. // let result = e.detail.value;
  193. that.house.master = '';
  194. that.house.area = '';
  195. if (room)
  196. {
  197. searchType = 'houseRoom'
  198. addressResult = hood + '/' + build + '/' + unit + '/' + room
  199. }
  200. if(build && unit && !room){
  201. searchType = 'houseNumber'
  202. addressResult = hood + '/' + build + '/' + unit
  203. }
  204. if(build && !unit){
  205. searchType = 'houseUnit'
  206. addressResult = hood + '/' + build
  207. }
  208. if(!build && !unit){
  209. searchType = 'houseBuilding'
  210. addressResult = hood
  211. }
  212. let md5Sign = md5(
  213. "method=" +
  214. "user" +
  215. "&timestamp=" +
  216. getApp().globalData.globalTimestamp +
  217. "&secret=" +
  218. getApp().globalData.secret
  219. );
  220. let url =
  221. getApp().globalData.shareUrl +
  222. "api/api.php" +
  223. "?method=user&source=user&action=get_address&timestamp=" +
  224. getApp().globalData.globalTimestamp +
  225. "&sign=" +
  226. md5Sign;
  227. let postData = {
  228. address:addressResult,
  229. openId: getApp().globalData.open_id,
  230. };
  231. uni.request({
  232. url: url,
  233. method: "POST",
  234. header: {
  235. "content-type": "application/x-www-form-urlencoded",
  236. },
  237. data: postData,
  238. success: (res) => {
  239. if (res.data.code === 200) {
  240. if(res.data.data.length === 0){
  241. uni.showToast({
  242. title: "暂无数据",
  243. icon: "error",
  244. });
  245. that.buildList = [];
  246. that.unitList = [];
  247. that.numList = [];
  248. that.house.master = '';
  249. that.house.area = '';
  250. }else{
  251. that.makeHouseData(searchType,res.data.data)
  252. }
  253. }
  254. },
  255. fail: () => {
  256. console.log("连接失败");
  257. },
  258. });
  259. },
  260. makeHouseData(type,dataList){
  261. let that = this , obj = dataList;
  262. switch (type){
  263. case 'houseBuilding':
  264. that.buildList = [];
  265. for (let key in obj) {
  266. let child = {
  267. name:obj[key]
  268. }
  269. that.buildList.push(child)
  270. }
  271. that.searchDetail(that.hoodList[that.hoodIndex].name,that.buildList[0].name)
  272. break;
  273. case 'houseUnit':
  274. that.unitList = [];
  275. for (let key in obj) {
  276. let child = {
  277. name:obj[key]
  278. }
  279. that.unitList.push(child)
  280. }
  281. that.searchDetail(that.hoodList[that.hoodIndex].name,that.buildList[that.buildIndex].name,that.unitList[0].name)
  282. break;
  283. case 'houseNumber':
  284. that.numList = [];
  285. for (let key in obj) {
  286. let child = {
  287. name:obj[key]
  288. }
  289. that.numList.push(child)
  290. }
  291. that.numList[that.numIndex].name = that.numList[0].name
  292. that.searchDetail(that.hoodList[that.hoodIndex].name,that.buildList[that.buildIndex].name,that.unitList[that.unitIndex].name,that.numList[0].name);
  293. break;
  294. case 'houseRoom':
  295. that.house.master = obj.name;
  296. that.house.area = obj.area;
  297. default:
  298. break;
  299. }
  300. },
  301. houseSubmit(){
  302. //uni.navigateBack({});
  303. this.open()
  304. },
  305. hoodChange(e){
  306. this.hoodIndex = e.detail.value;
  307. this.searchDetail(this.hoodList[this.hoodIndex].name)
  308. },
  309. buildingChange(e) {
  310. if(!this.hoodList.length){
  311. uni.showToast({
  312. title: "请先选择小区",
  313. icon: "error",
  314. });
  315. return
  316. }
  317. this.buildIndex = e.detail.value;
  318. this.searchDetail(this.hoodList[this.hoodIndex].name,this.buildList[this.buildIndex].name)
  319. },
  320. unitChange(e) {
  321. if(!this.buildList.length){
  322. uni.showToast({
  323. title: "请先选择楼栋",
  324. icon: "error",
  325. });
  326. return
  327. }
  328. this.unitIndex = e.detail.value;
  329. this.searchDetail(this.hoodList[this.hoodIndex].name,this.buildList[this.buildIndex].name,this.unitList[this.unitIndex].name)
  330. },
  331. numChange(e) {
  332. if(!this.unitList.length){
  333. uni.showToast({
  334. title: "请先选择单元",
  335. icon: "error",
  336. });
  337. return
  338. }
  339. this.numIndex = e.detail.value;
  340. this.searchDetail(this.hoodList[this.hoodIndex].name,this.buildList[this.buildIndex].name,this.unitList[this.unitIndex].name,this.numList[this.numIndex].name);
  341. },
  342. submitPop(){
  343. this.closePopup()
  344. this.submit()
  345. },
  346. closePop(){
  347. this.closePopup()
  348. },
  349. open() {
  350. this.$refs.popup.open('center')
  351. },
  352. closePopup() {
  353. this.$refs.popup.close()
  354. },
  355. submit() {
  356. if (
  357. !this.buildList.length ||
  358. !this.unitList.length ||
  359. !this.numList.length
  360. ) {
  361. uni.showToast({
  362. title: "小区信息不完善",
  363. icon: "error",
  364. });
  365. return;
  366. }
  367. let addressResult = this.hoodList[this.hoodIndex].name + '/' + this.buildList[this.buildIndex].name + '/' + this.unitList[this.unitIndex].name + '/' + this.numList[this.numIndex].name
  368. let md5Sign = md5(
  369. "method=" +
  370. "user" +
  371. "&timestamp=" +
  372. getApp().globalData.globalTimestamp +
  373. "&secret=" +
  374. getApp().globalData.secret
  375. );
  376. let url =
  377. getApp().globalData.shareUrl +
  378. "api/api.php" +
  379. "?method=user&source=user&action=band_owner&timestamp=" +
  380. getApp().globalData.globalTimestamp +
  381. "&sign=" +
  382. md5Sign;
  383. let postData = {
  384. address:addressResult,
  385. openId: getApp().globalData.open_id,
  386. };
  387. uni.request({
  388. url: url,
  389. method: "POST",
  390. header: {
  391. "content-type": "application/x-www-form-urlencoded",
  392. },
  393. data: postData,
  394. success: (res) => {
  395. if (res.data.code === 200) {
  396. uni.showToast({
  397. title: "绑定成功",
  398. icon: "success",
  399. });
  400. }
  401. },
  402. fail: () => {
  403. console.log("连接失败");
  404. },
  405. });
  406. },
  407. },
  408. };
  409. </script>
  410. <style lang="scss" scoped>
  411. .content {
  412. font-size: 28rpx;
  413. font-weight: 200;
  414. padding: 1% 2%;
  415. .title {
  416. font-size: 30rpx;
  417. margin: 4% 0;
  418. }
  419. label {
  420. display: inline-block;
  421. width: 25%;
  422. vertical-align: middle;
  423. }
  424. .card {
  425. background-color: rgb(248, 247, 247);
  426. border-radius: 10rpx;
  427. }
  428. .flex {
  429. display: flex;
  430. align-items: center;
  431. margin-bottom: 2%;
  432. }
  433. .input {
  434. padding: 0 2%;
  435. margin: 2% 0;
  436. display: inline-block;
  437. width: 80%;
  438. height: 70rpx;
  439. }
  440. .supplyInfo {
  441. border-radius: 40rpx;
  442. padding: 4%;
  443. box-shadow: rgba(100, 100, 111, 0.2) 14rpx 14rpx 40rpx 14rpx;
  444. margin: 30rpx 0 30rpx 0;
  445. }
  446. .info {
  447. margin-top: 2%;
  448. border-radius: 40rpx;
  449. padding: 2% 4%;
  450. box-shadow: rgba(100, 100, 111, 0.2) 14rpx 14rpx 40rpx 14rpx;
  451. }
  452. .submit {
  453. color: white;
  454. font-weight: normal;
  455. width: 55%;
  456. border-radius: 20rpx;
  457. background-color: #02a7f0;
  458. margin: 120rpx auto;
  459. }
  460. }
  461. .popup-box {
  462. height: 100%;
  463. display: flex;
  464. flex-direction: column;
  465. justify-content: space-between;
  466. }
  467. .popup-title {
  468. text-align: center;
  469. font-weight: bold;
  470. height: 30px;
  471. border-bottom: 1px solid #d8d8d8;
  472. }
  473. .popup-content {
  474. font-size: 28rpx;
  475. padding: 10rpx 0 10rpx 0;
  476. }
  477. .popup-type {
  478. height: 80rpx;
  479. text-align: center;
  480. margin-top: 150rpx;
  481. }
  482. .popup-footer {
  483. display: flex;
  484. button{
  485. font-size: 26rpx;
  486. height: 60rpx;
  487. width: 150rpx;
  488. line-height: 60rpx;
  489. color: #FFFFFF;
  490. }
  491. }
  492. .popup-cancel {
  493. background-color: #AAAAAA;
  494. }
  495. .popup-submit {
  496. background-color: #249CD3;
  497. }
  498. </style>