task.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="total-page page-box task-bg">
  3. <Nav title="法案查询" :genre="1" :toBack="true" is_fixed></Nav>
  4. <view class="page-env-160">
  5. <!-- 身份认证start -->
  6. <view class="m-t20 m-lr30 text-color-12">
  7. <view class="sys-background-fff r-20 p-lr30 p-t30">
  8. <en-select v-model="propertyData.modelType" :local-data="typeOption" label="评估模型"
  9. placeholder="请选择评估模型"></en-select>
  10. <en-input v-model="propertyData.address" label="评估地址" disabled="disabled" placeholder="请输入评估地址"
  11. @inputBut="inputBut"></en-input>
  12. <en-input v-model="propertyData.complexName" :label="'小区名称'" disabled="disabled"
  13. placeholder="请输入小区名称"> </en-input>
  14. <en-input :value="propertyData.lng+','+propertyData.lat" disabled="disabled" label="评估坐标"
  15. placeholder="地址经纬度"></en-input>
  16. <en-input v-model="propertyData.area" :label="'建筑面积'" placeholder="请输入建筑面积"> </en-input>
  17. <en-select v-model="propertyData.district" :local-data="districtOption" :label="'所属区域'"
  18. placeholder="请选择所属区域"> </en-select>
  19. </view>
  20. </view>
  21. <view class="sys-background-fff r-20 m-t20 p-lr30" v-if="propertyData.modelType===1">
  22. <en-select v-model="propertyData.houseType" :local-data="houseTypeOption" label="房屋类型"
  23. placeholder="请选择房屋类型"></en-select>
  24. </view>
  25. <view class="sys-background-fff r-20 m-t20 p-lr30" v-if="propertyData.modelType===2">
  26. <EnRadio v-model="propertyData.is_rent" label="是否出租" :list="statusOption"> </EnRadio>
  27. <EnRadio v-model="propertyData.is_morgaged" label="是否抵押" :list="statusOption"> </EnRadio>
  28. <EnRadio v-model="propertyData.is_occupied" label="是否占用" :list="statusOption"> </EnRadio>
  29. <EnRadio v-model="propertyData.is_seizured" label="是否查封" :list="statusOption"> </EnRadio>
  30. </view>
  31. <view class="sys-background-fff r-20 m-t20 p-lr30" v-if="propertyData.modelType===3">
  32. <en-select v-model="propertyData.level_id" :local-data="levelOption" :label="'土地等级'"
  33. placeholder="请选择土地等级"> </en-select>
  34. <en-select v-model="propertyData.transfer_method" :local-data="transferMethodOption" :label="'出让方式'"
  35. placeholder="请选择出让方式"> </en-select>
  36. <en-select v-model="propertyData.land_use" :local-data="landUseOption" :label="'土地用途'"
  37. placeholder="请选择土地用途"> </en-select>
  38. <en-select v-model="propertyData.land_source" :local-data="landSourceOption" :label="'土地来源'"
  39. placeholder="请选择土地来源"> </en-select>
  40. <en-input v-model="propertyData.age_limit" :label="'出让年限'" placeholder="请输入出让年限"> </en-input>
  41. <en-input v-model="propertyData.investment" :label="'投资强度'" placeholder="请输入投资强度"> </en-input>
  42. <en-input v-model="propertyData.plot_mix" :label="'最小容积'" placeholder="请输入最小容积率"> </en-input>
  43. <en-input v-model="propertyData.plot_max" :label="'最大容积'" placeholder="请输入最大容积率"> </en-input>
  44. <en-input v-model="propertyData.greening_mix" :label="'最小绿化'" placeholder="请输入最小绿化面积"> </en-input>
  45. <en-input v-model="propertyData.greening_max" :label="'最大绿化'" placeholder="请输入最大绿化面积"> </en-input>
  46. <en-input v-model="propertyData.height_mix" :label="'最小高度'" placeholder="请输入最小建筑高度"> </en-input>
  47. <en-input v-model="propertyData.height_max" :label="'最大高度'" placeholder="请输入最大建筑高度"> </en-input>
  48. </view>
  49. </view>
  50. <EnButton :text="'评估'" @onSubmit="onSubmit"></EnButton>
  51. <uni-popup ref="consentObj">
  52. <view class="iPhone-padding agreement-data sys-background-fff">
  53. </view>
  54. </uni-popup>
  55. </view>
  56. </template>
  57. <script>
  58. import EnUpload from "@/components/en-from/en-upload/en-upload.vue";
  59. import EnSelect from "@/components/en-from/en-select/en-select.vue";
  60. import EnRadio from "@/components/en-from/en-radio/en-radio.vue";
  61. import EnInput from "@/components/en-from/en-input/en-input.vue";
  62. import {
  63. predictProperty
  64. } from "@/api/valuation.js"
  65. export default {
  66. components: {
  67. EnInput,
  68. EnSelect,
  69. EnRadio,
  70. EnUpload,
  71. },
  72. data() {
  73. return {
  74. typeOption: [{
  75. value: 1,
  76. text: '住宅模型'
  77. }, {
  78. value: 2,
  79. text: '公建模型'
  80. }, {
  81. value: 3,
  82. text: '土地模型'
  83. }, {
  84. value: 4,
  85. text: '工业模型'
  86. }],
  87. statusOption: [{
  88. value: 1,
  89. text: '是'
  90. }, {
  91. value: 0,
  92. text: '否'
  93. }],
  94. houseTypeOption: [],
  95. levelOption: [],
  96. transferMethodOption: [],
  97. landUseOption: [],
  98. landSourceOption: [],
  99. districtOption: [{
  100. value: 1,
  101. text: '甘井子区'
  102. }, {
  103. value: 2,
  104. text: '中山区'
  105. }, {
  106. value: 3,
  107. text: '西岗区'
  108. }, {
  109. value: 4,
  110. text: '沙河口区'
  111. }, {
  112. value: 5,
  113. text: '旅顺口区'
  114. }, {
  115. value: 6,
  116. text: '金州区'
  117. }, {
  118. value: 7,
  119. text: '瓦房店市'
  120. }, {
  121. value: 8,
  122. text: '庄河市'
  123. }, {
  124. value: 9,
  125. text: '普兰店区'
  126. }],
  127. propertyData: {
  128. level_id: 1,
  129. transfer_method: 1,
  130. land_use: 1,
  131. land_source: 1,
  132. investment: 0,
  133. plot_mix: 0,
  134. plot_max: 0,
  135. height_mix: 0,
  136. height_max: 0,
  137. greening_mix: 0,
  138. greening_max: 0,
  139. age_limit: 0,
  140. floor_area: 0,
  141. lat: 0,
  142. lng: 0,
  143. is_sold: 0,
  144. is_rent: 0,
  145. is_morgaged: 0,
  146. is_occupied: 0,
  147. is_seizured: 0,
  148. address: '',
  149. modelType: '',
  150. area: '',
  151. district: '',
  152. houseType: '',
  153. complexName: '',
  154. },
  155. propertyRes: {
  156. unit_price: '',
  157. predict_msg: '',
  158. },
  159. location: {
  160. lat: 0,
  161. lng: 0,
  162. address: '',
  163. districtName: '',
  164. complexName: ''
  165. },
  166. };
  167. },
  168. onLoad(options) {},
  169. onShow() {},
  170. watch: {},
  171. mounted() {},
  172. methods: {
  173. async inputBut() {
  174. let that = this;
  175. try {
  176. // 选择位置
  177. uni.chooseLocation({
  178. success: function(res) {
  179. // 更新数据
  180. that.propertyData.lng = res.longitude;
  181. that.propertyData.lat = res.latitude;
  182. that.propertyData.address = res.address;
  183. that.propertyData.complexName = res.name || '';
  184. // 根据地址信息设置区域
  185. that.setDistrictByAddress(res.address);
  186. console.log('当前位置的经度:' + res.longitude);
  187. console.log('当前位置的纬度:' + res.latitude);
  188. },
  189. fail: async function(err) {
  190. console.log('获取位置失败:', err);
  191. // 如果是授权被拒绝
  192. if (err.errMsg.indexOf('auth deny') !== -1) {
  193. try {
  194. // 引导用户手动开启授权
  195. await showAuthorizeGuide();
  196. } catch (e) {
  197. console.log('授权引导失败:', e);
  198. }
  199. }
  200. }
  201. });
  202. } catch (err) {
  203. console.log('获取位置失败:', err);
  204. if (err.errMsg && (err.errMsg.includes('auth deny') || err.errMsg.includes('fail cancel'))) {
  205. uni.showToast({
  206. title: '需要位置权限才能选择地址',
  207. icon: 'none'
  208. });
  209. }
  210. }
  211. },
  212. // 检查位置权限
  213. checkLocationAuth() {
  214. return new Promise((resolve) => {
  215. uni.getSetting({
  216. success: (res) => {
  217. const authSetting = res.authSetting;
  218. resolve(authSetting['scope.userLocation'] || false);
  219. },
  220. fail: () => {
  221. resolve(false);
  222. }
  223. });
  224. });
  225. },
  226. // 选择位置
  227. // chooseLocation() {
  228. // return new Promise((resolve, reject) => {
  229. // uni.chooseLocation({
  230. // success: resolve,
  231. // fail: reject
  232. // });
  233. // });
  234. // },
  235. showAuthorizeGuide() {
  236. return new Promise((resolve, reject) => {
  237. uni.showModal({
  238. title: '位置权限未开启',
  239. content: '需要您授权位置信息才能提供此服务,请到设置中开启权限',
  240. confirmText: '去设置',
  241. success: (modalRes) => {
  242. if (modalRes.confirm) {
  243. // 打开小程序设置页面
  244. uni.openSetting({
  245. success: (openRes) => {
  246. if (openRes.authSetting['scope.userLocation']) {
  247. uni.showToast({
  248. title: '授权成功',
  249. icon: 'success'
  250. });
  251. resolve();
  252. } else {
  253. uni.showToast({
  254. title: '授权失败',
  255. icon: 'none'
  256. });
  257. reject();
  258. }
  259. }
  260. });
  261. } else {
  262. reject();
  263. }
  264. }
  265. });
  266. });
  267. },
  268. // 根据地址设置区域
  269. setDistrictByAddress(address) {
  270. if (!address) return;
  271. const districtText = this.extractDistrictFromAddress(address);
  272. if (districtText) {
  273. const district = this.districtOption.find(item =>
  274. districtText.includes(item.text) || item.text.includes(districtText)
  275. );
  276. if (district) {
  277. this.propertyData.district = district.value;
  278. }
  279. }
  280. },
  281. // 从地址中提取区域信息
  282. extractDistrictFromAddress(address) {
  283. if (!address) return '';
  284. // 简单的区域提取逻辑,可以根据实际需求调整
  285. for (let district of this.districtOption) {
  286. if (address.includes(district.text)) {
  287. return district.text;
  288. }
  289. }
  290. return '';
  291. },
  292. setLocation(res) {
  293. console.log("收到监听", res)
  294. this.propertyData.address = res.address
  295. this.propertyData.lat = res.lat
  296. this.propertyData.lng = res.lng
  297. this.propertyData.complexName = res.complexName
  298. this.setDistrictByAddress(res.address);
  299. // this.districtOption.forEach(item => {
  300. // if (res.districtName === item.text) {
  301. // this.propertyData.district = item.value
  302. // }
  303. // })
  304. },
  305. getValuationOption() {
  306. if (this.propertyData.houseType === "") {
  307. this.propertyData.houseType = 0
  308. }
  309. getValuationOption({
  310. "modelType": this.propertyData.modelType
  311. }).then(res => {
  312. if (res.code === 0) {
  313. if (this.propertyData.modelType === 1) {
  314. this.houseTypeOption = res.data.houseTypeOption
  315. } else if (this.propertyData.modelType === 3) {
  316. this.levelOption = res.data.levelOption
  317. this.transferMethodOption = res.data.transferMethodOption
  318. this.landUseOption = res.data.landUseOption
  319. this.landSourceOption = res.data.landSourceOption
  320. this.propertyData.land_source = this.landSourceOption[0].id
  321. }
  322. }
  323. })
  324. },
  325. onSubmit() {
  326. console.log('提交评估数据', this.propertyData)
  327. predictProperty(this.propertyData).then(res => {
  328. if (res.code === 0) {
  329. console.log(res, 'res');
  330. this.propertyRes = res.data
  331. } else {
  332. tools.error(res.msg)
  333. }
  334. })
  335. },
  336. setMapMarker(lng, lat, status) {
  337. if (this.marker === undefined) {
  338. this.marker = new AMap.Marker({
  339. position: new AMap.LngLat(lng, lat),
  340. offset: new AMap.Pixel(-10, -10),
  341. icon: "//vdata.amap.com/icons/b18/1/2.png", //添加 icon 图标 URL
  342. title: "标记位",
  343. });
  344. this.map.add(this.marker);
  345. } else {
  346. this.marker.setPosition(new AMap.LngLat(lng, lat));
  347. }
  348. if (status) {
  349. this.location.lat = lat
  350. this.location.lng = lng
  351. AMap.plugin("AMap.Geocoder", () => {
  352. let geocoder = new AMap.Geocoder({
  353. city: "大连市", // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
  354. extensions: "all"
  355. });
  356. let lnglat = [this.location.lng, this.location.lat];
  357. geocoder.getAddress(lnglat, (status, result) => {
  358. if (status === "complete" && result.info === "OK") {
  359. // result为对应的地理位置详细信息
  360. console.log(result.regeocode)
  361. if (result.regeocode.formattedAddress !== undefined && result.regeocode
  362. .formattedAddress !== "") {
  363. this.location.address = result.regeocode.formattedAddress;
  364. this.location.districtName = result.regeocode.addressComponent
  365. .district;
  366. if (result.regeocode.pois !== undefined && result.regeocode.pois
  367. .length > 0) {
  368. this.location.complexName = result.regeocode.pois[0].name
  369. }
  370. }
  371. }
  372. });
  373. });
  374. }
  375. },
  376. },
  377. }
  378. </script>
  379. <style lang="scss" scoped>
  380. .input-item:last-child {
  381. margin-top: 30rpx;
  382. }
  383. .input-send {
  384. display: flex;
  385. justify-content: flex-start;
  386. align-items: center;
  387. border-bottom: 1px solid #E5E5E5;
  388. .login-input {
  389. width: calc(100% - 150rpx);
  390. }
  391. .login-send {
  392. width: 100rpx;
  393. text-align: center;
  394. margin-left: 20rpx;
  395. border: 1rpx solid #0FB160;
  396. border-radius: 50rpx;
  397. }
  398. }
  399. .left-w {
  400. width: 210rpx;
  401. min-width: 210rpx;
  402. color: #333333;
  403. }
  404. .iconfont {
  405. font-size: 36rpx;
  406. color: #333333;
  407. }
  408. .class-c-6C6F93 {
  409. color: #0FB160;
  410. }
  411. .agreement-data {
  412. border-radius: 30rpx 30rpx 0 0;
  413. .data-title {
  414. width: 100%;
  415. border-radius: 30rpx 30rpx 0 0;
  416. }
  417. .data-content {
  418. padding: 20rpx 40rpx;
  419. .content-box {
  420. height: 600rpx;
  421. }
  422. }
  423. .data-but {
  424. height: 96rpx;
  425. line-height: 96rpx;
  426. text-align: center;
  427. margin: 0 75rpx;
  428. }
  429. }
  430. </style>