list.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <style lang="scss">
  2. .m-app{
  3. }
  4. .mpp{
  5. padding: 10px 20rpx;
  6. }
  7. .sreach{
  8. background: #fff;
  9. border-radius: 32rpx;
  10. padding: 16rpx 32rpx;
  11. .icon{
  12. width: 46rpx;
  13. height: 46rpx;
  14. }
  15. input{
  16. width: calc(100% - 46rpx - 16rpx - 50px);
  17. font-size: 16px;
  18. }
  19. .search-btn{
  20. font-size: 14px;
  21. color: #FF4C4C;
  22. }
  23. }
  24. .shop-items{
  25. background: #fff;
  26. padding: 10px 20rpx;
  27. .item{
  28. margin-top: 30rpx;
  29. .img{
  30. width: 180rpx;
  31. height: 180rpx;
  32. border-radius: 10rpx;
  33. }
  34. .info{
  35. position: relative;
  36. margin-left: 20rpx;
  37. width: calc(100% - 200rpx);
  38. border-bottom: 1px solid #F8F8F8;
  39. .title{
  40. font-weight: bold;
  41. font-size: 34rpx;
  42. color: #333333;
  43. width: calc(60%);
  44. overflow:hidden;
  45. text-overflow:ellipsis;
  46. white-space:nowrap;
  47. }
  48. .ii{
  49. image{width: 20rpx;height: 28rpx;margin-right: 8rpx}
  50. font-weight: 400;
  51. font-size: 22rpx;
  52. color: #666666;
  53. }
  54. .address{
  55. .icon{width: 28rpx;height: 28rpx;}
  56. .value{font-size: 22rpx;color: #666666;opacity: 0.5;margin-left: 10rpx;}
  57. margin-top: 20rpx;
  58. }
  59. .tel{
  60. margin-top: 16rpx;
  61. .icon{width: 28rpx;height: 28rpx;}
  62. .value{font-size: 22rpx;color: #666666;opacity: 0.5;margin-left: 10rpx;}
  63. }
  64. .business{
  65. font-weight: bold;
  66. font-size: 24rpx;
  67. color: #FF6F0F;
  68. background: rgba(252, 243, 240, 0.8);
  69. border-radius: 16rpx 16rpx 16rpx 0px;
  70. padding: 10rpx 10rpx;
  71. display: inline-block;
  72. margin-bottom: 20rpx;
  73. }
  74. .wiget{
  75. position: absolute;
  76. right: 0;
  77. bottom: 20rpx;
  78. .wline{
  79. margin: 0px 24rpx;
  80. height: 40rpx;
  81. width: 1px;
  82. background: #eee;
  83. }
  84. .witem{
  85. image{
  86. width: 46rpx;
  87. height: 46rpx;
  88. }
  89. .text{
  90. font-size: 14px;
  91. color: #666666;
  92. margin-top: 8rpx;
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. </style>
  100. <template>
  101. <view class="m-app">
  102. <!--关键词搜索-->
  103. <view class="mpp">
  104. <view class="sreach fx-r fx-bc fx-ac" id="top-main" >
  105. <image class="icon" src="/static/img/tb-seach.png"></image>
  106. <input type="text" confirm-type="search" v-model="keyword" @confirm="tapInput" placeholder="请输入关键词" placeholder-style="color: #B3B3B3;" />
  107. <view class="fx-g1"></view>
  108. <view class="search-btn" @tap="tapInput" v-if="keyword != ''">搜索</view>
  109. </view>
  110. </view>
  111. <scroll-view :style="'height:calc(100vh - ' + topHeight + 'px - ' + h5Foot + 'px - 20px)'" class="mid-body clearfix" scroll-y="true" @scrolltolower="loadMoreData">
  112. <view class="shop-items">
  113. <view class="item fx-r" @tap="tapOpen" :data-url="'../merchant/index?id=' + item.id" v-for="item in data">
  114. <image :src="item.logo" class="img" mode="aspectFill"></image>
  115. <view class="info">
  116. <view class="iview-top fx-r">
  117. <view class="title">{{ item.name }}</view>
  118. <view class="fx-g1"></view>
  119. <view class="ii fx-r fx-bc">
  120. <image src="/static/img/shop-small-location.png"></image>
  121. 距离{{ item.dis_km }}
  122. </view>
  123. </view>
  124. <view class="address fx-r fx-bc">
  125. <image src="/static/img/address-shop.png" class="icon"></image>
  126. <view class="value">{{ item.address }}</view>
  127. </view>
  128. <view class="tel fx-r fx-bc">
  129. <image src="/static/img/tel-shop.png" class="icon"></image>
  130. <view class="value">{{ item.tel }}</view>
  131. </view>
  132. <view class="business">
  133. 营业时间: {{ item.business }}
  134. </view>
  135. <view class="wiget fx-r">
  136. <view class="witem fx-h fx-bc fx-ac" @tap="tapTel(item)">
  137. <image src="/static/img/shop-tel.png"></image>
  138. <view class="text">电话</view>
  139. </view>
  140. <view class="wline"></view>
  141. <view class="witem fx-h fx-bc fx-ac" @tap="tapLbs(item)">
  142. <image src="/static/img/shop-location.png"></image>
  143. <view class="text">导航</view>
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. <view class="loading fx-r fx-ac fx-bc" v-if="!page.isFoot">
  149. <image src="/static/img/xloading.png"></image>
  150. <text>正在载入更多...</text>
  151. </view>
  152. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  153. </view>
  154. </scroll-view>
  155. </view>
  156. </template>
  157. <script>
  158. import {mapState,mapMutations } from 'vuex'
  159. export default {
  160. computed: mapState(['user','lbs']),
  161. data() {
  162. return {
  163. keyword : "",
  164. data : [],
  165. h5Foot : 0,
  166. topHeight : 0,
  167. page:{
  168. page:1,
  169. isLoad:false,
  170. isFoot:false
  171. }
  172. }
  173. },
  174. /**
  175. * 跳转的值
  176. * @param {Object} option
  177. */
  178. onLoad(option){
  179. this.$nextTick(()=>{
  180. const query = uni.createSelectorQuery().in(this);
  181. query.select("#top-main").boundingClientRect(res=>{
  182. this.topHeight = res.height;
  183. }).exec();
  184. });
  185. //判断是否H5
  186. // #ifdef H5
  187. this.h5Foot = 50;
  188. // #endif
  189. this.getData(true);
  190. },
  191. methods: {
  192. /**
  193. * 输入
  194. */
  195. tapInput:function(ev){
  196. this.page = {page:1,isLoad:false,isFoot:false};
  197. this.getData(true);
  198. },
  199. /**
  200. * 下拉加载
  201. */
  202. loadMoreData:function(){
  203. if(this.page.isFoot || this.page.isLoad) {
  204. return;
  205. }
  206. this.page.page ++;
  207. this.getData();
  208. },
  209. /**
  210. * 获取get数据
  211. */
  212. getData:function(isPull = false){
  213. if (this.page.isLoad) return;
  214. this.page.isLoad = true;
  215. if (isPull) {
  216. uni.showLoading({ title: '获取数据中..'});
  217. }
  218. var post = {};
  219. if(this.keyword != "") {
  220. post.keyword = this.keyword;
  221. }
  222. post.page = this.page.page;
  223. if(this.lbs != null) {
  224. post.lat = this.utils.isDefine(this.lbs.latitude) ? this.lbs.latitude : 0 ;
  225. post.lng = this.utils.isDefine(this.lbs.longitude) ? this.lbs.longitude : 0 ;
  226. }
  227. this
  228. .request
  229. .post("merchantList",post)
  230. .then(res => {
  231. uni.hideLoading();
  232. if (isPull) {
  233. this.data = res.data.list;
  234. } else {
  235. this.data = this.data.concat(res.data.list);
  236. }
  237. this.page.isLoad = false;
  238. //是否到底
  239. if (res.data.list.length != res.data.pageSize) {
  240. this.page.isFoot = true;
  241. }
  242. })
  243. .catch(res=>{
  244. console.log(res);
  245. uni.hideLoading();
  246. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  247. });
  248. },
  249. /**
  250. * 打开其他页面
  251. * @param {Object} ev
  252. */
  253. tapOpen: function(ev) {
  254. let url = ev.currentTarget.dataset.url
  255. uni.navigateTo({
  256. url: url
  257. });
  258. },
  259. /**
  260. * 返回上一页
  261. */
  262. tapBack: function () {
  263. uni.navigateBack({ delta: 1 });
  264. },
  265. }
  266. }
  267. </script>