index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <view class="index-home">
  3. <view class="ongoing" v-if="goingOrder" @click="onGoing">
  4. 您有一个正在进行中的订单
  5. </view>
  6. <!-- 授权手机号 -->
  7. <view class="mobile-frame" v-show="frameIshow">
  8. <view class="frame">
  9. <image src="../../static/image/tips.png" mode=""></image>
  10. <view class="title">
  11. 当前操作需要授权手机号
  12. </view>
  13. <view class="submit">
  14. <button type="default" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立即授权</button>
  15. </view>
  16. </view>
  17. <view class="close" @click="frameIshow=false">
  18. <image src="../../static/image/close-white.png" mode=""></image>
  19. </view>
  20. </view>
  21. <view class="index-swiper">
  22. <view class="uni-padding-wrap">
  23. <view class="page-section swiper">
  24. <view class="page-section-spacing">
  25. <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
  26. :duration="duration">
  27. <swiper-item v-for="(item, index) in bannerList" :key='index'>
  28. <view class="swiper-item uni-bg-red">
  29. <image :src="item.path" mode="widthFix"></image>
  30. </view>
  31. </swiper-item>
  32. </swiper>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="video" v-if="videoList.length>0">
  38. <view class="title" @click="getVideoList()">
  39. <text>氢知驿站</text>
  40. <text class=" iconfont icon-iconfontjiantou2"></text>
  41. <text class="more" style="float: right;">更多</text>
  42. </view>
  43. <view class="video-list" v-for="(item,index) in videoList" :key='index'>
  44. <view class="video-item" @click="videoDetail(item.id)">
  45. <view class="image">
  46. <image :src="item.cover" mode=""></image>
  47. <!-- <video id="myVideo" src="https://qingyujiankang.baomihua222.top/storage/videos/1a9f8d7d2eb55f4f96c14118606d1c33.mp4" controls
  48. ></video> -->
  49. </view>
  50. <view class="video-title">
  51. {{item.title? item.title:'--'}}
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="index-list">
  57. <view class="title" @click="shopMore()">
  58. <text>附近服务站点</text>
  59. <text class=" iconfont icon-iconfontjiantou2"></text>
  60. <text class="more" style="float: right;">更多</text>
  61. </view>
  62. <view class="list" v-for="(item,index) in sitList" :key='index' @click="skipDetail(item.id)">
  63. <view class="left">
  64. <image v-if="item.cover" :src="imageUrl + item.cover" mode="heightFix"></image>
  65. <image v-else src="../../static/image/banner3.jpg" mode="heightFix"></image>
  66. </view>
  67. <view class="right">
  68. <view class="name">
  69. {{item.name}}
  70. </view>
  71. <view class="address">
  72. 地址:{{item.address}}
  73. </view>
  74. <view class="num">
  75. <text>设备数:{{item.device_nums}}</text><text class="distance">距您{{item.distance}} </text>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <footerBar :page='pages' @getFrame="getFrame"></footerBar>
  81. </view>
  82. </template>
  83. <script>
  84. import footerBar from '../../components/footer-bar/footer-bar.vue'
  85. var app = getApp()
  86. export default {
  87. components: {
  88. footerBar
  89. },
  90. data() {
  91. return {
  92. videoList: [1, 1, 1, 1, 1], //视频图文列表
  93. page: 0,
  94. background: ['color1', 'color2', 'color3'],
  95. title: 'Hello',
  96. indicatorDots: false,
  97. autoplay: true,
  98. interval: 2000,
  99. duration: 500,
  100. shopList: [0, 1, 2, 3, 4],
  101. item_index: 1, // 单页面id
  102. sitList: [], //站点列表
  103. page: 1,
  104. lng: '',
  105. lat: '',
  106. bannerList: [],
  107. frameIshow: false,
  108. imageUrl: app.globalData.imageUrl,
  109. goingOrder: '', //进行中的订单
  110. }
  111. },
  112. onLoad() {
  113. let that = this
  114. uni.showLoading()
  115. uni.getLocation({
  116. type: 'gcj02',
  117. isHighAccuracy: true,
  118. success: function(res) {
  119. that.lng = res.longitude
  120. that.lat = res.latitude
  121. console.log(that.lng + '当前位置的经度:' + res.longitude);
  122. console.log(that.lat + '当前位置的纬度:' + res.latitude);
  123. that.getSiteList()
  124. uni.hideLoading()
  125. }
  126. });
  127. this.getBanner()
  128. this.getVideo();
  129. },
  130. onShow() {
  131. this.exitOrder()
  132. },
  133. onPullDownRefresh() {
  134. this.exitOrder()
  135. this.getVideo()
  136. this.getSiteList()
  137. },
  138. methods: {
  139. //是否有正在进行中的订单
  140. exitOrder() {
  141. app.request('/order/is-server-exist', '', 'get').then(res => {
  142. console.log(res, '是否有进行中订单')
  143. this.goingOrder = res.data.data.no
  144. })
  145. },
  146. //更多站点列表
  147. shopMore: function() {
  148. uni.navigateTo({
  149. url: './shopList'
  150. })
  151. },
  152. //获取视频列表
  153. getVideo: function() {
  154. let data = {
  155. status: 1,
  156. limit: 6
  157. }
  158. app.request('/resources-home', data, 'get').then((res => {
  159. console.log(res, 'pppp')
  160. this.videoList = res.data.data.data
  161. }))
  162. },
  163. getVideoList: function() {
  164. uni.navigateTo({
  165. url: './video_list'
  166. })
  167. },
  168. //跳转视频详情
  169. videoDetail: function(id) {
  170. console.log(id, 'ooo')
  171. uni.navigateTo({
  172. url: './video_detail?id=' + id
  173. })
  174. },
  175. //获取手机号
  176. getPhoneNumber: function(e) {
  177. console.log(e.detail)
  178. let data = {
  179. session_key: uni.getStorageSync('session_key'),
  180. iv: e.detail.iv,
  181. encryptedData: e.detail.encryptedData
  182. }
  183. app.request('/user/sync-mobile', data, 'post').then(res => {
  184. this.frameIshow = false
  185. app.globalData.is_auth = true
  186. })
  187. },
  188. // 获取轮播图
  189. getBanner: function() {
  190. let params = {
  191. type: 1
  192. }
  193. app.request('/banners', params, 'get').then(res => {
  194. console.log(res, 'lunbo')
  195. this.bannerList = res.data.data.data
  196. })
  197. },
  198. // 扫码获取子组件传值
  199. getFrame: function(e) {
  200. console.log(e)
  201. this.frameIshow = e
  202. },
  203. //获取站点列表
  204. getSiteList: function() {
  205. let that = this
  206. let params = {
  207. page: this.page,
  208. lat: this.lat,
  209. lng: this.lng
  210. }
  211. app.request('/shops', params, 'get').then(res => {
  212. console.log(res, "站点列表")
  213. this.sitList = this.sitList.concat(res.data.data.data)
  214. this.sitList.map(item => {
  215. if (item.distance < 1000) {
  216. item.distance = item.distance.toFixed(2) + 'm';
  217. } else {
  218. item.distance = (item.distance / 2 / 500).toFixed(2) + 'km'
  219. }
  220. })
  221. })
  222. },
  223. // 跳转详情
  224. skipDetail: function(e) {
  225. if (app.globalData.is_auth == true) {
  226. uni.navigateTo({
  227. url: './equipmentList?id=' + e
  228. })
  229. } else {
  230. this.frameIshow = true
  231. }
  232. },
  233. //正在进行中的订单
  234. onGoing: function() {
  235. uni.navigateTo({
  236. url: './order?order_no=' + this.goingOrder
  237. })
  238. }
  239. }
  240. }
  241. </script>
  242. <style lang="scss" scoped>
  243. page {}
  244. .index-home {
  245. background-color: #f6f6f6;
  246. // height: 100%;
  247. padding-bottom: 140upx;
  248. .ongoing {
  249. position: fixed;
  250. bottom: 20%;
  251. padding: 20upx;
  252. right: 0;
  253. font-size: 28upx;
  254. background-color: $mine-background-color;
  255. color: #FFFFFF;
  256. border-radius: 50upx 0 0 50upx;
  257. }
  258. .mobile-frame {
  259. position: fixed;
  260. height: 100vh;
  261. width: 100%;
  262. background: rgba($color: #000000, $alpha: 0.6);
  263. z-index: 99999;
  264. top: 0;
  265. .frame {
  266. width: 50%;
  267. margin: 0 auto;
  268. padding: 50upx 30upx;
  269. margin-top: 40%;
  270. border-radius: 12upx;
  271. background-color: #FFFFFF;
  272. text-align: center;
  273. image {
  274. height: 90upx;
  275. width: 90upx;
  276. }
  277. .title {
  278. height: 70upx;
  279. line-height: 70upx;
  280. font-size: 28upx;
  281. }
  282. .submit {
  283. margin: 0 auto;
  284. width: 50%;
  285. margin-top: 30upx;
  286. button {
  287. background-color: $mine-background-color;
  288. height: 70upx;
  289. line-height: 70upx;
  290. text-align: center;
  291. font-size: 26upx;
  292. color: #FFFFFF;
  293. background-color: $mine-background-color;
  294. }
  295. }
  296. }
  297. .close {
  298. margin: 0 auto;
  299. height: 100upx;
  300. width: 100upx;
  301. text-align: center;
  302. margin-top: 10%;
  303. image {
  304. height: 50upx;
  305. width: 50upx;
  306. }
  307. }
  308. }
  309. .swiper {
  310. height: 300upx;
  311. .swiper-item {
  312. height: 100%;
  313. image {
  314. width: 100%;
  315. }
  316. }
  317. }
  318. .video-list {
  319. .video-item {
  320. background-color: #FFFFFF;
  321. margin: 0 30upx;
  322. margin-top: 30upx;
  323. // height: 300upx;
  324. }
  325. .image {
  326. height: 320upx;
  327. overflow: hidden;
  328. image {
  329. width: 100%;
  330. height: 320upx;
  331. }
  332. }
  333. .video-title {
  334. padding: 30upx 20upx;
  335. line-height: 40upx;
  336. font-size: 30upx;
  337. }
  338. }
  339. .video {
  340. .title {
  341. font-size: 34upx;
  342. margin: 22upx 30upx;
  343. font-weight: bold;
  344. .icon-iconfontjiantou2 {
  345. float: right;
  346. font-size: 34upx;
  347. margin-top: 5upx;
  348. }
  349. .more {
  350. float: right;
  351. font-size: 30upx;
  352. }
  353. }
  354. }
  355. .index-list {
  356. padding: 30upx;
  357. .title {
  358. font-size: 34upx;
  359. margin: 22upx 0;
  360. font-weight: bold;
  361. .icon-iconfontjiantou2 {
  362. float: right;
  363. font-size: 34upx;
  364. margin-top: 5upx;
  365. }
  366. .more {
  367. float: right;
  368. font-size: 30upx;
  369. }
  370. }
  371. .list {
  372. background-color: #FFFFFF;
  373. padding: 46upx 20upx 36upx 20upx;
  374. display: flex;
  375. margin-top: 12upx;
  376. margin-bottom: 30upx;
  377. .left {
  378. flex: 0 0 180upx;
  379. // height: 130upx;
  380. overflow: hidden;
  381. margin-right: 30upx;
  382. image {
  383. width: 100%;
  384. height: 100%;
  385. }
  386. }
  387. .right {
  388. flex: 1;
  389. .name {
  390. font-size: 36upx;
  391. font-family: PingFang SC;
  392. font-weight: 500;
  393. color: #000000;
  394. margin-bottom: 20upx;
  395. }
  396. .address {
  397. font-size: 28upx;
  398. font-family: PingFang SC;
  399. font-weight: 500;
  400. color: #383838;
  401. }
  402. .num {
  403. font-size: 28upx;
  404. font-family: PingFang SC;
  405. font-weight: 500;
  406. color: #373737;
  407. margin-top: 5upx;
  408. .distance {
  409. float: right;
  410. color: #ABA8A8;
  411. }
  412. }
  413. }
  414. }
  415. }
  416. }
  417. </style>