App.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <script>
  2. let socketID;
  3. import amapFile from './libs/amap-wx.js'
  4. export default {
  5. data(){
  6. return {
  7. // 地图
  8. amapPlugin: null,
  9. key: 'bb6f4ed802756f963b37c184ce4e9766',
  10. timer:null
  11. }
  12. },
  13. onLaunch: function() {
  14. console.log('App Launch')
  15. // 定位
  16. this.amapPlugin = new amapFile.AMapWX({
  17. key: this.key
  18. });
  19. this.connect()
  20. this.$store.commit('getCity', '')
  21. let tabList = []
  22. this.$http('/addons/ddrive/banner/market_setting').then(data => {
  23. if (data.dj_status == 1) {
  24. tabList.push({
  25. name: '代驾',
  26. id: 0
  27. })
  28. }
  29. if (data.sf_status == 1) {
  30. tabList.push({
  31. name: '顺风车',
  32. id: 1
  33. })
  34. }
  35. if (data.dc_status == 1) {
  36. tabList.push({
  37. name: '货运',
  38. id: 2
  39. })
  40. }
  41. this.$store.commit('getTab', tabList)
  42. })
  43. },
  44. onShow: function() {
  45. console.log('App Show')
  46. },
  47. onHide: function() {
  48. console.log('App Hide')
  49. },
  50. beforeDestroy() {
  51. clearInterval(this.timer)
  52. this.timer = null
  53. },
  54. methods: {
  55. connect() {
  56. socketID = uni.connectSocket({
  57. url: 'ws://47.115.43.235:2340', //仅为示例,并非真实接口地址。
  58. success: () => {
  59. //console.log('连接成功');
  60. }
  61. });
  62. socketID.onOpen(() => {
  63. let _this = this
  64. this.timer=setInterval(()=>{
  65. this.amapPlugin.getRegeo({
  66. success: (data) => {
  67. _this.$
  68. if(_this.$store.state.token&&_this.$store.state.userInfo.real_verified==1&&_this.$store.state.userInfo.driver_verified==1){
  69. let addr = [_this.$store.state.userInfo.user_id,_this.$store.state.userInfo.truename,data[0].latitude,data[0].longitude,_this.$store.state.userInfo.driver_status]
  70. console.log(addr);
  71. socketID.send({
  72. data:addr.join(',')
  73. })
  74. }
  75. }
  76. });
  77. },4000)
  78. });
  79. socketID.onClose(() => {
  80. //this.connect()
  81. });
  82. socketID.onError(() => {
  83. //this.connect()
  84. });
  85. },
  86. }
  87. }
  88. </script>
  89. <style lang="scss">
  90. uni-page-body {
  91. color: $gray !important;
  92. font-size: 30rpx !important;
  93. }
  94. // 自定义头部,状态栏盒子样式
  95. .status_bar {
  96. height: var(--status-bar-height);
  97. width: 100%;
  98. background-color: #fff;
  99. }
  100. // tab切换选中加下边框
  101. .active-bb {
  102. &::after {
  103. content: '';
  104. position: absolute;
  105. width: 90%;
  106. height: 5rpx;
  107. background-color: $blue;
  108. left: 5%;
  109. bottom: -25rpx;
  110. }
  111. }
  112. // filed
  113. .u-field {
  114. padding: 26rpx 34rpx !important;
  115. .u-label-text {
  116. font-weight: 700 !important;
  117. }
  118. }
  119. // 提交按钮
  120. .u-btn--primary {
  121. background: $blue !important;
  122. }
  123. .u-size-default {
  124. width: 682rpx !important;
  125. height: 88rpx !important;
  126. font-weight: 700 !important;
  127. }
  128. // cell组件右边箭头对其文字
  129. .u-cell_title {
  130. font-weight: 700 !important;
  131. color: #333 !important;
  132. }
  133. .u-cell__right-icon-wrap {
  134. height: 55rpx !important;
  135. }
  136. /*每个页面公共css */
  137. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  138. @import "uview-ui/index.scss";
  139. @import './common/common.scss'
  140. </style>