storeDetail.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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" 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. if (res.data) {
  166. this.waitPhoto = res.data
  167. this.showPop=true
  168. } else {
  169. this.toashMsg('暂无数据')
  170. }
  171. }
  172. })
  173. },
  174. // 打开导航位置信息界面
  175. openLocation () {
  176. let data = this.storeInfo
  177. let _this = this
  178. uni.getLocation({
  179. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  180. success: function (res) {
  181. const latitude = data.lat;
  182. const longitude = data.lng;
  183. uni.openLocation({
  184. latitude: latitude,
  185. longitude: longitude,
  186. name: data.name,
  187. address: data.addrDetail,
  188. success: function () {
  189. console.log('success');
  190. }
  191. })
  192. },
  193. fail:function(){
  194. _this.toashMsg('获取位置信息失败,请先授权开启定位功能!')
  195. }
  196. });
  197. }
  198. }
  199. }
  200. </script>
  201. <style lang="scss">
  202. page{
  203. height: 100%;
  204. }
  205. .content{
  206. padding: 0 20rpx;
  207. width: 100%;
  208. height: 100%;
  209. display: flex;
  210. flex-direction: column;
  211. .page-content{
  212. flex: 1;
  213. overflow-y: scroll;
  214. }
  215. .header {
  216. padding: 20rpx 0;
  217. display: flex;
  218. .store-info {
  219. display: flex;
  220. flex: 1;
  221. flex-direction: column;
  222. justify-content: space-between;
  223. padding: 0 20rpx;
  224. .name {
  225. font-size: 32rpx;
  226. color: #000;
  227. }
  228. .address{
  229. font-size: 26rpx;
  230. }
  231. .location {
  232. display: flex;
  233. align-items: center;
  234. font-size: 24rpx;
  235. .left {
  236. margin-right: 20rpx;
  237. }
  238. .icon {
  239. color: #999;
  240. margin-right: 5rpx;
  241. }
  242. }
  243. }
  244. }
  245. .store-mark{
  246. padding: 20rpx 0;
  247. width: 100%;
  248. .mark-item{
  249. padding: 10rpx 20rpx;
  250. border: 1px solid #eee;
  251. border-radius: 30rpx;
  252. margin-right: 20rpx;
  253. font-size: 24rpx;
  254. }
  255. }
  256. .store-server{
  257. padding: 20rpx 0;
  258. width: 100%;
  259. font-size: 24rpx;
  260. border-bottom: 1px solid #eee;
  261. text{
  262. margin-right: 30rpx;
  263. }
  264. }
  265. .store-rich{
  266. padding: 20rpx 0;
  267. width: 100%;
  268. display: flex;
  269. flex-direction: column;
  270. align-items: center;
  271. justify-content: center;
  272. }
  273. .store-line{
  274. border-bottom: 1px solid #eee;
  275. }
  276. .footer{
  277. width: 100%;
  278. display: flex;
  279. margin-bottom: 20rpx;
  280. justify-content: space-between;
  281. button{
  282. width: 45%;
  283. }
  284. }
  285. .pop-img{
  286. width: 100%;
  287. height: 100%;
  288. }
  289. }
  290. </style>