123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932 |
- <template>
- <view class="scenic-makeOut">
- <u--form
- labelPosition="left"
- :model="form"
- ref="uForm"
- labelWidth="150rpx"
- >
- <view class="content info">
- <view class="title">
- {{ticketInfo.productName}}
- </view>
- <view class="notice" @click="showNotice = true">
- <view class="text">
- 预定须知
- </view>
- <image class="jiantou" src="../static/right.png" mode=""></image>
- </view>
- <u-form-item
- label="出游日期"
- borderBottom
- ref="startTime"
- required
- prop="startTime"
- >
- <view class="time-box" @click="chooseTime">
- {{form.startTime}}
- <image class="right-icon" src="../static/right.png" mode=""></image>
- </view>
- </u-form-item>
- <view class="signUp-box">
- <view class="label-box">
- <view class="label">
- 预订数量
- </view>
- <view class="desc">
- (最多10张)
- </view>
- </view>
- <view class="num-box">
- <view class="btn" :class="[form.bookNumber == 1?'disabled':'']" @click="add(-1)">
- -
- </view>
- <view class="num">
- {{form.bookNumber}}
- </view>
- <view class="btn" :class="[form.bookNumber == 10?'disabled':'']" @click="add(1)">
- +
- </view>
- </view>
- </view>
- </view>
-
- <view class="content ">
- <view class="sub-title">
- 取票人信息
- </view>
- <u-form-item
- label="姓名"
- borderBottom
- ref="item1"
- prop="contact.contactName"
- required
- >
- <u--input
- v-model="form.contact.contactName"
- border="none"
- placeholder="请输入姓名"
- ></u--input>
- </u-form-item>
- <u-form-item
- label="手机号"
- borderBottom
- ref="item1"
- prop="contact.contactTel"
- required
- >
- <u--input
- v-model="form.contact.contactTel"
- border="none"
- :maxlength="11"
- placeholder="请输入手机号"
- ></u--input>
- </u-form-item>
- <u-form-item
- label="邮箱"
- borderBottom
- ref="item1"
- prop="contact.contactEmail"
- required
- v-if="ticketInfo.admissionVoucher.admissionVoucherCode == 205 || ticketInfo.admissionVoucher.admissionVoucherCode == 302"
- >
- <u--input
- v-model="form.contact.contactEmail"
- border="none"
- placeholder="请输入邮箱号"
- ></u--input>
- </u-form-item>
- <u-form-item
- label="证件类型"
- borderBottom
- ref="item1"
- :required="showContact"
- v-if="showContact"
- >
- <view class="time-box" @click="chooseType('取票')">
- {{form.contact.psptType | filterType(that)}}
- <image class="right-icon" src="../static/right.png" mode=""></image>
- </view>
- </u-form-item>
- <u-form-item
- label="证件号"
- ref="item1"
- prop="contact.psptId"
- :required="showContact"
- v-if="showContact"
- >
- <u--input
- v-model="form.contact.psptId"
- border="none"
- placeholder="请输入证件号"
- :maxlength="18"
- ></u--input>
- </u-form-item>
- </view>
-
- <template v-if="required">
-
- <view class="content" v-for="(item,index) in form.touristList" :key="item">
- <view class="sub-title">
- 出游人信息
- </view>
- <view class="no">
- 第{{index+1}}位
- </view>
- <u-form-item
- label="姓名"
- borderBottom
- :ref="'touristList'+index+'name'"
- :prop="`touristList.${index}.name`"
- :required="required"
- >
- <u--input
- v-model="item.name"
- border="none"
- placeholder="请输入姓名"
- ></u--input>
- </u-form-item>
- <u-form-item
- label="手机号"
- borderBottom
- :ref="'touristList'+index+'tel'"
- :prop="'touristList.'+index+'.tel'"
- :required="required"
- >
- <u--input
- v-model="item.tel"
- border="none"
- :maxlength="11"
- placeholder="请输入手机号"
- ></u--input>
- </u-form-item>
- <u-form-item
- label="证件类型"
- borderBottom
- ref="item13"
- prop="name"
- :required="idRequired"
- v-if="idRequired"
- >
- <view class="time-box" @click="chooseType(index)">
- {{item.psptType | filterType(that)}}
- <image class="right-icon" src="../static/right.png" mode=""></image>
- </view>
- </u-form-item>
- <u-form-item
- label="证件号"
- ref="item14"
- :ref="'touristList'+index+'psptId'"
- :prop="'touristList.'+index+'.psptId'"
- :required="idRequired"
- v-if="idRequired"
- >
- <u--input
- v-model="item.psptId"
- border="none"
- placeholder="请输入证件号"
- :maxlength="18"
- ></u--input>
- </u-form-item>
- </view>
- </template>
-
- </u--form>
-
- <view class="btn-box">
- <view class="left">
- <view class="num">
- 共{{form.bookNumber}}件
- </view>
- <view class="total">
- 合计 <view class="price-box">
- <view class="unit">
- ¥
- </view>
- <view class="price">
- {{total}}
- </view>
- </view>
- </view>
- </view>
- <button class="btn" @click="handleBuy" :loading="loading">
- 提交订单
- </button>
- </view>
-
- <u-calendar
- confirmDisabledText="请选择日期"
- :show="show"
- @confirm="confirmTime"
- @close="show = false"
- ref="calendar"
- :rowHeight="120"
- closeOnClickOverlay
- color="#EE4320"
- :customList="ticketInfo.priceCalendar"
- :monthNum="12"
- >
- </u-calendar>
-
- <u-picker :show="show1" :columns="columns" closeOnClickOverlay keyName="label" @cancel="close" @close="close" @confirm="confirm"></u-picker>
-
- <!-- 预定须知 -->
- <u-popup :show="showNotice" round="16rpx" mode="bottom" @close="showNotice = false">
- <view class="popup-title">
- {{ticketInfo.shopName}}
- </view>
- <view class="box">
- <template v-if="ticketInfo.drawAddress">
- <view class="sub-title">
- 取票地点
- </view>
- <view class="intro">
- {{ticketInfo.drawAddress}}
- </view>
- </template>
- <view class="sub-title">
- 入园方式
- </view>
- <view class="intro">
- {{ticketInfo.admissionVoucher.admissionVoucherCode | filterVoucherType}}
- </view>
- <view class="sub-title">
- 有效期
- </view>
- <view class="intro">
- {{ticketInfo.indate || '-'}}
- </view>
- <view class="sub-title">
- 预定截止
- </view>
- <view class="intro">
- {{ticketInfo.advanceDay}}天 {{ticketInfo.advanceHour}}小时
- </view>
- <view class="sub-title">
- 退改规则
- </view>
- <rich-text class="intro" :nodes="ticketInfo.mpLossInfo"></rich-text>
- <view class="sub-title">
- 预定须知
- </view>
- <rich-text class="intro" :nodes="ticketInfo.bookNotice"></rich-text>
- <view class="sub-title">
- 其他说明
- </view>
- <rich-text class="intro" :nodes="ticketInfo.info"></rich-text>
-
- </view>
- </u-popup>
-
- </view>
- </template>
- <script>
- import {createOrderNew} from '@/api/scenic.js'
- import {
- creatPayOrder,
- queryPayOrder,
- } from '@/api/payment.js'
- export default {
- data() {
- return {
- that:this,
- show:false,
- show1:false,
- showNotice:false,
- loading:false,
- form:{
- "scenicId":0,
- "epId":0,
- "channel":'ZhongShu',
- "bookNumber": 1,
- "contact": {
- "contactEmail": "",
- "contactName": "",
- "contactTel": "",
- "psptId": "",
- "psptType": 1
- },
- "couponValue": 0,
- "delivery": {
- "deliveryEndAddress": "",
- "deliveryType": 0,
- "receiverName": "",
- "telNum": "",
- "zipCode": ""
- },
- "productId": 0,
- "startTime": "",
- "touristList": [
- {
- "email": "",
- "name": "",
- "psptId": "",
- "psptType": 1,
- "tel": ""
- }
- ]
- },
- required:false,//游客信息是否必填
- idRequired:false,//游客身份证信息是否必填
- showContact:false,//取票人信息是否必填
- rules: {
- 'startTime':[
- {
- required: true,
- message: '请选择出游日期',
- trigger: ['blur', 'change']
- },
- ],
- contact:{
- contactName:[
- {
- required: true,
- message: '请输入姓名',
- trigger: ['blur', 'change']
- },
-
- ],
- contactTel:[
- {
- required: true,
- message: '请输入手机号',
- trigger: ['blur', 'change']
- },
- {
- // 自定义验证函数,见上说明
- validator: (rule, value, callback) => {
- // 上面有说,返回true表示校验通过,返回false表示不通过
- // uni.$u.test.mobile()就是返回true或者false的
- return uni.$u.test.mobile(value);
- },
- message: '手机号码不正确',
- // 触发器可以同时用blur和change
- trigger: ['change','blur'],
- }
- ],
- contactEmail:[
- {
- required: true,
- message: '请输入取票人邮箱',
- trigger: ['blur', 'change']
- },
- {
- // 自定义验证函数,见上说明
- validator: (rule, value, callback) => {
- // 上面有说,返回true表示校验通过,返回false表示不通过
- // uni.$u.test.mobile()就是返回true或者false的
- return uni.$u.test.email(value);
- },
- message: '邮箱号不正确',
- // 触发器可以同时用blur和change
- trigger: ['change','blur'],
- }
- ],
- psptId:[
- {
- required: true,
- message: '请输入证件号码',
- trigger: ['blur', 'change']
- }
- ],
- },
- touristList:[]
- },
- ticketInfo:{salePrice:0},
- columns: [
- [
- {
- label: '身份证',
- id: 1
- },
- {
- label: '护照',
- id: 2
- },
- {
- label: '军官证',
- id: 3
- },
- {
- label: '港澳通行证',
- id: 4
- },
- {
- label: '台胞证',
- id: 7
- },
- {
- label: '回乡证',
- id: 8
- },
- {
- label: '户口簿',
- id: 9
- },
- {
- label: '出生证明',
- id: 10
- },
- {
- label: '台湾通行证',
- id: 11
- },
- ]
- ],
- active:0,
- query: {
- "msgType": "wx.unifiedOrder",
- "orderDesc": "",
- "orderNo": "",
- "channel":'ZhongShu',
- "subOpenId": "",
- "userId": ""
- },
- payData:null,
- price:0
- }
- },
- filters: {
- filterType: function(value,that) {
- let msg
- that.columns[0].map(item=>{
- if(value == item.id){
- msg = item.label
- }
- })
- return msg;
- },
- filterVoucherType: function(val) {
- if(val == 1){
- return '实体票入园'
- }else if(val == 201){
- return '换票入园短信'
- }else if(val == 202){
- return '换票入园二维码'
- }else if(val == 203){
- return '换票入园数字码'
- }else if(val == 204){
- return '换票入园换票证'
- }else if(val == 205){
- return '换票入园邮件'
- }else if(val == 206){
- return '换票入园身份证'
- }else if(val == 207){
- return '换票入园护照'
- }else if(val == 208){
- return '换票入园港澳通行证'
- }else if(val == 209){
- return '换票入园军官证'
- }else if(val == 210){
- return '换票入园台胞证'
- }else if(val == 301){
- return '直接验证入园二维码'
- }else if(val == 302){
- return '直接验证入园邮件'
- }else if(val == 303){
- return '直接验证入园身份证'
- }else if(val == 304){
- return '直接验证入园护照'
- }else if(val == 305){
- return '直接验证入园港澳通行证'
- }else if(val == 306){
- return '直接验证入园军官证'
- }else if(val == 307){
- return '直接验证入园台胞证'
- }
- }
- },
- computed: {
- total() {
- if(this.price){
- return this.price*this.form.bookNumber
- }else{
- return this.ticketInfo.salePrice*this.form.bookNumber
- }
- }
- },
- methods: {
- confirmTime(val){
- if(!val.length) return uni.showToast({
- title:'请选择日期',
- icon:'none'
- })
- this.show = false
- this.form.startTime = val[0]
- this.ticketInfo.priceCalendar.forEach(item=>{
- if(item.departDate == val[0]){
- this.price = item.salePrice
- }
- })
- this.$refs.uForm.validateField('startTime')
- },
- confirm(val){
- console.log(val);
- this.show1 = false
- if(this.active == '取票'){
- this.form.contact.psptType = val.value[0].id
- }else{
- this.form.touristList[this.active].psptType = val.value[0].id
- }
- },
- close(){
- console.log(9999);
- this.show1 = false
- },
- chooseTime() {
- this.show = true
- },
- chooseType(index){
- this.show1 = true
- this.active = index
- },
- add(val){
- if((val==-1&&this.form.bookNumber == 1)||(val==1&&this.form.bookNumber == 10)) return
- if(val == 1){
- if(this.required){
- this.form.touristList.push({
- "email": "",
- "name": "",
- "psptId": "",
- "psptType": 1,
- "tel": ""
- })
- }
- }else{
- this.form.touristList.pop()
- }
- this.form.bookNumber+=val
- this.setRules()
- },
- handleBuy(){
- this.$refs.uForm.validate().then(res => {
- this.createOrderNew(this.form)
- })
- },
- createOrderNew(query){
- if (this.loading) return
- this.loading = true
- uni.showLoading({
- title: '支付中'
- })
- let that = this
- createOrderNew(query).then(res=>{
- if(res.state == 'Success'){
- this.query.orderNo = res.content.orderNo
- this.query.subOpenId = JSON.parse(uni.getStorageSync('userInfo')).openId
- this.query.orderDesc = this.ticketInfo.productName
- creatPayOrder(this.query).then(data => {
- that.payData = JSON.parse(data.content.miniPayRequest)
- if (data.content.miniPayRequest == null) return uni.hideLoading()
- console.log(666,that.payData);
- uni.requestPayment({
- "provider": "wxpay",
- "orderInfo": that.payData,
- "appid": that.payData
- .appId, // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
- "paySign": that.payData.paySign,
- "nonceStr": that.payData.nonceStr, // 随机字符串
- "package": that.payData.package, // 固定值
- // "prepayid": that.payData.package, // 统一下单订单号
- "timeStamp": that.payData.timeStamp, // 时间戳(单位:秒)
- "signType": that.payData.signType, //签名算法
- success(msg) {
- console.log('msg', that.query.orderNo);
- queryPayOrder(that.query.orderNo).then(res1 => {
- uni.hideLoading()
- that.loading = false
- if (res1.state == 'Success') {
- uni.reLaunch({
- url: '/my/order/index'
- })
- }
- })
- },
- fail(e) {
- console.log('err', e);
- that.loading = false
- uni.hideLoading()
- uni.showToast({
- title: '取消支付',
- icon: 'fail'
- })
- // 取消支付后
- uni.reLaunch({
- url:'/my/order/scenic/detail?id='+that.query.orderNo
- })
- }
- })
-
- })
-
- }else{
- that.loading = false
- uni.hideLoading()
- uni.hideToast()
- if(res.content.indexOf('不符合资源') != -1){
- uni.showToast({
- title: res.content.split('不符合资源')[0]+'不合法',
- icon: 'none'
- })
- }else{
- uni.showToast({
- title: res.content,
- icon: 'none'
- })
- }
- }
- })
- },
- setRules() {
- //custInfoLimit=2,3,6,7这几种类型 游客信息必填 否则直接不填
- if(this.required){
- this.form.touristList.forEach((ele, index) => {
- this.$set(this.rules, `touristList.${index}.name`, [
- {
- required: true,
- message: '请填写姓名',
- trigger: ['blur', 'change']
- }
- ])
- this.$set(this.rules, `touristList.${index}.tel`, [
- {
- required: true,
- message: '请填写手机号',
- trigger: ['blur', 'change']
- },
- {
- validator: (rule, value, callback) => {
- // 上面有说,返回true表示校验通过,返回false表示不通过
- return uni.$u.test.mobile(value);
- },
- message: '手机号码不正确',
- // 触发器可以同时用blur和change
- trigger: ['change','blur'],
- }
- ])
- if(this.idRequired){
- this.$set(this.rules, `touristList.${index}.psptId`, [
- {
- required: true,
- message: '请填写证件号码',
- trigger: ['blur', 'change']
- }
- ])
- }
- })
- }
- console.log('rule',this.rules);
- this.$nextTick(() => {
- this.$refs.uForm.setRules(this.rules)
- })
- },
- },
- onReady() {
- //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
- // this.$refs.uForm.setRules(this.rules)
- this.setRules()
- },
- mounted() {
- // this.setRules()
- },
- onLoad(options) {
- let userInfo = JSON.parse(uni.getStorageSync('userInfo'))
- this.query.userId = userInfo.userId
- this.form.scenicId = options.id
- let that = this
- const eventChannel = this.getOpenerEventChannel();
- eventChannel.on('pay', function(data) {
- that.form.epId = data.epId
- that.ticketInfo = data
- that.ticketInfo.priceCalendar.map(i=>{i.bottomInfo = i.salePrice})
- that.form.productId = data.productId
- // 这几种类型 才需要填写游客信息
- if([2,3,6,7].includes(that.ticketInfo.custInfoLimit)){
- that.required = true
- // 必填游客身份证
- if([3,6].includes(that.ticketInfo.custInfoLimit)){
- that.idRequired = true
- }else{
- that.idRequired = false
- }
- }else{
- that.required = false
- that.form.touristList = []
- }
-
- // 这几种类型 才需要填写取票人证件信息
- if([4,6,7].includes(that.ticketInfo.custInfoLimit)){
- that.showContact = true
- }else{
- that.showContact = false
- delete that.form.contact.psptType
- delete that.form.contact.psptId
- }
-
- })
- }
- }
- </script>
- <style lang="scss" >
- .scenic-makeOut{
- background: #F9F9F9;
- border-radius: 0rpx 0rpx 0rpx 0rpx;
- padding: 20rpx 24rpx 120rpx;
- min-height: 100vh;
- .content{
- background: #FFFFFF;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- margin-bottom: 20rpx;
- padding: 24rpx;
- }
- .sub-title{
- font-weight: 600;
- font-size: 28rpx;
- color: #222222;
- padding-bottom: 24rpx;
- border-bottom: 1rpx solid #F0F0F0;
- }
- .no{
- padding: 24rpx 0;
- font-size: 28rpx;
- color: #222222;
- font-weight: bold;
- }
- .time-box{
- display: flex;
- justify-content: flex-end;
- text-align: center;
- .right-icon{
- width: 48rpx;
- height: 48rpx;
- }
- }
- .info{
- .title{
- font-weight: 600;
- font-size: 36rpx;
- color: #222222;
- width: 100%;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- margin-top: 10rpx;
- }
- .notice{
- display: flex;
- align-items: center;
- font-size: 24rpx;
- color: #AAAAAA;
- margin-top: 20rpx;
- .jiantou{
- width: 48rpx;
- height: 48rpx;
- }
- }
-
- .signUp-box{
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding-top: 20rpx;
- .label-box{
- display: flex;
- align-items: center;
- .label{
- font-weight: 300;
- font-size: 24rpx;
- color: #181818;
- }
- .desc{
- font-weight: 300;
- font-size: 24rpx;
- color: #AAAAAA;
- }
- }
- .num-box{
- display: flex;
- align-items: center;
- .btn.disabled{
- background: #F0F0F0;
- color: #AAAAAA;
- }
- .btn{
- width: 36rpx;
- height: 36rpx;
- line-height: 36rpx;
- border-radius: 50%;
- background: #E2ECFF;
- color: #3879F9;
- font-size: 30rpx;
- text-align: center;
- vertical-align: top;
- }
- .num{
- font-weight: 400;
- font-size: 24rpx;
- color: #222222;
- width: 50rpx;
- text-align: center;
-
- }
- }
- }
-
- }
- .btn-box {
- position: fixed;
- bottom: 0%;
- left: 0%;
- z-index: 2;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- box-sizing: border-box;
- padding: 10rpx 24rpx env(safe-area-inset-bottom);
- background: #fff;
- border-top: 1rpx solid #EEEEEE;
- .left{
- display: flex;
- align-items: flex-end;
- .num{
- font-weight: 300;
- font-size: 24rpx;
- color: #AAAAAA;
- }
- .total{
- font-weight: 300;
- font-size: 24rpx;
- color: #222222;
- display: flex;
- align-items: flex-end;
- margin-left: 6rpx;
- .price-box{
- display: flex;
- align-items: flex-end;
- font-weight: 400;
- font-size: 32rpx;
- color: #222222;
- .unit{
- font-size: 20rpx;
- }
- .price{
- font-weight: bold;
- }
- }
- }
- }
-
- .btn {
- width: 280rpx;
- height: 80rpx;
- line-height: 80rpx;
- text-align: center;
- background: $uni-color-primary;
- border-radius: 40rpx;
- font-weight: 600;
- font-size: 28rpx;
- color: #FFFFFF;
- margin: 0;
- }
- }
-
-
- .u-popup__content{
- padding: 0 24rpx 28rpx;
- position: relative;
- .popup-title{
- font-weight: 600;
- font-size: 32rpx;
- color: #222222;
- padding: 28rpx 0;
- border-bottom: 1rpx solid #F0F0F0;
- }
- .box{
- max-height: 70vh;
- overflow: auto;
- .sub-title{
- font-weight: 600;
- font-size: 28rpx;
- color: #222222;
- margin: 20rpx 0;
- border: none;
- }
- .intro{
- font-weight: 300;
- font-size: 24rpx;
- color: #AAAAAA;
- line-height: 40rpx;
- padding-bottom: 24rpx;
- }
- .border-bottom{
- border-bottom: 1rpx solid #F0F0F0!important;
- }
- }
- }
-
-
- }
- </style>
|