index.vue 9.3 KB

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