with_house.vue 12 KB

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