renLing.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  364. this.$api.getPhoneNumber(
  365. {
  366. main_body_id: 1,
  367. encryptedData: e.detail.encryptedData,
  368. iv: e.detail.iv
  369. },
  370. function (res) {
  371. // console.log(res, '成功');
  372. if (res.data == 'volunteer') {
  373. that.$common.successToShow(res.msg);
  374. that.queren = true;
  375. console.log('1');
  376. } else if (res.data == 'mobile' || res.data == 'isBoundMobile') {
  377. // 手动输入手机号
  378. console.log('2');
  379. that.$common.errorToShow(res.msg);
  380. setTimeout(() => {
  381. that.deleteShow = true;
  382. }, 2000);
  383. } else if (res.data == 'bound') {
  384. console.log('3');
  385. setTimeout(() => {
  386. that.$common.errorToShow(res.msg);
  387. }, 1000);
  388. } else {
  389. console.log('4');
  390. // console.log('失败');
  391. setTimeout(() => {
  392. that.$common.errorToShow(res.msg);
  393. }, 1000);
  394. }
  395. }
  396. );
  397. }
  398. return;
  399. },
  400. // 绑定成功回到守护页
  401. querenBtn() {
  402. uni.switchTab({
  403. url: '/pages/shouhu/shouhu'
  404. });
  405. },
  406. // 手动输入手机号
  407. isOk() {
  408. if (this.mobile != '' && this.mobile != undefined) {
  409. this.$api.mobileBindVolunteer({ main_body_id: 1, mobile: this.mobile }, function (res) {
  410. if (res.code == 1) {
  411. that.$common.errorToShow(res.msg);
  412. setTimeout(() => {
  413. that.deleteShow = false;
  414. that.queren = true;
  415. }, 1500);
  416. } else {
  417. // console.log('手动输入');
  418. that.$common.errorToShow(res.msg);
  419. }
  420. });
  421. } else {
  422. that.$common.errorToShow('请输入手机号');
  423. }
  424. },
  425. rightClick() {
  426. uni.switchTab({
  427. url: '/pages/index/index'
  428. });
  429. },
  430. close() {
  431. this.introduceShow = false;
  432. this.deleteShow = false;
  433. }
  434. }
  435. };
  436. </script>
  437. <style>
  438. /deep/.u-swiper-indicator__wrapper__dot--active {
  439. width: 5px !important;
  440. }
  441. .box {
  442. /* height: auto; */
  443. height: 100%;
  444. width: 100%;
  445. padding-bottom: 50rpx;
  446. background-image: url('https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/xy_bgt.png');
  447. background-repeat: repeat-y;
  448. background-size: cover;
  449. background-size: 100% 100%;
  450. }
  451. .active {
  452. border: 6rpx solid #efb57a;
  453. border-radius: 10rpx;
  454. }
  455. .img {
  456. width: 230rpx;
  457. height: 250rpx;
  458. border: 6rpx solid #efb57a;
  459. border-radius: 10rpx;
  460. }
  461. .map_tit {
  462. display: flex;
  463. align-items: center;
  464. margin-left: 60rpx;
  465. margin-top: 40rpx;
  466. font-size: 40rpx;
  467. font-family: Songti SC, Songti SC;
  468. font-weight: 900;
  469. line-height: 52rpx;
  470. color: #444444;
  471. }
  472. .scarch_box2 {
  473. width: 674rpx;
  474. height: 82rpx;
  475. padding: 6rpx 0 0 30rpx;
  476. margin-top: 20rpx;
  477. background-image: url('/static/img/search_bg1.png');
  478. background-size: 100% 100%;
  479. }
  480. .rl_box {
  481. width: 90%;
  482. margin: auto;
  483. margin-top: 40rpx;
  484. display: flex;
  485. justify-content: space-between;
  486. }
  487. .rl_item {
  488. width: 188rpx;
  489. height: 102rpx;
  490. background-image: url('/static/img/rl_bg.png');
  491. background-size: 100% 100%;
  492. }
  493. .tit {
  494. text-align: center;
  495. line-height: 102rpx;
  496. font-weight: 700;
  497. font-size: 36rpx;
  498. letter-spacing: 6rpx;
  499. background: linear-gradient(180deg, #af7e44 0%, #934b36 100%);
  500. -webkit-background-clip: text;
  501. -webkit-text-fill-color: transparent;
  502. }
  503. .fj_box {
  504. width: 90%;
  505. margin: auto;
  506. margin-top: 40rpx;
  507. margin-bottom: 20rpx;
  508. /* display: flex;
  509. justify-content: space-between; */
  510. }
  511. .fj_item {
  512. display: flex;
  513. align-items: center;
  514. justify-content: center;
  515. width: 300rpx;
  516. height: 78rpx;
  517. background-image: url('/static/img/search_bg1.png');
  518. background-size: 100% 100%;
  519. }
  520. .tit2 {
  521. text-align: center;
  522. line-height: 66rpx;
  523. font-weight: 700;
  524. font-size: 30rpx;
  525. letter-spacing: 6rpx;
  526. background: linear-gradient(180deg, #af7e44 0%, #934b36 100%);
  527. -webkit-background-clip: text;
  528. -webkit-text-fill-color: transparent;
  529. }
  530. .claim_tit {
  531. width: 190rpx;
  532. height: 70rpx;
  533. margin: auto;
  534. margin-top: 30rpx;
  535. font-weight: 600;
  536. text-align: center;
  537. line-height: 70rpx;
  538. font-size: 32rpx;
  539. background-color: #efb681;
  540. }
  541. .xx_box {
  542. padding: 20rpx;
  543. background-color: #e1bf9a;
  544. width: 660rpx;
  545. /* height: 560rpx; */
  546. padding-top: 80rpx;
  547. }
  548. .xx_tit {
  549. height: 360rpx;
  550. font-size: 30rpx;
  551. padding: 20rpx;
  552. text-indent: 2em;
  553. margin-top: 30rpx;
  554. background-color: #f3e3d3;
  555. overflow: scroll;
  556. }
  557. .search_box {
  558. width: 87%;
  559. position: absolute;
  560. height: 400rpx;
  561. z-index: 9;
  562. left: 50rpx;
  563. /* top: -295rpx; */
  564. padding: 40rpx;
  565. background-color: #f7dfc0;
  566. }
  567. .item_tit {
  568. line-height: 50rpx;
  569. font-size: 30rpx;
  570. }
  571. button::after {
  572. border: none;
  573. margin: 0;
  574. }
  575. button {
  576. margin: 0;
  577. }
  578. .bt_box {
  579. display: flex;
  580. margin-top: 50rpx;
  581. justify-content: space-around;
  582. }
  583. .bt1 {
  584. width: 244rpx;
  585. height: 78rpx;
  586. border: 1px solid #312520;
  587. border-radius: 39rpx;
  588. text-align: center;
  589. line-height: 78rpx;
  590. color: black;
  591. }
  592. .bt2 {
  593. width: 244rpx;
  594. height: 78rpx;
  595. margin: auto;
  596. margin-top: 120rpx;
  597. background: #ca5642;
  598. border-radius: 39rpx;
  599. text-align: center;
  600. line-height: 78rpx;
  601. color: #ffffff;
  602. }
  603. .bt3 {
  604. width: 244rpx;
  605. height: 78rpx;
  606. background: #ca5642;
  607. border-radius: 39rpx;
  608. text-align: center;
  609. line-height: 78rpx;
  610. color: #ffffff;
  611. }
  612. /deep/.u-textarea.data-v-09988a29 {
  613. background-color: #fce3c4 !important;
  614. border-radius: 0;
  615. }
  616. /deep/.u-textarea.data-v-09988a29 {
  617. background-color: #fce3c4 !important;
  618. }
  619. </style>