shopList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <view class="main">
  3. <navbar :config="config" backColor="#999999">
  4. <template v-slot:left>
  5. <view class="city-text" @click="addressShow=true">
  6. <view>{{cityName}}</view>
  7. <image mode="aspectFit" src="/static/convenienceService/drop-arrow.png"></image>
  8. </view>
  9. <view class="searchBox">
  10. <image src="/static/convenienceService/search.png" mode=""></image>
  11. <input v-model="param.title" type="text" @confirm="getShopList()" placeholder-style="color:#B3B3B3"
  12. placeholder="请输入关键字" @input="search()" />
  13. </view>
  14. </template>
  15. <!-- <template v-slot:center maxSlot>
  16. <view class="searchBox">
  17. <image src="/static/convenienceService/search.png" mode=""></image>
  18. <input v-model="param.title" type="text" @confirm="sreach()" placeholder-style="color:#B3B3B3"
  19. placeholder="请输入关键字" />
  20. </view>
  21. </template> -->
  22. </navbar>
  23. <!-- <view class="tabBox">
  24. <view class="active">推荐</view>
  25. <view>商超</view>
  26. <view>茶舍</view>
  27. <view>美容</view>
  28. <view>商超</view>
  29. <view>茶舍</view>
  30. <view>美容</view>
  31. <view>商超</view>
  32. <view>茶舍</view>
  33. <view>美容</view>
  34. <view>商超</view>
  35. <view>茶舍</view>
  36. <view class="mr0">美容</view>
  37. </view> -->
  38. <view class="tabsBox">
  39. <u-tabs name="cate_name" :bar-width="60" active-color="#3775F6" inactive-color="#666666" :list="typeList"
  40. is-scroll :current="tabCurrent" @change="tabsChange"></u-tabs>
  41. </view>
  42. <view class="shopListBox" v-if="list.length>0">
  43. <view class="shopItem" v-for="(v,i) in list" :key="i" @click="goShopDetails(v)">
  44. <view class="shopItem_title">{{v.shop_name}}</view>
  45. <view class="shopItem_data">
  46. <view class="rateBox">
  47. <view>
  48. <rate :value="Math.round(v.average)"></rate>
  49. </view>
  50. <view>{{v.average}}分</view>
  51. </view>
  52. <view class="shopItem_data_addr">
  53. <image src="/static/convenienceService/location1.png" mode=""></image>
  54. {{v.city_name}}
  55. </view>
  56. <view class="shopItem_data_distance">距离:{{Math.round(v.distance/1000*100)/100}}KM</view>
  57. </view>
  58. <view class="gooodsBox" v-if="v.list&&v.list.length>0">
  59. <view class="gooods_item" v-for="(k,j) in v.list" :key="j">
  60. <image :src="k.cover" mode=""></image>
  61. <view class="gooods_item_r">
  62. <view class="gooods_item_r_title">{{k.title}}</view>
  63. <view>
  64. <view class="gooods_item_r_price" v-if="k.market_price">
  65. <text>¥</text>
  66. {{(k.market_price+'').split('.').length>=1?(k.market_price+'').split('.')[0]:0}}
  67. <text>.{{(k.market_price+'').split('.').length>=2?(k.market_price+'').split('.')[1]:'00'}}</text>
  68. </view>
  69. <view class="gooods_item_r_expense">消费 {{k.result_sale_num}}</view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="lookOther" v-if="v.service_goods_total>2">
  75. 查看其他{{v.service_goods_total-2}}个商品
  76. <text class="iconfont2">&#xe65f;</text>
  77. </view>
  78. </view>
  79. </view>
  80. <view>
  81. <noData v-if="list.length<=0"></noData>
  82. </view>
  83. <view class="loadmoreBox" v-if="list.length>0">
  84. <u-loadmore :status="status" />
  85. </view>
  86. <!-- 选择地区 -->
  87. <u-select v-model="addressShow" mode="mutil-column-auto" :list="cityTree" @confirm="addressConfirm">
  88. </u-select>
  89. </view>
  90. </template>
  91. <script>
  92. import noData from "@/components/noData/nodata.vue"
  93. import rate from "@/components/rate.vue"
  94. export default {
  95. components: {
  96. rate,
  97. noData
  98. },
  99. data() {
  100. return {
  101. //手机状态栏高度
  102. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  103. config: {
  104. back: false,
  105. title: '',
  106. color: 'black',
  107. backgroundColor: [1, "#fff"],
  108. statusBarFontColor: 'black',
  109. leftSlot: true
  110. },
  111. value: "",
  112. status: "nomore",
  113. addressShow: false,
  114. cityTree: [],
  115. param: {},
  116. list: [],
  117. cityName: "长沙市",
  118. typeList: [],
  119. tabCurrent: 0,
  120. setTime: null
  121. }
  122. },
  123. mounted() {
  124. this.init()
  125. },
  126. methods: {
  127. init() {
  128. this.getCitys();
  129. this.getType()
  130. },
  131. tabsChange(index) {
  132. this.tabCurrent = index;
  133. this.getShopList()
  134. },
  135. // 获取类型
  136. getType() {
  137. let that = this;
  138. this.$http.get('/classify/all').then(res => {
  139. if (res && res.code == 200) {
  140. this.typeList=res.list;
  141. uni.getLocation({
  142. type: 'gcj02',
  143. geocode: true,
  144. success: function(res) {
  145. that.cityName = res.address ? res.address.city : '';
  146. that.param.lon = res.longitude;
  147. that.param.lat = res.latitude;
  148. that.getShopList()
  149. if (!that.cityName) {
  150. uni.request({
  151. url: `https://restapi.amap.com/v3/geocode/regeo?key=47798318a0d39673a1fb9729aa6a468a&location=${res.longitude+','+res.latitude}`, //仅为示例,并非真实接口地址。
  152. method: "GET",
  153. header: {
  154. "content-type": "application/x-www-form-urlencoded"
  155. },
  156. success: (re) => {
  157. console.log(re);
  158. that.cityName = re.data.regeocode
  159. .addressComponent.city;
  160. }
  161. });
  162. }
  163. },
  164. complete(e) {
  165. console.log(e)
  166. }
  167. });
  168. // #ifdef H5
  169. this.getShopList()
  170. // #endif
  171. }
  172. })
  173. },
  174. // 跳转 门店详情
  175. goShopDetails(item) {
  176. uni.navigateTo({
  177. url: "/pages/convenienceService/shopDetails?shopId=" + item.shop_id
  178. })
  179. },
  180. // 跳转 搜索
  181. // goSearch() {
  182. // uni.navigateTo({
  183. // url: "/pages/product/search/productList"
  184. // })
  185. // },
  186. // 获取城市
  187. getCitys() {
  188. this.$http.get('/cnarea/tree-lbs/city').then(res => {
  189. if (res && res.code == 200) {
  190. this.cityTree = res.tree.children
  191. this.cityTree.forEach(v => {
  192. if (v.children.length <= 0) {
  193. v.children = [{}]
  194. }
  195. })
  196. }
  197. })
  198. },
  199. // 选择地区
  200. addressConfirm(e) {
  201. this.param.city_code = e[1].value || e[0].value;
  202. this.cityName = e[1].label || e[0].label;
  203. // this.param.lon = e[1].data.longitude || e[0].data.longitude;
  204. // this.param.lat = e[1].data.latitude || e[0].data.latitude;
  205. console.log(e)
  206. this.getShopList()
  207. },
  208. // 门店列表
  209. getShopList() {
  210. this.param.category_id = this.typeList[this.tabCurrent].id;
  211. this.$http.get('/service/goods/nearby', this.param).then(res => {
  212. uni.stopPullDownRefresh()
  213. if (res && res.code == 200) {
  214. this.list = res.list;
  215. }
  216. })
  217. },
  218. // 搜索防抖
  219. search() {
  220. clearTimeout(this.setTime)
  221. this.setTime = setTimeout(() => {
  222. this.getShopList()
  223. }, 1000)
  224. },
  225. }
  226. }
  227. </script>
  228. <style lang="scss">
  229. .city-text {
  230. margin-left: 30rpx;
  231. font-size: 30rpx;
  232. font-family: PingFang SC, PingFang SC-Regular;
  233. font-weight: 400;
  234. text-align: center;
  235. color: #1a1a1a;
  236. display: flex;
  237. align-items: center;
  238. margin-top: 10rpx;
  239. view {
  240. max-width: 100rpx;
  241. white-space: nowrap;
  242. text-overflow: ellipsis;
  243. overflow: hidden;
  244. }
  245. image {
  246. width: 20rpx;
  247. height: 12rpx;
  248. margin-left: 5rpx;
  249. vertical-align: middle;
  250. }
  251. }
  252. .searchBox {
  253. width: 80%;
  254. display: flex;
  255. padding: 10rpx 35rpx;
  256. border: 1rpx solid #CCCCCC;
  257. border-radius: 36rpx;
  258. margin: 0 30rpx;
  259. display: flex;
  260. align-items: center;
  261. margin-top: 10rpx;
  262. image {
  263. width: 35rpx;
  264. height: 35rpx;
  265. margin-right: 15rpx;
  266. flex-shrink: 0;
  267. }
  268. input {
  269. text-align: left;
  270. }
  271. }
  272. .tabsBox {
  273. padding-top: 20rpx;
  274. position: sticky;
  275. top: 88rpx;
  276. /* #ifdef H5 */
  277. top: 88rpx;
  278. /* #endif */
  279. background: #ffffff;
  280. z-index: 1;
  281. }
  282. .tabBox {
  283. padding: 40rpx 40rpx 20rpx 40rpx;
  284. display: flex;
  285. overflow: auto;
  286. position: sticky;
  287. top: 88rpx;
  288. background: #ffffff;
  289. z-index: 1;
  290. >view {
  291. color: #666666;
  292. font-weight: 28rpx;
  293. margin-right: 50rpx;
  294. padding-bottom: 15rpx;
  295. flex-shrink: 0;
  296. }
  297. >.active {
  298. font-size: 30rpx;
  299. color: #2BB42D;
  300. position: relative;
  301. &::after {
  302. display: block;
  303. content: "";
  304. width: 100%;
  305. height: 4rpx;
  306. background: #2BB42D;
  307. border-radius: 2rpx;
  308. position: absolute;
  309. bottom: 0%;
  310. left: 0;
  311. }
  312. }
  313. }
  314. .shopListBox {
  315. padding: 30rpx 30rpx 0 30rpx;
  316. .shopItem {
  317. border-bottom: 1rpx solid #E6E6E6;
  318. padding-bottom: 40rpx;
  319. margin-bottom: 40rpx;
  320. .shopItem_title {
  321. font-size: 34rpx;
  322. color: #1A1A1A;
  323. font-weight: 700;
  324. margin-bottom: 20rpx;
  325. }
  326. .shopItem_data {
  327. display: flex;
  328. align-items: center;
  329. justify-content: space-between;
  330. font-size: 26rpx;
  331. image {
  332. width: 22rpx;
  333. height: 30rpx;
  334. }
  335. >view {
  336. display: flex;
  337. align-items: center;
  338. image {
  339. margin-right: 10rpx;
  340. }
  341. }
  342. .shopItem_data_distance {
  343. color: #666666;
  344. }
  345. }
  346. .gooodsBox {
  347. .gooods_item {
  348. display: flex;
  349. margin-top: 20rpx;
  350. image {
  351. width: 136rpx;
  352. height: 136rpx;
  353. margin-right: 35rpx;
  354. border-radius: 10rpx;
  355. flex-shrink: 0;
  356. }
  357. .gooods_item_r {
  358. display: flex;
  359. flex-direction: column;
  360. justify-content: space-around;
  361. >view {
  362. display: flex;
  363. align-items: center;
  364. }
  365. .gooods_item_r_title {
  366. font-size: 26rpx;
  367. color: #1A1A1A;
  368. overflow: hidden;
  369. text-overflow: ellipsis;
  370. display: -webkit-box;
  371. -webkit-line-clamp: 2;
  372. -webkit-box-orient: vertical;
  373. }
  374. .gooods_item_r_price {
  375. font-size: 36rpx;
  376. color: #FF6600;
  377. font-weight: 600;
  378. text {
  379. font-size: 20rpx;
  380. display: inline-block;
  381. margin-right: 10rpx;
  382. }
  383. }
  384. .gooods_item_r_expense {
  385. font-size: 26rpx;
  386. color: #666666;
  387. margin-left: 52rpx;
  388. }
  389. }
  390. }
  391. }
  392. .lookOther {
  393. font-size: 24rpx;
  394. color: #333333;
  395. width: 288rpx;
  396. height: 59rpx;
  397. border-radius: 8rpx;
  398. background: #F2F2F2;
  399. display: flex;
  400. align-items: center;
  401. justify-content: center;
  402. margin: 20rpx auto 0;
  403. }
  404. }
  405. }
  406. .loadmoreBox {
  407. margin-bottom: 10rpx;
  408. }
  409. .mr0 {
  410. margin-right: 0 !important;
  411. }
  412. /deep/ .hx-navbar__content__main_center_flex:first-child {
  413. flex: 10;
  414. }
  415. /deep/ .hx-navbar__content__main_center_flex:last-child {
  416. display: none;
  417. }
  418. /deep/.hx-navbar__content__main_left {
  419. margin: 0 !important;
  420. width: 100%;
  421. justify-content: space-between;
  422. }
  423. </style>