shopList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="container">
  3. <navbar :config="config" backColor="#999999"></navbar>
  4. <view class="top u-plr30">
  5. <view class="bg-color">
  6. </view>
  7. <view class="zdtopbox">
  8. <view>
  9. <text class="iconfont position-ab u-mt20 u-ml30 u-D1D9D4">&#xe650;</text>
  10. <input placeholder="请输入店铺名字" placeholder-class="pc" v-model="param.shop_name" @keyup.enter.native="loadShopList"
  11. @blur="loadShopList" />
  12. </view>
  13. <view class="br-rd20 u-bg-fff u-text-center mt52 userInfo u-1A1A1A position-re">
  14. <image class="u-avatar83 head" :src="currShop.logo"></image>
  15. <view class="join-btn enter" v-if="notCurr ==true" @click="goShop(currShop)">进入店铺</view>
  16. <view class="u-font28">推荐店长:<text class="u-999">{{currShop.loser}}</text> </view>
  17. <view class="u-font36 u-bold">{{currShop.shop_name}}</view>
  18. <view class="u-font24 u-mt10"><text class="iconfont u-font30 u-193E2C u-mt5 u-mr15">&#xe68d;</text>
  19. {{currShop.address}}</view>
  20. </view>
  21. </view>
  22. <view>
  23. <view class="u-font34 u-181818 u-bold u-mt25">附近店铺</view>
  24. <view class="shop-list">
  25. <view class="shop-item u-bg-fff br-rd20" v-for="(v,i) in shopList" :key="i">
  26. <view class="u-font30 u-1A1A1A u-bold">店长:{{v.loser}}</view>
  27. <view class="join-btn curr" v-if="v.id==storageId">当前店铺</view>
  28. <view class="u-flex-center u-mt15">
  29. <view>
  30. <image class="u-avatar104" :src="v.logo"></image>
  31. </view>
  32. <view class="u-ml20">
  33. <view class="u-font28 u-1A1A1A">{{v.shop_name}}</view>
  34. <!-- {{v.province_name}}{{v.city_name}}{{v.area_name}} -->
  35. <view class="u-font24 u-999"> <text class="u-FF0000 u-mr5">{{v.distance | distance}} </text>| {{v.address}}</view>
  36. </view>
  37. </view>
  38. <view class="u-mt20 wt444 ml100">
  39. <button class="u-btn-two" @click="goShop(v)">进入店铺</button>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <!--页面加载动画-->
  45. <ldLoading isFullScreen :active="loading"></ldLoading>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. config: {
  54. back: true, //false是tolbar页面 是则不写
  55. title: '店铺',
  56. color: '#1A1A1A',
  57. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  58. backgroundColor: [1, "#fff"],
  59. statusBarFontColor: '#1A1A1A'
  60. },
  61. shopList: [],
  62. loading: false,
  63. currShop: {},
  64. notCurr: null,
  65. storageId:null,
  66. param: {
  67. shop_name: '',
  68. shop_id: null,
  69. lon: null,
  70. lat: null
  71. }
  72. }
  73. },
  74. created() {
  75. this.loading = true;
  76. this.getIndexList()
  77. let shop = uni.getStorageSync('shop')
  78. if(shop){
  79. this.storageId = shop.id
  80. }
  81. },
  82. filters: {
  83. distance: function (value) {
  84. let res = null;
  85. if(value){
  86. if(value>1000){
  87. res = (value*0.001).toFixed(4) +'km'
  88. }else{
  89. res = value.toFixed(4)+'m'
  90. }
  91. }else{
  92. res = '暂无距离'
  93. }
  94. return res;
  95. }
  96. },
  97. methods: {
  98. // 获取主页数据
  99. getIndexList() {
  100. this.$http.get('/yxt/shop/getShop')
  101. .then(res => {
  102. uni.stopPullDownRefresh()
  103. this.loading = false;
  104. if (res.data && res.code == 200) {
  105. this.currShop = res.data;
  106. this.storageId = res.data.id;
  107. this.loadShopList();
  108. }
  109. })
  110. },
  111. goShop(e) {
  112. uni.setStorageSync('shop', e);
  113. let prevPage = this.$mUtil.getPrevPage();
  114. prevPage.onLoad();
  115. uni.navigateBack({
  116. delta: 1
  117. })
  118. },
  119. //查看店铺列表
  120. loadShopList() {
  121. let location = uni.getStorageSync('LOCATION');
  122. if (this.currShop) {
  123. this.param.shop_id = this.storageId;
  124. this.param.lon = location.longitude;
  125. this.param.lat = location.latitude;
  126. this.$http.get('/yxt/shop/nearbyShop', this.param)
  127. .then(res => {
  128. if (res && res.code == 200) {
  129. this.shopList = res.list;
  130. for (let item of res.list) {
  131. if (item.id == this.storageId) {
  132. this.notCurr = true;
  133. break;
  134. }
  135. }
  136. }
  137. this.loading = false;
  138. }).then(res => {
  139. this.loading = false;
  140. })
  141. }
  142. },
  143. }
  144. }
  145. </script>
  146. <style lang="scss">
  147. page {
  148. background-color: #F5F5F5;
  149. }
  150. .position-ab {
  151. position: absolute;
  152. }
  153. .u-193E2C {
  154. color: #193E2C;
  155. }
  156. .mt52 {
  157. margin-top: 52rpx;
  158. }
  159. .top {
  160. position: relative;
  161. overflow: hidden;
  162. }
  163. .br-rd20 {
  164. border-radius: 20rpx;
  165. }
  166. .wt444 {
  167. width: 444rpx;
  168. }
  169. .ml100 {
  170. margin-left: 100rpx;
  171. }
  172. .bg-color {
  173. position: absolute;
  174. top: 0;
  175. left: -13%;
  176. width: 126%;
  177. height: 280rpx;
  178. text-align: center;
  179. background: -webkit-linear-gradient(to bottom, #0B844A, #284534);
  180. background: linear-gradient(180deg, #0B844A, #284534);
  181. border-radius: 0 0 50% 50%;
  182. z-index: 1;
  183. }
  184. .zdtopbox {
  185. position: relative;
  186. z-index: 1;
  187. input {
  188. width: 100%;
  189. height: 74rpx;
  190. line-height: 74rpx;
  191. border-radius: 50rpx;
  192. opacity: 0.4;
  193. background-color: #ABC5B5;
  194. padding-left: 78rpx;
  195. box-sizing: border-box;
  196. }
  197. .pc {
  198. font-size: 22rpx;
  199. color: #193E2C !important;
  200. }
  201. .userInfo {
  202. padding-bottom: 38rpx;
  203. }
  204. .head {
  205. margin-top: -42rpx;
  206. }
  207. }
  208. .shop-list {
  209. padding-bottom: 48rpx;
  210. .shop-item {
  211. padding: 28rpx 20rpx;
  212. margin-top: 20rpx;
  213. position: relative;
  214. }
  215. }
  216. .join-btn {
  217. position: absolute;
  218. right: 2%;
  219. padding: 3rpx 15rpx;
  220. border-radius: 2px;
  221. color: 26rpx;
  222. color: white;
  223. }
  224. .curr {
  225. background-color: #FFB100;
  226. top: 27rpx;
  227. }
  228. .enter {
  229. background-color: #00A246;
  230. // top: 60%;
  231. }
  232. </style>