indexComponents.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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"
  13. v-model="content.keyword"></input>
  14. <view class="search" @click="searchMap()">
  15. <text class="iconfont icon-sousuo6" />
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 门店列表 -->
  20. <view class="content" v-if="info.length>0">
  21. <view class="list acea-row row-between-wrapper" v-for="(item,index) in info" :key="index"
  22. :class="{active:sortIndex==item.id}" @click="navTuShopIndex">
  23. <view class="flex">
  24. <image :src="item.image" class="storeImg" mode="scaleToFill"></image>
  25. <view class="left">
  26. <view class="name line2">
  27. {{item.name}}
  28. </view>
  29. <view class="adress acea-row">
  30. <view class="con line2"><text class="iconfont icon-dingwei2" />{{item.detailed_address}}</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. },
  87. info: [],
  88. map: 1,
  89. header: 1,
  90. comeType: 0,
  91. // 门店位置
  92. latitudeStore: 0,
  93. longitudeStore: 0,
  94. covers: []
  95. };
  96. },
  97. methods: {
  98. // 跳转到门店详情页面
  99. navTuShopIndex(){
  100. uni.navigateTo({
  101. url: '/pages/store_cate/store_cate_index',
  102. });
  103. },
  104. // 门店列表
  105. getlist(address) {
  106. let cot = this.content;
  107. let content = {
  108. store_type:cot.store_type,
  109. keyword: cot.keyword,
  110. limit:cot.limit,
  111. page:cot.page,
  112. }
  113. console.log(address)
  114. if(address){
  115. // 自己的位置
  116. content.latitude=address.latitude;
  117. content.longitude=address.longitude
  118. }else{
  119. // 自己的位置
  120. content.latitude=uni.getStorageSync('user_latitude');
  121. content.longitude=uni.getStorageSync('user_longitude');
  122. }
  123. getList(content).then(res => {
  124. this.info = res.data
  125. res.data.forEach(item => {
  126. if (this.sortIndex == item.id) {
  127. this.latitudeStore = item.latitude;
  128. this.longitudeStore = item.longitude;
  129. this.covers.push({
  130. title: item.name,
  131. latitude: item.latitude,
  132. longitude: item.longitude,
  133. iconPath: item.image,
  134. width: 30,
  135. height: 30
  136. })
  137. }
  138. })
  139. })
  140. },
  141. // 输入关键字搜索门店
  142. setValue(e) {
  143. this.getlist()
  144. },
  145. // 点击高亮
  146. // activeFn(row) {
  147. // this.sortIndex = row.id
  148. // if (this.comeType) {
  149. // uni.$emit("handClick", {
  150. // latitude: row.latitude,
  151. // longitude: row.longitude,
  152. // store_id: row.id
  153. // });
  154. // uni.navigateBack();
  155. // }
  156. // },
  157. // 搜索门店
  158. searchMap() {
  159. // this.header = 0
  160. },
  161. // 收起地图
  162. putMap() {
  163. if (this.map == 1) {
  164. this.map = 0
  165. } else if (this.map == 0) {
  166. this.map = 1
  167. }
  168. },
  169. // 打电话
  170. callPhone(row) {
  171. uni.makePhoneCall({
  172. phoneNumber: row.phone //仅为示例
  173. });
  174. },
  175. btnFn(num) {
  176. switch (num) {
  177. case 1:
  178. this.active = 1
  179. this.content.store_type = 1
  180. break;
  181. case 2:
  182. this.active = 2
  183. this.content.store_type = 2
  184. break;
  185. }
  186. this.getlist()
  187. },
  188. showMaoLocation(e) {
  189. let self = this;
  190. // #ifdef H5
  191. if (self.$wechat.isWeixin()) {
  192. self.$wechat.seeLocation({
  193. latitude: Number(e.latitude),
  194. longitude: Number(e.longitude),
  195. name: e.name,
  196. scale: 13,
  197. address: `${e.address}-${e.detailed_address}`,
  198. }).then(res => {})
  199. } else {
  200. // #endif
  201. uni.openLocation({
  202. latitude: Number(e.latitude),
  203. longitude: Number(e.longitude),
  204. name: e.name,
  205. address: `${e.address}-${e.detailed_address}`,
  206. success: function() {
  207. Number
  208. }
  209. });
  210. // #ifdef H5
  211. }
  212. // #endif
  213. },
  214. }
  215. }
  216. </script>
  217. <style lang="scss">
  218. page {
  219. width: 750rpx;
  220. }
  221. .active {
  222. position: relative;
  223. border: 1px solid var(--view-theme) !important;
  224. .icon-xuanzhong6 {
  225. font-size: 46rpx;
  226. position: absolute;
  227. bottom: -4rpx;
  228. right: -6rpx;
  229. color: var(--view-theme);
  230. }
  231. }
  232. .activeColor {
  233. background-color: var(--view-theme) !important;
  234. color: #fff !important;
  235. }
  236. .nearby {
  237. width: 100%;
  238. background-color: #fff;
  239. box-shadow: 0px -2px 22px 0px rgba(0, 0, 0, 0.0400);
  240. .store {
  241. height: 132rpx;
  242. padding: 0 30rpx;
  243. .input {
  244. padding-left: 30rpx;
  245. height: 60rpx;
  246. background: #F5F5F5;
  247. border-radius: 30rpx;
  248. font-size: 26rpx;
  249. font-weight: 400;
  250. }
  251. .btn {
  252. margin-right: 16rpx;
  253. width: 160rpx;
  254. height: 56rpx;
  255. background: #F5F5F5;
  256. border-radius: 29rpx;
  257. text-align: center;
  258. line-height: 56rpx;
  259. font-size: 26rpx;
  260. font-weight: 400;
  261. color: #999999;
  262. }
  263. .put {
  264. color: #666666 !important;
  265. margin-left: 96rpx;
  266. background-color: #fff !important;
  267. .icon-xiangshang {
  268. margin-right: 10rpx;
  269. color: #666666;
  270. font-size: 24rpx;
  271. }
  272. .icon-xiangxia {
  273. margin-right: 10rpx;
  274. color: #666666;
  275. font-size: 24rpx;
  276. }
  277. }
  278. .search {
  279. position: absolute;
  280. right: 30rpx;
  281. text-align: center;
  282. line-height: 56rpx;
  283. width: 56rpx;
  284. height: 56rpx;
  285. background: #F5F5F5;
  286. border-radius: 50%;
  287. }
  288. }
  289. }
  290. .content {
  291. width: 100%;
  292. height: 100%;
  293. padding: 0 30rpx;
  294. .list {
  295. margin-top: 20rpx;
  296. width: 100%;
  297. background: #FFFFFF;
  298. border-radius: 12rpx;
  299. padding: 28rpx 30rpx;
  300. border: 1px solid #fff;
  301. .flex{
  302. flex-grow: 1;
  303. }
  304. .storeImg{
  305. width: 200rpx;
  306. height:200rpx;
  307. }
  308. .left {
  309. width: 300rpx;
  310. flex-grow: 1;
  311. padding: 0 20rpx;
  312. .name {
  313. font-size: 32rpx;
  314. font-weight: bold;
  315. color: #333333;
  316. }
  317. .adress {
  318. width: 100%;
  319. margin-top: 18rpx;
  320. word-wrap: break-word;
  321. font-size: 28rpx;
  322. font-weight: 400;
  323. color: #888888;
  324. .con {
  325. flex-shrink: 1;
  326. }
  327. .icon-dingwei2 {
  328. margin-right: 8rpx;
  329. font-size: 18rpx;
  330. color: #ccc;
  331. margin-top: 6rpx;
  332. }
  333. .icon-yingyeshijian2 {
  334. margin-right: 8rpx;
  335. font-size: 18rpx;
  336. color: #ccc;
  337. }
  338. }
  339. }
  340. .right {
  341. align-items: center;
  342. .gostore {
  343. font-size: 22rpx;
  344. font-weight: 400;
  345. color: var(--view-theme);
  346. }
  347. .distance {
  348. margin-top: 14rpx;
  349. font-size: 28rpx;
  350. font-weight: bold;
  351. color: #999999;
  352. flex-grow: 1;
  353. }
  354. .telephone {
  355. margin-top: 14rpx;
  356. display: flex;
  357. .phone:nth-child(2){
  358. margin-left: 30rpx;
  359. }
  360. .phone {
  361. position: relative;
  362. width: 60rpx;
  363. height: 60rpx;
  364. background: var(--view-minorColorT);
  365. border-radius: 50%;
  366. text-align: center;
  367. line-height: 60rpx;
  368. z-index: 10;
  369. .icon-dingwei2 {
  370. font-size: 32rpx;
  371. color: var(--view-theme) !important;
  372. }
  373. .icon-dianhua {
  374. font-size: 32rpx;
  375. color: var(--view-theme) !important;
  376. }
  377. }
  378. }
  379. }
  380. }
  381. }
  382. .lyric-enter,
  383. .lyric-leave-to {
  384. opacity: 0;
  385. transform: translateY(60px);
  386. }
  387. .lyric-enter-to,
  388. .lyric-leave {
  389. opacity: 1;
  390. }
  391. .lyric-enter-active,
  392. .lyric-leave-active {
  393. transition: all 0.3s;
  394. }
  395. .default {
  396. display: flex;
  397. flex-direction: column;
  398. align-items: center;
  399. .img {
  400. width: 414rpx;
  401. height: 256rpx;
  402. }
  403. .text {
  404. margin-top: 54rpx;
  405. font-size: 26rpx;
  406. font-weight: 400;
  407. color: #999999;
  408. }
  409. }
  410. </style>