storeDetail.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="content">
  3. <view class="page-content">
  4. <view class="header">
  5. <u-image width="160rpx" height="160rpx" :border-radius="10" :src="storeInfo?storeInfo.icon:''"></u-image>
  6. <view class="store-info">
  7. <view class="name">
  8. {{storeInfo ?storeInfo.name : ''}}
  9. </view>
  10. <view class="address">
  11. {{storeInfo?storeInfo.addrDetail:''}}
  12. </view>
  13. <view class="location">
  14. <view class="left">
  15. <uni-icons class="icon" size="16" type="paperplane"></uni-icons>
  16. <text>{{storeInfo?storeInfo.distance:''}}km</text>
  17. </view>
  18. <view class="right">
  19. <u-icon class="icon" size="32" name="clock"></u-icon>
  20. <text>{{storeInfo?storeInfo.beginTime:''}}-{{storeInfo?storeInfo.endTime:''}} 营业</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 网点标签 -->
  26. <view class="store-mark">
  27. <text v-for="(item,index) in labelList" :key="index" class="mark-item">
  28. {{item}}
  29. </text>
  30. </view>
  31. <view class="store-server">
  32. 服务项目:
  33. <text v-for="item in storeInfo.itemVOList" :key="item.id">{{item.itemName}}</text>
  34. </view>
  35. <!-- 路线指引 -->
  36. <view class="store-rich store-line" v-if="storeInfo&&storeInfo.guidance">
  37. <view class="line-title">
  38. * 路线指引 *
  39. </view>
  40. <view class="line-content">
  41. <u-parse :html="storeInfo&&storeInfo.guidance?storeInfo.guidance:''"></u-parse>
  42. </view>
  43. </view>
  44. <!-- 温馨提示 -->
  45. <view class="store-rich" v-if="storeInfo&&storeInfo.reminder">
  46. <view class="line-title">
  47. * 温馨提示 *
  48. </view>
  49. <view class="line-content">
  50. <u-parse :html="storeInfo&&storeInfo.reminder?storeInfo.reminder:''"></u-parse>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="footer">
  55. <button type="warn" :loading="loading" plain @click="getWaitPhoto">排队情况</button>
  56. <button type="warn" @click="openLocation">立刻导航</button>
  57. </view>
  58. <u-popup v-model="showPop" mode="center" @close="showPop=false" width="90%" height="60%" closeable>
  59. <image mode="aspectFit" class="pop-img" :src="waitPhoto"></image>
  60. </u-popup>
  61. </view>
  62. </template>
  63. <script>
  64. import {getStoreDetail, getWaitPhoto} from '@/api/store.js'
  65. export default {
  66. components: {
  67. },
  68. data() {
  69. return {
  70. // 用户拒绝授权位置信息时默认展示青海西宁位置地图
  71. currentPosition: {
  72. lat: '36.636193',
  73. lng: '101.760521'
  74. },
  75. showPop: false, // 是否显示排队弹窗
  76. storeInfo: null, // 网点详细信息
  77. labelList: [], // 网点标签
  78. waitPhoto: '', // 排队照片
  79. loading: false // 是否显示排队按钮loading
  80. }
  81. },
  82. onLoad(option) {
  83. // 获取当前经纬度
  84. let _this = this
  85. this.pageInit()
  86. uni.getLocation({
  87. type: 'wgs84', // 默认wgs84
  88. success: function(res) {
  89. _this.currentPosition.lat = res.latitude;
  90. _this.currentPosition.lng = res.longitude;
  91. // 查询门店信息
  92. if (option.id) {
  93. _this.getStoreDetail(option.id)
  94. }
  95. },
  96. fail: function(res) {
  97. console.log(res)
  98. // 查询门店信息
  99. if (option.id) {
  100. _this.getStoreDetail(option.id)
  101. }
  102. },
  103. });
  104. },
  105. methods: {
  106. pageInit () {
  107. this.storeInfo = null
  108. this.labelList = []
  109. this.loading = false
  110. },
  111. // 获取网点详情信息
  112. getStoreDetail (id) {
  113. uni.showLoading({
  114. title: '加载中...'
  115. })
  116. let params = {
  117. id: id,
  118. lat: this.currentPosition.lat,
  119. lng: this.currentPosition.lng
  120. }
  121. getStoreDetail(params).then(res=>{
  122. uni.hideLoading()
  123. if (res.status == 200) {
  124. this.storeInfo = Object.assign({},res.data)
  125. if (this.storeInfo.addrDetail.indexOf("省") > 0 && this.storeInfo.addrDetail.indexOf("市") > 0 && this.storeInfo.addrDetail.indexOf("区") >
  126. 0) {
  127. this.storeInfo.addrDetail = this.storeInfo.addrDetail
  128. } else {
  129. if (this.storeInfo.addrDetail.indexOf("市") > 0 && this.storeInfo.addrDetail.indexOf("区") > 0) {
  130. this.storeInfo.addrDetail = this.storeInfo.addrProvinceName + this.storeInfo.addrDetail
  131. } else if (this.storeInfo.addrDetail.indexOf("区") > 0) {
  132. this.storeInfo.addrDetail = this.storeInfo.addrProvinceName + this.storeInfo.addrCityName + this.storeInfo.addrDetail
  133. } else {
  134. this.storeInfo.addrDetail = this.storeInfo.addrProvinceName + this.storeInfo.addrCityName + this.storeInfo.addrDistrictName + this.storeInfo.addrDetail
  135. }
  136. }
  137. this.getOptionName()
  138. this.storeInfo.distance = this.storeInfo.distanct && this.storeInfo.distanct.distance ? Math.round(this.storeInfo.distanct.distance / 1000) : ''
  139. } else {
  140. }
  141. })
  142. },
  143. // 匹配数据字典 获取相应的name
  144. getOptionName () {
  145. console.log(222)
  146. let storeLabelList = this.$store.state.vuex_storeLabel // 网点标签数据字典列表
  147. let arr = []
  148. this.storeInfo.labelList.map(item =>{
  149. let p = storeLabelList.find((i) => {
  150. return i.code == item
  151. })
  152. if (p) {
  153. arr.push(p.dispName)
  154. }
  155. })
  156. this.labelList = arr
  157. },
  158. // 获取排队情况
  159. getWaitPhoto () {
  160. this.loading = true
  161. let deviceNo = this.storeInfo.deviceVOList && this.storeInfo.deviceVOList.length? this.storeInfo.deviceVOList[0].deviceNo :''
  162. getWaitPhoto({deviceNo:deviceNo}).then(res=>{
  163. this.loading = false
  164. if(res.status==200) {
  165. this.waitPhoto = res.data ? res.data : '/static/img/noPic.jpg'
  166. this.showPop=true
  167. }
  168. })
  169. },
  170. // 打开导航位置信息界面
  171. openLocation () {
  172. let data = this.storeInfo
  173. let _this = this
  174. uni.getLocation({
  175. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  176. success: function (res) {
  177. const latitude = data.lat;
  178. const longitude = data.lng;
  179. uni.openLocation({
  180. latitude: latitude,
  181. longitude: longitude,
  182. name: data.name,
  183. address: data.addrDetail,
  184. success: function () {
  185. console.log('success');
  186. }
  187. })
  188. },
  189. fail:function(){
  190. _this.toashMsg('获取位置信息失败,请先授权开启定位功能!')
  191. }
  192. });
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss">
  198. page{
  199. height: 100%;
  200. }
  201. .content{
  202. padding: 0 20rpx;
  203. width: 100%;
  204. height: 100%;
  205. display: flex;
  206. flex-direction: column;
  207. .page-content{
  208. flex: 1;
  209. overflow-y: scroll;
  210. }
  211. .header {
  212. padding: 20rpx 0;
  213. display: flex;
  214. .store-info {
  215. display: flex;
  216. flex: 1;
  217. flex-direction: column;
  218. justify-content: space-between;
  219. padding: 0 20rpx;
  220. .name {
  221. font-size: 32rpx;
  222. color: #000;
  223. }
  224. .address{
  225. font-size: 26rpx;
  226. }
  227. .location {
  228. display: flex;
  229. align-items: center;
  230. font-size: 24rpx;
  231. .left {
  232. margin-right: 20rpx;
  233. }
  234. .icon {
  235. color: #999;
  236. margin-right: 5rpx;
  237. }
  238. }
  239. }
  240. }
  241. .store-mark{
  242. padding: 20rpx 0;
  243. width: 100%;
  244. .mark-item{
  245. padding: 10rpx 20rpx;
  246. border: 1px solid #eee;
  247. border-radius: 30rpx;
  248. margin-right: 20rpx;
  249. font-size: 24rpx;
  250. }
  251. }
  252. .store-server{
  253. padding: 20rpx 0;
  254. width: 100%;
  255. font-size: 24rpx;
  256. border-bottom: 1px solid #eee;
  257. text{
  258. margin-right: 30rpx;
  259. }
  260. }
  261. .store-rich{
  262. padding: 20rpx 0;
  263. width: 100%;
  264. display: flex;
  265. flex-direction: column;
  266. align-items: center;
  267. justify-content: center;
  268. }
  269. .store-line{
  270. border-bottom: 1px solid #eee;
  271. }
  272. .footer{
  273. width: 100%;
  274. display: flex;
  275. margin-bottom: 20rpx;
  276. justify-content: space-between;
  277. button{
  278. width: 45%;
  279. }
  280. }
  281. .pop-img{
  282. width: 100%;
  283. height: 100%;
  284. }
  285. }
  286. </style>