完成手机号+头像+昵称H5信息获取的改造

master
linyongLynn 6 days ago
parent 2915c68432
commit 8862b359e3

@ -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;

@ -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 = 'wxbf4862e929ab85b0'
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