storeDetails.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view class="container-view">
  3. <!-- <view class="store-img-view" style="background-image: url('https://qiniu.bms16.com/FhG-xwyMdxPVjYNrxXnq5enGFT-2');background-repeat: no-repeat;background-size: 100% 500rpx;">
  4. </view> -->
  5. <view class="store-img-view">
  6. <swiper v-if="shop_image.length!=0" class="swiper" :indicator-dots="true" :autoplay="true" :interval="2000"
  7. indicator-color="rgba(0, 0, 0, 0.3)" indicator-active-color="#000000" :duration="1000" circular>
  8. <swiper-item class="swiper-item" v-for="(item,index) in shop_image" :key="index">
  9. <image class="swiper-item-img" :src="item" mode="aspectFill"></image>
  10. </swiper-item>
  11. </swiper>
  12. <image v-else class="bg-img" src="https://qiniu.bms16.com/FhRnr7rADHHsOFfpWO4duD15SgIt" mode="aspectFill">
  13. </image>
  14. </view>
  15. <view class="p-bg">
  16. <view class="store-info-view">
  17. <view class="store-name">{{storeInfo.shop_name}}</view>
  18. <view class="flex-row align-center" style="margin-bottom: 24rpx;">
  19. <view v-for="(item,index) of storeInfo.service_type_list" :key="index" class="store-type">
  20. {{item.title}}
  21. </view>
  22. <view class="store-num-type"> <text class="store-num">{{storeInfo.model_list.length || 0}}</text>
  23. 款车型
  24. </view>
  25. <view class="store-phone" @tap="tapPhone"><img style="width: 84rpx;height: 64rpx;"
  26. src="https://qiniu.bms16.com/Ft0YA1JYmq66hdoeEN-PgBHy5vLa" alt=""></view>
  27. </view>
  28. <view class="flex-row flex-between">
  29. <view :class="isWorkTimer ? 'left_grid_2' : 'left_grid_1'">
  30. <view class="flex-row">
  31. <img style="width: 40rpx;height: 40rpx;"
  32. :src="!isWorkTimer ? 'https://zxappfile.bms16.com/zx_admin/cab_timer.png' : 'https://zxappfile.bms16.com/zx_admin/cab_timer_work.png'">
  33. <view :class="isWorkTimer ? 'grid_text_1' : 'grid_text_rest' ">
  34. {{isWorkTimer ? '营业中' : '已休息'}}
  35. </view>
  36. </view>
  37. <view class="grid_text_2">
  38. {{storeInfo.work_begin_time[0]}}:{{storeInfo.work_begin_time[1]}}-{{storeInfo.work_end_time[0]}}:{{storeInfo.work_end_time[1]}}
  39. </view>
  40. </view>
  41. <view @tap="bindToNav" class="right_grid flex-between">
  42. <view>
  43. <view class="cab_distance">
  44. 直线距您 {{storeInfo.distance}}
  45. </view>
  46. <view class="cab_address">{{storeInfo.address}}</view>
  47. </view>
  48. <view>
  49. <img class="icon_grid_1" src="https://zxappfile.bms16.com/zx_admin/cab_nav.png">
  50. <view class="grid_nav">导航</view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <useGuidance />
  56. <view class="unit-type-view">
  57. <view @click="status = 0;modelListsFn()" class="unit-type " :class="{'unit-type-i' : status == 0}">短租
  58. </view>
  59. <view @click="status = 1;modelListsFn()" class="unit-type" :class="{'unit-type-i' : status == 1}">长租
  60. </view>
  61. <view @click="status = 2;modelListsFn()" class="unit-type " :class="{'unit-type-i' : status == 2}">出售
  62. </view>
  63. </view>
  64. <view class="car-info-list-view">
  65. <view v-for="(item,index) of modelListsFn()" :key="index" class="car-info-view align-center flex-row">
  66. <!-- <img class="car-img" src="https://qiniu.bms16.com/FsxOysJT2V3KNYev2YWadvjyKn2j" alt=""> -->
  67. <image class="car-img" :src="item.model_images" mode="aspectFill"></image>
  68. <view class="car-info">
  69. <view class="car-name flex-row">{{item.model_name}}</view>
  70. <view class="car-model-info">续航{{item.endurance}}km|重量{{item.weight}}kg</view>
  71. <view class="flex-row flex-between">
  72. <view class="unit-type-price flex-row">
  73. <text v-if="status == 0" style="margin-right: 8rpx;">短租</text>
  74. <text v-if="status == 1" style="margin-right: 8rpx;">长租</text>
  75. <text v-if="status == 2" style="margin-right: 8rpx;">出售</text>
  76. <priceTool :price="item.money" :font_size="40" />
  77. </view>
  78. <view @click="srcFn(`/pages/carDetail/carDetail?model_id=${item.model_id}`)"
  79. class="lease-btn">购/租</view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  88. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  89. <script>
  90. var config = require('../../common/config.js');
  91. var common = require('../../common/common.js');
  92. var http = require('../../common/http.js');
  93. var storage = require('../../common/storage.js');
  94. import priceTool from '@/component/priceTool/priceTool';
  95. import UseGuidance from '@/component/useGuidance/useGuidance';
  96. export default {
  97. components: {
  98. priceTool,
  99. UseGuidance
  100. },
  101. data() {
  102. return {
  103. shop_id:0,
  104. status: 0,
  105. shop_image: [],
  106. storeInfo: {
  107. model_list: []
  108. },
  109. isWorkTimer: null
  110. };
  111. },
  112. computed: {},
  113. /**
  114. * 生命周期函数--监听页面加载
  115. */
  116. onLoad: function(options) {
  117. console.log(options, 'options');
  118. this.shop_id = options.admin_id || ''
  119. this.locationFn()
  120. },
  121. /**
  122. * 生命周期函数--监听页面显示
  123. */
  124. onShow: function() {
  125. },
  126. methods: {
  127. modelListsFn() {
  128. let obj = []
  129. for (let index = 0; index < this.storeInfo.model_list.length; index++) {
  130. let item = this.storeInfo.model_list[index];
  131. if(item.sell_price){
  132. obj.push({
  133. ...item,
  134. money:(item.sell_price / 100).toFixed(2)
  135. })
  136. }
  137. for (var i = 0; i < item.price_setting.length; i++) {
  138. var items = item.price_setting[i];
  139. let money = (items.hire_price / 100).toFixed(2)
  140. if (!item.sell_price && this.status == 0 && (items.hire_duration_unit == 1 || items.hire_duration_unit == 4 || items
  141. .hire_duration_unit == 5 || items.hire_duration_unit == 6)) {
  142. obj.push({
  143. ...item,
  144. money
  145. })
  146. break
  147. }
  148. if (!item.sell_price && this.status == 1 && (items.hire_duration_unit == 2 || items.hire_duration_unit == 3 || items
  149. .hire_duration_unit == 4)) {
  150. obj.push({
  151. ...item,
  152. money
  153. })
  154. break
  155. }
  156. }
  157. }
  158. return obj
  159. },
  160. locationFn() {
  161. let _this = this
  162. uni.getLocation({
  163. success(res) {
  164. _this.loadStoreDetail(_this.shop_id, res.longitude, res.latitude)
  165. }
  166. })
  167. },
  168. srcFn(url) {
  169. uni.navigateTo({
  170. url
  171. })
  172. },
  173. isWorkTimerFn() {
  174. this.storeInfo.work_end_time = ''
  175. this.storeInfo.work_end_time = ''
  176. },
  177. loadStoreDetail(shop_id, longitude, latitude) {
  178. const me = this
  179. console.log(shop_id)
  180. console.log(longitude)
  181. console.log(latitude)
  182. http.postApi(config.API_NEAR_SHOP_INFO, {
  183. shop_id,
  184. longitude,
  185. latitude,
  186. }, (resp) => {
  187. if (resp.data.code === 200) {
  188. me.setData({
  189. storeInfo: resp.data.data.info
  190. })
  191. this.storeInfo.distance = common.formatDistance(Number(this.storeInfo.distance))
  192. this.shop_image = JSON.parse(resp.data.data.info.shop_image) || []
  193. var cabinetInfo = resp.data.data.info
  194. this.storeInfo.work_begin_time = (cabinetInfo.work_begin_time == null ? '00:00:00' :
  195. cabinetInfo
  196. .work_begin_time).split(':')
  197. this.storeInfo.work_end_time = (cabinetInfo.work_end_time == null ? '00:00:00' :
  198. cabinetInfo
  199. .work_end_time).split(':')
  200. this.isWorkTimer = this.isWithinTimeRange(cabinetInfo.work_begin_time,
  201. cabinetInfo.work_end_time)
  202. } else {
  203. common.simpleToast(resp.data.msg)
  204. }
  205. })
  206. },
  207. isWithinTimeRange(startTime, endTime) {
  208. // 获取当前时间
  209. const now = new Date();
  210. const currentMinutes = now.getHours() * 60 + now.getMinutes();
  211. // 将传入的时间转换为分钟
  212. const [startHour, startMinute] = startTime.map(Number);
  213. const [endHour, endMinute] = endTime.map(Number);
  214. const startMinutes = startHour * 60 + startMinute;
  215. const endMinutes = endHour * 60 + endMinute;
  216. // 判断当前时间是否在指定范围内
  217. return currentMinutes >= startMinutes && currentMinutes <= endMinutes;
  218. },
  219. tapPhone() {
  220. const me = this
  221. uni.showModal({
  222. content: `您是否要拨打电话${me.storeInfo.link_phone}?`,
  223. confirmText: '确定',
  224. success: (res) => {
  225. if (res.confirm) {
  226. me.clearTimer()
  227. uni.makePhoneCall({
  228. phoneNumber: me.storeInfo.link_phone,
  229. success() {},
  230. fail() {}
  231. })
  232. }
  233. },
  234. fail: (res) => {}
  235. })
  236. },
  237. bindToNav() {
  238. const {
  239. address,
  240. latitude,
  241. longitude,
  242. shop_name
  243. } = this.storeInfo
  244. uni.openLocation({
  245. latitude: latitude - 0,
  246. longitude: longitude - 0,
  247. scale: 15,
  248. name: shop_name,
  249. address: address,
  250. success: function(res) {},
  251. })
  252. },
  253. }
  254. };
  255. </script>
  256. <style>
  257. @import './storeDetails.css';
  258. </style>