| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- <template>
- <div class="settledMerchantList">
- <my-nav v-model="Query.name" @send="navSearch" />
- <view class="next-search-history" v-if="oldKeywordList.length && !Query.name">
- <view class="history-title">
- <view class="title-name"><text>搜索历史</text></view>
- <view class="history-delete" v-if="isDelete">
- <view class="delete-all" @click="deleteAll"><text>全部删除</text></view>
- <view class="delete-line"></view>
- <view class="delete-complete" @click="deleteHistory"><text>完成</text></view>
- </view>
- <view v-else class="icon-block" @click="deleteHistory"><text class="iconfont" style="font-size: 36rpx;"></text></view>
- </view>
- <view class="next-history-list">
- <view class="history-name" v-for="(item,index) in oldKeywordList" :key="index" @click="historyItemClick(item,index)">
- <text>{{item}}</text>
- <text v-if="isDelete" class="iconfont"></text>
- </view>
- </view>
- <view class="history-title">
- <view class="title-name"><text>附近商家</text></view>
- </view>
- </view>
- <div class="list" v-if="list.length">
- <div class="li_item" v-for="(i,s) in list" :key="s" @click="goMerchant(i)">
- <!-- <div class="li_title">{{ i.name }}</div> -->
- <div class="logo_img">
- <img :src="i.logo" alt="">
- </div>
- <div class="con_box">
- <div class="p1 ellipsis">{{ i.name }}</div>
- <div class="p2">{{ i.address }}</div>
- <div class="p3">{{ $h.Div(i.distance, 1000).toFixed(2) }} km</div>
- </div>
- </div>
- </div>
- <empty v-else />
- </div>
- </template>
- <script>
- import { post } from "@/request/api.js";
- import myNav from "@/pagesC/components/nav/nav"
- import empty from "@/pagesC/components/empty/empty"
- export default {
- name: "settledMerchantList",
- props: {},
- components: { myNav, empty },
- data() {
- return {
- list: [],
- Query: {
- latitude: 113.9367,
- longitude: 22.5325,
- page: 1,
- rows: 20
- },
- pageData: {},
- oldKeywordList: [],
- isDelete: false,
- };
- },
- methods: {
- navSearch(va) {
- if (va) {
- this.Query.name = va
- if (!this.oldKeywordList.includes(va)) this.oldKeywordList.push(va);
- this.setLS("oldKeywords", this.oldKeywordList)
- } else delete this.Query.name
- this.getList(1);
- },
- goMerchant(da) {
- this.setLS("merchant", da)
- this.goto("/pagesC/settledMerchant/merchant", { id: da.id })
- },
- // 获取当前位置
- async getLocation() {
- let adres = await uni.Location();
- this.Query.longitude = adres.lng;
- this.Query.latitude = adres.lat;
- },
- getList(page) {
- if (page) {
- this.list = []
- this.Query.page = 1
- }
- post("v1/merchant/list", this.Query).then(res => {
- if (res.code == 0) {
- let da = res.data.data
- delete res.data.data
- this.pageData = res.data
- this.list = [...this.list, ...da]
- this.Query.page++
- }
- })
- },
- deleteHistory() {
- this.isDelete = !this.isDelete
- },
- deleteAll() {
- this.setLS("oldKeywords", [])
- this.oldKeywordList = []
- },
- historyItemClick(name, index) {
- if (this.isDelete) {
- this.oldKeywordList.splice(index, 1)
- this.setLS("oldKeywords", this.oldKeywordList)
- } else {
- this.Query.name = name
- this.getList(1);
- }
- },
- },
- onLoad(da) {
- this.oldKeywordList = this.getLS("oldKeywords") || [];
- this.getLocation();
- if (da.key) this.navSearch(decodeURIComponent(da.key))
- else this.getList();
- },
- onShow() {},
- mounted() {},
- onReachBottom() {
- if (this.Query.page < this.pageData.last_page) this.getList();
- },
- };
- </script>
- <style scoped lang='scss'>
- .settledMerchantList {
- min-height: 100vh;
- background-color: #F5F5F5;
- }
- .next-search-history {
- padding: 0 20rpx;
- margin-top: 24rpx;
- .history-title {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .title-name {
- font-size: 30rpx;
- color: #666666;
- font-weight: bold;
- margin-left: 12rpx;
- }
- .history-delete {
- height: auto;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- .delete-all {
- font-size: 26rpx;
- color: #666666;
- }
- .delete-line {
- width: 1px;
- height: 20rpx;
- background-color: #999999;
- margin: 0 12rpx;
- }
- .delete-complete {
- font-size: 26rpx;
- color: #F71E1E;
- }
- }
- }
- .next-history-list {
- width: 100%;
- display: flex;
- align-items: flex-start;
- justify-content: flex-start;
- flex-wrap: wrap;
- padding: 12rpx 0;
- .history-name {
- background-color: #FFFFFF;
- border-radius: 25rpx;
- margin: 10rpx 12rpx;
- font-size: 26rpx;
- height: 48rpx;
- line-height: 48rpx;
- padding: 0 24rpx;
- color: #666666;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- .iconfont {
- margin-left: 8rpx;
- }
- }
- }
- }
- .list {
- padding: 30rpx;
- .li_item {
- margin-bottom: 20rpx;
- padding: 28rpx 32rpx;
- background-color: #fff;
- border-radius: 10rpx;
- box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
- }
- .li_title {
- font-size: 36rpx;
- margin-bottom: 16rpx;
- }
- .logo_img,
- .con_box {
- display: inline-block;
- vertical-align: top;
- }
- .logo_img {
- img {
- height: 180rpx;
- width: 180rpx;
- border-radius: 10rpx;
- }
- }
- .con_box {
- height: 180rpx;
- width: calc(100% - 180rpx - 28rpx);
- margin-left: 28rpx;
- position: relative;
- .p1 {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 6rpx;
- }
- .p2 {
- font-size: 24rpx;
- color: #999;
- }
- .p3 {
- font-size: 24rpx;
- color: #666;
- position: absolute;
- right: 0;
- bottom: 0;
- }
- }
- }
- </style>
|