123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506 |
- <template>
- <view class="content">
- <view class="search flex">
- <view class="input-box flex" @click.stop="clickSearch">
- <view class=" input-content flex">
- <view class="iconfont iconsearch"></view>
- <view class="input"><input type="text" placeholder="请输入店铺名称" v-model="name" /></view>
- </view>
- </view>
- <view class="search-btn" @click="search()">
- 搜索
- </view>
- </view>
- <scroll-view scroll-y="true" :style="{'height': height}" class="shop-list-wrap" @scrolltolower="getStoreList()">
- <!-- 空白页 -->
- <empty v-if="loaded === true && shopList.length === 0"></empty>
- <view class="djq-wrap flex f-ai-s" v-for="(item,index) in shopList"
- @click="navTo('/pages/shop/shopDetail?id=' + item.id)">
- <image :src="item.image" mode="" class="djq-img"></image>
- <view class="djq-right pl20">
- <view class="djq-tit flex f-j-sb f-ai-s">
- <view class="djq-name clamp">
- {{item.name}}
- </view>
- <view class="djq-dis">
- <image src="../../static/icon/dh.png" mode=""></image>
- 距离{{item.range}}KM
- </view>
- </view>
- <view class="flex f-d-c f-j-sb f-ai-s fg1" style="height: 110rpx;">
- <view class="djq-dz clamp2">
- {{item.detailed_address}}
- </view>
- <view class="djq-hd flex f-j-sb">
- <!-- <view class="buy-info">
- {{item.count}}人已购买
- </view> -->
- <view class="hd-btn">
- <image src="../../static/icon/call.png" mode="" style="margin-right: 15rpx;"
- @click.stop="makeCall(item.phone)"></image>
- <!-- #ifdef H5 -->
- <image src="../../static/icon/dh.png" mode=""
- @click.stop="toGaodeMap(item.latitude,item.longitude,item.name)"></image>
- <!-- #endif -->
- <!-- #ifdef APP -->
- <image src="../../static/icon/dh.png" mode="" @click.stop="toGaodeMap(index)"></image>
- <!-- #endif -->
- </view>
- </view>
- </view>
- <view class="" style="padding: 10rpx 0 0 0;">
- <view class="left-btm flex f-j-s" v-for="itemt in item.coupon">
- <view class="j-logo">
- 券
- </view>
- <view class="j-price">
- <text>¥</text>{{itemt.price}}
- </view>
- <view class="j-zk">
- {{(((itemt.price*10)/(itemt.ot_price*1)).toFixed(1))}}折
- </view>
- <view class="j-name">
- {{itemt.store_name}}
- </view>
- </view>
- </view>
- </view>
- </view>
- <uni-load-more :status="loadingType"></uni-load-more>
- </scroll-view>
- </view>
- </template>
- <script>
- import empty from '@/uview-ui/components/u-empty/u-empty.vue';
- // #ifdef H5
- import {
- weixindata,
- shareLoad
- } from '@/utils/wxAuthorized';
- import {
- jsonp
- } from 'vue-jsonp'
- // #endif
- import {
- mapState,
- mapMutations
- } from 'vuex';
- import {
- getStoreList
- } from '@/api/shop.js'
- export default {
- components: {
- empty
- },
- data() {
- return {
- id: '',
- page: 1,
- limit: 10,
- shopList: [],
- name: '',
- height: '',
- loadingType: 'more',
- loaded: false,
- latitude: '',
- longitude: '',
- }
- },
- computed: {
- ...mapState(['loginInterceptor', 'baseURL']),
- },
- onLoad(opt) {
- let obj = this
- if (opt.id) {
- this.id = opt.id
- }
-
- // var urlStr = encodeURI( `https://uri.amap.com/marker?position=${obj.info.longitude},${obj.info.latitude}&name=${obj.info.name}`)
- // plus.runtime.openURL(urlStr);
-
-
- //先获取当前地理位置
- uni.getLocation({
- type: 'wgs84',
- success: function(res) {
- console.log(res, 'res');
- obj.latitude = res.latitude
- obj.longitude = res.longitude
- console.log('当前位置的经度:', obj.latitude, obj.longitude, );
- obj.getStoreList()
- // console.log('当前位置的纬度:' + res.latitude);
- },fail: (err) => {
- console.log(err,'rrrr');
- }
- })
- },
- onShow() {
-
- // this.getStoreList()
-
- },
- onReachBottom() {
- },
- onReady() {
- var obj = this;
- uni.getSystemInfo({
- success: resu => {
- const query = uni.createSelectorQuery();
- query.select('.shop-list-wrap').boundingClientRect();
- query.exec(function(res) {
- obj.height = resu.windowHeight - res[0].top + 'px';
- });
- },
- fail: res => {}
- });
- },
- methods: {
- // 调用高德
- toGaodeMap(index) {
- let obj = this
- // console.log(obj.shopList[index],'index');
- console.log(obj.shopList[index].longitude,obj.shopList[index].latitude,obj.shopList[index].name,'调用高德');
-
- var urlStr = encodeURI( `https://uri.amap.com/marker?position=${obj.shopList[index].longitude},${obj.shopList[index].latitude}&name=${obj.shopList[index].name}`)
- plus.runtime.openURL(urlStr);
-
- },
- navTo(url) {
- console.log('没点进去,没有执行');
- uni.navigateTo({
- url,
- fail() {
- console.log(url, '没点进去');
- uni.switchTab({
- url
- })
- }
- })
- },
- search() {
- let obj = this
- obj.shopList = []
- obj.loadingType = 'more'
- obj.page = 1
- obj.getStoreList()
- },
- // 拨打电话
- makeCall(phone) {
- uni.makePhoneCall({
- phoneNumber: phone //仅为示例
- });
- },
- // 导航
- dh(item) {
- wx.openLocation({
- latitude: item.latitude * 1,
- longitude: item.longitude * 1,
- name: item.name,
- address: item.detailed_address
- })
- },
- //app导航到地图中
- getLocation(item) {
- uni.chooseLocation({
- latitude: item.latitude,
- longitude: item.longitude,
- success: function(res) {
- console.log(res, '当前地位置');
- console.log('位置名称:' + res.name);
- console.log('详细地址:' + res.address);
- console.log('纬度:' + res.latitude);
- console.log('经度:' + res.longitude);
- }
- });
- },
- getStoreList() {
- let obj = this
- if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
- return
- }
- obj.loadingType = 'loading'
- console.log(obj.latitude, obj.longitude, '传给接口');
- getStoreList({
- cate_id: obj.id,
- name: obj.name,
- latitude: obj.latitude,
- longitude: obj.longitude,
- page: obj.page,
- limit: obj.limit,
- // address: obj.$store.state.chooseDistrict,
- }).then(res => {
- console.log(res,'23232')
- obj.shopList = obj.shopList.concat(res.data.list)
- obj.page++
- if (obj.limit == res.data.list.length) {
- obj.loadingType = 'more'
- } else {
- obj.loadingType = 'noMore'
- }
- obj.loaded = true
- })
- },
- // 调用高德
- // toGaodeMap(latitude, longitude, address) {
- // console.log('选择高德', latitude, longitude, address);
- // window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`;
- // },
- }
- }
- </script>
- <style lang="scss">
- .search-top {
- // position: fixed;
- // top: 0;
- // z-index: 99;
- }
- .shop {
- // margin-top: 20rpx;
- background: #ffffff;
- padding: 0 12rpx;
- .shop-title {
- padding: 30rpx 0 20rpx;
- display: flex;
- align-items: center;
- border-bottom: 1px solid #e3e6e7;
- .shop-item {
- width: 33%;
- display: flex;
- align-items: center;
- justify-content: center;
- .sitem-font {
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- .jt-down {
- width: 10rpx;
- height: 8rpx;
- margin-left: 12rpx;
- }
- }
- }
- }
- .shop-list-wrap {
- // background-color: red;
- padding-top: 20rpx;
- }
- .djq-wrap {
- width: 701rpx;
- // height: 255rpx;
- background: #FFFFFF;
- box-shadow: 0px 0px 27rpx 0px rgba(50, 50, 52, 0.06);
- border-radius: 20rpx;
- margin: 0 auto 20rpx;
- padding: 23rpx 22rpx;
- &:last-of-type {
- margin-bottom: 0;
- }
- .djq-img {
- flex-shrink: 0;
- width: 150rpx;
- height: 150rpx;
- border-radius: 10rpx;
- }
- .djq-right {
- flex-grow: 1;
- .djq-tit {
- font-size: 34rpx;
- font-weight: bold;
- color: #333333;
- line-height: 52rpx;
- .djq-name {
- max-width: 300rpx;
- }
- .djq-dis {
- flex-shrink: 0;
- image {
- width: 20rpx;
- height: 28rpx;
- margin-right: 10rpx;
- }
- font-size: 22rpx;
- font-weight: 500;
- color: #666666;
- }
- }
- .djq-dz {
- width: 100%;
- font-size: 24rpx;
- font-weight: 500;
- color: #666666;
- }
- .djq-hd {
- width: 100%;
- // border-bottom: 1rpx solid #EAECED;
- .buy-info {
- display: inline-block;
- height: 32rpx;
- border-radius: 16rpx 16rpx 16rpx 0px;
- line-height: 32rpx;
- font-size: 20rpx;
- font-weight: 500;
- color: #FF440D;
- padding: 0 15rpx;
- background-color: #fff;
- }
- .hd-btn {
- image {
- width: 46rpx;
- height: 46rpx;
- }
- }
- }
- }
- }
- .left-btm {
- height: 50rpx;
- .j-logo {
- width: 32rpx;
- line-height: 33rpx;
- background: linear-gradient(-48deg, #FFA30B, #FFD158);
- border-radius: 13rpx;
- font-size: 21rpx;
- font-weight: 500;
- color: #FFFFFF;
- text-align: center;
- }
- .j-price {
- font-size: 27rpx;
- font-weight: bold;
- color: #FF4C4C;
- margin: 0 10rpx 0 5rpx;
- }
- .j-zk {
- height: 31rpx;
- border: 1rpx solid #FF4C4C;
- border-radius: 7rpx;
- line-height: 31rpx;
- padding: 0 8rpx;
- font-size: 20rpx;
- font-weight: bold;
- color: #FF4C4C;
- margin-right: 5rpx;
- }
- .j-name {
- font-size: 23rpx;
- font-weight: bold;
- color: #333333;
- }
- }
- .search {
- justify-content: flex-start;
- padding: 10rpx 32rpx 20rpx;
- align-items: center;
- background-color: #fff;
- .search-btn {
- display: inline-block;
- // flex-grow: ;
- flex-shrink: 0;
- padding: 0 0 0 20rpx;
- font-size: 32rpx;
- color: #FF4C4C;
- z-index: 99;
- }
- .address {
- width: 32rpx;
- height: 38rpx;
- }
- .shop-name {
- height: 38rpx;
- position: relative;
- top: -4rpx;
- z-index: 100;
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: 500;
- padding-left: 10rpx;
- }
- .shop-jt {
- margin-left: 8rpx;
- width: 16rpx;
- height: 10rpx;
- }
- .input-box {
- margin-left: 10rpx;
- position: relative;
- z-index: 99;
- width: 710rpx;
- height: 60rpx;
- background: #EEEEEE;
- border-radius: 30rpx;
- .input-content {
- position: relative;
- z-index: 11;
- border-radius: 99rpx;
- flex-grow: 1;
- padding: 5rpx 30rpx;
- background: #EEEEEE;
- .iconsearch {
- font-size: 50rpx;
- color: #CBCBCB;
- }
- .input {
- margin-left: 19rpx;
- flex-grow: 1;
- input {
- font-size: 28rpx;
- color: #000;
- }
- }
- }
- .input-button {
- padding-left: 20rpx;
- font-size: $font-base;
- height: 100%;
- }
- }
- }
- </style>
|