task.vue 16 KB

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