index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <!-- 首页 -->
  3. <view>
  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 class="title_hint">{{item.title}}</view>
  16. </view>
  17. </view>
  18. <view class="card_bottle" @click="scanning">
  19. <view class="card_fiche" :style="{backgroundColor:'#67C23A'}">
  20. <span class="iconfont icon_image icon-saomachaxun"></span>
  21. <view class="title_hint">扫码查询气瓶流转信息</view>
  22. </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: '#f4b237',
  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. .head_address {
  122. padding: 20rpx;
  123. display: flex;
  124. align-items: center;
  125. }
  126. .add_title {
  127. font-size: 30rpx;
  128. font-weight: 600;
  129. margin: 0rpx 5rpx;
  130. }
  131. .card_gas_cylinder {
  132. display: flex;
  133. justify-content: center;
  134. align-items: center;
  135. font-size: 46rpx;
  136. font-weight: bold;
  137. color: #027DB4;
  138. padding: 10rpx 20rpx 0rpx 20rpx;
  139. }
  140. .card_port {
  141. font-size: 40rpx;
  142. font-weight: bold;
  143. color: #027DB4;
  144. padding-bottom: 20rpx;
  145. }
  146. .card_cylinder {
  147. display: flex;
  148. flex-direction: row;
  149. flex-wrap: wrap;
  150. justify-content: space-evenly;
  151. }
  152. .card_bottle {
  153. margin: 30rpx 0rpx;
  154. width: 40%;
  155. display: flex;
  156. flex-direction: column;
  157. align-items: center;
  158. }
  159. .card_fiche {
  160. display: flex;
  161. align-items: center;
  162. flex-direction: column;
  163. // justify-content: center;
  164. justify-content: flex-end;
  165. width: 100%;
  166. height: 240rpx;
  167. background-color: #027DB4;
  168. border-radius: 26rpx;
  169. }
  170. .icon_image {
  171. color: #fff;
  172. font-size: 80rpx;
  173. }
  174. .title_hint {
  175. height: 80rpx;
  176. margin-top: 20rpx;
  177. margin-bottom: 20rpx;
  178. color: #fff;
  179. width: 80%;
  180. text-align: center;
  181. font-size: 32rpx;
  182. }
  183. </style>