task.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. const authSetting = await this.checkLocationAuth();
  178. if (!authSetting) {
  179. await this.showAuthorizeGuide();
  180. return;
  181. }
  182. // 选择位置
  183. const res = await this.chooseLocation();
  184. console.log('位置名称:' + res.name);
  185. console.log('详细地址:' + res.address);
  186. console.log('纬度:' + res.latitude);
  187. console.log('经度:' + res.longitude);
  188. // 更新数据
  189. that.propertyData.lng = res.longitude;
  190. that.propertyData.lat = res.latitude;
  191. that.propertyData.address = res.address;
  192. that.propertyData.complexName = res.name || '';
  193. // 根据地址信息设置区域
  194. this.setDistrictByAddress(res.address);
  195. } catch (err) {
  196. console.log('获取位置失败:', err);
  197. if (err.errMsg && (err.errMsg.includes('auth deny') || err.errMsg.includes('fail cancel'))) {
  198. uni.showToast({
  199. title: '需要位置权限才能选择地址',
  200. icon: 'none'
  201. });
  202. }
  203. }
  204. },
  205. // 检查位置权限
  206. checkLocationAuth() {
  207. return new Promise((resolve) => {
  208. uni.getSetting({
  209. success: (res) => {
  210. const authSetting = res.authSetting;
  211. resolve(authSetting['scope.userLocation'] || false);
  212. },
  213. fail: () => {
  214. resolve(false);
  215. }
  216. });
  217. });
  218. },
  219. // 选择位置
  220. chooseLocation() {
  221. return new Promise((resolve, reject) => {
  222. uni.chooseLocation({
  223. success: resolve,
  224. fail: reject
  225. });
  226. });
  227. },
  228. showAuthorizeGuide() {
  229. return new Promise((resolve, reject) => {
  230. uni.showModal({
  231. title: '位置权限未开启',
  232. content: '需要您授权位置信息才能提供此服务,请到设置中开启权限',
  233. confirmText: '去设置',
  234. success: (modalRes) => {
  235. if (modalRes.confirm) {
  236. // 打开小程序设置页面
  237. uni.openSetting({
  238. success: (openRes) => {
  239. if (openRes.authSetting['scope.userLocation']) {
  240. uni.showToast({
  241. title: '授权成功',
  242. icon: 'success'
  243. });
  244. resolve();
  245. } else {
  246. uni.showToast({
  247. title: '授权失败',
  248. icon: 'none'
  249. });
  250. reject();
  251. }
  252. }
  253. });
  254. } else {
  255. reject();
  256. }
  257. }
  258. });
  259. });
  260. },
  261. // 根据地址设置区域
  262. setDistrictByAddress(address) {
  263. if (!address) return;
  264. const districtText = this.extractDistrictFromAddress(address);
  265. if (districtText) {
  266. const district = this.districtOption.find(item =>
  267. districtText.includes(item.text) || item.text.includes(districtText)
  268. );
  269. if (district) {
  270. this.propertyData.district = district.value;
  271. }
  272. }
  273. },
  274. // 从地址中提取区域信息
  275. extractDistrictFromAddress(address) {
  276. if (!address) return '';
  277. // 简单的区域提取逻辑,可以根据实际需求调整
  278. for (let district of this.districtOption) {
  279. if (address.includes(district.text)) {
  280. return district.text;
  281. }
  282. }
  283. return '';
  284. },
  285. setLocation(res) {
  286. console.log("收到监听", res)
  287. this.propertyData.address = res.address
  288. this.propertyData.lat = res.lat
  289. this.propertyData.lng = res.lng
  290. this.propertyData.complexName = res.complexName
  291. this.setDistrictByAddress(res.address);
  292. // this.districtOption.forEach(item => {
  293. // if (res.districtName === item.text) {
  294. // this.propertyData.district = item.value
  295. // }
  296. // })
  297. },
  298. getValuationOption() {
  299. if (this.propertyData.houseType === "") {
  300. this.propertyData.houseType = 0
  301. }
  302. getValuationOption({
  303. "modelType": this.propertyData.modelType
  304. }).then(res => {
  305. if (res.code === 0) {
  306. if (this.propertyData.modelType === 1) {
  307. this.houseTypeOption = res.data.houseTypeOption
  308. } else if (this.propertyData.modelType === 3) {
  309. this.levelOption = res.data.levelOption
  310. this.transferMethodOption = res.data.transferMethodOption
  311. this.landUseOption = res.data.landUseOption
  312. this.landSourceOption = res.data.landSourceOption
  313. this.propertyData.land_source = this.landSourceOption[0].id
  314. }
  315. }
  316. })
  317. },
  318. onSubmit() {
  319. console.log('提交评估数据', this.propertyData)
  320. predictProperty(this.propertyData).then(res => {
  321. if (res.code === 0) {
  322. console.log(res, 'res');
  323. this.propertyRes = res.data
  324. } else {
  325. tools.error(res.msg)
  326. }
  327. })
  328. },
  329. setMapMarker(lng, lat, status) {
  330. if (this.marker === undefined) {
  331. this.marker = new AMap.Marker({
  332. position: new AMap.LngLat(lng, lat),
  333. offset: new AMap.Pixel(-10, -10),
  334. icon: "//vdata.amap.com/icons/b18/1/2.png", //添加 icon 图标 URL
  335. title: "标记位",
  336. });
  337. this.map.add(this.marker);
  338. } else {
  339. this.marker.setPosition(new AMap.LngLat(lng, lat));
  340. }
  341. if (status) {
  342. this.location.lat = lat
  343. this.location.lng = lng
  344. AMap.plugin("AMap.Geocoder", () => {
  345. let geocoder = new AMap.Geocoder({
  346. city: "大连市", // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
  347. extensions: "all"
  348. });
  349. let lnglat = [this.location.lng, this.location.lat];
  350. geocoder.getAddress(lnglat, (status, result) => {
  351. if (status === "complete" && result.info === "OK") {
  352. // result为对应的地理位置详细信息
  353. console.log(result.regeocode)
  354. if (result.regeocode.formattedAddress !== undefined && result.regeocode
  355. .formattedAddress !== "") {
  356. this.location.address = result.regeocode.formattedAddress;
  357. this.location.districtName = result.regeocode.addressComponent
  358. .district;
  359. if (result.regeocode.pois !== undefined && result.regeocode.pois
  360. .length > 0) {
  361. this.location.complexName = result.regeocode.pois[0].name
  362. }
  363. }
  364. }
  365. });
  366. });
  367. }
  368. },
  369. },
  370. }
  371. </script>
  372. <style lang="scss" scoped>
  373. .input-item:last-child {
  374. margin-top: 30rpx;
  375. }
  376. .input-send {
  377. display: flex;
  378. justify-content: flex-start;
  379. align-items: center;
  380. border-bottom: 1px solid #E5E5E5;
  381. .login-input {
  382. width: calc(100% - 150rpx);
  383. }
  384. .login-send {
  385. width: 100rpx;
  386. text-align: center;
  387. margin-left: 20rpx;
  388. border: 1rpx solid #0FB160;
  389. border-radius: 50rpx;
  390. }
  391. }
  392. .left-w {
  393. width: 210rpx;
  394. min-width: 210rpx;
  395. color: #333333;
  396. }
  397. .iconfont {
  398. font-size: 36rpx;
  399. color: #333333;
  400. }
  401. .class-c-6C6F93 {
  402. color: #0FB160;
  403. }
  404. .agreement-data {
  405. border-radius: 30rpx 30rpx 0 0;
  406. .data-title {
  407. width: 100%;
  408. border-radius: 30rpx 30rpx 0 0;
  409. }
  410. .data-content {
  411. padding: 20rpx 40rpx;
  412. .content-box {
  413. height: 600rpx;
  414. }
  415. }
  416. .data-but {
  417. height: 96rpx;
  418. line-height: 96rpx;
  419. text-align: center;
  420. margin: 0 75rpx;
  421. }
  422. }
  423. </style>