store.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="center">
  3. <!-- <view class="search-top">
  4. <view class="search flex">
  5. <view class="shop-name clamp">椒江区</view>
  6. <image class="shop-jt" src="../../static/icon/dsjh.png" mode=""></image>
  7. <view class="input-box flex">
  8. <view class=" input-content flex">
  9. <image src="../../static/icon/search-h.png" mode="" class="" style="width: 32rpx;height: 32rpx;"></image>
  10. <view class="input"><input type="text" value="输入关键字搜索" /></view>
  11. </view>
  12. </view>
  13. <view class="search-tit" @click.stop="clickSearch">搜索</view>
  14. </view>
  15. <view class="shop">
  16. <view class="shop-title">
  17. <view class="shop-item">
  18. <view class="sitem-font">智能排序</view>
  19. <image class="jt-down" src="../../static/index/index06.png" mode=""></image>
  20. </view>
  21. <view class="shop-item">
  22. <view class="sitem-font">位置距离</view>
  23. <image class="jt-down" src="../../static/index/index06.png" mode=""></image>
  24. </view>
  25. <view class="shop-item">
  26. <view class="sitem-font">折扣优惠</view>
  27. <image class="jt-down" src="../../static/index/index06.png" mode=""></image>
  28. </view>
  29. <view class="shop-item">
  30. <view class="sitem-font">筛选</view>
  31. <image class="jt-down" src="../../static/index/index06.png" mode=""></image>
  32. </view>
  33. </view>
  34. </view>
  35. </view> -->
  36. <!-- <view class="jg" style="height: 120rpx;"></view> -->
  37. <view class="shop">
  38. <view class="shop-main flex" v-for="(item, index) in stop" :key="index" @click="navTo('/pages/store/storeInfo?id=' + item.id)">
  39. <image class="main-left" :src="item.image" mode=""></image>
  40. <view class="main-right flex">
  41. <view class="shopm-info">
  42. <view class="shopm-title">
  43. <view class="shopmt-font clamp">{{ item.name }}</view>
  44. </view>
  45. <!-- <view class="address">椒江区市府大道200号</view> -->
  46. <view class="shopmt-tip">{{ item.detailed_address }}</view>
  47. </view>
  48. <view class="right">
  49. <view class="mright-top" v-if="item.jl">
  50. <image class="mrt-image" src="../../static/index/index10.png" mode=""></image>
  51. <view class="mrt-font">距离{{ item.jl }}KM</view>
  52. </view>
  53. <view class="mright-bottom">
  54. <image class="mrb-item" src="../../static/index/index14.png" mode=""></image>
  55. <image class="mrb-item" src="../../static/index/index11.png" mode=""></image>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import { store_list } from '@/api/index.js';
  65. export default {
  66. data() {
  67. return {
  68. stop: [],
  69. longitude: '',
  70. latitude: ''
  71. };
  72. },
  73. onLoad() {
  74. this.loadData();
  75. },
  76. methods: {
  77. loadData() {
  78. let obj = this;
  79. uni.getLocation({
  80. type: 'gcj02',
  81. success: res => {
  82. console.log('dizhi+++++++++++');
  83. this.longitude = res.longitude; //经度
  84. this.latitude = res.latitude; //纬度
  85. store_list({
  86. page: 1,
  87. limit: 1000,
  88. latitude: res.latitude,
  89. longitude: res.longitude
  90. }).then(e => {
  91. if (e.data.length != 0) {
  92. e.data.list.forEach(e => {
  93. e.jl = this.getFlatternDistance(this.latitude, this.longitude, e.latitude, e.longitude);
  94. });
  95. }
  96. obj.stop = e.data.list;
  97. console.log(e);
  98. });
  99. },
  100. fail: err => {
  101. console.log(err);
  102. openMap().then(e => {
  103. this.getaddress();
  104. });
  105. }
  106. });
  107. },
  108. //根据经纬度计算距离
  109. getFlatternDistance(lat1, lng1, lat2, lng2) {
  110. let radLat1 = (lat1 * Math.PI) / 180.0;
  111. let radLat2 = (lat2 * Math.PI) / 180.0;
  112. let a = radLat1 - radLat2;
  113. let b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
  114. let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  115. s = s * 6378.137;
  116. s = Math.round(s * 10000) / 10000;
  117. return s;
  118. },
  119. navTo(url) {
  120. uni.navigateTo({
  121. url,
  122. fail() {
  123. uni.switchTab({
  124. url
  125. });
  126. }
  127. });
  128. }
  129. }
  130. };
  131. </script>
  132. <style lang="less">
  133. .kong {
  134. height: 100vh;
  135. }
  136. .search-top {
  137. position: fixed;
  138. top: 0;
  139. z-index: 99;
  140. }
  141. .search {
  142. justify-content: flex-start;
  143. padding: 10rpx 32rpx 20rpx;
  144. align-items: center;
  145. background-color: #fff;
  146. .address {
  147. width: 32rpx;
  148. height: 38rpx;
  149. }
  150. .shop-name {
  151. height: 38rpx;
  152. position: relative;
  153. top: -4rpx;
  154. z-index: 100;
  155. font-size: 30rpx;
  156. font-family: PingFang SC;
  157. font-weight: 500;
  158. color: #666;
  159. padding-left: 10rpx;
  160. }
  161. .shop-jt {
  162. margin-left: 8rpx;
  163. width: 16rpx;
  164. height: 10rpx;
  165. }
  166. .input-box {
  167. margin-left: 10rpx;
  168. position: relative;
  169. z-index: 99;
  170. width: 520rpx;
  171. height: 60rpx;
  172. // background: rgba(255, 255, 255, 0.4);
  173. border-radius: 30rpx;
  174. .input-content {
  175. position: relative;
  176. z-index: 11;
  177. // border-radius: 99rpx;
  178. flex-grow: 1;
  179. padding: 5rpx 30rpx;
  180. background: #f6f6f6;
  181. .iconsearch {
  182. font-size: 50rpx;
  183. color: #ffffff;
  184. }
  185. .input {
  186. margin-left: 19rpx;
  187. flex-grow: 1;
  188. color: #666;
  189. background: #f6f6f6;
  190. input {
  191. font-size: 28rpx;
  192. }
  193. }
  194. }
  195. .input-button {
  196. padding-left: 20rpx;
  197. // font-size: $font-base;
  198. height: 100%;
  199. }
  200. }
  201. .search-tit {
  202. font-size: 28rpx;
  203. font-family: PingFang SC;
  204. font-weight: 500;
  205. color: #666666;
  206. flex-shrink: 0;
  207. padding-left: 10rpx;
  208. }
  209. }
  210. .shop {
  211. // margin-top: 20rpx;
  212. background: #ffffff;
  213. padding: 0 12rpx;
  214. .shop-title {
  215. padding: 30rpx 0 20rpx;
  216. display: flex;
  217. align-items: center;
  218. border-bottom: 1px solid #e3e6e7;
  219. .shop-item {
  220. width: 25%;
  221. display: flex;
  222. align-items: center;
  223. justify-content: center;
  224. .sitem-font {
  225. font-size: 26rpx;
  226. font-family: PingFang SC;
  227. font-weight: bold;
  228. color: #333333;
  229. }
  230. .jt-down {
  231. width: 10rpx;
  232. height: 8rpx;
  233. margin-left: 12rpx;
  234. }
  235. }
  236. }
  237. .shop-main {
  238. padding: 32rpx 18rpx 0 12rpx;
  239. align-items: flex-start;
  240. justify-content: flex-start;
  241. .main-left {
  242. width: 180rpx;
  243. height: 180rpx;
  244. border-radius: 10rpx;
  245. }
  246. .main-right {
  247. width: 500rpx;
  248. justify-content: space-between;
  249. align-items: flex-start;
  250. margin-left: 20rpx;
  251. padding: 13rpx 0 35rpx;
  252. border-bottom: 1px solid #eaeced;
  253. .shopm-info {
  254. max-width: 60%;
  255. line-height: 1;
  256. .shopm-title {
  257. display: flex;
  258. justify-content: flex-start;
  259. .shopmt-font {
  260. font-size: 34rpx;
  261. font-family: PingFang SC;
  262. font-weight: bold;
  263. color: #333333;
  264. }
  265. }
  266. .shopmt-tip {
  267. position: relative;
  268. margin-top: 92rpx;
  269. font-size: 24rpx;
  270. font-family: PingFang SC;
  271. font-weight: 500;
  272. color: #666666;
  273. }
  274. }
  275. .right {
  276. height: 100%;
  277. margin-top: 5rpx;
  278. display: flex;
  279. flex-direction: column;
  280. .mright-top {
  281. display: flex;
  282. justify-content: flex-end;
  283. align-items: center;
  284. .mrt-image {
  285. width: 20rpx;
  286. height: 28rpx;
  287. }
  288. .mrt-font {
  289. margin-left: 8rpx;
  290. font-size: 22rpx;
  291. font-family: PingFang SC;
  292. font-weight: 500;
  293. color: #666666;
  294. }
  295. }
  296. .mright-bottom {
  297. margin-top: 80rpx;
  298. display: flex;
  299. justify-content: flex-end;
  300. .mrb-item {
  301. width: 46rpx;
  302. height: 46rpx;
  303. margin-left: 14rpx;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. }
  310. </style>