store.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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}}M</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. store_list({
  80. page:1,
  81. limit:1000,
  82. // latitude:res.latitude,
  83. // longitude: res.longitude,
  84. }).then(e =>{
  85. obj.stop = e.data.list
  86. console.log(e);
  87. })
  88. // uni.getLocation({
  89. // type: 'gcj02',
  90. // success: res => {
  91. // console.log('dizhi+++++++++++');
  92. // this.longitude = res.longitude //经度
  93. // this.latitude = res.latitude //纬度
  94. // store_list({
  95. // page:1,
  96. // limit:3,
  97. // latitude:res.latitude,
  98. // longitude: res.longitude,
  99. // }).then(e =>{
  100. // if(e.data.length != 0){
  101. // e.data.list.forEach(e =>{
  102. // e.jl = this.getFlatternDistance(this.latitude,this.longitude,e.latitude,e.longitude)
  103. // })
  104. // }
  105. // obj.stop = e.data.list
  106. // console.log(e);
  107. // })
  108. // },
  109. // fail: err => {
  110. // console.log(err);
  111. // openMap().then(e => {
  112. // this.getaddress();
  113. // });
  114. // }
  115. // });
  116. },
  117. //根据经纬度计算距离
  118. getFlatternDistance(lat1, lng1, lat2, lng2){
  119. let f = getRad((lat1 + lat2)/2);
  120. let g = getRad((lat1 - lat2)/2);
  121. let l = getRad((lat1 - lng2)/2);
  122. let sg = Math.sin(g);
  123. let sl = Math.sin(1);
  124. let sf = Math.sin(f);
  125. let s,C,W,r ,d,h1,h2;
  126. let a = EARTH_RADIUS ;
  127. let fl = 1/298.257;
  128. sg = sg*sg;
  129. s1 = s1*sl;
  130. sf = sf*sf;
  131. g*(1-s1) + (1-sf)*s1;
  132. C = (1-sg)*(1-s1) + sf*sl;
  133. N = Math.atan(Math.sqrt(s/c));
  134. r = Math.sqrt(s*c)/w;
  135. d = 2*w*a;
  136. h1 = (3*r -1)/2/c;
  137. h2 = (3*r +1)/2/s;
  138. return d*(1 + fl*(h1*sf*(1-sg) - h2*(1-sf)*sg));
  139. },
  140. navTo(url){
  141. uni.navigateTo({
  142. url,
  143. fail() {
  144. uni.switchTab({
  145. url
  146. })
  147. }
  148. })
  149. }
  150. }
  151. };
  152. </script>
  153. <style lang="less">
  154. .kong {
  155. height: 100vh;
  156. }
  157. .search-top {
  158. position: fixed;
  159. top: 0;
  160. z-index: 99;
  161. }
  162. .search {
  163. justify-content: flex-start;
  164. padding: 10rpx 32rpx 20rpx;
  165. align-items: center;
  166. background-color: #fff;
  167. .address {
  168. width: 32rpx;
  169. height: 38rpx;
  170. }
  171. .shop-name {
  172. height: 38rpx;
  173. position: relative;
  174. top: -4rpx;
  175. z-index: 100;
  176. font-size: 30rpx;
  177. font-family: PingFang SC;
  178. font-weight: 500;
  179. color: #666;
  180. padding-left: 10rpx;
  181. }
  182. .shop-jt {
  183. margin-left: 8rpx;
  184. width: 16rpx;
  185. height: 10rpx;
  186. }
  187. .input-box {
  188. margin-left: 10rpx;
  189. position: relative;
  190. z-index: 99;
  191. width: 520rpx;
  192. height: 60rpx;
  193. // background: rgba(255, 255, 255, 0.4);
  194. border-radius: 30rpx;
  195. .input-content {
  196. position: relative;
  197. z-index: 11;
  198. // border-radius: 99rpx;
  199. flex-grow: 1;
  200. padding: 5rpx 30rpx;
  201. background: #f6f6f6;
  202. .iconsearch {
  203. font-size: 50rpx;
  204. color: #ffffff;
  205. }
  206. .input {
  207. margin-left: 19rpx;
  208. flex-grow: 1;
  209. color: #666;
  210. background: #f6f6f6;
  211. input {
  212. font-size: 28rpx;
  213. }
  214. }
  215. }
  216. .input-button {
  217. padding-left: 20rpx;
  218. // font-size: $font-base;
  219. height: 100%;
  220. }
  221. }
  222. .search-tit {
  223. font-size: 28rpx;
  224. font-family: PingFang SC;
  225. font-weight: 500;
  226. color: #666666;
  227. flex-shrink: 0;
  228. padding-left: 10rpx;
  229. }
  230. }
  231. .shop {
  232. // margin-top: 20rpx;
  233. background: #ffffff;
  234. padding: 0 12rpx;
  235. .shop-title {
  236. padding: 30rpx 0 20rpx;
  237. display: flex;
  238. align-items: center;
  239. border-bottom: 1px solid #e3e6e7;
  240. .shop-item {
  241. width: 25%;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. .sitem-font {
  246. font-size: 26rpx;
  247. font-family: PingFang SC;
  248. font-weight: bold;
  249. color: #333333;
  250. }
  251. .jt-down {
  252. width: 10rpx;
  253. height: 8rpx;
  254. margin-left: 12rpx;
  255. }
  256. }
  257. }
  258. .shop-main {
  259. padding: 32rpx 18rpx 0 12rpx;
  260. align-items: flex-start;
  261. justify-content: flex-start;
  262. .main-left {
  263. width: 180rpx;
  264. height: 180rpx;
  265. border-radius: 10rpx;
  266. }
  267. .main-right {
  268. width: 500rpx;
  269. justify-content: space-between;
  270. align-items: flex-start;
  271. margin-left: 20rpx;
  272. padding: 13rpx 0 35rpx;
  273. border-bottom: 1px solid #eaeced;
  274. .shopm-info {
  275. max-width: 60%;
  276. line-height: 1;
  277. .shopm-title {
  278. display: flex;
  279. justify-content: flex-start;
  280. .shopmt-font {
  281. font-size: 34rpx;
  282. font-family: PingFang SC;
  283. font-weight: bold;
  284. color: #333333;
  285. }
  286. }
  287. .shopmt-tip {
  288. position: relative;
  289. margin-top: 92rpx;
  290. font-size: 24rpx;
  291. font-family: PingFang SC;
  292. font-weight: 500;
  293. color: #666666;
  294. }
  295. }
  296. .right {
  297. height: 100%;
  298. margin-top: 5rpx;
  299. display: flex;
  300. flex-direction: column;
  301. .mright-top {
  302. display: flex;
  303. justify-content: flex-end;
  304. align-items: center;
  305. .mrt-image {
  306. width: 20rpx;
  307. height: 28rpx;
  308. }
  309. .mrt-font {
  310. margin-left: 8rpx;
  311. font-size: 22rpx;
  312. font-family: PingFang SC;
  313. font-weight: 500;
  314. color: #666666;
  315. }
  316. }
  317. .mright-bottom {
  318. margin-top: 80rpx;
  319. display: flex;
  320. justify-content: flex-end;
  321. .mrb-item {
  322. width: 46rpx;
  323. height: 46rpx;
  324. margin-left: 14rpx;
  325. }
  326. }
  327. }
  328. }
  329. }
  330. }
  331. </style>