You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

286 lines
7.5 KiB

1 year ago
<template>
<view class="container">
1 year ago
<image class="cbg" :src="base.imgHost('common_bg.png')"></image>
1 year ago
<view class="wrap">
<view>{{courseInfo.name}}</view>
<view v-if="info.fee_status==1">
您已缴费成功
</view>
<view v-else-if="info.fee_status==2">
您上传的缴费图片有误请重新上传
</view>
<view v-else-if="info.fee_status==3">
您已上传成功请等待确认
</view>
<view v-if="info.fee_status!=1">
上传缴费图片
<u-button type="primary" size="mini" @click="uploadFile()"></u-button>
<!-- <u-upload :header='header'
@on-success="uploadSuccess"
:action="action" :file-list="fileList" max-count="1"></u-upload> -->
</view>
<view v-if="hasFeeFiles" style="width:100%;">
<image mode="widthFix" style="width:80%;margin:0 auto;display: block;" :src="info.fee_files[0].url">
</image>
</view>
</view>
<view class="modal">
<u-popup v-model="showPark" mode="bottom">
<view class="modal-tip">绑定车牌号</view>
<view class="modal-content">
<view>
车牌1<u-input type="text" placeholder="请输入车牌" v-model="plate1" />
</view>
<view>
车牌2<u-input type="text" placeholder="请输入车牌" v-model="plate2" />
</view>
</view>
<view class="modal-btn">
<u-button type="primary" @click="updatePlate"></u-button>
</view>
</u-popup>
1 year ago
</view>
</view>
</template>
1 year ago
<script>
import {
ROOTPATH as baseUrl
1 year ago
} from "@/common/config.js"
export default {
1 year ago
components: {},
1 year ago
data() {
1 year ago
return {
hasFeeFiles: false,
course_id: '',
info: {},
userInfo: {},
courseInfo: {},
header: {},
action: `${baseUrl}/api/mobile/upload-file`,
fileList: {},
showPark: false,
plate1: '',
plate2: ''
1 year ago
}
},
1 year ago
onLoad(options) {
this.course_id = options.id
let token = uni.getStorageSync('stbc_lifeData') ? uni.getStorageSync('stbc_lifeData').vuex_token : ''
this.header.Authorization = `Bearer ${token}`
1 year ago
this.getCourseDetail(options.id)
1 year ago
},
methods: {
async getCourseDetail(id) {
const res = await this.$u.api.courseGetSign({
course_id: id
})
this.info = res.detail
this.userInfo = res.detail.user
this.courseInfo = res.detail.course
if (res.detail.fee_files.length > 0) {
this.hasFeeFiles = true
} else {
this.hasFeeFiles = false
}
},
uploadFile() {
uni.chooseImage({
success: (chooseImageRes) => {
console.log("chooseImageRes", chooseImageRes)
const tempFilePaths = chooseImageRes.tempFilePaths;
if (chooseImageRes.tempFilePaths && chooseImageRes.tempFilePaths.length > 1) {
this.base.toast("缴费图片只能上传1张")
return
}
uni.uploadFile({
url: this.action,
filePath: tempFilePaths[0],
fileType: 'image',
name: 'file',
header: this.header,
success: (uploadFileRes) => {
this.fileList = {}
this.fileList = JSON.parse(uploadFileRes.data)
this.updateSign()
},
fail(err) {
console.log("err", err)
this.base.toast("上传失败")
},
});
}
});
},
updateSign() {
1 year ago
let files_id = [this.fileList.id]
1 year ago
let that = this
this.$u.api.courseUpdateSign({
id: this.info.id,
fee_file_ids: files_id,
fee_status: 3
}).then(res => {
that.base.toast("上传成功", 1500, function() {
setTimeout(function() {
that.newsSubscription()
}, 500)
})
})
},
updatePlate() {
if (this.base.isNull(this.plate1) && this.base.isNull(this.plate2)) {
this.base.toast('请输入至少一个车牌')
return
}
this.$u.api.saveUser({
id: this.userInfo.id,
plate: this.plate1 + ',' + this.plate2
}).then(res => {
this.base.toast("绑定车牌成功")
this.$u.api.user().then(res => {
this.$u.vuex('vuex_user', res.user)
this.showPark = false
})
})
},
// 订阅缴费
newsSubscription() {
let that = this
uni.getSetting({
withSubscriptions: true, //是否获取用户订阅消息的订阅状态默认false不返回
success(res) {
console.log("resdfg", res)
if (res.subscriptionsSetting.mainSwitch) {
if (res.subscriptionsSetting.itemSettings && res.subscriptionsSetting.itemSettings[
'CCEUrg9t8aW40NEDoqEk7NY7pyllW_0GEHfjwg_DF6A'] === 'accept') {
// 用户已经订阅该消息模板,执行相应操作
if (!that.hasFeeFiles) {
// 第一次 且 没有车牌号 弹出
if (that.base.isNull(that.userInfo.plate)) {
that.showPark = true
}
}
that.getCourseDetail(that.course_id)
} else {
// 用户没有订阅该消息模板,显示订阅弹窗
uni.showModal({
title: '订阅消息',
content: '是否需要订阅缴费结果消息',
success(res1) {
if (res1.confirm) {
uni.requestSubscribeMessage({
tmplIds: [
'CCEUrg9t8aW40NEDoqEk7NY7pyllW_0GEHfjwg_DF6A',
],
success(res) {
that.base.toast("订阅成功", 1500, function() {
// 有缴费图片,证明不是第一次上传,不弹出车位绑定
if (!that.hasFeeFiles) {
// 第一次 且 没有车牌号 弹出
if (that.base.isNull(that
.userInfo.plate)) {
that.showPark = true
}
}
that.getCourseDetail(that
.course_id)
})
},
fail(err) {
// 有缴费图片,证明不是第一次上传,不弹出车位绑定
if (!that.hasFeeFiles) {
// 第一次 且 没有车牌号 弹出
if (that.base.isNull(that.userInfo
.plate)) {
that.showPark = true
}
}
that.getCourseDetail(that.course_id)
}
})
} else {
if (!that.hasFeeFiles) {
// 第一次 且 没有车牌号 弹出
if (that.base.isNull(that.userInfo.plate)) {
that.showPark = true
}
}
that.getCourseDetail(that.course_id)
}
}
})
}
} else {
if (!that.hasFeeFiles) {
// 第一次 且 没有车牌号 弹出
if (that.base.isNull(that.userInfo.plate)) {
that.showPark = true
}
}
that.getCourseDetail(that.course_id)
// 用户尚未开启订阅消息总开关,建议提醒用户开启
}
}
});
},
1 year ago
}
}
</script>
<style scoped lang="scss">
.container {
padding: 30rpx;
width: 100%;
height: 100vh;
overflow: scroll;
1 year ago
1 year ago
.cbg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
}
.wrap {
position: relative;
1 year ago
&>view {
margin: 20rpx 0;
}
}
.modal {
&-tip {
text-align: center;
padding: 30rpx;
font-size: 28rpx;
}
&-content {
height: 300rpx;
padding: 0 30rpx;
}
&-btn {
display: flex;
justify-content: center;
padding: 30rpx;
u-button {
width: 45%;
}
1 year ago
}
}
}
</style>