renLing.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <template>
  2. <view class="box">
  3. <u-navbar @leftClick="rightClick" title="文物认领" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#000000"></u-navbar>
  4. <view class="fj_box">
  5. <view class="" style="display: flex; justify-content: space-between; margin-left: -25rpx">
  6. <button open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">
  7. <view class="fj_item">
  8. <view class="tit2">通过手机号找回</view>
  9. </view>
  10. </button>
  11. <view class="fj_item" @click="vicinityBtn">
  12. <view class="tit2">附近可被认领文物</view>
  13. </view>
  14. </view>
  15. <view class="scarch_box2">
  16. <u--input
  17. @change="search"
  18. @input="onInputChange"
  19. placeholderStyle="color: #985741"
  20. height="25"
  21. prefixIcon="search"
  22. shape="square"
  23. placeholder="输入文物关键字"
  24. v-model.trim="value"
  25. ></u--input>
  26. </view>
  27. </view>
  28. <!-- 搜索的文物 -->
  29. <view class="" style="position: relative">
  30. <u-transition :show="searchList.length > 0">
  31. <scroll-view v-if="searchList.length > 0" class="search_box" scroll-y="true" @scrolltolower="LoadMore">
  32. <view>
  33. <view @click="searchItem(item)" class="item_tit" v-for="item in searchList" :key="item.id">
  34. {{ item.title }}
  35. </view>
  36. </view>
  37. </scroll-view>
  38. </u-transition>
  39. </view>
  40. <!-- 文物信息 -->
  41. <u-popup :show="introduceShow" @close="close" mode="center" :closeable="true" bgColor="#f9dbbf" round="5">
  42. <view class="xx_box">
  43. <view v-if="swiperList != null">
  44. <u-swiper
  45. :list="swiperList"
  46. imgMode="aspectFill"
  47. :height="160"
  48. :indicator="true"
  49. radius="5"
  50. :autoplay="true"
  51. :circular="true"
  52. indicatorStyle="bottom: 10px"
  53. indicatorMode="dot"
  54. indicatorActiveColor="#fff"
  55. indicatorInactiveColor="rgba(255, 255, 255, 0.35)"
  56. ></u-swiper>
  57. </view>
  58. <view v-else><u-empty text="暂无图片 " iconColor="#4a433d" textColor="#4a433d" mode="data"></u-empty></view>
  59. <view class="xx_tit" v-if="claimDetails.intro != '' && claimDetails.intro != null">
  60. <u-parse :content="claimDetails.intro"></u-parse>
  61. </view>
  62. <view v-else><u-empty text="该文物暂无介绍 " iconColor="#4a433d" textColor="#4a433d" mode="data"></u-empty></view>
  63. <view class="claim_tit" @click="claimBtn">认领</view>
  64. </view>
  65. </u-popup>
  66. <!-- 地图 -->
  67. <view>
  68. <mapComponent
  69. ref="mychild"
  70. @subComponent="subComponent"
  71. :markers="markers"
  72. :height="height"
  73. :latitudeAndLongitude="latitudeAndLongitude"
  74. :introduceShow="introduceShow"
  75. ></mapComponent>
  76. </view>
  77. <!-- 手机号弹层 -->
  78. <u-popup bgColor="#f2c8a2" :show="deleteShow" @close="close" mode="center" customStyle="width:600rpx;padding: 30rpx;" round="20rpx">
  79. <view style="text-align: center; font-size: 30rpx">请输入报名志愿者的手机号</view>
  80. <view style="margin-top: 20rpx">
  81. <u--textarea height="50" v-model.trim="mobile" placeholder="请输入手机号:"></u--textarea>
  82. </view>
  83. <view class="bt_box">
  84. <view
  85. class="bt1"
  86. @click="
  87. deleteShow = false;
  88. reasonVal = '';
  89. "
  90. >
  91. 取消
  92. </view>
  93. <view @click="isOk" class="bt3">确认</view>
  94. </view>
  95. </u-popup>
  96. <!-- 确认弹层 -->
  97. <u-popup bgColor="#f2c8a2" :show="queren" mode="center" customStyle="width:600rpx;height: 300rpx; padding: 30rpx;" round="20rpx">
  98. <view style="text-align: center; font-size: 30rpx">手机号绑定成功</view>
  99. <view @click="querenBtn" class="bt2">确认</view>
  100. </u-popup>
  101. </view>
  102. </template>
  103. <script>
  104. let that;
  105. export default {
  106. data() {
  107. return {
  108. queren: false,
  109. volunteer_id: '',
  110. mobile: '',
  111. deleteShow: false,
  112. longitude: '',
  113. latitude: '',
  114. page: 1,
  115. searchList: [] /* 搜索的数组 */,
  116. isProcessingItemClick: false,
  117. volunteerId: '' /* 志愿者id */,
  118. value: '',
  119. swiperList: [],
  120. height: '1200',
  121. latitudeAndLongitude: {
  122. latitude: '24.504403',
  123. longitude: ' 118.143033',
  124. anchorPoint: true /* 定位点是否显示 */
  125. },
  126. markers: [],
  127. claimDetails: {} /* 文物详情 */,
  128. introduceShow: false,
  129. joinList: []
  130. };
  131. },
  132. onLoad() {
  133. that = this;
  134. this.details();
  135. // this.vicinityBtn();
  136. this.getContentList();
  137. },
  138. methods: {
  139. search() {
  140. if (this.preventSearchOnChange) {
  141. this.preventSearchOnChange = false;
  142. return;
  143. }
  144. // console.log(this.value, '666');
  145. if (this.value) {
  146. // 只有在搜索词变化时重置page为1
  147. if (this.prevSearchVal !== this.value) {
  148. this.prevSearchVal = this.value; // 更新prevSearchVal为当前搜索词
  149. this.page = 1; // 当搜索词变化时重置page
  150. this.searchList = []; // 清空已有搜索结果
  151. }
  152. this.$api.getContentList(
  153. {
  154. main_body_id: 1,
  155. model_id: 1,
  156. keywords: this.value || '',
  157. page: this.page,
  158. claim_status: '0',
  159. pageSize: '10'
  160. },
  161. function (res) {
  162. that.searchList = [...that.searchList, ...res.data];
  163. }
  164. );
  165. } else {
  166. this.searchList = [];
  167. }
  168. },
  169. // 解决选中文物后再次触发change事件
  170. onInputChange(value) {
  171. // 如果在处理点击搜索结果,不触发搜索
  172. if (!this.isProcessingItemClick) {
  173. this.value = value;
  174. }
  175. },
  176. // 搜索的每项
  177. searchItem(item) {
  178. // console.log(item, 'item');
  179. this.isProcessingItemClick = true;
  180. this.value = item.title;
  181. // this.cr_id = item.id;
  182. this.searchList = []; // 清空已有的搜索结果
  183. // 在操作完成后恢复标记
  184. this.$nextTick(() => {
  185. this.isProcessingItemClick = false;
  186. });
  187. this.latitude = '';
  188. this.longitude = '';
  189. this.getContentList(this.value);
  190. this.latitudeAndLongitude.latitude = item.latitude;
  191. this.latitudeAndLongitude.longitude = item.longitude;
  192. },
  193. // 下滑加载
  194. LoadMore() {
  195. this.page++;
  196. this.search();
  197. },
  198. // 附近
  199. vicinityBtn() {
  200. // console.log(this.$refs.mychild);
  201. this.$refs.mychild.vicinityBtn();
  202. this.value = '';
  203. this.longitude = this.$refs.mychild.longitude;
  204. this.latitude = this.$refs.mychild.latitude;
  205. // console.log(this.longitude, this.latitude, '子组件经纬度');
  206. // 附近未被认领文物
  207. this.$api.getContentList(
  208. {
  209. model_id: '1',
  210. main_body_id: '1',
  211. page: 1,
  212. pageSize: '100',
  213. region: 5,
  214. claim_status: 0,
  215. longitude: this.longitude,
  216. latitude: this.latitude
  217. },
  218. function (res) {
  219. that.markers = [];
  220. res.data.forEach((item, index) => {
  221. // console.log(item, 'itemitem');
  222. that.markers.push({
  223. id: parseFloat(item.id),
  224. latitude: parseFloat(item.latitude), //纬度
  225. longitude: parseFloat(item.longitude), //经度
  226. // iconPath: item.thumbnail, //显示的图标
  227. iconPath: item.thumbnail ? item.thumbnail : '/static/img.icon_map.png',
  228. width: 30, //宽
  229. height: 30, //高
  230. title: item.title, //标注点名
  231. label: {
  232. //自定义标记点上方的文本
  233. content: item.title, //文本
  234. color: '#444444', //文字颜色
  235. fontSize: 14, //文本大小
  236. bgColor: '#f1cdb2', // 背景颜色(半透明黑色)
  237. borderRadius: 5, // 边框圆角
  238. padding: [2, 2], // 内边距
  239. textAlign: 'center', // 文本对齐方式
  240. display: 'ALWAYS' // 始终显示标签
  241. },
  242. joinCluster: true
  243. });
  244. });
  245. }
  246. );
  247. },
  248. getContentList() {
  249. this.$api.getContentList(
  250. {
  251. model_id: '1',
  252. main_body_id: '1',
  253. page: 1,
  254. pageSize: '100',
  255. region: 5,
  256. keywords: this.value,
  257. longitude: this.longitude,
  258. latitude: this.latitude
  259. },
  260. function (res) {
  261. // console.log(res, '地图文物');
  262. if (res.data.length <= 0 || res.data == []) {
  263. that.$common.errorToShow('该文物已被认领');
  264. } else {
  265. that.markers = [];
  266. res.data.forEach((item, index) => {
  267. // console.log(item, 'itemitem');
  268. that.markers.push({
  269. id: parseFloat(item.id),
  270. latitude: parseFloat(item.latitude), //纬度
  271. longitude: parseFloat(item.longitude), //经度
  272. // iconPath: item.thumbnail, //显示的图标
  273. iconPath: item.thumbnail ? item.thumbnail : '/static/img.icon_map.png',
  274. width: 30, //宽
  275. height: 30, //高
  276. title: item.title, //标注点名
  277. label: {
  278. //自定义标记点上方的文本
  279. content: item.title, //文本
  280. color: '#444444', //文字颜色
  281. fontSize: 14, //文本大小
  282. bgColor: '#f1cdb2', // 背景颜色(半透明黑色)
  283. borderRadius: 5, // 边框圆角
  284. padding: [2, 2], // 内边距
  285. textAlign: 'center', // 文本对齐方式
  286. display: 'ALWAYS' // 始终显示标签
  287. },
  288. joinCluster: true
  289. });
  290. });
  291. }
  292. }
  293. );
  294. },
  295. // 接收子组件传递的id
  296. subComponent(newShow, id) {
  297. // console.log(newShow, 'ooo');
  298. this.introduceShow = newShow;
  299. // 详情
  300. this.$api.getContentDetail(
  301. {
  302. main_body_id: 1,
  303. id: id
  304. },
  305. function (res) {
  306. that.claimDetails = res.data;
  307. that.swiperList = res.data.images;
  308. }
  309. );
  310. },
  311. details() {
  312. this.$api.details({ main_body_id: 1 }, function (res) {
  313. if (res.code == 1) {
  314. that.volunteer_id = res.data.id;
  315. }
  316. });
  317. },
  318. // 认领文物
  319. claimBtn() {
  320. if (that.claimDetails.claim_status === 1 && that.claimDetails.is_multiple_claims === 0) {
  321. that.$common.errorToShow('该文物已被认领');
  322. } else if (this.volunteer_id != undefined && this.volunteer_id != '') {
  323. this.$api.claimCr(
  324. {
  325. main_body_id: 1,
  326. type: 'volunteer',
  327. volunteer_id: this.volunteer_id,
  328. cr_id: this.claimDetails.id,
  329. cr_code: this.claimDetails.code,
  330. desc: ''
  331. },
  332. function (res) {
  333. console.log(res, '详情');
  334. that.$common.errorToShow(res.msg);
  335. }
  336. );
  337. } else {
  338. uni.navigateTo({
  339. url: '/index_fenbao/fuWu/baoMing/baoMing?id=' + this.claimDetails.id
  340. });
  341. }
  342. },
  343. // 获取老志愿者手机号
  344. decryptPhoneNumber(e) {
  345. // console.log(e, '手机号信息');
  346. wx.login({
  347. success: (res) => {
  348. // console.log(res, 'code');
  349. that.$api.wxLogin(
  350. {
  351. main_body_id: 1,
  352. code: res.code
  353. },
  354. (res) => {
  355. // console.log(res, 'code22222');
  356. }
  357. );
  358. },
  359. fail: function (error) {
  360. console.log('login failed ' + error);
  361. }
  362. });
  363. console.log(e, 'phone')
  364. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  365. this.$api.getPhoneNumber(
  366. {
  367. main_body_id: 1,
  368. encryptedData: e.detail.encryptedData,
  369. iv: e.detail.iv
  370. },
  371. function (res) {
  372. // console.log(res, '成功');
  373. if (res.data == 'volunteer') {
  374. that.$common.successToShow(res.msg);
  375. that.queren = true;
  376. console.log('1');
  377. } else if (res.data == 'mobile' || res.data == 'isBoundMobile') {
  378. // 手动输入手机号
  379. console.log('2');
  380. that.$common.errorToShow(res.msg);
  381. setTimeout(() => {
  382. that.deleteShow = true;
  383. }, 2000);
  384. } else if (res.data == 'bound') {
  385. console.log('3');
  386. setTimeout(() => {
  387. that.$common.errorToShow(res.msg);
  388. }, 1000);
  389. } else {
  390. console.log('4');
  391. // console.log('失败');
  392. setTimeout(() => {
  393. that.$common.errorToShow(res.msg);
  394. }, 1000);
  395. }
  396. }
  397. );
  398. }
  399. return;
  400. },
  401. // 绑定成功回到守护页
  402. querenBtn() {
  403. uni.switchTab({
  404. url: '/pages/shouhu/shouhu'
  405. });
  406. },
  407. // 手动输入手机号
  408. isOk() {
  409. if (this.mobile != '' && this.mobile != undefined) {
  410. this.$api.mobileBindVolunteer({ main_body_id: 1, mobile: this.mobile }, function (res) {
  411. if (res.code == 1) {
  412. that.$common.errorToShow(res.msg);
  413. setTimeout(() => {
  414. that.deleteShow = false;
  415. that.queren = true;
  416. }, 1500);
  417. } else {
  418. // console.log('手动输入');
  419. that.$common.errorToShow(res.msg);
  420. }
  421. });
  422. } else {
  423. that.$common.errorToShow('请输入手机号');
  424. }
  425. },
  426. rightClick() {
  427. uni.switchTab({
  428. url: '/pages/index/index'
  429. });
  430. },
  431. close() {
  432. this.introduceShow = false;
  433. this.deleteShow = false;
  434. }
  435. }
  436. };
  437. </script>
  438. <style>
  439. /deep/.u-swiper-indicator__wrapper__dot--active {
  440. width: 5px !important;
  441. }
  442. .box {
  443. /* height: auto; */
  444. height: 100%;
  445. width: 100%;
  446. padding-bottom: 50rpx;
  447. background-image: url('https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/xy_bgt.png');
  448. background-repeat: repeat-y;
  449. background-size: cover;
  450. background-size: 100% 100%;
  451. }
  452. .active {
  453. border: 6rpx solid #efb57a;
  454. border-radius: 10rpx;
  455. }
  456. .img {
  457. width: 230rpx;
  458. height: 250rpx;
  459. border: 6rpx solid #efb57a;
  460. border-radius: 10rpx;
  461. }
  462. .map_tit {
  463. display: flex;
  464. align-items: center;
  465. margin-left: 60rpx;
  466. margin-top: 40rpx;
  467. font-size: 40rpx;
  468. font-family: Songti SC, Songti SC;
  469. font-weight: 900;
  470. line-height: 52rpx;
  471. color: #444444;
  472. }
  473. .scarch_box2 {
  474. width: 674rpx;
  475. height: 82rpx;
  476. padding: 6rpx 0 0 30rpx;
  477. margin-top: 20rpx;
  478. background-image: url('/static/img/search_bg1.png');
  479. background-size: 100% 100%;
  480. }
  481. .rl_box {
  482. width: 90%;
  483. margin: auto;
  484. margin-top: 40rpx;
  485. display: flex;
  486. justify-content: space-between;
  487. }
  488. .rl_item {
  489. width: 188rpx;
  490. height: 102rpx;
  491. background-image: url('/static/img/rl_bg.png');
  492. background-size: 100% 100%;
  493. }
  494. .tit {
  495. text-align: center;
  496. line-height: 102rpx;
  497. font-weight: 700;
  498. font-size: 36rpx;
  499. letter-spacing: 6rpx;
  500. background: linear-gradient(180deg, #af7e44 0%, #934b36 100%);
  501. -webkit-background-clip: text;
  502. -webkit-text-fill-color: transparent;
  503. }
  504. .fj_box {
  505. width: 90%;
  506. margin: auto;
  507. margin-top: 40rpx;
  508. margin-bottom: 20rpx;
  509. /* display: flex;
  510. justify-content: space-between; */
  511. }
  512. .fj_item {
  513. display: flex;
  514. align-items: center;
  515. justify-content: center;
  516. width: 300rpx;
  517. height: 78rpx;
  518. background-image: url('/static/img/search_bg1.png');
  519. background-size: 100% 100%;
  520. }
  521. .tit2 {
  522. text-align: center;
  523. line-height: 66rpx;
  524. font-weight: 700;
  525. font-size: 30rpx;
  526. letter-spacing: 6rpx;
  527. background: linear-gradient(180deg, #af7e44 0%, #934b36 100%);
  528. -webkit-background-clip: text;
  529. -webkit-text-fill-color: transparent;
  530. }
  531. .claim_tit {
  532. width: 190rpx;
  533. height: 70rpx;
  534. margin: auto;
  535. margin-top: 30rpx;
  536. font-weight: 600;
  537. text-align: center;
  538. line-height: 70rpx;
  539. font-size: 32rpx;
  540. background-color: #efb681;
  541. }
  542. .xx_box {
  543. padding: 20rpx;
  544. background-color: #e1bf9a;
  545. width: 660rpx;
  546. /* height: 560rpx; */
  547. padding-top: 80rpx;
  548. }
  549. .xx_tit {
  550. height: 360rpx;
  551. font-size: 30rpx;
  552. padding: 20rpx;
  553. text-indent: 2em;
  554. margin-top: 30rpx;
  555. background-color: #f3e3d3;
  556. overflow: scroll;
  557. }
  558. .search_box {
  559. width: 87%;
  560. position: absolute;
  561. height: 400rpx;
  562. z-index: 9;
  563. left: 50rpx;
  564. /* top: -295rpx; */
  565. padding: 40rpx;
  566. background-color: #f7dfc0;
  567. }
  568. .item_tit {
  569. line-height: 50rpx;
  570. font-size: 30rpx;
  571. }
  572. button::after {
  573. border: none;
  574. margin: 0;
  575. }
  576. button {
  577. margin: 0;
  578. }
  579. .bt_box {
  580. display: flex;
  581. margin-top: 50rpx;
  582. justify-content: space-around;
  583. }
  584. .bt1 {
  585. width: 244rpx;
  586. height: 78rpx;
  587. border: 1px solid #312520;
  588. border-radius: 39rpx;
  589. text-align: center;
  590. line-height: 78rpx;
  591. color: black;
  592. }
  593. .bt2 {
  594. width: 244rpx;
  595. height: 78rpx;
  596. margin: auto;
  597. margin-top: 120rpx;
  598. background: #ca5642;
  599. border-radius: 39rpx;
  600. text-align: center;
  601. line-height: 78rpx;
  602. color: #ffffff;
  603. }
  604. .bt3 {
  605. width: 244rpx;
  606. height: 78rpx;
  607. background: #ca5642;
  608. border-radius: 39rpx;
  609. text-align: center;
  610. line-height: 78rpx;
  611. color: #ffffff;
  612. }
  613. /deep/.u-textarea.data-v-09988a29 {
  614. background-color: #fce3c4 !important;
  615. border-radius: 0;
  616. }
  617. /deep/.u-textarea.data-v-09988a29 {
  618. background-color: #fce3c4 !important;
  619. }
  620. </style>