导游中台-游客端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

191 lines
4.4 KiB

<template></template>
<script>
import store from '@/store/index.js'; //需要引入store
export default {
name: "Base",
data() {
return {
}
},
methods: {
// 折扣显示
showDiscount(discount) {
if (discount && discount != 0) return (discount / 10).toFixed(1) + '折'
},
// 价格显示
showPrice(price) {
return (price && price != 0) ? (price / 100).toFixed(2) : '0.00'
},
// 返回上一页
goBack() {
getCurrentPages().length > 1 ? uni.navigateBack({}) : uni.switchTab({
url: '/pages/index/index'
})
},
// 手机号验证规则
mobileValid(val) {
return /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(val);
},
// 身份证验证规则
idNumberValid(val) {
return /^\d{17}(\d{1}|[X|x])$/.test(val);
},
// 护照验证正则
passportValid(val) {
return /^([a-zA-z]|[0-9]){5,17}$/.test(val);
},
// 台胞证正则
taiwanValid(val) {
return /^\d{8}|^[a-zA-Z0-9]{10}|^\d{18}$/.test(val);
},
// 港澳通行证正则
gangaoValid(val) {
return /^([A-Z]\d{6,10}(\(\w{1}\))?)$/.test(val);
},
// 外国人永久居留证正则
foreignerValid(val) {
return /(^[A-Za-z]{3})([0-9]{12}$)/.test(val);
},
// 军官证正则
officerValid(val) {
return /^[\u4E00-\u9FA5](字第)([0-9a-zA-Z]{4,8})(号?)$/.test(val);
},
// 邮箱验证正则
emailValid(val){
return /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(val)
},
// 拨打电话
clickPhone(phone) {
uni.makePhoneCall({
phoneNumber:phone
})
},
// 图片显示判断
showImg(img) {
if (img.indexOf('https://') != -1 || img.indexOf('http://') != -1) {
return img;
} else {
return this.NEWAPIURL + img;
}
},
// 路由页面跳转
gotoPath(path) {
uni.navigateTo({
url: path
})
},
// 获取经纬度
getLocation() {
uni.startLocationUpdate({
success: res => {
console.log(res)
uni.onLocationChange(data => {
console.log(data)
store.commit('changeLoationInfo', {
lat: data.latitude,
lon: data.longitude
})
})
}
})
},
// m转化为km
getDistance(distance){
return (distance / 1000).toFixed(2) + 'km'
},
// 打开地图
openLocation(lat,lon){
uni.openLocation({
latitude: Number(lat),
longitude: Number(lon),
success: function () {
console.log('success');
}
});
},
// 拨打电话
goPhone(phone){
uni.showModal({
title:'温馨提示',
content:`确定拨打电话?`,
success: res => {
if(res.confirm){
uni.makePhoneCall({
phoneNumber: phone, //仅为示例,并非真实的电话号码
success(){
console.log('拨打成功')
},
fail(){
console.log('拨打失败')
}
})
}else{
console.log('失败')
}
}
})
},
// 限时、新品、首页五大类详情跳转goods_tag_id,type_id
gotoDetails(item){
if(item.goods){
var ids = item.goods.goods_tag_id.split(',')
var type_id = item.goods.type_id
var id = item.goods.id
}else{
var ids = item.goods_tag_id.split(',')
var type_id = item.type_id
var id = item.id
}
if(ids.includes("2")){
// 酒店详情
uni.navigateTo({
url: '/subPackages1/hotel/hotelDetails?id='+id
});
}else if(ids.includes("16")){
// 民宿详情
}else if(type_id == 3){
// 美食详情
if(ids.includes("12")){
// 堂食
uni.navigateTo({
url: '/subPackages/details/eateryDetails?id='+id
});
}else if(ids.includes("6")){
// 邮寄
uni.navigateTo({
url: '/subPackages/details/goodDetails?type=1&id='+id
});
}else if(ids.includes("7")){
// 自提
uni.navigateTo({
url: '/subPackages/details/goodDetails?type=0&id='+id
});
}
}else if(type_id == 5){
// 文创特产详情
if(ids.includes("6")){
// 邮寄
uni.navigateTo({
url: '/subPackages/details/goodDetails?type=1&id='+id
});
}else if(ids.includes("7")){
// 自提
uni.navigateTo({
url: '/subPackages/details/goodDetails?type=0&id='+id
});
}
}else if(type_id == 1){
uni.navigateTo({
url: '/subPackages/details/scenicDetails?id='+id
});
}
}
}
}
</script>
<style scoped>
</style>