task.vue 13 KB

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