Compare commits

...

3 Commits

Author SHA1 Message Date
linyongLynn b7f898eede save
24 hours ago
linyongLynn 54c0c5e3b2 增加停车场预约功能
5 days ago
linyongLynn 8862b359e3 完成手机号+头像+昵称H5信息获取的改造
5 days ago

@ -9,8 +9,7 @@
onLaunch: function() {
var that = this;
util.getOpenidInfo(function(res) {
console.log(res);
console.log(res);
}, true);
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
@ -47,7 +46,7 @@
},
onHide: function() {
console.log('App Hide')
}
},
}
</script>
@ -98,4 +97,4 @@
.orderBoxInfoRowTxt {
font-size: 28rpx !important;
}
</style>
</style>

@ -86,6 +86,9 @@
"key" : ""
}
}
},
"router" : {
"base" : "h5"
}
}
}

@ -25,7 +25,7 @@
<view class="activityBox-row">
<text class="icon-renshu iconfont"></text>
<text>人数限制{{(list.form==2?10 : (numberlist.total==0?'不限':numberlist.total))}}</text>
<text>人数限制{{(list.form==2?10 : (numberlist.total==0?'不限':numberlist.total))}}</text>
</view>
<view class="activityBox-row flex-row align-center" @click="tothere">
@ -198,35 +198,41 @@
<u-picker :show="cardshow" @cancel="cancel" @confirm="confirmCard" ref="uPicker" :columns="cardLists"
keyName="label"></u-picker>
<u-picker :show="cardshows" @cancel="cancels" @confirm="confirmCards" ref="uPickers" :columns="cardLists"
keyName="label"></u-picker>
<u-popup :show="showInfo" mode="bottom" @close="closeInfo" :round="10" closeable>
<view class="mpopup" :style="[{height:maxheight}]">
<view class="mpopup-title">
{{currentNotice.title}}
</view>
<view class="mpopup-content" style="margin-top: 60rpx;">
<scroll-view scroll-y="true" :style="[{height:scrollheight}]">
<view class="htmls" style="line-height: 50rpx;text-indent: 2em;" v-html="currentNotice.content">
</view>
<view @click="downLoad" style="color:#cf995a ;">下载模版</view>
</scroll-view>
<view style="margin-top: 40rpx;"></view>
<u-button type="primary" @click="closeInfo"></u-button>
</view>
</view>
keyName="label"></u-picker>
<u-popup :show="showInfo" mode="bottom" @close="closeInfo" :round="10" closeable>
<view class="mpopup" :style="[{height:maxheight}]">
<view class="mpopup-title">
{{currentNotice.title}}
</view>
<view class="mpopup-content" style="margin-top: 60rpx;">
<scroll-view scroll-y="true" :style="[{height:scrollheight}]">
<view class="htmls" style="line-height: 50rpx;text-indent: 2em;" v-html="currentNotice.content">
</view>
<view @click="downLoad" style="color:#cf995a ;">下载模版</view>
</scroll-view>
<view style="margin-top: 40rpx;"></view>
<u-button type="primary" @click="closeInfo"></u-button>
</view>
</view>
</u-popup>
<u-popup :show="showAuthorization" closeable mode="bottom" @close="closePhone" :round="10">
<view class="box">
<view class="box-title" style="text-align: center;padding: 20rpx 0;font-size: 32rpx;">
请授权您的手机号
{{isH5 ? '请输入您的手机号' : '请授权您的手机号'}}
</view>
<view class="box-content" style="padding: 20px;">
<u-button type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<!-- H5环境手动输入手机号 -->
<view v-if="isH5">
<u-input v-model="inputMobile" placeholder="请输入手机号" type="number" maxlength="11"></u-input>
<u-button type="primary" @click="confirmMobile" style="margin-top: 20rpx;">确认</u-button>
</view>
<!-- 小程序环境微信授权 -->
<u-button v-else type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
</u-button>
</view>
</view>
@ -257,6 +263,8 @@
isEdit: false,
isEditIndex: 0,
showInfo: false,
isH5: false,
inputMobile: '',
list: {},
numberlist: {},
common_user: [],
@ -328,55 +336,58 @@
content: "<p>1.批量上传EXCEL的以xlsx结尾</p><p>2.第一列为标题列 姓名 手机号 证件号</p><p>3.文件是从微信聊天记录中选取或者微信文件传输助手</p><img src='@host@/export.png' style='width:100%'/>"
}]
}
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onLoad(options) {
this.type = options.type;
this.form.type = (options.type == 'user' ? 2 : 1);
this.form.activity_id = parseInt(options.activity_id);
this.form.activity_number_id = parseInt(options.activity_number_id);
},
onShow(){
var that = this;
that.numberlist={};
wx.getStorage({
key: 'activityinfo',
success(res) {
that.list = res.data;
for (var m of that.list.numbers) {
if (that.form.activity_number_id == m.id) {
that.numberlist = m
}
}
if (that.form.type == 2) {
that.form.total = 1
} else if (that.form.type == 1) {
that.form.total = 1;//res.data.team_min_count;
}
}
})
//
that.util.getOpenidInfo(function(res) {
//
that.util.getUserInfo(function(r) {
//
if (that.util.isNull(r.mobile)) {
that.showAuthorization = true;
} else {
that.showAuthorization = false;
that.form.mobile = r.mobile;
}
}, true);
that.loadCommonUser()
}, true);
//
this.isH5 = typeof window !== 'undefined' && window.location
},
onShow(){
var that = this;
that.numberlist={};
wx.getStorage({
key: 'activityinfo',
success(res) {
that.list = res.data;
for (var m of that.list.numbers) {
if (that.form.activity_number_id == m.id) {
that.numberlist = m
}
}
if (that.form.type == 2) {
that.form.total = 1
} else if (that.form.type == 1) {
that.form.total = 1;//res.data.team_min_count;
}
}
})
//
that.util.getOpenidInfo(function(res) {
//
that.util.getUserInfo(function(r) {
//
if (that.util.isNull(r.mobile)) {
that.showAuthorization = true;
} else {
that.showAuthorization = false;
that.form.mobile = r.mobile;
}
}, true);
that.loadCommonUser()
}, true);
},
onHide() {
clearInterval(this.t)
@ -387,35 +398,63 @@
clearInterval(this.t)
clearTimeout(this.timer)
},
methods: {
downLoad() {
const downloadTask = uni.downloadFile({
url: 'https://gbyuyue.szgmbwg.org.cn/Template.xlsx', //
success: (res) => {
var filePath = res.tempFilePath
if (res.statusCode === 200) {
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
console.log('打开文档成功')
}
})
}
}
});
downloadTask.onProgressUpdate((res) => {
console.log('下载进度' + res.progress);
console.log('已经下载的数据长度' + res.totalBytesWritten);
console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
});
methods: {
downLoad() {
const downloadTask = uni.downloadFile({
url: 'https://gbyuyue.szgmbwg.org.cn/Template.xlsx', //
success: (res) => {
var filePath = res.tempFilePath
if (res.statusCode === 200) {
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
console.log('打开文档成功')
}
})
}
}
});
downloadTask.onProgressUpdate((res) => {
console.log('下载进度' + res.progress);
console.log('已经下载的数据长度' + res.totalBytesWritten);
console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
});
},
closePhone() {
this.showAuthorization = false
},
// H5
confirmMobile() {
if (!this.inputMobile) {
uni.showToast({ title: '请输入手机号', icon: 'none' })
return
}
if (!/^1[3-9]\d{9}$/.test(this.inputMobile)) {
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
return
}
var that = this;
this.util.request({
api: '/api/mobile/user/save',
method: 'POST',
data: {
mobile: this.inputMobile
},
utilSuccess: function(res) {
that.form.mobile = that.inputMobile;
that.showAuthorization = false
},
utilFail: function(res) {
uni.showToast({ title: '手机号保存失败', icon: 'none' })
}
})
},
//
getPhoneNumber(e) {
var that = this;
this.util.request({
@ -709,25 +748,25 @@
}
}
</script>
<style scoped>
/deep/ .u-form-item__body__left__content__required{
left:0!important
}
/deep/ .u-form-item__body__left__content__label{
margin-left:20rpx;
}
<style scoped>
/deep/ .u-form-item__body__left__content__required{
left:0!important
}
/deep/ .u-form-item__body__left__content__label{
margin-left:20rpx;
}
</style>
<style lang="scss" scoped>
@import url("@/static/css/bookbox.css");
@import url("@/static/css/activitybox.css");
.tag{
height:auto;
max-width:40%
}
.book-box-row-timeitem{
font-size:30rpx;
border-radius: 10rpx;
.tag{
height:auto;
max-width:40%
}
.book-box-row-timeitem{
font-size:30rpx;
border-radius: 10rpx;
}
.box-visitor-item {
display: flex;

@ -1,8 +1,16 @@
<template>
<view>
<!-- 定位失败提示 -->
<view v-if="locationError" class="location-error">
<view class="location-error-content">
<text class="location-error-text">无法获取位置信息活动距离可能不准确</text>
<u-button size="mini" type="primary" @click="retryLocation" class="location-error-btn">重新定位</u-button>
</view>
</view>
<view class="listActivity">
<u-empty mode="list" text="暂无活动" marginTop="50" v-if="list.length==0&&!isloading"></u-empty>
<view class="activityBox" v-for="(item,index) in list" :key="index" @click="openInfo(item)">
<view class="activityBox" v-for="(item,index) in list" :key="index" @click="openInfo(item)">
<view :class="!item.isCanBook?'gray100':''"></view>
<view class="activityBox-top">
<image :src='item.cover_upload.url' style="width: 100%;height: 333rpx;"></image>
@ -34,16 +42,16 @@
<view style="display: inline-block;">
<text class="icon-shijian iconfont"></text>活动场次
</view>
<view style="display: flex;flex-direction: column;">
<block v-for="(k,index) in item.numbers">
<view v-if="index<2" class="tag tag_green activityBox_btn activityBox_time" style="margin-top: -5px;margin-bottom: 10px;">
<text style="margin-right:12rpx">
{{timeFormat(k.start_time,"MM月DD日")}}
</text>
<text>
{{getHm(k.start_time)}}-{{getHm(k.end_time)}}
</text>
</view>
<view style="display: flex;flex-direction: column;">
<block v-for="(k,index) in item.numbers">
<view v-if="index<2" class="tag tag_green activityBox_btn activityBox_time" style="margin-top: -5px;margin-bottom: 10px;">
<text style="margin-right:12rpx">
{{timeFormat(k.start_time,"MM月DD日")}}
</text>
<text>
{{getHm(k.start_time)}}-{{getHm(k.end_time)}}
</text>
</view>
</block>
</view>
@ -82,28 +90,120 @@
list: [],
latitude: "",
longitude: "",
isloading: true
isloading: true,
locationError: false //
}
},
onLoad() {
var that = this;
wx.getLocation({
success(res) {
console.log(res)
that.latitude = res.latitude;
that.longitude = res.longitude;
//
const isH5 = typeof window !== 'undefined' && window.location
if (isH5) {
// H5使API
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function(position) {
that.latitude = position.coords.latitude;
that.longitude = position.coords.longitude;
console.log('定位成功:', that.latitude, that.longitude);
that.loadActivity()
},
function(error) {
console.log('定位失败:', error);
that.locationError = true;
//
switch(error.code) {
case error.PERMISSION_DENIED:
console.log('用户拒绝了定位权限');
break;
case error.POSITION_UNAVAILABLE:
console.log('位置信息不可用');
break;
case error.TIMEOUT:
console.log('定位超时');
break;
default:
console.log('定位失败,未知错误');
break;
}
//
that.loadActivity()
},
{
enableHighAccuracy: true,
timeout: 15000, // 15
maximumAge: 300000 // 5
}
);
} else {
console.log('浏览器不支持定位');
uni.showToast({
title: '浏览器不支持定位功能',
icon: 'none'
});
that.loadActivity()
}
})
} else {
// 使wx.getLocation
wx.getLocation({
success(res) {
console.log(res)
that.latitude = res.latitude;
that.longitude = res.longitude;
that.loadActivity()
},
fail(err) {
console.log('定位失败:', err);
that.loadActivity()
}
})
}
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
methods: {
//
retryLocation() {
this.locationError = false;
this.latitude = "";
this.longitude = "";
const isH5 = typeof window !== 'undefined' && window.location;
var that = this;
if (isH5 && navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function(position) {
that.latitude = position.coords.latitude;
that.longitude = position.coords.longitude;
console.log('重新定位成功:', that.latitude, that.longitude);
that.loadActivity();
},
function(error) {
console.log('重新定位失败:', error);
that.locationError = true;
uni.showToast({
title: '定位失败,请检查浏览器定位权限',
icon: 'none',
duration: 3000
});
},
{
enableHighAccuracy: true,
timeout: 15000,
maximumAge: 0 // 使
}
);
}
},
tothere(item) {
uni.openLocation({
latitude: parseFloat(item.latitude),
@ -119,17 +219,25 @@
})
},
loadActivity() {
console.log("aaa")
console.log("加载活动列表")
var that = this;
var nt = new Date();
that.isloading = true;
//
var requestData = {
page_size: 100
};
//
if (that.latitude && that.longitude) {
requestData.latitude = that.latitude;
requestData.longitude = that.longitude;
}
this.util.request({
api: '/api/mobile/activity/index',
data: {
latitude: that.latitude,
longitude: that.longitude,
page_size: 100
},
data: requestData,
utilSuccess: function(res) {
for (var mod of res.data) {
mod.isCanBook = that.$moment(nt).isBefore(mod.end_plan);
@ -138,7 +246,7 @@
that.isloading = false;
},
utilFail: function(res) {
that.isloading = false;
}
})
},
@ -166,32 +274,32 @@
page {
background-color: #f7f6f4;
}
.activityBox{
position: relative;
}
.activityBox-title {
font-size: 32rpx;
}
.activityBox-row{
font-size: 28rpx;
}
.activityBox-top{
font-size: 0;
}
.gray100{
width:100%;
height:333rpx;
position: absolute;
top:0;
left:0;
background-color: rgba(0,0,0,0.5);
z-index:999;
/* opacity: 50%;
filter: grayscale(100%);
opacity: 50%;
-webkit-filter: blackscale(100%);
filter: brightness(0.2); */
.activityBox{
position: relative;
}
.activityBox-title {
font-size: 32rpx;
}
.activityBox-row{
font-size: 28rpx;
}
.activityBox-top{
font-size: 0;
}
.gray100{
width:100%;
height:333rpx;
position: absolute;
top:0;
left:0;
background-color: rgba(0,0,0,0.5);
z-index:999;
/* opacity: 50%;
filter: grayscale(100%);
opacity: 50%;
-webkit-filter: blackscale(100%);
filter: brightness(0.2); */
}
.activityBox_time {
/* height: 70rpx; */
@ -201,16 +309,46 @@
background: #FCF6E3;
border: 2rpx solid #cf995a;
border-radius: 20rpx;
color: #4E4E4E;
color: #4E4E4E;
margin-right: 10rpx;
}
.activityMore{
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 400;
display: flex;
color: #cf995a;
flex-direction: column-reverse;
margin-left:10rpx
}
</style>
.activityMore{
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 400;
display: flex;
color: #cf995a;
flex-direction: column-reverse;
margin-left:10rpx
}
.location-error {
background-color: #fff3cd;
border: 1px solid #ffeaa7;
border-radius: 8rpx;
margin: 20rpx;
padding: 20rpx;
}
.location-error-content {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
color: #856404;
flex-wrap: wrap;
gap: 20rpx;
}
.location-error-text {
flex: 1;
min-width: 0;
word-wrap: break-word;
line-height: 1.4;
}
.location-error-btn {
flex-shrink: 0;
white-space: nowrap;
}
</style>

@ -2,14 +2,115 @@
<view>
<view class="page-body">
<view class="page-section page-section-gap">
<map id='map' ref='map' style="width: 100%; height: 100vh;position: relative;" :latitude="latitude"
:longitude="longitude" :markers="covers">
<!-- <cover-view slot='callout' style='position: relative;'>
<cover-view style='height:200px'>
<cover-image style="position: absolute;width:70px;height:70px" :src='covers[0].iconPath' :animation='animationData'>
</cover-image>
</cover-view>
<!-- H5环境嵌入iframe地图 -->
<view v-if="isH5" class="h5-map-container">
<iframe
:src="getMapUrl()"
width="100%"
height="100vh"
frameborder="0"
class="h5-map-iframe">
</iframe>
<!-- H5环境覆盖在地图上的UI内容 -->
<view class="book-box">
<view class="activityBox-content flex-col">
<view class="activityBox-row" style="margin-bottom: 56rpx;">
<text class="activityBox-title">{{info.name||""}}</text>
</view>
<view class="activityBox-row">
<text class="icon-shijian iconfont"></text>
<text>可入场时间段{{info.start_time||""}}-{{info.end_time||""}}</text>
</view>
<view class="activityBox-row">
<text class="icon-huodong iconfont"></text>
<text>地址{{info.address||""}}</text>
</view>
<view class="activityBox-row flex-row align-center" style="margin-bottom: 0rpx;"
@click="openlocation">
<text class="icon-ditu-dibiao iconfont"></text>
<text>距离{{distance||"0"}}km</text>
<view class="tomap">
<text class="icon-daohang1 iconfont" style="margin-right: 0;"></text>
</view>
</view>
<view class="parkbox">
<view class="parkbox-title">可预约车位</view>
<view class="parkbox-content flex-row justify-around">
<view class="parkbox-item flex-row align-center"
style="margin-right: 10rpx;padding: 28rpx 20rpx;" @click="handleSelectPark(2)"
:class="(currentPark==2?'parkbox-item-on':'')" v-if="remain_big_park>0">
<view class="parkbox-item-status" v-if="currentPark==2">
<u-icon name="checkmark" color="#fff" size="20rpx"></u-icon>
</view>
<text class="iconfont icon-tingchechang1" style="font-size: 28rpx;"></text>
<view>
<text>大中(09:00-12:00){{remain_big_park}}</text>
</view>
</view>
<view class="parkbox-item flex-col align-center"
:class="(currentPark==1?'parkbox-item-on':'')" @click="handleSelectPark(1)"
style="margin-right: 10rpx;" v-if="remain_small_park>0">
<view class="parkbox-item-status" v-if="currentPark==1">
<u-icon name="checkmark" color="#fff" size="20rpx"></u-icon>
</view>
<view class="flex-row align-center">
<text class="iconfont icon-tingchechang1"
style="font-size: 28rpx;"></text><text>小车{{remain_small_park}}</text>
</view>
<text style="font-size: 24rpx;color: #828282;">可预约车位{{remain_small_park}}</text>
</view>
<view class="parkbox-item flex-row align-center"
style="margin-right: 10rpx;padding: 28rpx 20rpx;" @click="handleSelectPark(4)"
:class="(currentPark==4?'parkbox-item-on':'')" v-if="remain_big_park2>0">
<view class="parkbox-item-status" v-if="currentPark==4">
<u-icon name="checkmark" color="#fff" size="20rpx"></u-icon>
</view>
<text class="iconfont icon-tingchechang1" style="font-size: 28rpx;"></text>
<view>
<text>大中(13:00-16:00){{remain_big_park2}}</text>
</view>
</view>
<view class="parkbox-item flex-row align-center" style=""
@click="handleSelectPark(3)" :class="(currentPark==3?'parkbox-item-on':'')"
v-if="remain_special_park>0">
<view class="parkbox-item-status" v-if="currentPark==3">
<u-icon name="checkmark" color="#fff" size="20rpx"></u-icon>
</view>
<text class="iconfont icon-tingchechang1" style="font-size: 28rpx;"></text>
<view>
<text>残疾人车位{{remain_special_park}}</text>
</view>
</view>
<view class="parkbox-item flex-row align-center" style=""
v-if="remain_special_park<=0&&remain_big_park<=0&&remain_small_park<=0">
<text class="iconfont icon-tingchechang1" style="font-size: 28rpx;"></text>
<view>
<text>暂无可选停车位</text>
</view>
</view>
</view>
</view>
<view class="activityBox-row" style="margin-top: 20rpx;color: #cf995a;"
@click="openselectorder">
<text>选择信息{{selectInfo.info||"暂未选择"}}</text>
</view>
</view>
</view>
<view class="footer">
<u-button type="primary" :disabled="btnDisabled" @click="tobook"></u-button>
</view>
</view>
<!-- 小程序环境使用uni-app地图组件 -->
<map v-else id='map' ref='map' style="width: 100%; height: 100vh;position: relative;" :latitude="latitude"
:longitude="longitude" :markers="covers">
<!-- <cover-view slot='callout' style='position: relative;'>
<cover-view style='height:200px'>
<cover-image style="position: absolute;width:70px;height:70px" :src='covers[0].iconPath' :animation='animationData'>
</cover-image>
</cover-view>
</cover-view> -->
<view class="book-box">
<view class="activityBox-content flex-col">
@ -95,7 +196,7 @@
</view>
<view class="activityBox-row" style="margin-top: 20rpx;color: #cf995a;"
@click="showSelectorder=false">
@click="openselectorder">
<text>选择信息{{selectInfo.info||"暂未选择"}}</text>
</view>
</view>
@ -167,7 +268,7 @@
distance: 0,
info: {},
covers: [{
latitude: 31.297241,
latitude: 31.297241,
longitude: 120.580792,
width: 30,
height: 30,
@ -189,48 +290,86 @@
remain_big_park: 0,
remain_small_park: 0,
remain_special_park: 0,
remain_big_park2: 0,
animationData:null
remain_big_park2: 0,
animationData: null,
isH5: false
}
},
onshow(){
var animation = uni.createAnimation({
duration:200,
timingFunction:'linear'
})
var next = true
setInterval(()=>{
if(next){
animation.translateY(-2).step()
}else{
animation.translateY(0).step()
}
next = !next
this.animationData = animation.export()
},800)
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onshow(){
var animation = uni.createAnimation({
duration:200,
timingFunction:'linear'
})
var next = true
setInterval(()=>{
if(next){
animation.translateY(-2).step()
}else{
animation.translateY(0).step()
}
next = !next
this.animationData = animation.export()
},800)
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onLoad() {
var that = this;
let map = uni.createMapContext('map');
map.setCenterOffset({
offset: [0.5, 0.25]
})
wx.getLocation({
success(res) {
that.userlatitude = res.latitude;
that.userlongitude = res.longitude;
//
this.isH5 = typeof window !== 'undefined' && window.location
//
if (this.isH5) {
// H5使API
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function(position) {
that.userlatitude = position.coords.latitude;
that.userlongitude = position.coords.longitude;
console.log('H5定位成功:', that.userlatitude, that.userlongitude);
that.loadOrder(function(res) {
that.loadactivityOrder(function(r) {
if (res.length + r.length == 0) {
that.btnDisabled = true;
} else {
that.btnDisabled = true;
that.showSelectorder = false;
}
})
});
},
function(error) {
console.log('H5定位失败:', error);
// 使
that.loadOrder(function(res) {
that.loadactivityOrder(function(r) {
if (res.length + r.length == 0) {
that.btnDisabled = true;
} else {
that.btnDisabled = true;
that.showSelectorder = false;
}
})
});
},
{
enableHighAccuracy: true,
timeout: 15000,
maximumAge: 300000
}
);
} else {
console.log('浏览器不支持定位');
// 使
that.loadOrder(function(res) {
that.loadactivityOrder(function(r) {
if (res.length + r.length == 0) {
// that.util.toast("");
that.btnDisabled = true;
} else {
that.btnDisabled = true;
@ -239,10 +378,59 @@
})
});
}
})
} else {
// 使wx.getLocation
wx.getLocation({
success(res) {
that.userlatitude = res.latitude;
that.userlongitude = res.longitude;
console.log('小程序定位成功:', that.userlatitude, that.userlongitude);
that.loadOrder(function(res) {
that.loadactivityOrder(function(r) {
if (res.length + r.length == 0) {
that.btnDisabled = true;
} else {
that.btnDisabled = true;
that.showSelectorder = false;
}
})
});
},
fail(err) {
console.log('小程序定位失败:', err);
// 使
that.loadOrder(function(res) {
that.loadactivityOrder(function(r) {
if (res.length + r.length == 0) {
that.btnDisabled = true;
} else {
that.btnDisabled = true;
that.showSelectorder = false;
}
})
});
}
})
}
},
methods: {
// H5URL
getMapUrl() {
console.log('getMapUrl - info:', this.info);
console.log('getMapUrl - latitude:', this.info.latitude);
console.log('getMapUrl - longitude:', this.info.longitude);
if (this.info.latitude && this.info.longitude) {
// 使
const url = `https://apis.map.qq.com/uri/v1/marker?marker=coord:${this.info.latitude},${this.info.longitude};title:${encodeURIComponent(this.info.name || '停车场')};addr:${encodeURIComponent(this.info.address || '')}&referer=myapp`;
console.log('使用真实坐标:', url);
return url;
}
// 使
console.log('使用默认坐标');
return 'https://apis.map.qq.com/uri/v1/marker?marker=coord:31.297241,120.580792;title:苏州革命博物馆停车场;addr:苏州市姑苏区&referer=myapp';
},
handleConfirmOrder() {
if (this.selectInfo.orderid === 0) {
this.util.toast("请选择预约的活动或者预约的参观");
@ -313,8 +501,8 @@
},
utilSuccess: function(res) {
for (var mod of res) {
mod.checked = false;
mod.active_start_time = mod.number[0]['start_time']
mod.checked = false;
mod.active_start_time = mod.number[0]['start_time']
mod.active_end_time = mod.number[0]['end_time']
}
that.listActivtyOrder = res;
@ -330,12 +518,31 @@
this.currentPark = type;
},
openlocation() {
uni.openLocation({
latitude: this.info.latitude,
longitude: this.info.longitude,
name: this.info.name,
address: this.info.address
});
if (this.isH5) {
// H5使JS-SDK
if (typeof wx !== 'undefined' && wx.openLocation) {
// JS-SDK
wx.openLocation({
latitude: this.info.latitude,
longitude: this.info.longitude,
name: this.info.name,
address: this.info.address,
scale: 14
});
} else {
// 使
const mapUrl = `https://apis.map.qq.com/uri/v1/marker?marker=coord:${this.info.latitude},${this.info.longitude};title:${encodeURIComponent(this.info.name)};addr:${encodeURIComponent(this.info.address)}&referer=myapp`;
window.open(mapUrl, '_blank');
}
} else {
// 使uni.openLocation
uni.openLocation({
latitude: this.info.latitude,
longitude: this.info.longitude,
name: this.info.name,
address: this.info.address
});
}
},
loadInfo() {
var that = this;
@ -363,7 +570,7 @@
height: 30,
iconPath: '/static/img/location.png',
id: 1
}
}
that.covers = []
that.covers.push(mod);
let map = uni.createMapContext('map');
@ -441,7 +648,7 @@
font-size: 26rpx;
color: #cf995a;
box-sizing: border-box;
}
}
.book-box {
height: 60%;
@ -470,4 +677,30 @@
box-shadow: 2rpx 3rpx 10rpx 0rpx rgba(107, 94, 77, 0.3);
padding: 21rpx 25rpx;
}
/* H5地图iframe容器样式 */
.h5-map-container {
width: 100%;
height: 100vh;
position: relative;
background: #f5f5f5;
}
.h5-map-iframe {
width: 100%;
height: 100%;
border: none;
display: block;
}
.map-loading {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background: #f5f5f5;
color: #666;
font-size: 28rpx;
}
</style>

@ -27,7 +27,7 @@
<view :class="showBook?'relic_active':''" @click="changeBook('book')"></view>
</view>
<view class="books" v-if="showBook">
<image class="books_img" src="../../static/book/book_bottom.png" mode=""></image>
<image class="books_img" :src="isH5 ? '/h5/static/book/book_bottom.png' : '../../static/book/book_bottom.png'" mode=""></image>
<u-swiper @click="toBook" :list="bookList" :displayMultipleItems="displayMultipleItems" :circular="true"
:indicator="true" indicatorStyle="bottom" indicatorMode="dot" bgColor="transparent"
indicatorActiveColor="#9f4946" indicatorInactiveColor="#9f4946" :autoplay="false"
@ -55,7 +55,7 @@
</swiper>
<view class="myswiper-item-title">
<view class="">
{{relicList[relicIndex].name?relicList[relicIndex].name:''}}
{{relicList[relicIndex] && relicList[relicIndex].name ? relicList[relicIndex].name : ''}}
</view>
<!-- <view class="">
革命博物馆典藏
@ -108,28 +108,42 @@
exhibitList: [],
bookList: [],
relicList: [],
bgimg: '../../static/book/relic_bg.png',
bgimg: '',
padTop: 0,
showBook: false,
relicIndex: 0,
displayMultipleItems: 0,
authToken: ''
authToken: '',
isH5: false
}
},
onLoad() {
const MenuButton = uni.getMenuButtonBoundingClientRect()
this.padTop = MenuButton.top + MenuButton.height + 10
// H5
const isH5 = typeof window !== 'undefined' && window.location
this.isH5 = isH5
if (isH5) {
// H5使
this.padTop = 80 // H5
this.bgimg = '/h5/static/book/relic_bg.png' // H5使
} else {
// 使getMenuButtonBoundingClientRect
const MenuButton = uni.getMenuButtonBoundingClientRect()
this.padTop = MenuButton.top + MenuButton.height + 10
this.bgimg = '../../static/book/relic_bg.png' // 使
}
this.authToken = uni.getStorageSync('userInfo_token').token
this.getExhibit()
this.getRelic()
this.getBooks()
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
methods: {
cancelTime(str) {
@ -148,10 +162,12 @@
changeBook(e) {
if (e === 'book') {
this.showBook = true
this.bgimg = '../../static/book/book_bg.png'
//
this.bgimg = this.isH5 ? '/h5/static/book/book_bg.png' : '../../static/book/book_bg.png'
} else {
this.showBook = false
this.bgimg = '../../static/book/relic_bg.png'
//
this.bgimg = this.isH5 ? '/h5/static/book/relic_bg.png' : '../../static/book/relic_bg.png'
}
},
toRelicDetail(id) {
@ -199,7 +215,11 @@
},
changeRelic(e) {
console.log(e)
this.relicIndex = e.detail.current
const newIndex = e.detail.current
//
if (newIndex >= 0 && newIndex < this.relicList.length) {
this.relicIndex = newIndex
}
},
getRelic() {
var that = this;
@ -215,6 +235,10 @@
that.relicList = res.data.filter(item => {
return item.show_list === 1
})
// relicIndex
if (that.relicList.length > 0 && that.relicIndex >= that.relicList.length) {
that.relicIndex = 0
}
},
utilFail: function(res) {
@ -227,9 +251,9 @@
api: '/api/mobile/book/index',
data: {
page: 1,
page_size: 99,
sort_name:"datetime",
sort_type:'ASC'
page_size: 99,
sort_name:"datetime",
sort_type:'ASC'
},
utilSuccess: function(res) {
@ -372,7 +396,7 @@
}
.relic .relic_active {
background: url(../../static/book/current.png) no-repeat left top;
background: url(/h5/static/book/current.png) no-repeat left top;
background-size: 100% 100%;
border: 1px solid transparent;
color: #fff;
@ -408,18 +432,18 @@
.books .u-swiper__wrapper__item__wrapper::before {
content: "";
content: "";
position: absolute;
left: 22%;
bottom: 115rpx;
width: 30rpx;
height: 40rpx;
z-index: -1;
background-color: transparent;
/* margin: 50px; */
box-shadow: 30rpx 10rpx 20rpx rgba(0, 0, 0, 0.3);
transform: translateY(4px) translateX(24rpx) scale(1, 0.9) translateZ(19px) rotate(132deg);
transform-style: preserve-3d;
content: "";
position: absolute;
left: 22%;
bottom: 115rpx;
width: 30rpx;
height: 40rpx;
z-index: -1;
background-color: transparent;
/* margin: 50px; */
box-shadow: 30rpx 10rpx 20rpx rgba(0, 0, 0, 0.3);
transform: translateY(4px) translateX(24rpx) scale(1, 0.9) translateZ(19px) rotate(132deg);
transform-style: preserve-3d;
perspective: 2000rpx;
/* background: hsl(48, 100%, 20%);

@ -15,9 +15,9 @@
<image src="../../static/img/index_bg.jpg" class="index_bg"></image>
</view>
<view class="box-body">
<view class="box-notice">
<u-notice-bar @click="openInfo" :text="list" direction="column" color="#cf995a"></u-notice-bar>
<view class="box-body">
<view class="box-notice">
<u-notice-bar @click="openInfo" :text="list" direction="column" color="#cf995a"></u-notice-bar>
</view>
<view>
<view class="box-row">
@ -40,40 +40,40 @@
</u-row>
</view>
</view>
</view>
<!-- 展厅导览 -->
<view class="box-bottom" style="padding-bottom:0" @click='toDl'>
<view class="exhibit">
<view>
<view>
<span></span>
<span>展厅导览</span>
</view>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<view class="exhibit_list">
<img :src="dlimg" alt="" style="height:300rpx">
<span>2F 平面图</span>
</view>
</view>
<view class="box-bottom" style="padding-top:0">
<!-- 当前展览 -->
<view class="exhibit">
<view @click='toExhibitList'>
<view>
<span></span>
<span>当前展览</span>
</view>
<u-icon name="arrow-right"></u-icon>
</view>
<view class="exhibit_list" v-for="item in exhibitList" @click='todetail(item.id)'>
<img :src="item.head_upload.url" alt="">
<span>{{item.name}}</span>
</view>
</view>
</view>
</view>
<!-- 展厅导览 -->
<view class="box-bottom" style="padding-bottom:0" @click='toDl'>
<view class="exhibit">
<view>
<view>
<span></span>
<span>展厅导览</span>
</view>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<view class="exhibit_list">
<img :src="dlimg" alt="" style="height:300rpx">
<span>2F 平面图</span>
</view>
</view>
<view class="box-bottom" style="padding-top:0">
<!-- 当前展览 -->
<view class="exhibit">
<view @click='toExhibitList'>
<view>
<span></span>
<span>当前展览</span>
</view>
<u-icon name="arrow-right"></u-icon>
</view>
<view class="exhibit_list" v-for="item in exhibitList" @click='todetail(item.id)'>
<img :src="item.head_upload.url" alt="">
<span>{{item.name}}</span>
</view>
</view>
</view>
<!-- 参观预约 -->
<u-popup :show="showBook" mode="bottom" @close="closeBook" :round="10" closeable>
<view class="mpopup">
@ -171,44 +171,50 @@
<u-calendar ref="calendar" :show-confirm="false" :show="showCalendar" :minDate="minDate" :maxDate="maxDate"
color="#cf995a" round="20" defaultDate="2022-02-15" @confirm="handleSelectDate" @close="closecalendar">
</u-calendar>
<u-popup :show="showAuthorization" closeable mode="bottom" @close="closePhone" :round="10">
<view class="box">
<view class="box-title" style="text-align: center;padding: 20rpx 0;font-size: 32rpx;">
请授权您的手机号
{{isH5 ? '请输入您的手机号' : '请授权您的手机号'}}
</view>
<view class="box-content" style="padding: 20px;">
<u-button type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<!-- H5环境手动输入手机号 -->
<view v-if="isH5">
<u-input v-model="inputMobile" placeholder="请输入手机号" type="number" maxlength="11"></u-input>
<u-button type="primary" @click="confirmMobile" style="margin-top: 20rpx;">确认</u-button>
</view>
<!-- 小程序环境微信授权 -->
<u-button v-else type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
</u-button>
</view>
</view>
</u-popup>
<u-popup :show="showInfo" mode="center" @close="closeInfo" :round="10" closeable :customStyle="{margin:'40rpx'}">
<view class="mpopup">
<view class="mpopup-title">
{{currentNotice.name}}
</view>
<view class="mpopup-content" style="padding: 40rpx;">
<view v-html="currentNotice.content" style="font-size:28rpx;line-height: 2.3;text-indent: 2em;">
</view>
</view>
</view>
</u-popup>
<u-popup :show="showInfo" mode="center" @close="closeInfo" :round="10" closeable :customStyle="{margin:'40rpx'}">
<view class="mpopup">
<view class="mpopup-title">
{{currentNotice.name}}
</view>
<view class="mpopup-content" style="padding: 40rpx;">
<view v-html="currentNotice.content" style="font-size:28rpx;line-height: 2.3;text-indent: 2em;">
</view>
</view>
</view>
</u-popup>
</view>
</view>
<tabbar :current-page="0"></tabbar>
</view>
</template>
<script>
<script>
import tabbar from "../../components/tabbar/tabbar.vue"
export default {
components:{
tabbar
export default {
components:{
tabbar
},
data() {
const d = new Date()
@ -218,17 +224,17 @@
const date = d.getDate()
return {
//
statusBarHeight: 0,
navBarBoxHeight:0,
statusBarHeight: 0,
navBarBoxHeight:0,
exhibitList:[],
showBook: false,
minDate: `${year}-${month}-${date + 1}`,
maxDate: `${year}-${month}-${date + 7}`,
showCalendar: false,
info: {},
list: ["暂无通知通告"],
listNotice: [],
currentNotice: {},
info: {},
list: ["暂无通知通告"],
listNotice: [],
currentNotice: {},
showInfo: false,
listDatePrice: [],
currentDate: {},
@ -236,24 +242,30 @@
currentIndex: 0,
listCalendar: [],
showAuthorization: false,
openType: 1,
dlimg:require("../../static/img/daolan.png")
openType: 1,
dlimg:require("../../static/img/daolan.png"),
isH5: false,
inputMobile: ''
}
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onLoad() {
//
this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
this.navBarBoxHeight = 80 + this.statusBarHeight*2
this.loadInfo();
this.loadNotice();
this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
this.navBarBoxHeight = 80 + this.statusBarHeight*2
//
this.isH5 = typeof window !== 'undefined' && window.location
this.loadInfo();
this.loadNotice();
this.getExhibit()
},
onReady() {
@ -263,16 +275,16 @@
onHide() {
this.showBook = false;
},
methods: {
toExhibitList(){
uni.navigateTo({
url: "/pages/exhibit/list"
});
},
toDl(){
uni.navigateTo({
url: "/packages/dl/index"
});
methods: {
toExhibitList(){
uni.navigateTo({
url: "/pages/exhibit/list"
});
},
toDl(){
uni.navigateTo({
url: "/packages/dl/index"
});
},
togame() {
uni.navigateToMiniProgram({
@ -281,39 +293,69 @@
//
}
})
},
openInfo(e) {
this.currentNotice = this.listNotice[e];
this.currentNotice.content = this.currentNotice.content.replace(/\<p/gi, "<p class='richp'");
this.showInfo = true;
},
closeInfo() {
this.showInfo = false;
},
loadNotice() {
var that = this;
this.util.request({
api: '/api/mobile/other/notice-index',
utilSuccess: function(res) {
if(res.data.length>0){
let arr = [];
for (var m of res.data) {
arr.push(m.name)
}
that.listNotice = res.data;
that.list = arr;
}
},
utilFail: function(res) {
}
})
},
openInfo(e) {
this.currentNotice = this.listNotice[e];
this.currentNotice.content = this.currentNotice.content.replace(/\<p/gi, "<p class='richp'");
this.showInfo = true;
},
closeInfo() {
this.showInfo = false;
},
loadNotice() {
var that = this;
this.util.request({
api: '/api/mobile/other/notice-index',
utilSuccess: function(res) {
if(res.data.length>0){
let arr = [];
for (var m of res.data) {
arr.push(m.name)
}
that.listNotice = res.data;
that.list = arr;
}
},
utilFail: function(res) {
}
})
},
closePhone() {
this.showAuthorization = false
},
// H5
confirmMobile() {
if (!this.inputMobile) {
uni.showToast({ title: '请输入手机号', icon: 'none' })
return
}
if (!/^1[3-9]\d{9}$/.test(this.inputMobile)) {
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
return
}
var that = this;
this.util.request({
api: '/api/mobile/user/save',
method: 'POST',
data: {
mobile: this.inputMobile
},
utilSuccess: function(res) {
that.showAuthorization = false
that.util.getUserInfo(function(r) {
that.checkUser();
}, true)
},
utilFail: function(res) {
uni.showToast({ title: '手机号保存失败', icon: 'none' })
}
})
},
//
getPhoneNumber(e) {
var that = this;
this.util.request({
@ -509,33 +551,33 @@
}
})
},
//
todetail(id){
uni.navigateTo({
url: "/pages/exhibit/detail?id="+id
});
},
getExhibit(){
var that = this;
this.util.request({
api: '/api/mobile/exhibit-hall/index',
data:{
page:1,
page_size:2,
state:1,
sort_name:'state',
sort_name_tow:'release_time',
sort_type:"DESC",
sort_type_tow:'DESC'
},
utilSuccess: function(res) {
that.exhibitList = res.data
},
utilFail: function(res) {
}
})
},
//
todetail(id){
uni.navigateTo({
url: "/pages/exhibit/detail?id="+id
});
},
getExhibit(){
var that = this;
this.util.request({
api: '/api/mobile/exhibit-hall/index',
data:{
page:1,
page_size:2,
state:1,
sort_name:'state',
sort_name_tow:'release_time',
sort_type:"DESC",
sort_type_tow:'DESC'
},
utilSuccess: function(res) {
that.exhibitList = res.data
},
utilFail: function(res) {
}
})
},
load3Day(sdate, callbak) { //7
var that = this;
@ -623,15 +665,15 @@
<style>
@import url("@/static/css/bookbox.css");
.wrap{
background-color: #cf995a;
.wrap{
background-color: #cf995a;
}
.navBarBox {
position: fixed;
top:0;
left:0;
width:100%;
z-index:999;
.navBarBox {
position: fixed;
top:0;
left:0;
width:100%;
z-index:999;
background: linear-gradient(to bottom,#f6d593,#cf995a);
}
@ -640,7 +682,7 @@
.navBarBox .navBar {
padding: 20rpx 50rpx;
padding-left: 30rpx;
text-align: left;
text-align: left;
height:80rpx;
/* display: flex;
flex-direction: row;
@ -664,10 +706,10 @@
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding-bottom:120rpx;
min-height:100vh;
background-color: #fff;
justify-content: center;
padding-bottom:120rpx;
min-height:100vh;
background-color: #fff;
/* padding-top:190rpx; */
}
@ -683,18 +725,18 @@
.u-notice-bar {
border-top-left-radius: 15rpx !important;
border-top-right-radius: 15rpx !important;
border-top-right-radius: 15rpx !important;
background-color: ##fbf3ea !important;
}
.box-body {
width: 100%;
padding: 40rpx 0;
background-color: #f6f6f6;
background-color: #f6f6f6;
padding-top:0
}
.box-notice{
margin-bottom:40rpx;
.box-notice{
margin-bottom:40rpx;
}
.box-row {
display: flex;
@ -712,60 +754,60 @@
}
.box-body-title {
margin-top: 10rpx;
font-size:28rpx;
margin-top: 10rpx;
font-size:28rpx;
}
.box-bottom{
background-color: #fff;
padding:50rpx 30rpx;
padding-top:35rpx;
width:100%;
/* padding-bottom: 0;
min-height: 41vh; */
}
.exhibit{
}
.box-bottom{
background-color: #fff;
padding:50rpx 30rpx;
padding-top:35rpx;
width:100%;
/* padding-bottom: 0;
min-height: 41vh; */
}
.exhibit{
}
.exhibit>view:first-child{
display: flex;
justify-content: space-between;
font-size: 36rpx;
}
.exhibit>view:first-child span:first-child{
background-color: #DEA166;
width:5rpx;
height:50rpx;
margin-right:22rpx;
display: inline-block;
vertical-align: text-top;
}
.exhibit_list{
position: relative;
margin-top:35rpx;
margin-bottom:35rpx;
font-size: 0;
}
.exhibit_list img{
width:100%;
height:410rpx;
border-radius: 20rpx;
}
.exhibit_list span{
display: inline-block;
width:100%;
box-sizing: border-box;
border-radius:0 0 20rpx 20rpx;
position: absolute;
bottom:0;
left:0;
color:#fff;
font-size: 32rpx;
padding:20rpx 32rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
background: linear-gradient(to bottom,rgba(255,255,255,0),rgba(0,0,0,0.5));
.exhibit>view:first-child{
display: flex;
justify-content: space-between;
font-size: 36rpx;
}
.exhibit>view:first-child span:first-child{
background-color: #DEA166;
width:5rpx;
height:50rpx;
margin-right:22rpx;
display: inline-block;
vertical-align: text-top;
}
.exhibit_list{
position: relative;
margin-top:35rpx;
margin-bottom:35rpx;
font-size: 0;
}
.exhibit_list img{
width:100%;
height:410rpx;
border-radius: 20rpx;
}
.exhibit_list span{
display: inline-block;
width:100%;
box-sizing: border-box;
border-radius:0 0 20rpx 20rpx;
position: absolute;
bottom:0;
left:0;
color:#fff;
font-size: 32rpx;
padding:20rpx 32rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
background: linear-gradient(to bottom,rgba(255,255,255,0),rgba(0,0,0,0.5));
}
.footer-img {
width: 421rpx;
@ -774,15 +816,15 @@
.richp {
margin-bottom: 10rpx;
}
.book-box-row-timeitem {
display: flex;
align-items: center;
flex-wrap: wrap;
width: 32%;
padding: 19rpx 21rpx!important;
}
.book-box-row-timeitem-txt {
width:100%
}
.book-box-row-timeitem {
display: flex;
align-items: center;
flex-wrap: wrap;
width: 32%;
padding: 19rpx 21rpx!important;
}
.book-box-row-timeitem-txt {
width:100%
}
</style>

@ -66,15 +66,32 @@
<u-popup :show="showAuthorization" mode="bottom" @close="closeInfo" :round="10">
<view class="box">
<view class="box-title" style="text-align: center;padding: 20rpx 0;font-size: 32rpx;">
请授权您的微信头像和昵称
{{isH5 ? '请完善您的个人信息' : '请授权您的微信头像和昵称'}}
</view>
<view class="box-content" style="padding: 20px;">
<u-button type="primary" @click="getUserProfile"></u-button>
<!-- H5环境直接显示编辑表单 -->
<view v-if="isH5">
<u-form labelPosition="top" :model="form">
<u-form-item label="昵称" prop="name" labelWidth="60px" required>
<u-input v-model="form.name" placeholder="请输入昵称"></u-input>
</u-form-item>
<u-form-item label="头像" prop="avatar" labelWidth="60px">
<htz-image-upload :max="1" v-model="avatarList" mediaType="image" :chooseNum="1"
:sourceType="['album','camera']" :compress="false" :quality="80" :formData="otherData"
:remove="true" :dataType="1" @uploadSuccess="uploadSuccess" @imgDelete="imgDelete"
@uploadFail="uploadFail" :action="action"></htz-image-upload>
</u-form-item>
</u-form>
<u-button type="primary" @click="tosubmit"></u-button>
</view>
<!-- 小程序环境微信一键授权 -->
<u-button v-else type="primary" @click="getUserProfile"></u-button>
</view>
</view>
</u-popup>
<u-popup :show="showform" mode="bottom" @close="closeInfo" :round="10">
<!-- 小程序环境确认编辑弹窗 -->
<u-popup :show="showform" mode="bottom" @close="closeInfo" :round="10" v-if="!isH5">
<view class="box">
<view class="box-title" style="text-align: center;padding: 20rpx 0;font-size: 32rpx;">
请确认编辑您的微信头像和昵称
@ -92,7 +109,6 @@
</u-form-item>
</u-form>
<u-button type="primary" @click="tosubmit"></u-button>
</view>
</view>
</u-popup>
@ -123,20 +139,24 @@
form: {
name: '',
avatar: ''
}
},
isH5: false
}
},
onReady() {},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
onReady() {},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onShow() {
var that = this;
//
this.isH5 = typeof window !== 'undefined' && window.location
this.action = this.util.HOST + "/api/mobile/upload-file"
this.otherData.token = uni.getStorageSync("userInfo_token").token;
this.loadInfo(function(res) {
@ -175,7 +195,13 @@
url: res.avatarUrl
})
that.showAuthorization = false
that.showform = true
//
// H5
if (that.isH5) {
that.tosubmit()
} else {
that.showform = true
}
})
},
uploadSuccess(res) {
@ -198,12 +224,12 @@
this.avatarList = res.tempFilePaths
this.form.avatar = ''
},
tosubmit() {
if(this.util.isNull(this.form.name)){
uni.showLoading({
title: "请填写昵称"
})
return
tosubmit() {
if(this.util.isNull(this.form.name)){
uni.showLoading({
title: "请填写昵称"
})
return
}
var that = this
that.util.request({
@ -213,7 +239,7 @@
headimgurl: that.form.avatar,
nickname: that.form.name
},
utilSuccess: function(r) {
utilSuccess: function(r) {
that.showform = false;
that.loadInfo(function() {

@ -92,9 +92,9 @@
</u-form-item>
<u-form-item v-else label="人数" labelWidth="120" prop="total" ref="total">
<!-- {{form.total}} 请添加参与名单 -->
<u-number-box slot="right" v-model="form.total" inputWidth="44" color="#cf995a"
bgColor="#FCF6E3" :min="minCount" :max="maxCount" class="plus">
<!-- {{form.total}} 请添加参与名单 -->
<u-number-box slot="right" v-model="form.total" inputWidth="44" color="#cf995a"
bgColor="#FCF6E3" :min="minCount" :max="maxCount" class="plus">
</u-number-box>
</u-form-item>
<view class="box-tips">
@ -299,10 +299,16 @@
<u-popup :show="showAuthorization" closeable mode="bottom" @close="closePhone" :round="10">
<view class="box">
<view class="box-title" style="text-align: center;padding: 20rpx 0;font-size: 32rpx;">
请授权您的手机号
{{isH5 ? '请输入您的手机号' : '请授权您的手机号'}}
</view>
<view class="box-content" style="padding: 20px;">
<u-button type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<!-- H5环境手动输入手机号 -->
<view v-if="isH5">
<u-input v-model="inputMobile" placeholder="请输入手机号" type="number" maxlength="11"></u-input>
<u-button type="primary" @click="confirmMobile" style="margin-top: 20rpx;">确认</u-button>
</view>
<!-- 小程序环境微信授权 -->
<u-button v-else type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
</u-button>
</view>
</view>
@ -331,15 +337,17 @@
time: 3,
showInfo: false,
currentNotice: {},
isH5: false,
inputMobile: '',
maxheight: "",
scrollheight: "",
notice: [{
title: "参观须知",
content: "参观须知的内容",
content: "参观须知的内容",
isTemplate:false
}, {
title: "批量上传帮助",
content: "<p>1.批量上传EXCEL的以xlsx结尾</p><p>2.第一行为标题行 姓名 手机号 行动不便者</p><p>3.文件是从微信聊天记录中选取或者微信文件传输助手</p><img src='@host@/export.png?v=1.1' style='width:100%'/>",
content: "<p>1.批量上传EXCEL的以xlsx结尾</p><p>2.第一行为标题行 姓名 手机号 行动不便者</p><p>3.文件是从微信聊天记录中选取或者微信文件传输助手</p><img src='@host@/export.png?v=1.1' style='width:100%'/>",
isTemplate:true
}],
specialtype: false,
@ -472,6 +480,8 @@
//this.maxCount = (type == 'user' ? 5 : 50);
var that = this;
//
this.isH5 = typeof window !== 'undefined' && window.location
//
that.util.getOpenidInfo(function(res) {
@ -499,10 +509,10 @@
},
onShareAppMessage() {
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onShareTimeline(){
return this.util.shareInfo
},
onUnload() {
clearInterval(this.t)
@ -513,7 +523,34 @@
closePhone() {
this.showAuthorization = false
},
//
// H5
confirmMobile() {
if (!this.inputMobile) {
uni.showToast({ title: '请输入手机号', icon: 'none' })
return
}
if (!/^1[3-9]\d{9}$/.test(this.inputMobile)) {
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
return
}
var that = this;
this.util.request({
api: '/api/mobile/user/save',
method: 'POST',
data: {
mobile: this.inputMobile
},
utilSuccess: function(res) {
that.form.mobile = that.inputMobile;
that.showAuthorization = false
},
utilFail: function(res) {
uni.showToast({ title: '手机号保存失败', icon: 'none' })
}
})
},
//
getPhoneNumber(e) {
var that = this;
this.util.request({
@ -599,7 +636,7 @@
downLoad() {
const downloadTask = uni.downloadFile({
url: 'https://gbyuyue.szgmbwg.org.cn/Template.xlsx', //
success: (res) => {
success: (res) => {
var filePath = res.tempFilePath
if (res.statusCode === 200) {
uni.openDocument({
@ -671,14 +708,14 @@
this.form.date = this.currentDate.date;
this.form.rule_id = this.currentTime.id;
if(this.type!='team'){
if (this.form.details_list.length != this.form.total) {
uni.showToast({
icon: "none",
title: "请正确添加观众信息"
})
return false;
}
if(this.type!='team'){
if (this.form.details_list.length != this.form.total) {
uni.showToast({
icon: "none",
title: "请正确添加观众信息"
})
return false;
}
}
if (this.type != "user") {
@ -966,9 +1003,9 @@
this.$forceUpdate();
},
handleSelectTime(index) {
var mod = this.currentDate.rules[index];
if (!mod.isCanbook) {
return false
var mod = this.currentDate.rules[index];
if (!mod.isCanbook) {
return false
}
if (mod.remain_count == 0) {
this.util.toast("该时段已不可参观");
@ -1050,9 +1087,9 @@
that.currentTime = {};
let isDefault = false;
for (var mod of rules) {
mod.checked = false;
mod.endtime = that.currentDate.date + " " + mod.end_time;
var isCanbook = that.$moment(nt).isBefore(mod.endtime);
mod.checked = false;
mod.endtime = that.currentDate.date + " " + mod.end_time;
var isCanbook = that.$moment(nt).isBefore(mod.endtime);
mod.isCanbook = isCanbook;
if (that.bcurrentTime) {
if (that.bcurrentTime.id == mod.id) {
@ -1107,10 +1144,10 @@
.timeitem-none {
color: #ccc;
}
.commonuser .book-box-row-timeitem{
font-size:30rpx;
border-radius: 10rpx;
.commonuser .book-box-row-timeitem{
font-size:30rpx;
border-radius: 10rpx;
}
.box-visitor-item {
display: flex;
@ -1277,15 +1314,15 @@
.u-radio-group .u-radio {
margin-bottom: 10rpx;
margin-right: 10rpx
}
.book-box-row-timeitem {
display: flex;
align-items: center;
flex-wrap: wrap;
width: 32%;
padding: 19rpx 21rpx!important;
}
.book-box-row-timeitem-txt {
width:100%
}
.book-box-row-timeitem {
display: flex;
align-items: center;
flex-wrap: wrap;
width: 32%;
padding: 19rpx 21rpx!important;
}
.book-box-row-timeitem-txt {
width:100%
}
</style>

@ -1,48 +1,48 @@
import md5 from "./md5.min";
const HOSTARR = {
// 'development':'https://gb-test.ali251.langye.net',
// 'production': 'https://gb-test.ali251.langye.net',
'development':'https://gbyuyue.szgmbwg.org.cn',
'production': 'https://gbyuyue.szgmbwg.org.cn',
// 'production': 'https://gb-test.ali251.langye.net',
'development':'https://gbyuyue.szgmbwg.org.cn',
'production': 'https://gbyuyue.szgmbwg.org.cn',
// https://gbyuyue.szgmbwg.org.cn/
}; // 审核状态
const HOST = HOSTARR[process.env
.NODE_ENV]; //"https://tiantianxinye.365care.langye.net/";//HOSTARR[process.env.NODE_ENV];//
const replaceImgUrl = (str,before,after)=>{
if(str.indexOf(before) != -1){
return str.replace(new RegExp(before, 'g'),after)
}else{
return str
}
}
const splitTime = (start,end)=> {
let arrStart = start.substring(0, 10).split("-")
let year = parseInt(arrStart[0])
let month = parseInt(arrStart[1]) < 10 ? parseInt(arrStart[1]) : parseInt(arrStart[1])
const replaceImgUrl = (str,before,after)=>{
if(str.indexOf(before) != -1){
return str.replace(new RegExp(before, 'g'),after)
}else{
return str
}
}
const splitTime = (start,end)=> {
let arrStart = start.substring(0, 10).split("-")
let year = parseInt(arrStart[0])
let month = parseInt(arrStart[1]) < 10 ? parseInt(arrStart[1]) : parseInt(arrStart[1])
let day = parseInt(arrStart[2]) < 10 ? parseInt(arrStart[2]) : parseInt(arrStart[2])
if (end) {
// 判断end 是否为时间格式
if(isNaN(end)&&!isNaN(Date.parse(end))){
let arrEnd = end.substring(0, 10).split("-")
let yearEnd = parseInt(arrEnd[0])
let monthEnd = parseInt(arrEnd[1]) < 10 ? parseInt(arrEnd[1]) : parseInt(arrEnd[1])
let dayEnd = parseInt(arrEnd[2]) < 10 ? parseInt(arrEnd[2]) : parseInt(arrEnd[2])
if(year == yearEnd){
return year + '年' + month + '月' + day + '日' + '至' + monthEnd + '月' + dayEnd + '日'
}else{
return year + '年' + month + '月' + day + '日' + '至' + yearEnd + '年'+monthEnd + '月' + dayEnd + '日'
}
}else{
return year + '年' + month + '月' + day + '日' + '至' + end
if (end) {
// 判断end 是否为时间格式
if(isNaN(end)&&!isNaN(Date.parse(end))){
let arrEnd = end.substring(0, 10).split("-")
let yearEnd = parseInt(arrEnd[0])
let monthEnd = parseInt(arrEnd[1]) < 10 ? parseInt(arrEnd[1]) : parseInt(arrEnd[1])
let dayEnd = parseInt(arrEnd[2]) < 10 ? parseInt(arrEnd[2]) : parseInt(arrEnd[2])
if(year == yearEnd){
return year + '年' + month + '月' + day + '日' + '至' + monthEnd + '月' + dayEnd + '日'
}else{
return year + '年' + month + '月' + day + '日' + '至' + yearEnd + '年'+monthEnd + '月' + dayEnd + '日'
}
}else{
return year + '年' + month + '月' + day + '日' + '至' + end
}
} else {
return year + '年' + month + '月' + day + '日' + '起'
}
}
}
const formatTime = date => {
const year = date.getFullYear();
@ -75,32 +75,95 @@ const getUserInfo = (cb, refresh) => {
}
const getOpenidInfo = (cb, refresh) => {
cb = cb || function() {}
refresh = refresh || false
if (!refresh) {
let user_info = uni.getStorageSync(user_info_key)
if (!isNull(user_info)) {
cb(user_info)
return
}
// cb = cb || function() {}
// refresh = refresh || false
// console.log("getOpenidInfo", refresh)
// if (!refresh) {
// let user_info = uni.getStorageSync(user_info_key)
// if (!isNull(user_info)) {
// cb(user_info)
// return
// }
// }
let user_info = uni.getStorageSync(user_info_key)
if (!isNull(user_info)) {
cb(user_info)
return
}
// 判断运行环境H5还是小程序
const isH5 = typeof window !== 'undefined' && window.location
const isWeixinBrowser = isH5 && /MicroMessenger/i.test(navigator.userAgent)
if (isH5 && isWeixinBrowser) {
// H5环境下的微信授权登录
wxH5AuthLogin(cb)
} else {
// 小程序环境下的微信登录
uni.login({
provider: 'weixin',
success: (res) => {
console.log(res.code);
let url = HOST + '/api/mobile/user/login?code=' + res.code;
uni.request({
url: url,
method: 'GET',
success: result => {
let user_info = result.data
uni.setStorageSync(user_info_key, user_info)
cb(user_info)
}
});
}
});
}
}
uni.login({
provider: 'weixin',
success: (res) => {
console.log(res.code);
let url = HOST + '/api/mobile/user/login?code=' + res.code;
uni.request({
url: url,
method: 'GET',
success: result => {
let user_info = result.data
uni.setStorageSync(user_info_key, user_info)
cb(user_info)
// H5环境下的微信授权登录
const wxH5AuthLogin = (cb) => {
let link = window.location.href;
if (/code=/.test(link) || link.indexOf("code") > -1) {
// 已经获取到授权码,直接登录
let temp = decodeURIComponent((new RegExp('[?|&]' + 'code' + '=' + '([^&;]+?)(&|#|;|$)').exec(
link) || [, ''])[1].replace(/\+/g, '%20')) || null;
console.log("code", temp)
// 上传 code 到服务器获取 token
request({
api: `/api/mobile/user/wx-login?code=${temp}`,
method: 'GET',
utilSuccess: (res) => {
if (res.token && res.token.trim() !== '') {
console.log('获取 token 成功:', res.token)
// 保持与小程序登录一致的存储方式
const userInfo = {
token: res.token,
// 可以根据需要添加其他字段,如 WeChatOpenID 等
}
uni.setStorageSync(user_info_key, userInfo)
cb(userInfo)
} else {
console.error('登录失败: token为空')
uni.showToast({ title: '登录失败,请重试', icon: 'none' })
}
});
}
});
},
utilFail: (err) => {
console.error('获取 token 失败:', err)
uni.showToast({ title: '登录失败,请重试', icon: 'none' })
}
})
} else {
// 未获取授权码,跳转到微信授权页面
const appId = 'wx90acb6e2aa676977'
const currentUrl = window.location.href
const redirectUri = encodeURIComponent(currentUrl.replace(/#\//, ""));
const scope = 'snsapi_userinfo'
const state = 'STATE'
console.log(redirectUri)
const authUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`
// 重定向到微信授权页面
window.location.href = authUrl
}
}
@ -108,13 +171,39 @@ const getOpenidInfo = (cb, refresh) => {
const getUserProfile = (cb) => {
cb = cb || function() {}
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
uni.setStorageSync('user_profile', res.userInfo)
cb(res.userInfo)
}
})
// 判断运行环境H5还是小程序
const isH5 = typeof window !== 'undefined' && window.location
const isWeixinBrowser = isH5 && /MicroMessenger/i.test(navigator.userAgent)
if (isH5 && isWeixinBrowser) {
// H5环境下通过后端接口获取用户信息
// 微信公众号H5无法直接调用wx.getUserProfile
request({
api: '/api/mobile/user/profile',
method: 'GET',
utilSuccess: (res) => {
uni.setStorageSync('user_profile', res)
cb(res)
},
utilFail: (err) => {
console.error('获取用户信息失败:', err)
cb(null)
}
})
} else {
// 小程序环境下使用wx.getUserProfile
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
uni.setStorageSync('user_profile', res.userInfo)
cb(res.userInfo)
},
fail: (err) => {
console.error('获取用户信息失败:', err)
cb(null)
}
})
}
}
@ -338,8 +427,8 @@ const isLogin = () => {
const isNull = p => {
return p == '' || p == undefined || p == null || p == 'undefined' || p == 'null';
}; // 正则
}; // 正则
const phoneRegex = /^1[3456789]\d{9}$/;
@ -391,11 +480,11 @@ const isValidCardID = cardID => {
var last = parity[sum % 11];
return parity[sum % 11] == code[17];
};
const shareInfo = {
title:"",
imageUrl:"/static/share.jpg"
};
const shareInfo = {
title:"",
imageUrl:"/static/share.jpg"
}
/**
* UTF16和UTF8转换对照表
@ -580,6 +669,7 @@ module.exports = {
formatNumber: formatNumber,
alert: alert,
getOpenidInfo: getOpenidInfo,
wxH5AuthLogin: wxH5AuthLogin,
request: request,
payOrder: payOrder,
isLogin: isLogin,
@ -594,9 +684,9 @@ module.exports = {
auditStatusDic: auditStatusDic,
getUserProfile: getUserProfile,
getUserInfo: getUserInfo,
toast: toast,
isValidCardID:isValidCardID,
shareInfo:shareInfo,
replaceImgUrl:replaceImgUrl,
toast: toast,
isValidCardID:isValidCardID,
shareInfo:shareInfo,
replaceImgUrl:replaceImgUrl,
splitTime:splitTime
};
};

Loading…
Cancel
Save