shop-applet/pages/store/detail/index.vue

602 lines
14 KiB
Vue
Raw Normal View History

2023-09-20 18:16:59 +08:00
<template>
<view :style="viewColor">
2023-09-25 09:27:16 +08:00
<view class="store-detail">
<view class="section">
<view class="head">
<image class="head-image" :src="store.mer_avatar"></image>
<view class="text-wrap">
<view class="name line1">
<text class="name_store">{{ store.mer_name }}</text>
<image v-if="margin_ico_switch==1 && margin_ico && store.is_margin == 10" :src="margin_ico"
class="store-margin"></image>
<text v-if="store.type_name" class="font-bg-red ml8">{{ store.type_name }}</text>
<text v-else-if="store.is_trader" class="font-bg-red ml8">自营</text>
</view>
<view class="fans">粉丝数量
{{ store.care_count < 10000 ? store.care_count : (store.care_count / 10000).toFixed(2) + '万' }}
</view>
</view>
<!-- <button :class="{ followed: store.care }" hover-class="none" @click="followToggle">
<text v-show="!store.care" class="iconfont icon-guanzhu"></text>
{{ store.care ? '已关注' : '关注' }}
</button> -->
<view class="carebtn" @click="followToggle">
2023-09-25 09:27:16 +08:00
<image src="@/static/images/gz.png" v-if=" store.care" mode="aspectFit"></image>
<image src="@/static/images/gz1.png" v-else mode="aspectFit"></image>
2023-09-20 18:16:59 +08:00
</view>
</view>
2023-09-25 09:27:16 +08:00
<view class="section wrap">
<view class="name">店铺评级</view>
<view class="score-wrap">
<view class="star" :class="'star' + keyColor">
<view
:style="{ width: `${star.toFixed(2)}%`, backgroundImage: `url(${domain}/static/diy/score1${keyColor}.png)` }">
</view>
</view>
<view>{{ score.toFixed(1) }}</view>
</view>
2023-09-20 18:16:59 +08:00
</view>
</view>
2023-09-25 09:27:16 +08:00
<view class="section info">
<view class="item very" @click="popupShow = true">
<view class="name">店铺二维码</view>
<view><text class="iconfont icon-erweima1"></text></view>
</view>
<view class="item very">
<navigator v-if="store.isset_certificate" style="display: flex;"
:url="`/pages/store/qualifications/index?mer_id=${store.mer_id}&uid=${this.uid}&storeName=${store.mer_name}`">
<view class="name">店铺资质信息</view>
<view><text class="iconfont">&#xe743;</text></view>
</navigator>
</view>
2023-09-20 18:16:59 +08:00
</view>
<view v-if="store.services_type == 1" class="section wrap" @click="call">
<view class="name">联系客服</view>
2023-09-25 09:27:16 +08:00
<view><text class="iconfont icon-kefu1"></text></view>
2023-09-20 18:16:59 +08:00
</view>
2023-09-25 09:27:16 +08:00
<navigator v-else :url="`/pages/chat/customer_list/chat?mer_id=${store.mer_id}&uid=${this.uid}`"
class="section wrap">
2023-09-20 18:16:59 +08:00
<view class="name">联系客服</view>
<view><text class="iconfont icon-kefu1"></text></view>
2023-09-25 09:27:16 +08:00
</navigator>
2023-09-20 18:16:59 +08:00
<view class="section info">
<view class="item very">
<view class="name">店铺名称</view>
<view class="value">{{ store.mer_name }}</view>
2023-09-20 18:16:59 +08:00
</view>
<view class="item very">
<view class="name">店铺地址</view>
<view class="value">{{ store.mer_address }}</view>
2023-09-25 09:27:16 +08:00
<view v-if="store.lat && store.long && mer_location == 1" class="iconfont icon-dingwei"
@click="showMaoLocation(store.lat, store.long)"></view>
2023-09-20 18:16:59 +08:00
</view>
2023-09-20 18:16:59 +08:00
<view v-if="store.service_phone" class="item">
<view class="name">联系电话</view>
<view class="value">{{ store.service_phone }}</view>
</view>
2023-09-20 18:16:59 +08:00
<view class="item">
<view class="name">开店时间</view>
<view class="value">{{ store.create_time | dateFormat }}</view>
</view>
<view class="item">
<view class="name">营业时间</view>
<view class="value">{{ store.mer_info.mer_take_time[0] +"-"+ store.mer_info.mer_take_time[1] }}
</view>
</view>
2023-09-20 18:16:59 +08:00
</view>
<view :class="{ mask: popupShow }" @click="popupShow = false"></view>
<view :class="{ 'popup-active': popupShow }" class="popup-qrcode">
<view class="name">{{ store.mer_name }}</view>
<view class="info">保存二维码可分享店铺给好友哦~</view>
<!-- #ifndef MP -->
<image :src="storeCode"></image>
<!-- #endif -->
<!-- #ifdef MP -->
<image :src="storeCode" @longpress="savePosterPath(storeCode)"></image>
<!-- #endif -->
</view>
</view>
</view>
</template>
<script>
2023-09-25 09:27:16 +08:00
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
mapGetters
} from 'vuex';
import {
configMap
} from "@/utils";
import {
getStoreDetail,
followStore,
unfollowStore,
merchantQrcode
} from '@/api/store.js';
import {
HTTP_REQUEST_URL
} from '@/config/app';
let app = getApp();
export default {
computed: {
...configMap({
margin_ico_switch: 0,
margin_ico: ''
}, mapGetters(['isLogin', 'uid', 'viewColor', 'keyColor'])),
},
filters: {
dateFormat: function(value) {
if (!value) {
return '';
}
return value.split(' ')[0];
2023-09-20 18:16:59 +08:00
}
},
2023-09-25 09:27:16 +08:00
data() {
return {
domain: HTTP_REQUEST_URL,
id: 0,
store: {},
score: 0,
star: 0,
popupShow: false,
storeCode: '',
openSettingBtnHidden: true, //是否授权
mer_location: '',
};
2023-09-20 18:16:59 +08:00
},
2023-09-25 09:27:16 +08:00
onLoad: function(options) {
uni.getStorage({
key: 'GLOBAL_DATA',
success: res => {
this.mer_location = res.data.mer_location;
// console.log(this.mer_location);
2023-09-20 18:16:59 +08:00
}
});
2023-09-25 09:27:16 +08:00
this.id = options.mer_id || options.id;
this.getStore();
this.getStoreCode();
2023-09-20 18:16:59 +08:00
},
2023-09-25 09:27:16 +08:00
onReady: function() {},
mounted: function() {},
methods: {
call: function() {
uni.makePhoneCall({
phoneNumber: this.store.service_phone,
})
},
getStore: function() {
getStoreDetail(this.id).then(res => {
let store = res.data;
this.store = store;
this.score = (parseFloat(store.postage_score) + parseFloat(store.product_score) +
parseFloat(store.service_score)) / 3;
this.star = (this.score / 5) * 100;
2023-09-20 18:16:59 +08:00
});
2023-09-25 09:27:16 +08:00
},
follow: function() {
followStore(this.id).then(res => {
if (res.status === 200) {
this.store.care = true;
}
this.$util.Tips({
title: res.message
});
});
},
//查看地图
showMaoLocation(lat, long) {
// console.log(lat, long);
if (!lat || !long)
return this.$util.Tips({
title: '请设置允许商城访问您的位置!'
});
//#ifdef H5
if (this.$wechat.isWeixin() === true) {
this.$wechat
.seeLocation({
latitude: Number(lat),
longitude: Number(long),
name: this.store.mer_name,
address: this.store.mer_address ? this.store.mer_address : ''
})
.then(res => {
// console.log('success');
});
} else {
//#endif
uni.openLocation({
latitude: parseFloat(lat),
longitude: parseFloat(long),
scale: 8,
geocode: true,
2023-09-20 18:16:59 +08:00
name: this.store.mer_name,
2023-09-25 09:27:16 +08:00
address: this.store.mer_address ? this.store.mer_address : '',
success: function(res) {
// console.log(res);
}
2023-09-20 18:16:59 +08:00
});
2023-09-25 09:27:16 +08:00
// #ifdef H5
}
2023-09-20 18:16:59 +08:00
//#endif
2023-09-25 09:27:16 +08:00
},
unfollow: function() {
unfollowStore(this.id).then(res => {
if (res.status === 200) {
this.store.care = false;
2023-09-20 18:16:59 +08:00
}
2023-09-25 09:27:16 +08:00
this.$util.Tips({
title: res.message
});
2023-09-20 18:16:59 +08:00
});
2023-09-25 09:27:16 +08:00
},
followToggle: function() {
this.store.care ? this.unfollow() : this.follow();
},
// 店铺二维码
getStoreCode() {
let params = {};
// #ifdef MP
params = {
type: 'routine'
};
//#endif
merchantQrcode(this.id, params)
.then(res => {
this.storeCode = res.data.url;
})
.catch(err => {});
},
2023-09-20 18:16:59 +08:00
// #ifdef MP
2023-09-25 09:27:16 +08:00
// 小程序保存图片
savePosterPath(url) {
uni.downloadFile({
url,
success: resFile => {
if (resFile.statusCode === 200) {
uni.getSetting({
success: res => {
if (!res.authSetting['scope.writePhotosAlbum']) {
uni.authorize({
scope: 'scope.writePhotosAlbum',
success: () => {
uni.saveImageToPhotosAlbum({
filePath: resFile
.tempFilePath,
success: res => {
return uni
.showToast({
title: '保存成功!'
});
},
fail: res => {
return uni
.showToast({
title: res
.errMsg
});
},
complete: res => {}
});
},
fail: () => {
uni.showModal({
title: '您已拒绝获取相册权限',
content: '是否进入权限管理,调整授权?',
success: res => {
if (res.confirm) {
uni.openSetting({
success: res => {
// console.log(res.authSetting);
}
});
} else if (res
.cancel) {
return uni
.showToast({
title: '已取消!'
});
}
2023-09-20 18:16:59 +08:00
}
2023-09-25 09:27:16 +08:00
});
}
});
} else {
uni.saveImageToPhotosAlbum({
filePath: resFile.tempFilePath,
success: res => {
return uni.showToast({
title: '保存成功!'
});
},
fail: res => {
return uni.showToast({
title: res.errMsg
});
},
complete: res => {}
});
}
},
fail: res => {}
});
} else {
return uni.showToast({
title: resFile.errMsg
});
}
},
fail: res => {
2023-09-20 18:16:59 +08:00
return uni.showToast({
2023-09-25 09:27:16 +08:00
title: res.errMsg
2023-09-20 18:16:59 +08:00
});
}
2023-09-25 09:27:16 +08:00
});
}
// #endif
2023-09-20 18:16:59 +08:00
}
2023-09-25 09:27:16 +08:00
};
2023-09-20 18:16:59 +08:00
</script>
<style lang="scss" scoped>
2023-09-25 09:27:16 +08:00
.font-bg-red {
2023-09-20 18:16:59 +08:00
display: flex;
align-items: center;
2023-09-25 09:27:16 +08:00
background: var(--view-theme);
border-color: var(--view-theme);
color: #fff;
font-size: 20rpx;
text-align: center;
line-height: 30rpx;
height: 28rpx;
border-radius: 5rpx;
margin-right: 8rpx;
&.ml8 {
margin-left: 8rpx;
margin-right: 0;
}
}
.carebtn {
width: 136rpx;
height: 52rpx;
2023-09-25 09:27:16 +08:00
margin-top: -35rpx;
margin-right: 30rpx;
2023-09-20 18:16:59 +08:00
image {
2023-09-25 09:27:16 +08:00
width: 100%;
height: 100%;
2023-09-20 18:16:59 +08:00
}
2023-09-25 09:27:16 +08:00
}
.store-detail {
padding-top: 80rpx;
padding-right: 20rpx;
padding-left: 20rpx;
background: left top/750rpx 360rpx no-repeat fixed;
.section {
border-radius: 10rpx;
margin-bottom: 20rpx;
background-color: #ffffff;
border-radius: 21rpx 21rpx;
2023-09-25 09:27:16 +08:00
}
.head {
display: flex;
align-items: center;
padding: 20rpx;
border-bottom: 1px solid #e1e1e1;
.head-image {
width: 90rpx;
height: 90rpx;
border-radius: 6rpx;
2023-09-20 18:16:59 +08:00
}
2023-09-25 09:27:16 +08:00
.text-wrap {
flex: 1;
min-width: 0;
margin-right: 20rpx;
margin-left: 20rpx;
line-height: 1;
.store-margin {
width: 28rpx;
height: 30rpx;
margin-left: 10rpx;
}
.name {
display: flex;
align-items: center;
font-weight: bold;
font-size: 28rpx;
color: #282828;
.name_store {
display: inline-block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
max-width: 140px;
}
}
.fans {
margin-top: 15rpx;
font-weight: 500;
font-size: 22rpx;
color: #666666;
2023-09-20 18:16:59 +08:00
}
}
2023-09-25 09:27:16 +08:00
button {
display: flex;
justify-content: center;
align-items: center;
width: 113rpx;
height: 48rpx;
border-radius: 24rpx;
background-image: linear-gradient(-90deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
2023-09-20 18:16:59 +08:00
font-weight: 500;
font-size: 22rpx;
2023-09-25 09:27:16 +08:00
color: #ffffff;
.iconfont {
margin-right: 6rpx;
font-size: 22rpx;
}
}
.followed {
border: 1px solid #bfbfbf;
background: none;
color: #999999;
2023-09-20 18:16:59 +08:00
}
}
2023-09-25 09:27:16 +08:00
.wrap {
2023-09-20 18:16:59 +08:00
display: flex;
align-items: center;
2023-09-25 09:27:16 +08:00
padding: 32rpx 20rpx;
.name {
flex: 1;
min-width: 0;
font-weight: 400;
font-size: 28rpx;
color: #282828;
}
.score-wrap {
display: flex;
align-items: center;
font-weight: 500;
font-size: 28rpx;
color: var(--view-theme);
.star {
position: relative;
width: 111rpx;
height: 19rpx;
margin-right: 10rpx;
background: url(../../columnGoods/images/star.png) left top/100% 100% no-repeat;
overflow: hidden;
view {
position: absolute;
top: 0;
left: 0;
height: 100%;
background: url(../../columnGoods/images/star_active.png) left top/111rpx 19rpx no-repeat;
}
}
}
2023-09-20 18:16:59 +08:00
.iconfont {
2023-09-25 09:27:16 +08:00
font-size: 36rpx;
}
.icon-pingfen {
2023-09-20 18:16:59 +08:00
margin-right: 6rpx;
2023-09-25 09:27:16 +08:00
font-size: 23rpx;
color: #666666;
}
.active {
color: $theme-color;
2023-09-20 18:16:59 +08:00
}
}
2023-09-25 09:27:16 +08:00
.info {
.item {
display: flex;
align-items: center;
padding: 30rpx 20rpx;
font-weight: normal;
font-size: 28rpx;
line-height: 30rpx;
color: #282828;
.name {
margin-right: 18rpx;
}
.value {
flex: 1;
min-width: 0;
}
}
.very {
.name {
align-self: flex-start;
2023-09-20 18:16:59 +08:00
}
}
}
2023-09-25 09:27:16 +08:00
.popup-qrcode {
position: fixed;
top: 50%;
left: 50%;
z-index: 99;
width: 544rpx;
padding-top: 48rpx;
padding-bottom: 36rpx;
border-radius: 24rpx;
background-color: #ffffff;
transform: translate(-50%, -50%) scale(0);
opacity: 0;
transition: 0.3s;
line-height: 1;
text-align: center;
2023-09-20 18:16:59 +08:00
color: #282828;
2023-09-25 09:27:16 +08:00
2023-09-20 18:16:59 +08:00
.name {
2023-09-25 09:27:16 +08:00
max-width: 90%;
margin-right: auto;
margin-left: auto;
font-weight: bold;
font-size: 32rpx;
2023-09-20 18:16:59 +08:00
}
2023-09-25 09:27:16 +08:00
.info {
margin-top: 24rpx;
font-weight: 500;
font-size: 24rpx;
2023-09-20 18:16:59 +08:00
}
2023-09-25 09:27:16 +08:00
image {
width: 384rpx;
height: 384rpx;
margin-top: 18rpx;
2023-09-20 18:16:59 +08:00
}
}
2023-09-25 09:27:16 +08:00
.popup-active {
transform: translate(-50%, -50%) scale(1);
opacity: 1;
2023-09-20 18:16:59 +08:00
}
}
2023-09-25 09:27:16 +08:00
</style>