1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<template>
<!-- 1.获取购票凭证页面,索道等景区进入添加企业微信获取电子门票 -->
<!--2.判断是否添加,已经添加直接进入订单列表页面 ,没有添加就添加企业微信-->
<!-- 3.如果企业微信人数达到上线,直接跳转到订单列表页面 -->
<!-- 4.如果企业微信码停用,走公众号流程 -->
<!-- 5.暂时没用,用的公众号 -->
<view class="bigBox">
<!-- <image src="../../../static/img/common/getTicketBg.jpg" class="bigImg"></image> -->
<view class="title">获取电子门票</view>
<!-- 企业微信流程 -->
<view v-if="showCompany">
<view class="imgbox">
<image :src="imgUrl" style="width:360rpx;height:360rpx;"></image>
</view>
<view class="content1">长按二维码,添加“客服”</view>
<view class="content2">获取您的电子门票</view>
</view>
<!-- 公众号流程 -->
<div v-if="showPublic">
<view class="imgbox">
<image :src="imgUrl" style="width:360rpx;height:360rpx;"></image>
</view>
<view class="content1">长按二维码,关注“胖丁旅游”</view>
<view class="content2">获取您的电子门票</view>
</div>
</view>
</template>
<script>
export default {
data() {
return {
showCompany:false,//企业微信流程
showPublic:false,//公众号流程
merchantId:'',//商户Id
companyId:'',//公司Id
imgUrl:'',//图片地址
enterUrl:'',//进入页面路由
}
},
onLoad(option) {
//#ifdef MP-WEIXIN
this.enterUrl=option.q
//#endif
if(this.enterUrl){
this.merchantId=this.getUrlKey('merchantId')
this.companyId=this.getUrlKey('companyId')
}else{
this.merchantId=option.merchantId
this.companyId=option.companyId
}
this.ifAddWxUser()
},
methods: {
//----获取url
getUrlKey(name){
return(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(decodeURIComponent(this.enterUrl)) || [, ''])[1].replace(/\+/g, '%20') || ''
},
//---是否添加企业微信
ifAddWxUser(){
let data = {
openid:uni.getStorageSync('openid'),//openId
}
this.$request('wechatUser/login/findWxUserAndLogin',data).then(res => {
if (res.code == '00') {
if(res.data.alreadyAddAttendant=='1'){
//已添加
uni.navigateTo({
url: '/pages/my/order/orderList/orderList'
})
}else{
//未添加
this.getCompanyCode()
}
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
},
//---获取企业微信二维码编号
getCompanyCode() {
let data = {
merchantId: this.merchantId,
companyId:this.companyId
}
this.$request('scenic/wechatCodeConfig/load',data).then(res => {
if (res.code == '00') {
//微信码正常
if(res.data.status=='0'){
//达到上线跳转小程序页面
if(res.data.alreadyAddNumber>=res.data.canAddNumber){
uni.navigateTo({
url: '/pages/my/order/orderList/orderList'
})
}else{
this.showCompany=true
this.imgUrl = res.data.codeUrl
}
}else{
//微信码停用获取公众号二维码
this.showPublic=true
this.getCode()
}
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
},
//---获取公众号二维码编号
getCode() {
let data = {
codeType: 1,
select: 1,
companyId: this.companyId
}
this.$request('user/company/generateQrCodeUrl', data).then(res => {
if (res.code == '00') {
this.imgUrl = res.data.codeImgUrl
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
},
}
}
</script>
<style>
.bigBox {
height: 100%;
padding-top: 18vh;
text-align: center;
font-weight: bold;
font-size:28rpx;
box-sizing: border-box;
position: relative;
}
.bigImg{
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
.title {
font-size:66rpx;
font-weight: bold;
color: #ff570e;
}
.imgbox {
margin-top: 6vh;
}
.content1 {
margin-top: 6vh;
}
.content2 {
margin-top: 3vh;
}
@media only screen and (max-height:760px) {
.bigBox {
padding-top: 16vh;
}
.imgbox {
margin-top: 5vh;
}
.content1 {
margin-top: 5vh;
}
.content2 {
margin-top: 2vh;
}
}
</style>