store_cate.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <view :style="colorStyle">
  3. <!-- 附近门店 -->
  4. <view class="nearby" v-if="header">
  5. <view class="store acea-row row-middle">
  6. <view class="btn" :class="{'activeColor':active==1}" @click="btnFn(1)">
  7. 附近门店
  8. </view>
  9. <view class="btn" :class="{'activeColor':active==2}" @click="btnFn(2)">
  10. 常用门店
  11. </view>
  12. <input type="text" placeholder="搜索门店" class="input" @input="setValue" v-model="content.keyword"></input>
  13. <view class="search" @click="searchMap()">
  14. <text class="iconfont icon-sousuo6" />
  15. </view>
  16. </view>
  17. </view>
  18. <!-- 门店列表 -->
  19. <view class="content" v-if="info.length>0">
  20. <view class="list acea-row row-between-wrapper" v-for="(item,index) in info" :key="index"
  21. :class="{active:sortIndex==item.id}" @click="navTuShopIndex(item)">
  22. <view class="flex">
  23. <image :src="item.image" class="storeImg" mode="scaleToFill"></image>
  24. <view class="left">
  25. <view class="name line2">
  26. {{item.name}}
  27. </view>
  28. <view class="adress acea-row">
  29. <view class="con line2"><text class="iconfont icon-dingwei2" />{{item.detailed_address}}
  30. </view>
  31. </view>
  32. <view class="adress">
  33. <text class="iconfont icon-yingyeshijian2" />
  34. 营业时间:{{item.day_time}}
  35. </view>
  36. </view>
  37. </view>
  38. <!-- <text class="iconfont icon-xuanzhong6" v-if="sortIndex==item.id"></text> -->
  39. <view class="right flex">
  40. <view class="distance">
  41. 距离{{item.range}}km
  42. </view>
  43. <view class="telephone">
  44. <view class="phone" @click.stop="callPhone(item)">
  45. <text class="iconfont icon-dianhua"></text>
  46. </view>
  47. <view class="phone" @click.stop="showMaoLocation(item)">
  48. <text class="iconfont icon-dingwei2"></text>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 缺省页 -->
  55. <view class="default" v-if="info.length==0">
  56. <image :src="imgHost+'/statics/images/store-default.png'" mode="" class="img"></image>
  57. <view class="text">
  58. 暂无门店信息,再去试试其他地址吧~
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import {
  65. HTTP_REQUEST_URL
  66. } from '@/config/app';
  67. import colors from "@/mixins/color";
  68. import {
  69. getList
  70. } from '@/api/new_store.js'
  71. export default {
  72. mixins: [colors],
  73. data() {
  74. return {
  75. imgHost: HTTP_REQUEST_URL,
  76. sortIndex: 0,
  77. active: 1,
  78. content: {
  79. // 自己的位置
  80. latitude: uni.getStorageSync('user_latitude'),
  81. longitude: uni.getStorageSync('user_longitude'),
  82. store_type: 1,
  83. keyword: "",
  84. limit: 1000,
  85. page: 1,
  86. loding:false,//判断是否加载中
  87. lode:false//判断是否可以继续加载
  88. },
  89. info: [],
  90. map: 1,
  91. header: 1,
  92. comeType: 0,
  93. // 门店位置
  94. latitudeStore: 0,
  95. longitudeStore: 0,
  96. covers: []
  97. };
  98. },
  99. onShow() {
  100. if (this.content.latitude && this.content.longitude) {
  101. this.getlist();
  102. } else {
  103. this.selfLocation();
  104. }
  105. },
  106. // onReachBottom() {
  107. // if (this.content.latitude && this.content.longitude) {
  108. // this.getlist();
  109. // } else {
  110. // this.selfLocation();
  111. // }
  112. // },
  113. methods: {
  114. // 跳转到门店详情页面
  115. navTuShopIndex(item) {
  116. uni.setStorageSync('user_latitude', item.latitude);
  117. uni.setStorageSync('user_longitude', item.longitude);
  118. uni.navigateTo({
  119. url: '/pages/store_cate/store_cate_index',
  120. });
  121. },
  122. // 获取当前位置信息
  123. selfLocation() {
  124. let self = this
  125. // #ifdef H5
  126. if (self.$wechat.isWeixin()) {
  127. self.$wechat.location().then(res => {
  128. this.content.latitude = res.latitude;
  129. this.content.longitude = res.longitude;
  130. uni.setStorageSync('user_latitude', res.latitude);
  131. uni.setStorageSync('user_longitude', res.longitude);
  132. self.getlist();
  133. })
  134. } else {
  135. // #endif
  136. uni.getLocation({
  137. type: 'wgs84',
  138. success: (res) => {
  139. try {
  140. this.content.latitude = res.latitude;
  141. this.content.longitude = res.longitude;
  142. uni.setStorageSync('user_latitude', res.latitude);
  143. uni.setStorageSync('user_longitude', res.longitude);
  144. } catch {}
  145. self.getlist();
  146. },
  147. complete: function() {
  148. self.getlist();
  149. }
  150. });
  151. // #ifdef H5
  152. }
  153. // #endif
  154. },
  155. // 门店列表
  156. getlist(address) {
  157. let cot = this.content;
  158. let content = {
  159. store_type: cot.store_type,
  160. keyword: cot.keyword,
  161. limit: cot.limit,
  162. page: cot.page,
  163. }
  164. console.log(address)
  165. if (address) {
  166. // 自己的位置
  167. content.latitude = address.latitude;
  168. content.longitude = address.longitude
  169. } else {
  170. // 自己的位置
  171. content.latitude = uni.getStorageSync('user_latitude');
  172. content.longitude = uni.getStorageSync('user_longitude');
  173. }
  174. getList(content).then(res => {
  175. this.info = res.data
  176. res.data.forEach(item => {
  177. if (this.sortIndex == item.id) {
  178. this.latitudeStore = item.latitude;
  179. this.longitudeStore = item.longitude;
  180. this.covers.push({
  181. title: item.name,
  182. latitude: item.latitude,
  183. longitude: item.longitude,
  184. iconPath: item.image,
  185. width: 30,
  186. height: 30
  187. })
  188. }
  189. })
  190. if(res.data.length== cot.limit){
  191. cot.page++
  192. }else{
  193. }
  194. })
  195. },
  196. // 输入关键字搜索门店
  197. setValue(e) {
  198. this.getlist()
  199. },
  200. // 点击高亮
  201. // activeFn(row) {
  202. // this.sortIndex = row.id
  203. // if (this.comeType) {
  204. // uni.$emit("handClick", {
  205. // latitude: row.latitude,
  206. // longitude: row.longitude,
  207. // store_id: row.id
  208. // });
  209. // uni.navigateBack();
  210. // }
  211. // },
  212. // 搜索门店
  213. searchMap() {
  214. // this.header = 0
  215. },
  216. // 收起地图
  217. putMap() {
  218. if (this.map == 1) {
  219. this.map = 0
  220. } else if (this.map == 0) {
  221. this.map = 1
  222. }
  223. },
  224. // 打电话
  225. callPhone(row) {
  226. uni.makePhoneCall({
  227. phoneNumber: row.phone //仅为示例
  228. });
  229. },
  230. btnFn(num) {
  231. switch (num) {
  232. case 1:
  233. this.active = 1
  234. this.content.store_type = 1
  235. break;
  236. case 2:
  237. this.active = 2
  238. this.content.store_type = 2
  239. break;
  240. }
  241. this.getlist()
  242. },
  243. showMaoLocation(e) {
  244. let self = this;
  245. // #ifdef H5
  246. if (self.$wechat.isWeixin()) {
  247. self.$wechat.seeLocation({
  248. latitude: Number(e.latitude),
  249. longitude: Number(e.longitude),
  250. name: e.name,
  251. scale: 13,
  252. address: `${e.address}-${e.detailed_address}`,
  253. }).then(res => {})
  254. } else {
  255. // #endif
  256. uni.openLocation({
  257. latitude: Number(e.latitude),
  258. longitude: Number(e.longitude),
  259. name: e.name,
  260. address: `${e.address}-${e.detailed_address}`,
  261. success: function() {
  262. Number
  263. }
  264. });
  265. // #ifdef H5
  266. }
  267. // #endif
  268. },
  269. }
  270. }
  271. </script>
  272. <style lang="scss">
  273. page {
  274. width: 750rpx;
  275. }
  276. .active {
  277. position: relative;
  278. border: 1px solid var(--view-theme) !important;
  279. .icon-xuanzhong6 {
  280. font-size: 46rpx;
  281. position: absolute;
  282. bottom: -4rpx;
  283. right: -6rpx;
  284. color: var(--view-theme);
  285. }
  286. }
  287. .activeColor {
  288. background-color: var(--view-theme) !important;
  289. color: #fff !important;
  290. }
  291. .nearby {
  292. width: 100%;
  293. background-color: #fff;
  294. box-shadow: 0px -2px 22px 0px rgba(0, 0, 0, 0.0400);
  295. .store {
  296. height: 80rpx;
  297. padding: 0 30rpx;
  298. align-items: flex-start;
  299. .input {
  300. padding-left: 30rpx;
  301. height: 60rpx;
  302. background: #F5F5F5;
  303. border-radius: 30rpx;
  304. font-size: 26rpx;
  305. font-weight: 400;
  306. }
  307. .btn {
  308. margin-right: 16rpx;
  309. width: 160rpx;
  310. height: 56rpx;
  311. background: #F5F5F5;
  312. border-radius: 29rpx;
  313. text-align: center;
  314. line-height: 56rpx;
  315. font-size: 26rpx;
  316. font-weight: 400;
  317. color: #999999;
  318. }
  319. .put {
  320. color: #666666 !important;
  321. margin-left: 96rpx;
  322. background-color: #fff !important;
  323. .icon-xiangshang {
  324. margin-right: 10rpx;
  325. color: #666666;
  326. font-size: 24rpx;
  327. }
  328. .icon-xiangxia {
  329. margin-right: 10rpx;
  330. color: #666666;
  331. font-size: 24rpx;
  332. }
  333. }
  334. .search {
  335. position: absolute;
  336. right: 30rpx;
  337. text-align: center;
  338. line-height: 56rpx;
  339. width: 56rpx;
  340. height: 56rpx;
  341. background: #F5F5F5;
  342. border-radius: 50%;
  343. }
  344. }
  345. }
  346. .content {
  347. width: 100%;
  348. height: 100%;
  349. padding: 0 30rpx;
  350. .list {
  351. margin-top: 20rpx;
  352. width: 100%;
  353. background: #FFFFFF;
  354. border-radius: 12rpx;
  355. padding: 28rpx 30rpx;
  356. border: 1px solid #fff;
  357. .flex {
  358. flex-grow: 1;
  359. }
  360. .storeImg {
  361. width: 200rpx;
  362. height: 200rpx;
  363. }
  364. .left {
  365. width: 300rpx;
  366. flex-grow: 1;
  367. padding: 0 20rpx;
  368. .name {
  369. font-size: 32rpx;
  370. font-weight: bold;
  371. color: #333333;
  372. }
  373. .adress {
  374. width: 100%;
  375. margin-top: 18rpx;
  376. word-wrap: break-word;
  377. font-size: 28rpx;
  378. font-weight: 400;
  379. color: #888888;
  380. .con {
  381. flex-shrink: 1;
  382. }
  383. .icon-dingwei2 {
  384. margin-right: 8rpx;
  385. font-size: 18rpx;
  386. color: #ccc;
  387. margin-top: 6rpx;
  388. }
  389. .icon-yingyeshijian2 {
  390. margin-right: 8rpx;
  391. font-size: 18rpx;
  392. color: #ccc;
  393. }
  394. }
  395. }
  396. .right {
  397. align-items: center;
  398. .gostore {
  399. font-size: 22rpx;
  400. font-weight: 400;
  401. color: var(--view-theme);
  402. }
  403. .distance {
  404. margin-top: 14rpx;
  405. font-size: 28rpx;
  406. font-weight: bold;
  407. color: #999999;
  408. flex-grow: 1;
  409. }
  410. .telephone {
  411. margin-top: 14rpx;
  412. display: flex;
  413. .phone:nth-child(2) {
  414. margin-left: 30rpx;
  415. }
  416. .phone {
  417. position: relative;
  418. width: 60rpx;
  419. height: 60rpx;
  420. background: var(--view-minorColorT);
  421. border-radius: 50%;
  422. text-align: center;
  423. line-height: 60rpx;
  424. z-index: 10;
  425. .icon-dingwei2 {
  426. font-size: 32rpx;
  427. color: var(--view-theme) !important;
  428. }
  429. .icon-dianhua {
  430. font-size: 32rpx;
  431. color: var(--view-theme) !important;
  432. }
  433. }
  434. }
  435. }
  436. }
  437. }
  438. .lyric-enter,
  439. .lyric-leave-to {
  440. opacity: 0;
  441. transform: translateY(60px);
  442. }
  443. .lyric-enter-to,
  444. .lyric-leave {
  445. opacity: 1;
  446. }
  447. .lyric-enter-active,
  448. .lyric-leave-active {
  449. transition: all 0.3s;
  450. }
  451. .default {
  452. display: flex;
  453. flex-direction: column;
  454. align-items: center;
  455. .img {
  456. width: 414rpx;
  457. height: 256rpx;
  458. }
  459. .text {
  460. margin-top: 54rpx;
  461. font-size: 26rpx;
  462. font-weight: 400;
  463. color: #999999;
  464. }
  465. }
  466. </style>