store.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="content">
  3. <map
  4. id="map"
  5. :latitude="lat"
  6. :longitude="lng"
  7. scale="18"
  8. show-compass
  9. show-location
  10. :markers="markers"
  11. style="width: 100%; height:30%;">
  12. </map>
  13. <!-- 网点信息及设备 -->
  14. <view class="details" v-if="stationData">
  15. <view class="details-address">
  16. <view>{{ stationData.name }}</view>
  17. <view>{{ stationData.provinceName }}{{ stationData.cityName }}{{ stationData.districtName }}{{ stationData.address }}</view>
  18. <view>
  19. 营业时间:
  20. <text v-for="(tItem, tInd) in stationData.deliveryTimeRuleItemList" :key="tInd">
  21. {{ tItem.openTime }} - {{ tItem.closeTime }}{{ tInd == stationData.deliveryTimeRuleItemList.length - 1 ? '' : ',' }}
  22. </text>
  23. </view>
  24. </view>
  25. <!-- 设备列表 -->
  26. <view class="details-dev">
  27. <view class="details-dev-box" v-for="item in deviceData">
  28. <view class="details-dev-title">设备编号:<text>{{ item.srcDeviceCode }}</text></view>
  29. <view class="details-dev-cons">
  30. <view class="dev-item" v-for="boxItem in item.deviceTypeBoxList">
  31. <view>
  32. <u-image height="80" width="80" :src="`/static/${boxItem.rubbishType}.png`"></u-image>
  33. </view>
  34. <view>
  35. <view>
  36. {{ boxItem.rubbishTypeDictValue }}
  37. <u-tag v-if="boxItem.flag==1" text="已满" size="mini" mode="dark" type="info" />
  38. </view>
  39. <text>{{ getRule(boxItem.rubbishType).rubbishWeight }}g/{{ getRule(boxItem.rubbishType).goleNum }}乐豆</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <u-empty v-if="deviceData.length==0" text="暂无设备" mode="list" margin-top="120"></u-empty>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import { stationDetail, stationDevice } from '@/api/station.js'
  51. export default {
  52. data() {
  53. return {
  54. stationId: '', // 网点id
  55. stationNo: '', // 网点编号
  56. lat: '',
  57. lng: '',
  58. mapCtx: null, // 地图对象
  59. markers: [], // 标注点
  60. stationData: null, // 网点信息
  61. deviceData: [], // 设备信息
  62. };
  63. },
  64. onLoad(options) {
  65. this.stationId = options.id
  66. this.stationNo = options.stationNo
  67. // 获取经纬度
  68. this.getLocation()
  69. this.getStation() // 网点信息
  70. this.getDevice() // 设备信息
  71. },
  72. methods: {
  73. // 获取经纬度
  74. getLocation() {
  75. const _this = this;
  76. uni.getLocation({
  77. type: 'wgs84',
  78. success: function(res) {
  79. _this.lng = res.longitude
  80. _this.lat = res.latitude
  81. },
  82. fail: function(error) {
  83. console.log(error)
  84. uni.showToast({ icon: 'none', title: '定位失败' })
  85. }
  86. })
  87. },
  88. // 网点信息
  89. getStation(){
  90. stationDetail({ id: this.stationId }).then(res => {
  91. if(res.status == 200){
  92. this.stationData = res.data
  93. }else{
  94. this.stationData = null
  95. }
  96. })
  97. },
  98. // 设备信息
  99. getDevice(){
  100. stationDevice({ stationNo: this.stationNo }).then(res => {
  101. if(res.status == 200){
  102. this.deviceData = res.data
  103. this.markers = []
  104. for(let i=0; i<res.data.length; i++){
  105. this.markers.push({
  106. latitude: res.data[i].lat,
  107. longitude: res.data[i].lng,
  108. width: 30,
  109. height: 30,
  110. iconPath: "/static/store.png"
  111. })
  112. }
  113. }else{
  114. this.deviceData = []
  115. }
  116. })
  117. },
  118. // 根据垃圾类型获取兑换规则
  119. getRule(type){
  120. let row = null
  121. if(this.stationData.goldExRuleItemList){
  122. row = this.stationData.goldExRuleItemList.find(item => item.rubbishType == type)
  123. }
  124. return { rubbishWeight: row.rubbishWeight || 0, goleNum: row.goleNum || 0 }
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss">
  130. .content{
  131. width: 100%;
  132. padding: 0;
  133. .details{
  134. margin: 20upx;
  135. .details-address{
  136. padding: 20upx;
  137. background: #FFFFFF;
  138. border-radius: 15upx;
  139. box-shadow: 0upx 3upx 6upx #eee;
  140. margin-bottom: 20upx;
  141. >view{
  142. font-size: 24upx;
  143. padding: 5upx 0;
  144. color: #666;
  145. &:first-child{
  146. font-weight: bold;
  147. font-size: 30upx;
  148. color: #333;
  149. }
  150. }
  151. }
  152. .details-dev{
  153. .details-dev-box{
  154. padding: 20upx 20upx 5upx;
  155. background: #FFFFFF;
  156. border-radius: 15upx;
  157. box-shadow: 0upx 3upx 6upx #eee;
  158. margin-bottom: 20upx;
  159. .details-dev-title{
  160. border-bottom: 1px solid #F8F8F8;
  161. padding: 10upx 0 20upx;
  162. text{
  163. color: #666;
  164. }
  165. }
  166. .details-dev-cons{
  167. padding: 10upx;
  168. display: flex;
  169. flex-wrap: wrap;
  170. .dev-item{
  171. width: 50%;
  172. display: flex;
  173. align-items: center;
  174. > view{
  175. padding: 15upx 10upx;
  176. &:last-child{
  177. text{
  178. color: #666;
  179. font-size: 24upx;
  180. }
  181. view{
  182. display: flex;
  183. align-items: center;
  184. .u-tag{
  185. margin-left: 10upx;
  186. }
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. }
  196. </style>