第一次提交

This commit is contained in:
gxwebsoft
2023-08-04 13:14:48 +08:00
commit 1b923e5cff
1030 changed files with 128016 additions and 0 deletions

198
pages/shop/detail.vue Executable file
View File

@@ -0,0 +1,198 @@
<template>
<view v-if="!isLoading" class="container">
<view class="header">
<view class="shop-logo">
<image class="image" :src="detail.logo_url"></image>
</view>
<view class="shop-name">
<text>{{ detail.shop_name }}</text>
</view>
<view v-if="detail.summary" class="shop-summary dis-flex">
<text>门店简介{{ detail.summary }}</text>
</view>
</view>
<view class="content">
<view class="content-item dis-flex flex-y-center">
<view class="content-item__icon dis-flex">
<text class="iconfont icon-shijian"></text>
</view>
<view class="content-item__text flex-box dis-flex">
<text class="f-26">{{ detail.shop_hours }}</text>
</view>
</view>
<view class="content-item dis-flex flex-y-center" @click="onOpenLocation()">
<view class="content-item__icon dis-flex">
<text class="iconfont icon-dingwei"></text>
</view>
<view class="content-item__text flex-box dis-flex">
<text
class="f-26">{{ detail.region.province }}{{ detail.region.city }}{{ detail.region.region }}{{ detail.address }}</text>
</view>
<view class="content-item__arrow dis-flex">
<text class="iconfont icon-arrow-right"></text>
</view>
</view>
<view class="content-item dis-flex flex-y-center" @click="onMakePhoneCall()">
<view class="content-item__icon dis-flex">
<text class="iconfont icon-dianhua"></text>
</view>
<view class="content-item__text flex-box dis-flex">
<text class="f-26">{{ detail.phone }}</text>
</view>
<view class="content-item__arrow dis-flex">
<text class="iconfont icon-arrow-right"></text>
</view>
</view>
</view>
</view>
</template>
<script>
// import * as ShopApi from '@/api/shop'
export default {
data() {
return {
// 正在加载中
isLoading: true,
// 当前门店ID
shopId: undefined,
// 门店详情
detail: null
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 记录当前门店ID
this.shopId = options.shopId
// 获取门店详情
// this.getShopDetail()
},
methods: {
// 获取门店详情
getShopDetail() {
const app = this
app.isLoading = true
ShopApi.detail(app.shopId)
.then(result => app.detail = result.data.detail)
.finally(() => app.isLoading = false)
},
// 拨打电话
onMakePhoneCall() {
const app = this
uni.makePhoneCall({
phoneNumber: app.detail.phone
})
},
// 查看位置
onOpenLocation() {
const app = this
const { detail } = app
uni.openLocation({
name: detail.shop_name,
address: detail.region.province + detail.region.city + detail.region.region + detail.address,
longitude: Number(detail.longitude),
latitude: Number(detail.latitude),
scale: 15
})
},
},
/**
* 分享当前页面
*/
onShareAppMessage() {
const app = this
// 构建页面参数
const params = app.$getShareUrlParams({ shopId: app.shopId })
return {
title: app.detail.shop_name,
path: "/pages/shop/detail?" + params
}
},
/**
* 分享到朋友圈
* 本接口为 Beta 版本,暂只在 Android 平台支持,详见分享到朋友圈 (Beta)
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
*/
onShareTimeline() {
const app = this
// 构建页面参数
const params = app.$getShareUrlParams({ shopId: app.shopId })
return {
title: app.detail.shop_name,
path: "/pages/shop/detail?" + params
}
},
}
</script>
<style lang="scss">
page {
background: #f3f3f3;
}
</style>
<style lang="scss" scoped>
.container {
background: #fff;
padding: 0 30rpx;
}
.header {
padding: 30rpx 0;
border-bottom: 1rpx solid #f1f1f1;
.shop-logo,
.shop-name {
text-align: center;
}
.shop-logo {
.image {
width: 130rpx;
height: 130rpx;
border-radius: 50%;
box-shadow: 0 0 30rpx rgba(0, 0, 0, 0.1);
}
}
.shop-name {
margin-top: 16rpx;
font-size: 32rpx;
}
.shop-summary {
padding: 20rpx;
margin-top: 30rpx;
font-size: 26rpx;
line-height: 1.6;
background: #f9f9f9;
border-radius: 6rpx;
}
}
.content {
margin-top: 30rpx;
.content-item {
padding: 12rpx 0;
.content-item__text {
padding: 0 20rpx;
}
}
}
</style>

198
pages/shop/extract.vue Executable file
View File

@@ -0,0 +1,198 @@
<template>
<view class="container b-f">
<!-- 门店列表 -->
<view class="shop-list">
<view v-for="(item, index) in shopList" :key="index" @click="onSelectedShop(item.shop_id)" class="shop-item dis-flex flex-y-center">
<view class="shop-item__content flex-box">
<view class="shop-item__title">
<text>{{ item.shop_name }}</text>
</view>
<view class="shop-item__address">
<text>地址{{ item.region.province }}{{ item.region.city }}{{ item.region.region }}{{ item.address }}</text>
</view>
<view class="shop-item__phone">
<text>联系电话{{ item.phone }}</text>
</view>
<view v-if="item.distance" class="shop-item__distance">
<text class="iconfont icon-dingwei"></text>
<text class="f-24">{{ item.distance_unit }}</text>
</view>
</view>
<!-- 选中状态 -->
<view v-if="item.shop_id == selectedId" class="shop-item__right">
<text class="iconfont icon-check1"></text>
</view>
</view>
</view>
<!-- 定位按钮 -->
<view v-if="!isAuthor" class="widget-location dis-flex flex-x-center flex-y-center" @click="onAuthorize()">
<text class="iconfont icon-locate"></text>
</view>
<empty v-if="!shopList.length" :isLoading="isLoading" tips="亲,暂无自提门店哦" />
</view>
</template>
<script>
// import * as ShopApi from '@/api/shop'
import Empty from '@/components/empty'
export default {
components: {
Empty
},
data() {
return {
// 正在加载中
isLoading: true,
// 是否授权了定位权限
isAuthor: true,
// 当前选择的门店ID
selectedId: null,
// 门店列表
shopList: []
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad({ selectedId }) {
const app = this
// 记录当前选择的门店ID
app.selectedId = selectedId ? selectedId : null
// 获取默认门店列表
// app.getShopList()
// 获取用户坐标
// app.getLocation(res => {
// app.getShopList(res.longitude, res.latitude)
// })
},
methods: {
// 获取门店列表
getShopList(longitude, latitude) {
const app = this
app.isLoading = true
ShopApi.list({
isCheck: 1,
longitude: longitude ? longitude : '',
latitude: latitude ? latitude : ''
})
.then(result => app.shopList = result.data.list)
.finally(() => app.isLoading = false)
},
// 获取用户坐标
// 参考文档https://uniapp.dcloud.io/api/location/location?id=getlocation
getLocation(callback) {
const app = this
uni.getLocation({
type: 'wgs84',
success: callback,
fail() {
app.$toast('获取定位失败,请点击右下角按钮重新尝试定位')
app.isAuthor = false
}
})
},
// 授权启用定位权限
onAuthorize() {
const app = this
// #ifdef MP
uni.openSetting({
success(res) {
if (res.authSetting['scope.userLocation']) {
console.log('定位权限授权成功')
app.isAuthor = true
setTimeout(() => {
// 获取用户坐标
app.getLocation(res => {
app.getShopList(res.longitude, res.latitude)
})
}, 1000)
}
}
})
// #endif
// #ifdef H5
// 获取用户坐标
app.getLocation(res => {
app.getShopList(res.longitude, res.latitude)
})
// #endif
},
/**
* 选择门店
*/
onSelectedShop(selectedId) {
const app = this
// 设置选中的id
app.selectedId = selectedId
// 相应全局事件订阅: 选择自提门店
uni.$emit('syncSelectedId', selectedId)
// 返回上级页面
uni.navigateBack({
delta: 1
})
},
}
}
</script>
<style lang="scss" scoped>
.shop-list .shop-item {
padding: 20rpx 30rpx;
min-height: 180rpx;
font-size: 26rpx;
line-height: 1.5;
border-bottom: 1px solid #eee;
}
.shop-item__title {
font-size: 30rpx;
color: #535353;
margin-bottom: 10rpx;
}
.shop-item__address,
.shop-item__phone {
color: #919396;
}
.shop-item__distance {
margin-top: 10rpx;
color: #c1c1c1;
height: 40rpx;
}
.shop-item__distance .iconfont {
color: #81838e;
margin-right: 5rpx;
}
// 选中图标
.shop-item__right {
margin-left: 20rpx;
color: #535353;
font-size: 38rpx;
}
// 定位图标
.widget-location {
position: fixed;
right: calc(var(--window-right) + 40rpx);
bottom: calc(var(--window-bottom) + 70rpx);
width: 72rpx;
height: 72rpx;
z-index: 200;
border-radius: 50%;
background: #fff;
box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.2);
color: #555;
font-size: 40rpx;
}
</style>