index.vue 12 KB

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