list.vue 7.5 KB

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