123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- <template>
- <view class="container">
- <view class="topNav flex">
- <!-- <image @click="backIndex" class="back" src="../../static/icon/back.png" mode="widthFix"></image> -->
- <view class="inputbox flex">
- <image class="search" src="../../static/icon/search.png" mode="widthFix"></image>
- <input class="input" confirm-type='搜索' @confirm='searchData' placeholder="请输入城市或者门店" type="text"
- v-model="search" />
- </view>
- </view>
- <!-- <pickerAddress class="" @change="onCityClick">
- <view class="address flex">
- <view class="flex">
- <text class="text">{{province}}</text>
- <image class="tipButtom" src="../../static/icon/dom.png" mode="widthFix"></image>
- </view>
- <view class="flex">
- <text class="text">{{city}}</text>
- <image class="tipButtom" src="../../static/icon/dom.png" mode="widthFix"></image>
- </view>
- <view class="flex">
- <text class="text">{{district}}</text>
- <image class="tipButtom" src="../../static/icon/dom.png" mode="widthFix"></image>
- </view>
- </view>
- </pickerAddress> -->
- <scroll-view class="list-scroll-content" scroll-y @scrolltolower="storeList">
- <!-- 空白页 -->
- <!-- <empty v-if="loaded === true && orderList.length === 0"></empty> -->
- <!-- 订单列表 -->
- <view class="itemList">
- <view class="item flex" v-for="(item,index) in orderList" :key='index' @click="onChecked(item)">
- <view class="imgBox">
- <image class="logo" :src="item.image" mode="aspectFit"></image>
- </view>
- <view class="padding-l-20 flex-grow-true" style="max-width: 75%;">
- <view class="title clamp flex">
- <view class="name clamp">
- {{item.name}}
- </view>
- <view class="km">
- {{item.range<1?item.distance+'m':item.range+'km'}}
- </view>
- </view>
- <view class="list">
- <image src="../../static/store/store1.png" mode=""></image>{{item.detailed_address}}
- </view>
- <view class="list">
- <image src="../../static/store/phone1.png" mode=""></image>{{item.phone}}
- </view>
- <view class="flex addressBox ">
- <!-- <image class="iconA margin-r-10" src="../../static/icon/shopAddress.png" mode="heightFix">
- </image> -->
- <text class="clamp day-time">
- 营业时间:{{item.day_time | showTime}}
- </text>
- </view>
- <view class="opt">
- <view class="opt-item" @click.stop="toCall(item.phone + '')">
- <image src="../../static/store/call.png" mode=""></image>
- <view class="" style="color: #909399;">
- 电话
- </view>
- </view>
- <view class="opt-item" @click.stop="goWhere(item)">
- <image src="../../static/store/dh.png" mode=""></image>
- <view class="" style="color: #909399;">
- 导航
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <uni-load-more :status="loadingType"></uni-load-more>
- </scroll-view>
- </view>
- </template>
- <script>
- // #ifdef H5
- import weixinObj from "@/plugin/jweixin-module/index.js";
- // #endif
- import {
- storeList,
- } from '@/api/order.js';
- import {
- mapMutations,
- mapState
- } from 'vuex';
- export default {
- computed: {
- ...mapState('user', ['address'])
- },
- data() {
- return {
- select: 0,
- search: '', //查询内容
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10, //每次信息条数
- province: '请选择', //省
- city: '请选择', //市
- district: '请选择', //区
- loaded: false,
- type: 0 //默认为切换商店,1为不切换
- };
- },
- onLoad: function(option) {
- console.log(option.type);
- if (option.type) {
- this.type = option.type;
- }
- if (option.select) {
- this.select = option.select;
- }
- // #ifdef H5
- if(this.address.latitude == '0') {
- this.getAddress()
- this.storeList();
- }else {
- this.storeList();
- }
- // #endif
- },
- filters: {
- showTime(val) {
- let str = ''
- if(val) {
- let arr = val.split(' - ')
- let arr1 = arr[0].split(':')
- let arr2 = arr[1].split(':')
- str = arr1[0] + ':' + arr1[1] + ' - ' + arr2[0] + ':' + arr2[1]
- }
- return str
- }
- },
- methods: {
- ...mapMutations('user', ['setAddress','setStore']),
- toCall(phone) {
- uni.makePhoneCall({
- phoneNumber:phone
- })
- },
- goWhere(item) {
- let latitude = item.latitude;
- let longitude = item.longitude;
- let address = item.name;
- // #ifdef H5
- window.open(`http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};title:${address}`)
- // #endif
- },
- getAddress() {
- let that = this
- try{
- weixinObj.ready(() => {
- console.log('加载完毕注册事件');
- weixinObj.getLocation({
- type: 'gcj02',
- success: function(res) {
- that.setAddress({
- latitude: res.latitude,
- longitude: res.longitude
- })
- that.storeList();
- },
- fail(e) {
- console.log('失败', e);
- }
- });
- });
- }catch(e){
- that.storeList();
- }
-
- },
- toJSON() {
- return this;
- },
- backIndex() {
- uni.switchTab({
- url: '/pages/index/index'
- })
- },
- // 查询方法
- searchData() {
- // 初始化数据重新搜索
- this.loaded = false;
- this.page = 1;
- this.orderList = [];
- this.loadingType = 'more';
- this.storeList()
- },
- // 存储当前的门店
- onChecked(item) {
- let that = this
- if(that.type == 0) {
- let prepage = that.$api.prePage();
- prepage.checkedPoint = item
- that.setStore(item)
- uni.navigateBack()
- }else {
- that.setStore(item)
- }
-
- },
- storeList(source) {
- //这里是将订单挂载到tab列表下
- let navItem = this;
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- if (navItem.loadingType === 'noMore') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- let city = `${this.province},${this.city},${this.district}`;
- if (this.province == '请选择') {
- city = '';
- }
- storeList({
- city,
- page: navItem.page,
- limit: navItem.limit,
- key: this.search,
- latitude: this.address.latitude,
- longitude: this.address.longitude,
- })
- .then(({
- data
- }) => {
- let arr = data.list.map(e => {
- return e;
- });
- navItem.orderList = navItem.orderList.concat(arr);
- // console.log(navItem.orderList);
- navItem.page++;
- if (navItem.limit == arr.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'more';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'noMore';
- }
- uni.hideLoading();
- this.$set(navItem, 'loaded', true);
- console.log(this, '结果');
- })
- .catch(e => {
- console.log(e);
- });
- },
- // 内容改变事件
- onCityClick(item) {
- const arr = item.data;
- this.province = arr[0];
- this.city = arr[1];
- this.district = arr[2];
- // 开始查询
- console.log(this.province, this.city, this.district);
- console.log(arr);
- this.searchData()
- }
- },
- };
- </script>
- <style lang="scss">
- page,
- .container {
- height: 100%;
- }
- /* #ifdef APP */
- .container {
- padding-top: var(--status-bar-height);
- }
- /* #endif */
- .list-scroll-content {
- height: calc(100% - 44px);
- position: relative;
- overflow: hidden;
- z-index: 100;
- }
- .itemList {
- padding: 30rpx 0;
- .item {
- background-color: #FFFFFF;
- margin-bottom: 30rpx;
- padding: 20rpx;
- border-radius: 20rpx;
- position: relative;
- .day-time {
- background-color: #fef4eb;
- color: #fe7019;
- padding: 5rpx 10rpx;
- margin-top: 15rpx;
- }
- .opt {
- display: flex;
- width: 120rpx;
- justify-content: space-between;
- position: absolute;
- bottom: 20rpx;
- right: 20rpx;
- .opt-item {
- font-size: $font-sm;
- color: $font-color-light;
- }
- image {
- width: 45rpx;
- height: 45rpx;
- }
-
- }
- .list,
- .km {
- color: $font-color-light;
- font-size: $font-sm;
- }
- .list {
- padding-top: 10rpx;
- image {
- width: 28rpx;
- height: 28rpx;
- vertical-align: bottom;
- margin-right: 10rpx;
- }
- }
- .logo {
- height: 180rpx;
- width: 180rpx;
- border-radius: 20rpx;
- }
- .title {
- font-size: 36rpx;
- color: $font-color-dark;
- }
- .iconR {
- height: 24rpx;
- }
- .iconA {
- width: 24rpx;
- height: 24rpx;
- }
- .addressBox {
- font-size: 24rpx;
- color: $font-color-light;
- justify-content: flex-start;
- }
- }
- }
- .address {
- background-color: #FFFFFF;
- justify-content: space-around;
- height: 40px;
- .text {
- font-size: 22rpx;
- color: $font-color-dark;
- margin-right: 5px;
- }
- .tipButtom {
- width: 11px;
- }
- }
- .topNav {
- height: 44px;
- background-color: #FFFFFF;
- padding: 0 15px;
- /* #ifdef MP */
- height: calc(44px + var(--status-bar-height));
- padding-top: calc(var(--status-bar-height) - 15px);
- /* #endif */
- .back {
- width: 13px;
- }
- .inputbox {
- background-color: $page-color-base;
- height: 15px;
- flex-grow: 1;
- margin-left: 15px;
- border-radius: 50px;
- height: 30px;
- padding-left: 20px;
- /* #ifdef MP */
- margin-right: 200rpx;
- /* #endif */
- font-size: $font-base;
- .search {
- width: 18px;
- }
- .input {
- height: 100%;
- width: 100%;
- text-align: left;
- padding-left: 10px;
- }
- }
- }
-
- </style>
|