activity-entry.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <view class="container cashier">
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading="true" :loadingType="5" />
  4. <template v-else>
  5. <!-- <custom :navbar-data='nvabarData' /> -->
  6. <view class="container-banner" :style="{ paddingTop:CustomBar + 115 +'px' }">
  7. <view class="container-title">{{ voteTitle }}</view>
  8. <view class="login-input">
  9. <input type="text"
  10. v-model="params.ticket"
  11. maxlength="20"
  12. disabled="true"
  13. class="input"
  14. />
  15. </view>
  16. <view class="login-input">
  17. <input type="text"
  18. v-model="params.name"
  19. maxlength="6"
  20. class="input"
  21. placeholder="您的姓名"
  22. :disabled="!isBundled"
  23. />
  24. </view>
  25. <view class="login-input">
  26. <input type="text"
  27. v-model="params.mobile"
  28. maxlength="11"
  29. class="input"
  30. placeholder="您的联系电话"
  31. :disabled="!isBundled"
  32. />
  33. </view>
  34. <view class="login-input code" v-show="isBundled">
  35. <input type="text"
  36. v-model="params.smsCode"
  37. maxlength="6"
  38. class="input code"
  39. placeholder="手机验证码"
  40. />
  41. <view class="code-btn" :class="[isMobileDisabled ? 'disabled' : '']">
  42. <button
  43. class="code-button"
  44. type="button"
  45. @click.stop="getMobileCodeFn"
  46. :disabled="isMobileDisabled"
  47. >
  48. {{ mobileCodeText }}
  49. </button>
  50. </view>
  51. </view>
  52. <view class="login-input">
  53. <input type="text"
  54. v-model="params.idCard"
  55. maxlength="20"
  56. class="input"
  57. placeholder="证件号码(身份证/港澳台通行证/护照)"
  58. :disabled="!isBundled"
  59. />
  60. </view>
  61. <view class="login-input">
  62. <input type="text"
  63. v-model="params.work"
  64. maxlength="10"
  65. class="input"
  66. placeholder="您的职业"
  67. :disabled="!isBundled"
  68. />
  69. </view>
  70. <view class="login-btn" v-show="isBundled" @click="handleEntry">激活门票</view>
  71. <view class="login-text">注:</view>
  72. <view class="login-text">1、门票绑定的证件号码是作为进入大会会场的凭证。</view>
  73. <view class="login-text">2、到采美专区签到打卡,可领取超值礼包,更多惊喜和福利等你来解琐。</view>
  74. </view>
  75. </template>
  76. <!-- 提示弹窗 -->
  77. <tui-modal
  78. :show="modal"
  79. @click="handleClick"
  80. :content="contentModalText"
  81. :button="modalButton"
  82. color="#333"
  83. :size="32"
  84. shape="circle"
  85. :maskClosable="false"
  86. />
  87. <activity-model :show="isShowModel" @cancel="hideModel"/>
  88. </view>
  89. </template>
  90. <script>
  91. import { mapState, mapMutations } from 'vuex'
  92. import authorize from '@/common/config/authorize.js'
  93. import wxLogin from '@/common/config/wxLogin.js'
  94. import activityModel from './components/activity-model.vue'
  95. export default{
  96. components:{
  97. activityModel
  98. },
  99. data(){
  100. return{
  101. nvabarData: { //顶部自定义导航
  102. haveBack:false,
  103. haveHome:true,
  104. showCapsule:1, // 是否显示左上角图标 1表示显示 0表示不显示,
  105. showSearch: 0,
  106. title: '', // 导航栏 中间的标题
  107. textLeft:this.$store.state.isIphone
  108. },
  109. isIphoneX:this.$store.state.isIphoneX,
  110. CustomBar:this.CustomBar,// 顶部导航栏高度
  111. skeletonShow:true,
  112. isShowModel:false,
  113. params:{
  114. unionId:'',
  115. name:'',
  116. idCard:'',
  117. ticket:'',
  118. mobile:'',
  119. smsCode:'',
  120. work:'',
  121. userId:''
  122. },
  123. voteTitle:'',
  124. modal: false,
  125. contentModalText: '', //操作文字提示语句
  126. modalButton: [
  127. {
  128. text: '联系客服',
  129. type: 'gray',
  130. plain: true //是否空心
  131. },
  132. {
  133. text: '确认激活',
  134. customStyle: {
  135. color: '#fff',
  136. bgColor: '#e10078'
  137. },
  138. plain: false
  139. }
  140. ],
  141. modalType:0,
  142. isMobileDisabled: false, //手机验证码按钮控制
  143. mobilCount: '', //倒计时
  144. mobileCodeText: '获取验证码',
  145. mobilTime: null,
  146. isBundled:true
  147. }
  148. },
  149. onLoad(option) {
  150. wxLogin.wxLoginAuthorize()
  151. setTimeout(()=>{
  152. this.initData(option)
  153. },2000)
  154. },
  155. computed: {
  156. ...mapState(['hasLogin', 'userInfo', ])
  157. },
  158. methods:{
  159. // 初始化
  160. async initData(option) {
  161. const userInfo = await this.$api.getStorage()
  162. this.params.ticket = option.ticket
  163. this.voteTitle = option.voteType*1 === 1 ? '大会通票' : '学术套票'
  164. console.log('userInfo',userInfo)
  165. if(userInfo.userId){
  166. this.params.userId = userInfo.userId
  167. this.contentModalText = `您的采美帐号资料为【${userInfo.name}】,请确认并激活!`
  168. }
  169. this.getTicketDetails({ ticket: option.ticket ,userId: this.params.userId})
  170. },
  171. // 查询门票信息
  172. async getTicketDetails(params){
  173. try{
  174. const res = await this.UserService.getTicketDetails(params)
  175. const data = res.data
  176. if(data && data.ticketFlag === 1){
  177. this.modalType = 1
  178. this.contentModalText = '您已激活过门票,请勿重复激活!'
  179. this.modalButton = [
  180. {
  181. text: '知道了',
  182. customStyle: {
  183. color: '#fff',
  184. bgColor: '#e10078'
  185. },
  186. plain: false
  187. }
  188. ]
  189. this.modal = true
  190. }else{
  191. if(data.userId){
  192. this.isBundled = false
  193. this.params = {...this.params ,...data}
  194. this.params.idCard = data.idCard.substring(0, 4) + '**********' + data.idCard.substring(data.idCard.length - 4)
  195. this.params.name = this.exceptSurname(data.name)
  196. this.params.mobile = this.excePhoneNumber(data.mobile)
  197. }else{
  198. this.isBundled = true
  199. }
  200. this.skeletonShow = false
  201. }
  202. }catch(error){
  203. console.log('获取门票详情异常~')
  204. }
  205. },
  206. //点击绑定
  207. handleEntry(){
  208. if(!this.params.name){
  209. this.$util.msg('请输入您的姓名~', 2000)
  210. return
  211. }
  212. if(!this.params.idCard){
  213. this.$util.msg('请输入您的证件号码~', 2000)
  214. return
  215. }
  216. if(!this.params.mobile){
  217. this.$util.msg('请输入您的联系电话~', 2000)
  218. return
  219. }
  220. if (this.params.smsCode == '') {
  221. this.$util.msg('请输入手机验证码', 2000)
  222. return
  223. }
  224. if(!this.params.work){
  225. this.$util.msg('请输入您的职业~', 2000)
  226. return
  227. }
  228. if(this.hasLogin){
  229. this.modal = true
  230. }else{
  231. this.params.unionId = uni.getStorageSync('unionId')
  232. this.userTicketCheck({ mobile:this.params.mobile, smsCode:this.params.smsCode })
  233. }
  234. },
  235. // 校验
  236. async userTicketCheck(params){
  237. try{
  238. const res = await this.UserService.userTicketCheck(params)
  239. if(res.data && res.data.userId){
  240. this.params.userId = res.data.userId
  241. this.contentModalText = `您的采美帐号资料为【${userInfo.name}】,请确认并激活!`
  242. this.modal = true
  243. }else{
  244. this.userTicketBind(this.params)
  245. }
  246. }catch(error){
  247. this.$util.msg(error.msg,2000)
  248. }
  249. },
  250. //确认操作
  251. handleClick(e) {
  252. if(this.modalType === 0){
  253. if (e.index == 1) {
  254. if(this.modalType === 0){
  255. this.userTicketBind(this.params)
  256. }else{
  257. this.$api.navigateTo('/pages/h5/activity/activity-entry-list')
  258. }
  259. }else{
  260. // 拨号
  261. uni.makePhoneCall({
  262. phoneNumber: '15338851365' //仅为示例
  263. })
  264. }
  265. }else{
  266. this.$api.navigateTo('/pages/h5/activity/activity-entry-list')
  267. }
  268. this.modal = false
  269. },
  270. // 绑定门票
  271. async userTicketBind(params){
  272. try{
  273. await this.UserService.userTicketBind(params)
  274. wxLogin.wxLoginAuthorize()
  275. this.isShowModel = true
  276. this.params.idCard = ''
  277. }catch(error){
  278. this.$util.msg(error.msg,2000)
  279. }
  280. },
  281. getMobileCodeFn() {
  282. if (this.params.mobile == '') {
  283. this.$util.msg('请输入手机号', 2000)
  284. return
  285. }
  286. if (!this.$reg.isMobile(this.params.mobile)) {
  287. this.$util.msg('请输入正确的手机号', 2000)
  288. return
  289. }
  290. let params = {
  291. mobile: this.params.mobile,
  292. isCheckCaptcha: 1,
  293. activateCodeType: 16,
  294. platformType: 2
  295. }
  296. this.isMobileDisabled = true
  297. this.getMobileCode(params)
  298. },
  299. async getMobileCode(params){
  300. try{
  301. const TIME_COUNT = 60
  302. await this.PublicService.GetRegisterMobileCode(params)
  303. this.$util.msg('验证短信已发送', 2000)
  304. if (!this.mobilTime) {
  305. this.mobilCount = TIME_COUNT
  306. this.isMobileDisabled = true
  307. this.mobilTime = setInterval(() => {
  308. if (this.mobilCount > 1 && this.mobilCount <= TIME_COUNT) {
  309. this.mobilCount--
  310. this.mobileCodeText = this.mobilCount + '秒后重发'
  311. } else {
  312. this.isMobileDisabled = false
  313. clearInterval(this.mobilTime)
  314. this.mobilTime = null
  315. this.mobileCodeText = '获取验证码'
  316. }
  317. }, 1000)
  318. }
  319. }catch(error){
  320. this.$util.msg('获取短信验证码异常~', 2000)
  321. this.isMobileDisabled = false
  322. }
  323. },
  324. hideModel(){
  325. this.isShowModel = false
  326. this.getTicketDetails({ticket:this.params.ticket})
  327. },
  328. exceptSurname(fullName) {
  329. const parts = fullName.split('')
  330. if (parts.length > 1) {
  331. // 只替换名字的第一个字符
  332. parts[0] = '*' + parts[0].slice(1)
  333. return parts.join('')
  334. } else {
  335. // 如果只有一个名字(或姓),则替换第一个字符
  336. return '*' + fullName.slice(1)
  337. }
  338. },
  339. excePhoneNumber(phoneNumber) {
  340. // 假设phoneNumber是一个有效的手机号字符串
  341. // 保留手机号的前三位和后四位,中间用星号(*)替换
  342. // 检查手机号长度,确保是11位(中国大陆手机号标准)
  343. if (phoneNumber.length === 11) {
  344. // 提取前三位和后四位
  345. const prefix = phoneNumber.substring(0, 3)
  346. const suffix = phoneNumber.substring(7)
  347. // 生成中间部分的星号(*),长度为原手机号长度减去前后保留的长度
  348. const middle = '*'.repeat(phoneNumber.length - prefix.length - suffix.length)
  349. // 拼接脱敏后的手机号
  350. return prefix + middle + suffix
  351. } else {
  352. // 如果手机号长度不是11位,可以返回原始手机号或进行其他处理
  353. console.warn('手机号长度不是11位,可能不是有效的手机号')
  354. return phoneNumber // 或者返回 null, '' 等,根据实际需求
  355. }
  356. }
  357. },
  358. onShow() {
  359. }
  360. }
  361. </script>
  362. <style lang="scss">
  363. page{
  364. background-color: #3d68eb;
  365. height: auto !important;
  366. }
  367. .container-banner{
  368. width: 100%;
  369. height: 1142rpx;
  370. background: url(https://static.caimei365.com/app/img/bg/ziluo_bg.jpg) no-repeat;
  371. background-size: contain;
  372. box-sizing: border-box;
  373. padding: 0 110rpx;
  374. .container-title{
  375. height: 120rpx;
  376. line-height: 120rpx;
  377. font-size: $font-size-48;
  378. font-weight: 600;
  379. text-align: center;
  380. color: #FFFFFF;
  381. }
  382. .login-title{
  383. font-size: $font-size-28;
  384. line-height: 58rpx;
  385. color: #ffffff;
  386. }
  387. .login-input{
  388. width: 100%;
  389. height: 88rpx;
  390. padding:0 24rpx;
  391. margin: 0 auto;
  392. margin-bottom: 40rpx;
  393. background: #FFFFFF;
  394. box-sizing: border-box;
  395. border-radius: 50rpx;
  396. position: relative;
  397. &.code{
  398. padding-right: 180rpx;
  399. }
  400. .input{
  401. width: 100%;
  402. height: 100%;
  403. background: #FFFFFF;
  404. font-size: $font-size-28;
  405. line-height: 88rpx;
  406. color: #333333;
  407. border-radius: 50rpx;
  408. &.code{
  409. width: 300rpx;
  410. }
  411. }
  412. .code-btn{
  413. width: 180rpx;
  414. height: 64rpx;
  415. float: left;
  416. background: #e10078;
  417. padding: 0;
  418. border-radius: 32rpx;
  419. position: absolute;
  420. right: 10rpx;
  421. top:10rpx;
  422. .code-button {
  423. width: 180rpx;
  424. height: 64rpx;
  425. line-height: 64rpx;
  426. padding: 0;
  427. color: #ffffff;
  428. background: #e10078;
  429. text-align: center;
  430. border-radius: 32rpx;
  431. font-size: $font-size-24;
  432. }
  433. &.disabled {
  434. background: #f7f7f7;
  435. .code-button {
  436. background: #f7f7f7;
  437. color: #999999;
  438. font-size: 24rpx;
  439. }
  440. }
  441. }
  442. }
  443. .login-btn {
  444. width: 100%;
  445. height: 88rpx;
  446. font-size: $font-size-30;
  447. font-weight: 600;
  448. letter-spacing: 3rpx;
  449. line-height: 88rpx;
  450. color: #ffffff;
  451. margin: 0 auto;
  452. text-align: center;
  453. background-color: #e10078;
  454. border-radius: 50rpx;
  455. margin-bottom: 10rpx;
  456. }
  457. .login-text{
  458. font-size: $font-size-22;
  459. line-height: 36rpx;
  460. color: #ffffff;
  461. margin-top: 10rpx;
  462. }
  463. }
  464. </style>