with_house.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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. this.searchDetail(this.hoodList[this.hoodIndex].name)
  184. }
  185. },
  186. fail: () => {
  187. console.log("连接失败");
  188. },
  189. });
  190. },
  191. searchDetail(hood,build,unit){
  192. let that = this, addressResult,searchType;
  193. // let result = e.detail.value;
  194. if(build && unit){
  195. searchType = 'houseNumber'
  196. addressResult = hood + '/' + build + '/' + unit
  197. }
  198. if(build && !unit){
  199. searchType = 'houseUnit'
  200. addressResult = hood + '/' + build
  201. }
  202. if(!build && !unit){
  203. searchType = 'houseBuilding'
  204. addressResult = hood
  205. }
  206. let md5Sign = md5(
  207. "method=" +
  208. "user" +
  209. "&timestamp=" +
  210. getApp().globalData.globalTimestamp +
  211. "&secret=" +
  212. getApp().globalData.secret
  213. );
  214. let url =
  215. getApp().globalData.shareUrl +
  216. "api/api.php" +
  217. "?method=user&source=user&action=get_address&timestamp=" +
  218. getApp().globalData.globalTimestamp +
  219. "&sign=" +
  220. md5Sign;
  221. let postData = {
  222. address:addressResult,
  223. openId: getApp().globalData.open_id,
  224. };
  225. uni.request({
  226. url: url,
  227. method: "POST",
  228. header: {
  229. "content-type": "application/x-www-form-urlencoded",
  230. },
  231. data: postData,
  232. success: (res) => {
  233. if (res.data.code === 200) {
  234. if(res.data.data.length === 0){
  235. uni.showToast({
  236. title: "暂无数据",
  237. icon: "error",
  238. });
  239. }else{
  240. that.makeHouseData(searchType,res.data.data)
  241. }
  242. }
  243. },
  244. fail: () => {
  245. console.log("连接失败");
  246. },
  247. });
  248. },
  249. makeHouseData(type,dataList){
  250. let that = this , obj = dataList;
  251. switch (type){
  252. case 'houseBuilding':
  253. for (let key in obj) {
  254. let child = {
  255. name:obj[key]
  256. }
  257. that.buildList.push(child)
  258. }
  259. that.searchDetail(that.hoodList[that.hoodIndex].name,that.buildList[0].name)
  260. break;
  261. case 'houseUnit':
  262. for (let key in obj) {
  263. let child = {
  264. name:obj[key]
  265. }
  266. that.unitList.push(child)
  267. }
  268. that.searchDetail(that.hoodList[that.hoodIndex].name,that.buildList[that.buildIndex].name,that.unitList[0].name)
  269. break;
  270. case 'houseNumber':
  271. for (let key in obj) {
  272. let child = {
  273. name:obj[key]
  274. }
  275. that.numList.push(child)
  276. }
  277. that.numList[that.numIndex].name = that.numList[0].name
  278. break;
  279. default:
  280. break;
  281. }
  282. },
  283. houseSubmit(){
  284. //uni.navigateBack({});
  285. this.open()
  286. },
  287. hoodChange(e){
  288. this.hoodIndex = e.detail.value;
  289. this.searchDetail(this.hoodList[this.hoodIndex].name)
  290. },
  291. buildingChange(e) {
  292. if(!this.hoodList.length){
  293. uni.showToast({
  294. title: "请先选择小区",
  295. icon: "error",
  296. });
  297. return
  298. }
  299. this.buildIndex = e.detail.value;
  300. this.searchDetail(this.hoodList[this.hoodIndex].name,this.buildList[this.buildIndex].name)
  301. },
  302. unitChange(e) {
  303. if(!this.buildList.length){
  304. uni.showToast({
  305. title: "请先选择楼栋",
  306. icon: "error",
  307. });
  308. return
  309. }
  310. this.unitIndex = e.detail.value;
  311. this.searchDetail(this.hoodList[this.hoodIndex].name,this.buildList[this.buildIndex].name,this.unitList[this.unitIndex].name)
  312. },
  313. numChange(e) {
  314. if(!this.unitList.length){
  315. uni.showToast({
  316. title: "请先选择单元",
  317. icon: "error",
  318. });
  319. return
  320. }
  321. this.numIndex = e.detail.value;
  322. // this.searchDetail(this.hoodList[this.hoodIndex].name,this.buildList[this.buildIndex].name,this.unitList[this.unitIndex].name)
  323. },
  324. submitPop(){
  325. this.closePopup()
  326. this.submit()
  327. },
  328. closePop(){
  329. this.closePopup()
  330. },
  331. open() {
  332. this.$refs.popup.open('center')
  333. },
  334. closePopup() {
  335. this.$refs.popup.close()
  336. },
  337. submit() {
  338. if (
  339. !this.buildList.length ||
  340. !this.unitList.length ||
  341. !this.numList.length
  342. ) {
  343. uni.showToast({
  344. title: "小区信息不完善",
  345. icon: "error",
  346. });
  347. return;
  348. }
  349. let addressResult = this.hoodList[this.hoodIndex].name + '/' + this.buildList[this.buildIndex].name + '/' + this.unitList[this.unitIndex].name + '/' + this.numList[this.numIndex].name
  350. let md5Sign = md5(
  351. "method=" +
  352. "user" +
  353. "&timestamp=" +
  354. getApp().globalData.globalTimestamp +
  355. "&secret=" +
  356. getApp().globalData.secret
  357. );
  358. let url =
  359. getApp().globalData.shareUrl +
  360. "api/api.php" +
  361. "?method=user&source=user&action=band_owner&timestamp=" +
  362. getApp().globalData.globalTimestamp +
  363. "&sign=" +
  364. md5Sign;
  365. let postData = {
  366. address:addressResult,
  367. openId: getApp().globalData.open_id,
  368. };
  369. uni.request({
  370. url: url,
  371. method: "POST",
  372. header: {
  373. "content-type": "application/x-www-form-urlencoded",
  374. },
  375. data: postData,
  376. success: (res) => {
  377. if (res.data.code === 200) {
  378. uni.showToast({
  379. title: "绑定成功",
  380. icon: "success",
  381. });
  382. }
  383. },
  384. fail: () => {
  385. console.log("连接失败");
  386. },
  387. });
  388. },
  389. },
  390. };
  391. </script>
  392. <style lang="scss" scoped>
  393. .content {
  394. font-size: 28rpx;
  395. font-weight: 200;
  396. padding: 1% 2%;
  397. .title {
  398. font-size: 30rpx;
  399. margin: 4% 0;
  400. }
  401. label {
  402. display: inline-block;
  403. width: 25%;
  404. vertical-align: middle;
  405. }
  406. .card {
  407. background-color: rgb(248, 247, 247);
  408. border-radius: 10rpx;
  409. }
  410. .flex {
  411. display: flex;
  412. align-items: center;
  413. margin-bottom: 2%;
  414. }
  415. .input {
  416. padding: 0 2%;
  417. margin: 2% 0;
  418. display: inline-block;
  419. width: 80%;
  420. height: 70rpx;
  421. }
  422. .supplyInfo {
  423. border-radius: 40rpx;
  424. padding: 4%;
  425. box-shadow: rgba(100, 100, 111, 0.2) 14rpx 14rpx 40rpx 14rpx;
  426. margin: 30rpx 0 30rpx 0;
  427. }
  428. .info {
  429. margin-top: 2%;
  430. border-radius: 40rpx;
  431. padding: 2% 4%;
  432. box-shadow: rgba(100, 100, 111, 0.2) 14rpx 14rpx 40rpx 14rpx;
  433. }
  434. .submit {
  435. color: white;
  436. font-weight: normal;
  437. width: 55%;
  438. border-radius: 20rpx;
  439. background-color: #02a7f0;
  440. margin: 120rpx auto;
  441. }
  442. }
  443. .popup-box {
  444. height: 100%;
  445. display: flex;
  446. flex-direction: column;
  447. justify-content: space-between;
  448. }
  449. .popup-title {
  450. text-align: center;
  451. font-weight: bold;
  452. height: 30px;
  453. border-bottom: 1px solid #d8d8d8;
  454. }
  455. .popup-content {
  456. font-size: 28rpx;
  457. padding: 10rpx 0 10rpx 0;
  458. }
  459. .popup-type {
  460. height: 80rpx;
  461. text-align: center;
  462. margin-top: 150rpx;
  463. }
  464. .popup-footer {
  465. display: flex;
  466. button{
  467. font-size: 26rpx;
  468. height: 60rpx;
  469. width: 150rpx;
  470. line-height: 60rpx;
  471. color: #FFFFFF;
  472. }
  473. }
  474. .popup-cancel {
  475. background-color: #AAAAAA;
  476. }
  477. .popup-submit {
  478. background-color: #249CD3;
  479. }
  480. </style>