index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <!-- 首页 -->
  3. <view class="card_index_bgc">
  4. <view class="head_address" :style="{paddingTop:topHight + 40 + 'rpx'}" @click="goSelectAddress">
  5. <u-icon name="map" size="23"></u-icon>
  6. <view class="add_title">{{address || '定位中...'}}</view>
  7. <u-icon name="arrow-right" size="16"></u-icon>
  8. </view>
  9. <view class="card_gas_cylinder">气瓶安全追溯管理系统</view>
  10. <!-- <view class="card_port center_in">{{genreTitle}}</view> -->
  11. <view class="card_cylinder">
  12. <view class="card_bottle" v-for="(item,index) in stationList" :key="index" @click="scanCodes(item)">
  13. <view class="card_fiche" :style="{backgroundColor:item.color}">
  14. <span class="iconfont icon_image" :class="item.icon"></span>
  15. </view>
  16. <view class="title_hint">{{item.title}}</view>
  17. </view>
  18. <view class="card_bottle" @click="scanning">
  19. <view class="card_fiche" :style="{backgroundColor:'#195eea'}">
  20. <span class="iconfont icon_image icon-saomachaxun"></span>
  21. </view>
  22. <view class="title_hint">气瓶流转信息</view>
  23. </view>
  24. <!-- <view style="width: 40%;margin: 30rpx 0rpx;"></view> -->
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. dataList: [],
  33. stationList: [{
  34. id: 'Booking',
  35. title: '订气',
  36. icon: 'icon-lpg',
  37. color: '#1ee94d',
  38. }],
  39. city: '',
  40. latitude: '',
  41. longitude: '',
  42. address: '',
  43. addressList: {},
  44. topHight: '',
  45. token: ''
  46. }
  47. },
  48. created() {
  49. var city1 = this.$cache.getCache('city')
  50. var district2 = this.$cache.getCache('district')
  51. if (!city1 && !district2) {
  52. this.getLocation()
  53. } else {
  54. if (city1) {
  55. this.address = city1
  56. } else if (district2) {
  57. this.address = district2
  58. }
  59. }
  60. this.topHight = uni.getSystemInfoSync().statusBarHeight
  61. uni.$on('selectArea', () => {
  62. this.$nextTick(() => {
  63. var city1 = this.$cache.getCache('city')
  64. var district2 = this.$cache.getCache('district')
  65. if (district2) {
  66. this.address = district2
  67. } else if (city1) {
  68. this.address = city1
  69. }
  70. })
  71. })
  72. },
  73. mounted() {
  74. var token = this.$cache.getToken()
  75. this.token = token
  76. },
  77. methods: {
  78. //获取经纬度
  79. getLocation() {
  80. uni.getLocation({
  81. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  82. geocode: true,
  83. success: (res) => {
  84. this.addressList = res
  85. this.$cache.setCache('longitude', res)
  86. if (!this.address) {
  87. this.address = res.address.district
  88. this.$cache.setCache('city', res.address.city)
  89. this.$cache.setCache('district', res.address.district)
  90. }
  91. },
  92. });
  93. },
  94. scanCodes(value) {
  95. if (this.token) {
  96. if (value.id == 'Booking') {
  97. uni.navigateTo({
  98. url: '/pages/home/company'
  99. });
  100. }
  101. } else {
  102. uni.$u.toast('请先登录')
  103. }
  104. },
  105. // 选择地区
  106. goSelectAddress() {
  107. uni.navigateTo({
  108. url: '/pages/home/locationArea'
  109. });
  110. },
  111. // 扫码溯源
  112. scanning() {
  113. uni.navigateTo({
  114. url: '/pages/index/codeTracing'
  115. });
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .card_index_bgc {
  122. padding-top: constant(safe-area-inset-top);
  123. padding-top: env(safe-area-inset-top);
  124. background-image: linear-gradient(#a9e3f1, #f3f4f6, #ffffff);
  125. }
  126. .head_address {
  127. padding: 20rpx;
  128. display: flex;
  129. align-items: center;
  130. }
  131. .add_title {
  132. font-size: 30rpx;
  133. font-weight: 600;
  134. margin: 0rpx 5rpx;
  135. }
  136. .card_gas_cylinder {
  137. display: flex;
  138. justify-content: center;
  139. align-items: center;
  140. font-size: 46rpx;
  141. font-weight: bold;
  142. color: #027DB4;
  143. padding: 10rpx 20rpx 0rpx 20rpx;
  144. }
  145. .card_port {
  146. font-size: 40rpx;
  147. font-weight: bold;
  148. color: #027DB4;
  149. padding-bottom: 20rpx;
  150. }
  151. .card_cylinder {
  152. display: flex;
  153. flex-direction: row;
  154. flex-wrap: wrap;
  155. justify-content: space-evenly;
  156. margin: 30rpx;
  157. background-color: #fff;
  158. border-radius: 20rpx;
  159. padding: 20rpx 0rpx;
  160. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  161. }
  162. .card_bottle {
  163. width: 25%;
  164. margin: 10rpx 0rpx;
  165. display: flex;
  166. flex-direction: column;
  167. align-items: center;
  168. }
  169. .card_fiche {
  170. display: flex;
  171. align-items: center;
  172. flex-direction: column;
  173. justify-content: center;
  174. width: 120rpx;
  175. height: 120rpx;
  176. background-color: #027DB4;
  177. border-radius: 26rpx;
  178. }
  179. .icon_image {
  180. color: #fff;
  181. font-size: 70rpx;
  182. }
  183. .title_hint {
  184. margin-top: 10rpx;
  185. color: #606266;
  186. width: 90%;
  187. text-align: center;
  188. font-size: 26rpx;
  189. }
  190. </style>