index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <template>
  2. <view>
  3. <view class="margin-lr" v-if="modelSwt == '否'">
  4. <view class="">
  5. <swiper class="swiper" autoplay="1500" :indicator-dots="true" :circular='true'
  6. indicator-active-color="#ffffff" indicator-color="#cccccc">
  7. <swiper-item class="swiper-wrap" v-for="(item,index) in bannerList" :key='index'
  8. style="height: 300upx;">
  9. <image :src="item.imageUrl" style="width: 100%;border-radius: 8upx;height: 300upx;"
  10. @click="goWeb(item.url)" mode="scaleToFill"></image>
  11. </swiper-item>
  12. </swiper>
  13. </view>
  14. <view class="flex justify-between align-center bg-white margin-tb padding-lr-sm radius"
  15. style="width: 100%;height: 100rpx;">
  16. <image src="../static/xinxi.png" style="width: 126rpx;height: 30rpx;" mode=""></image>
  17. <view class="flex-sub margin-left-sm">
  18. <swiper class="swiper" autoplay="1500" :vertical='true' style="height: 40rpx;overflow: hidden;">
  19. <swiper-item class="" v-for="(item,index) in noticeList" :key='index' @click="goWeb1(item.url)">
  20. <text>{{item.title}}</text>
  21. </swiper-item>
  22. </swiper>
  23. </view>
  24. </view>
  25. <view>
  26. <view class="text-black text-xl text-bold margin-bottom">帮帮跑腿</view>
  27. <view class="flex justify-between flex-wrap">
  28. <view class="bg-video margin-tb-xs" v-for="(item,index) in classifyLsit" :key='index'
  29. @click="goNav(item.url)">
  30. <image :src="item.imageUrl" mode="" style="width: 340rpx;height: 200rpx;"></image>
  31. <view class="flex flex-direction justify-end"
  32. style="position: absolute;top: 0;padding: 30rpx;width: 100%;height: 100%;">
  33. <view class="text-white text-lg text-bold">{{item.name}}</view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 红包 -->
  39. <view class="hongbao" v-if="HBShow&&paotuiHB == '是'">
  40. <view style="width: 52%;margin: 0 auto;position: relative;">
  41. <view @click="HBShow=false"
  42. style="position: absolute;right: -10rpx;top: -10rpx;font-size: 32rpx;font-weight: bold;">X
  43. </view>
  44. <image src="../static/hb_bg.png" class="hb_img"></image>
  45. <image src="../static/hb_btn.png" class="hb_btn" @click="takemoney()"></image>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="content" v-if="modelSwt == '是'">
  50. <!-- #ifndef MP-WEIXIN -->
  51. <view class="page-body">
  52. <view class="page-section page-section-gap">
  53. <map id="map" style="width: 100%; height: 700px;" :latitude="latitude" :longitude="longitude"
  54. :markers="covers" :show-location="true">
  55. <cover-view style="position: fixed;top: 345px;right: 30px;" @click="onToGetLocation()">
  56. <cover-image class="img-map1" src="../static/dw.png">
  57. </cover-image>
  58. </cover-view>
  59. </map>
  60. </view>
  61. </view>
  62. <!-- #endif -->
  63. <!-- #ifdef MP-WEIXIN -->
  64. <view class="page-body">
  65. <view class="page-section page-section-gap">
  66. <map id="map" style="width: 100%; height: 700px;" :latitude="latitude" :longitude="longitude"
  67. :markers="covers" :show-location="true" :customCallout="customCallout">
  68. <cover-view style="position: fixed;bottom: 430rpx;right: 60rpx;" @click="onToGetLocation()">
  69. <cover-image class="img-map1" src="../static/dw.png">
  70. </cover-image>
  71. </cover-view>
  72. </map>
  73. </view>
  74. </view>
  75. <!-- #endif -->
  76. <cover-view class="controls-title">
  77. <cover-view class="controls-tabs">
  78. <cover-view v-for="(item,index) in classifyLsit" :key="index" v-if="index<4"
  79. @tap="change(index,item)" class="atabs_ds">
  80. <cover-view>{{item.name}}</cover-view>
  81. <cover-view :class="{btna:count == index}"></cover-view>
  82. </cover-view>
  83. </cover-view>
  84. <!-- 同城服务 -->
  85. <cover-view class="tabs_box">
  86. <cover-view class="pay_tit">
  87. <cover-view class="pay_name">请写明{{modelDet.name }}的内容</cover-view>
  88. <cover-view class="pay_set">请填写您的具体要求等</cover-view>
  89. <cover-view class="pay_radius" @click="bindcity(4)">下单</cover-view>
  90. </cover-view>
  91. </cover-view>
  92. </cover-view>
  93. <cover-view class="hongbao" v-if="newUserFlag == 1&&paotuiHB == '是'">
  94. <cover-view style="width: 52%;margin: 0 auto;position: relative;">
  95. <cover-view @click="HBShow=false"
  96. style="position: absolute;right: -10rpx;top: -10rpx;font-size: 32rpx;font-weight: bold;">X
  97. </cover-view>
  98. <cover-image src="../static/hb_bg.png" class="hb_img"></cover-image>
  99. <cover-image src="../static/hb_btn.png" class="hb_btn" @click="takemoney()"></cover-image>
  100. </cover-view>
  101. </cover-view>
  102. <cover-view v-else></cover-view>
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. export default {
  108. data() {
  109. return {
  110. HBShow: false,
  111. modelSwt: "否",
  112. modelDet: {},
  113. id: 0, // 使用 marker点击事件 需要填写id
  114. title: 'map',
  115. latitude: '',
  116. longitude: '',
  117. iconPath: '../static/location.png',
  118. covers: [{
  119. latitude: '',
  120. longitude: '',
  121. iconPath: '../static/location.png',
  122. width: 40,
  123. height: 40,
  124. callout: { //自定义标记点上方的气泡窗口 点击有效
  125. content: '当前附近骑手', //文本
  126. color: '#ffffff', //文字颜色
  127. fontSize: 10, //文本大小
  128. padding: 10, //附近留白
  129. borderRadius: 2, //边框圆角
  130. bgColor: '#00c16f', //背景颜色
  131. display: 'ALWAYS', //常显
  132. },
  133. }],
  134. count: "",
  135. list: [{
  136. id: 0,
  137. name: '帮我送'
  138. }, {
  139. id: 1,
  140. name: '帮我取'
  141. }, {
  142. id: 2,
  143. name: '同城帮买'
  144. }, {
  145. id: 3,
  146. name: '同城服务'
  147. }],
  148. current: 0,
  149. value0: '',
  150. value1: '',
  151. value2: '',
  152. value3: '',
  153. type: 'text',
  154. clearable: false,
  155. riderNumber: '',
  156. arr: [],
  157. // 用户红包
  158. newUserFlag: 2,
  159. token: '',
  160. bannerList: [],
  161. noticeList: [],
  162. classifyLsit: [],
  163. tuiguang: '',
  164. tuiguangImg: '',
  165. paotuiHB: '否'
  166. }
  167. },
  168. onLoad() {
  169. this.getBannerList()
  170. this.getNoticeList()
  171. // this.getZiZhi()
  172. let takeAddress = {
  173. data1: '',
  174. data2: '',
  175. }
  176. let closeAddress = {
  177. data1: '',
  178. data2: '',
  179. data3: '',
  180. data4: '',
  181. citydata: ''
  182. }
  183. uni.setStorageSync('takeAddress', takeAddress)
  184. uni.setStorageSync('closeAddress', closeAddress)
  185. if (uni.getStorageSync('disinfo')) {
  186. uni.removeStorageSync('disinfo')
  187. }
  188. },
  189. onShow() {
  190. // 首页是否展示地图
  191. this.$Request.getT('/app/common/type/294').then(res => {
  192. if (res.code == 0) {
  193. if (res.data && res.data.value) {
  194. this.modelSwt = res.data.value
  195. this.$queue.setData('modelSwt', res.data.value)
  196. }
  197. }
  198. });
  199. this.token = uni.getStorageSync('token')
  200. if (this.token) {
  201. this.getUser()
  202. }
  203. },
  204. onReady() {
  205. this.map = uni.createMapContext("map", this)
  206. },
  207. onShareAppMessage(res) { //发送给朋友
  208. return {
  209. title: this.tuiguang,
  210. path: '/pages/index/index',
  211. imageUrl: this.tuiguangImg,
  212. }
  213. },
  214. onShareTimeline(res) { //分享到朋友圈
  215. return {
  216. title: this.tuiguang,
  217. path: '/pages/index/index',
  218. imageUrl: this.tuiguangImg,
  219. }
  220. },
  221. methods: {
  222. // 分享文案和图片
  223. getZiZhi() {
  224. this.$Request.getT('/app/common/type/295').then(res => {
  225. if (res.code === 0) {
  226. this.tuiguang = res.data.value;
  227. }
  228. });
  229. this.$Request.getT('/app/common/type/296').then(res => {
  230. if (res.code === 0) {
  231. this.tuiguangImg = res.data.value;
  232. }
  233. });
  234. },
  235. goWeb(url) {
  236. console.log(url.indexOf('/pages/') !== -1)
  237. return
  238. if (url.indexOf('/pages/') !== -1) {
  239. uni.navigateTo({
  240. url
  241. });
  242. } else {
  243. //#ifndef H5
  244. uni.navigateTo({
  245. url: '/pages/index/webView?url=' + url
  246. });
  247. //#endif
  248. //#ifdef H5
  249. window.location.href = url;
  250. //#endif
  251. }
  252. },
  253. goWeb1(url) {
  254. if (url.indexOf('http') !== -1) {
  255. //#ifndef H5
  256. uni.navigateTo({
  257. url: '/pages/index/webView?url=' + url
  258. });
  259. //#endif
  260. //#ifdef H5
  261. window.location.href = url;
  262. //#endif
  263. }
  264. },
  265. // 跳转发布页面
  266. goNav(e) {
  267. if (this.token) {
  268. uni.navigateTo({
  269. url: e
  270. })
  271. } else {
  272. uni.navigateTo({
  273. url: '/pages/my/register'
  274. })
  275. }
  276. },
  277. // 获取轮播图
  278. getBannerList() {
  279. this.$Request.get("/app/banner/selectBannerList?classify=7&state=1").then(res => {
  280. if (res.code == 0) {
  281. this.bannerList = res.data
  282. }
  283. });
  284. this.$Request.get("/app/banner/selectBannerList?classify=6&state=1").then(res => {
  285. if (res.code == 0) {
  286. this.classifyLsit = res.data
  287. this.modelDet = this.classifyLsit[0]
  288. }
  289. });
  290. },
  291. // 获取公告
  292. getNoticeList() {
  293. let data = {
  294. page: 1,
  295. limit: 100
  296. }
  297. this.$Request.get("/app/notice/selectNoticeList", data).then(res => {
  298. if (res.code == 0) {
  299. this.noticeList = res.data.list
  300. }
  301. });
  302. },
  303. // 获取用户当前定位
  304. getUser() {
  305. console.log('执行')
  306. var that = this
  307. uni.getLocation({
  308. type: 'gcj02',
  309. success: function(res) {
  310. // console.log('成功')
  311. // console.log(res)
  312. console.log('当前位置的经度:' + res.longitude);
  313. console.log('当前位置的纬度:' + res.latitude);
  314. that.longitude = res.longitude
  315. that.latitude = res.latitude
  316. that.covers[0].longitude = res.longitude
  317. that.covers[0].latitude = res.latitude
  318. that.getAdd(that.longitude, that.latitude)
  319. that.getuserinfo()
  320. },
  321. fail: function(err) {
  322. console.log('授权失败', err)
  323. uni.showToast({
  324. title: "获取位置授权失败",
  325. icon: "none"
  326. })
  327. }
  328. });
  329. },
  330. //右下角定位按钮的点击事件
  331. onToGetLocation() {
  332. console.log('11')
  333. // this. getUser()
  334. // this.map.moveToLocation();
  335. let mapContext = uni.createMapContext('map');
  336. mapContext.moveToLocation(); //moveToLocation将地图中心移动到当前定位点,需要配合map组件的show-location使用
  337. },
  338. // 跑腿人位置
  339. getAdd(lng, lat) {
  340. this.$Request.getT('/app/tbindent/find5KmRider?lng=' + lng + '&lat=' + lat).then(res => {
  341. // console.log('```````````````', res)
  342. if (res.code == 0) {
  343. this.riderNumber = res.data.length
  344. if (res.data.length > 0) {
  345. var arr = []
  346. for (var i in res.data) {
  347. var obj = {}
  348. obj.latitude = res.data[i].stationLat
  349. obj.longitude = res.data[i].stationLng
  350. obj.iconPath = '../static/rider.png'
  351. obj.width = 30
  352. obj.height = 30
  353. arr.push(obj)
  354. }
  355. this.covers[0].callout.content = '当前附近骑手' + res.data.length + '人'
  356. // this.covers = arr
  357. this.covers = [...this.covers, ...arr];
  358. // console.log('this.covers ', this.covers)
  359. }
  360. }
  361. });
  362. },
  363. change(index, item) {
  364. // console.log(index)
  365. this.modelDet = item
  366. this.current = index;
  367. this.count = index;
  368. console.log(this.count)
  369. // uni.removeStorageSync('takeAddress')
  370. },
  371. bindHelppay(index) {
  372. // console.log(index)
  373. let token = this.$queue.getData("token");
  374. if (token) {
  375. uni.navigateTo({
  376. url: '/pages/Helppay/Helppay'
  377. })
  378. } else {
  379. uni.navigateTo({
  380. url: '/pages/my/register'
  381. })
  382. }
  383. },
  384. bindcity(index) {
  385. // console.log(index)
  386. let token = this.$queue.getData("token");
  387. if (token) {
  388. uni.navigateTo({
  389. url: this.modelDet.url
  390. })
  391. } else {
  392. uni.navigateTo({
  393. url: '/pages/my/register'
  394. })
  395. }
  396. },
  397. // 获取用户信息
  398. getuserinfo() {
  399. this.$Request.getT('/app/tbindent/findUserInfoById').then(res => {
  400. console.log(res)
  401. if (res.code == 0) {
  402. this.newUserFlag = res.data.newUserFlag
  403. console.log(this.newUserFlag)
  404. if (this.newUserFlag == 1) {
  405. this.paotuiHB = this.$queue.getData('paotuiHB')
  406. if (this.paotuiHB == '是') {
  407. this.HBShow = true
  408. }
  409. } else {
  410. this.HBShow = false
  411. }
  412. }
  413. });
  414. },
  415. // 红包
  416. takemoney() {
  417. this.$Request.getT('/app/tbindent/getNewUserRedPacket').then(res => {
  418. console.log(res)
  419. if (res.code === 0) {
  420. this.HBShow = false
  421. this.getuserinfo()
  422. setTimeout(function() {
  423. uni.navigateTo({
  424. url: '/my/hongbao/hongbao'
  425. })
  426. }, 100)
  427. } else {
  428. uni.showToast({
  429. title: res.msg,
  430. icon: "none"
  431. })
  432. this.newUserFlag = ''
  433. }
  434. });
  435. }
  436. }
  437. }
  438. </script>
  439. <style>
  440. .content {
  441. width: 100%;
  442. position: fixed;
  443. top: 0upx;
  444. left: 0upx;
  445. right: 0upx;
  446. bottom: 0upx;
  447. }
  448. .controls-title {
  449. width: 90%;
  450. height: 370upx;
  451. background: #FFFFFF;
  452. position: fixed;
  453. bottom: 0rpx;
  454. margin: 40upx;
  455. border-radius: 26upx;
  456. box-shadow: 0upx 30upx 40upx 0upx rgba(187, 170, 163, 0.20);
  457. /* #ifndef MP-WEIXIN */
  458. width: 90%;
  459. margin: 0 40rpx;
  460. margin-bottom: 150rpx;
  461. /* #endif */
  462. }
  463. /* tab选项卡 */
  464. .controls-tabs {
  465. display: flex;
  466. font-size: 33rpx;
  467. overflow-x: auto;
  468. }
  469. .atabs_ds {
  470. flex-grow: 1;
  471. text-align: center;
  472. height: 55rpx;
  473. }
  474. /* .tabs_box {
  475. display: none;
  476. background: #C8C7CC;
  477. } */
  478. .btna {
  479. background: #FF6A04;
  480. width: 68%;
  481. height: 8rpx;
  482. margin: 9rpx 10rpx 10rpx 29rpx;
  483. border-radius: 35rpx;
  484. }
  485. .tabs_box {
  486. /* display: none; */
  487. }
  488. .dis {
  489. display: block;
  490. }
  491. .controls-tabs {
  492. width: 100%;
  493. height: 90rpx;
  494. display: flex;
  495. justify-content: center;
  496. align-items: center;
  497. margin-top: 10rpx;
  498. }
  499. .box_bg {
  500. width: 90%;
  501. height: 100upx;
  502. background: #FFFFFF;
  503. margin: 0 auto;
  504. border-radius: 12upx;
  505. display: flex;
  506. margin-top: 20upx;
  507. }
  508. .box {
  509. width: 90%;
  510. height: 100upx;
  511. background: #F5F5F5;
  512. margin: 0 auto;
  513. border-radius: 12upx;
  514. display: flex;
  515. margin-top: 20upx;
  516. }
  517. .box_dian {
  518. flex: 1;
  519. display: flex;
  520. justify-content: center;
  521. align-items: center;
  522. }
  523. .box_dian cover-image {
  524. width: 20upx;
  525. height: 20upx;
  526. }
  527. .box_name {
  528. flex: 5;
  529. display: flex;
  530. justify-content: left;
  531. align-items: center;
  532. color: #333333;
  533. font-weight: 700;
  534. font-size: 34rpx;
  535. }
  536. .box_addres {
  537. flex: 5;
  538. }
  539. .add {
  540. color: #333333;
  541. font-size: 26upx;
  542. letter-spacing: 2upx;
  543. font-weight: bold;
  544. line-height: 50upx;
  545. }
  546. .name {
  547. display: inline;
  548. font-size: 24upx;
  549. color: #999999;
  550. }
  551. .number {
  552. display: initial;
  553. color: #999999;
  554. font-size: 24upx;
  555. margin-left: 30upx;
  556. }
  557. .box_image {
  558. flex: 1;
  559. display: flex;
  560. justify-content: center;
  561. align-items: center;
  562. }
  563. .icon_you {
  564. color: #CCCCCC !important;
  565. }
  566. /* 同城购买 */
  567. .pay_tit {
  568. width: 90%;
  569. margin: 0 auto;
  570. height: 200upx;
  571. position: relative;
  572. }
  573. .pay_name {
  574. font-size: 31rpx;
  575. font-weight: bold;
  576. width: 95%;
  577. margin: 0 auto;
  578. letter-spacing: 2upx;
  579. }
  580. .pay_set {
  581. color: #333333;
  582. font-size: 28rpx;
  583. width: 95%;
  584. margin: 0 auto;
  585. margin-top: 20upx;
  586. }
  587. .pay_radius {
  588. width: 100upx;
  589. height: 100upx;
  590. background: #FF7F00;
  591. color: white;
  592. text-align: center;
  593. line-height: 100upx;
  594. border-radius: 68upx;
  595. position: absolute;
  596. right: 20upx;
  597. }
  598. .hongbao {
  599. width: 100%;
  600. /* height: 100px; */
  601. /* background: #007AFF; */
  602. position: fixed;
  603. top: 24%;
  604. /* bottom: 50%; */
  605. left: 0rpx;
  606. right: 0rpx;
  607. /* display: none; */
  608. }
  609. .hb_img {
  610. width: 100%;
  611. height: 435rpx;
  612. }
  613. .hb_btn {
  614. width: 60%;
  615. height: 72rpx;
  616. position: absolute;
  617. top: 315rpx;
  618. left: 80rpx;
  619. }
  620. .img-map1 {
  621. width: 80rpx;
  622. height: 80rpx;
  623. }
  624. </style>