renLing.vue 15 KB

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