一些优化

This commit is contained in:
haomingming 2025-09-04 17:34:47 +08:00
parent b068fb00cc
commit 4659f30400
18 changed files with 508 additions and 87 deletions

View File

@ -297,6 +297,14 @@ const api = {
return request('/expertAPI/modifyMobile', data, 'post', false); return request('/expertAPI/modifyMobile', data, 'post', false);
}, },
pointTicketlist(data){
return request('/expertAPI/pointTicketlist', data, 'post', false);
},
pointTicketExchange(data){
return request('/expertAPI/updateStatus', data, 'post', false);
},
smsSend(data){ smsSend(data){
return request('/expertAPI/smsSend', data, 'post', false); return request('/expertAPI/smsSend', data, 'post', false);
}, },

View File

@ -23,7 +23,34 @@ const course_api = {
// 创建订单 // 创建订单
createExcellencourseMixedOrder(id, order_pay_type, openid) { createExcellencourseMixedOrder(id, order_pay_type, openid) {
return request('/expertPay/createExcellencourseOrder', {appid:"wx061c1f4e16a5f20f", openid: openid, excellencourse_id: id, order_pay_type: order_pay_type}, 'post', true); let appid = "wx061c1f4e16a5f20f"
if (process.env.UNI_PLATFORM == "h5") {
appid = "wx061c1f4e16a5f20f"
} else if(process.env.UNI_PLATFORM == "mp-weixin") {
appid = "wx061c1f4e16a5f20f"
}else{
//app
appid = "wxbf3658f5e674667c"
}
return request('/expertPay/createExcellencourseOrder', {appid:appid, openid: openid, excellencourse_id: id, order_pay_type: order_pay_type}, 'post', true);
},
payExcellencourseOrderContinue(order_id, openid) {
let appid = "wx061c1f4e16a5f20f"
if (process.env.UNI_PLATFORM == "h5") {
appid = "wx061c1f4e16a5f20f"
} else if(process.env.UNI_PLATFORM == "mp-weixin") {
appid = "wx061c1f4e16a5f20f"
}else{
//app
appid = "wxbf3658f5e674667c"
}
return request('/expertPay/payExcellencourseOrderContinue', {order_id: order_id, appid:appid, openid: openid}, 'post', true);
},
cancelExcellencourseOrder(order_id) {
return request('/expertPay/cancelExcellencourseOrder', {excellencourse_order_id: order_id}, 'post', true);
}, },
// 订单列表 // 订单列表

View File

@ -1,6 +1,6 @@
{ {
"name" : "uniapp", "name" : "uniapp",
"appid" : "__UNI__34144D0", "appid" : "__UNI__C3DFBD4",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "100", "versionCode" : "100",
@ -44,7 +44,9 @@
], ],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ] "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ]
}, },
"ios" : {}, "ios" : {
"dSYMs" : false
},
/* ios */ /* ios */
"sdkConfigs" : { "sdkConfigs" : {
"oauth" : { "oauth" : {
@ -55,7 +57,6 @@
} }
}, },
"payment" : { "payment" : {
"appleiap" : {},
"weixin" : { "weixin" : {
"__platform__" : [ "ios", "android" ], "__platform__" : [ "ios", "android" ],
"appid" : "wxbf3658f5e674667c", "appid" : "wxbf3658f5e674667c",
@ -92,5 +93,8 @@
}, },
"usingComponents" : true "usingComponents" : true
}, },
"vueVersion" : "3" "vueVersion" : "3",
"uniStatistics" : {
"version" : "2"
}
} }

View File

@ -748,6 +748,16 @@
{ {
"root": "pages_goods", "root": "pages_goods",
"pages": [ "pages": [
{
"path": "coupon/coupon",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "积分券",
"app": {
"bounce": "none"
}
}
},
{ {
"path": "pointMall/pointMall", "path": "pointMall/pointMall",
"style": { "style": {
@ -824,7 +834,7 @@
"list": [ "list": [
{ {
"name": "", // "name": "", //
"path": "pages_app/videoDetail/videoDetail", // "path": "pages/index/index", //
"query": "" //onLoad "query": "" //onLoad
} }
] ]

View File

@ -124,7 +124,7 @@
</view> </view>
<!-- 浮动签到按钮 --> <!-- 浮动签到按钮 -->
<view class="floating-checkin" @click="performCheckin" :class="{ loading: loading }"> <!-- <view class="floating-checkin" @click="performCheckin" :class="{ loading: loading }">
<view class="checkin-icon"> <view class="checkin-icon">
<text class="calendar-icon">📅</text> <text class="calendar-icon">📅</text>
<text class="checkmark"></text> <text class="checkmark"></text>
@ -133,7 +133,7 @@
<text class="checkin-label">{{ loading ? '签到中...' : '点击签到' }}</text> <text class="checkin-label">{{ loading ? '签到中...' : '点击签到' }}</text>
<text class="checkin-reward">+2</text> <text class="checkin-reward">+2</text>
</view> </view>
</view> </view> -->
<!-- 底部导航 --> <!-- 底部导航 -->
<view class="bottom-nav"> <view class="bottom-nav">
@ -249,10 +249,13 @@
// //
const goToPointsCoupon = () => { const goToPointsCoupon = () => {
uni.showToast({ uni.navigateTo({
title: '积分券功能开发中', url: '/pages_goods/coupon/coupon'
icon: 'none'
}); });
// uni.showToast({
// title: '',
// icon: 'none'
// });
}; };
const goToBuyPoints = () => { const goToBuyPoints = () => {
@ -263,7 +266,7 @@
const goToPointsMall = () => { const goToPointsMall = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pages_app/pointMall/pointMall' url: '/pages_goods/pointMall/pointMall'
}); });
}; };

View File

@ -102,7 +102,8 @@
import eyeOpenImg from "@/static/eye_open.png" import eyeOpenImg from "@/static/eye_open.png"
import eyeCloseImg from "@/static/eye_close.png" import eyeCloseImg from "@/static/eye_close.png"
import api from "@/api/api.js" import api from "@/api/api.js"
import BASE_URL from "@/utils/config.js";
const customStyle = reactive({ const customStyle = reactive({
height: "100rpx", height: "100rpx",
fontSize: "36rpx", fontSize: "36rpx",
@ -226,16 +227,35 @@
uni.setStorageSync('DEV_AUTH_YX_TOKEN_App', result.YX_token); uni.setStorageSync('DEV_AUTH_YX_TOKEN_App', result.YX_token);
uni.setStorageSync('userInfo', result.data); uni.setStorageSync('userInfo', result.data);
} }
}else{
if (BASE_URL.indexOf('dev') == -1) {
uni.setStorageSync('AUTH_TOKEN_App',result.access_token);
uni.setStorageSync('AUTH_YX_ACCID_App', result.YX_accid);
uni.setStorageSync('AUTH_YX_TOKEN_App', result.YX_token);
uni.setStorageSync('userInfo', result.data);
} else {
uni.setStorageSync('DEV_AUTH_TOKEN_App', result.access_token);
uni.setStorageSync('DEV_AUTH_YX_ACCID_App', result.YX_accid);
uni.setStorageSync('DEV_AUTH_YX_TOKEN_App', result.YX_token);
uni.setStorageSync('userInfo', result.data);
}
} }
console.log(uni.getStorageSync('userInfo'))
console.log(1)
uni.hideLoading(); uni.hideLoading();
console.log(2)
uni.showToast({ uni.showToast({
title: '登录成功', title: '登录成功',
icon: 'success' icon: 'success'
}); });
console.log(3)
uni.redirectTo({ uni.redirectTo({
url:'/pages_course/course/course' url:'/pages/index/index'
}) })
console.log(4)
}) })
// //
// setTimeout(() => { // setTimeout(() => {

View File

@ -295,17 +295,14 @@
<script setup> <script setup>
import { ref, onMounted, onUnmounted } from 'vue' import { ref, onMounted, onUnmounted } from 'vue'
import course_api from "@/api/course_api.js" import course_api from "@/api/course_api.js"
import { onLoad } from '@dcloudio/uni-app'
const courseId = ref(0) onLoad((options) => {
onMounted(() => { courseId.value = options.id // App-Plus
// console.log('课程ID:', options.id)
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const options = currentPage.options || {}
courseId.value = options.id
console.log('课程ID:', options.id)
}) })
const courseId = ref(0)
// //
@ -762,7 +759,6 @@ const updatePageData = (data) => {
} }
} }
//
onMounted(() => { onMounted(() => {
getSystemInfo() getSystemInfo()
startCountdown() startCountdown()

View File

@ -146,6 +146,8 @@
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import course_api from '@/api/course_api' import course_api from '@/api/course_api'
import { onLoad } from '@dcloudio/uni-app'
// //
const statusBarHeight = ref(0) const statusBarHeight = ref(0)
@ -327,18 +329,17 @@ const onSortChange = (e) => {
filterCourses() filterCourses()
} }
// onLoad((options) => {
onMounted(() => {
//
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const options = currentPage.options || {}
type_id.value = options.type type_id.value = options.type
special_type.value = options.special_type special_type.value = options.special_type
special_name.value = options.special_name special_name.value = options.special_name
console.log('特殊类型ID:', options.special_type) console.log('特殊类型ID:', options.special_type)
console.log('类型ID:', options.type) console.log('类型ID:', options.type)
})
//
onMounted(() => {
getSystemInfo() getSystemInfo()
if(type_id.value > 0){ if(type_id.value > 0){
getSecondType() getSecondType()

View File

@ -90,6 +90,10 @@ import { ref, onMounted, computed } from 'vue'
import course_api from "@/api/course_api.js" import course_api from "@/api/course_api.js"
import { requestPayment } from '@/utils/payment.js' import { requestPayment } from '@/utils/payment.js'
import { onLoad } from '@dcloudio/uni-app'
// //
const statusBarHeight = ref(0) const statusBarHeight = ref(0)
const navBarHeight = ref(88) const navBarHeight = ref(88)
@ -201,14 +205,27 @@ const confirmPayment = () => {
return return
} }
order_pay_type.value = computeOrderPayType() order_pay_type.value = computeOrderPayType()
console.log('确认支付,支付方式:', { usePoints: usePoints.value, useBalance: useBalance.value, order_pay_type: order_pay_type.value }) console.log('确认支付,支付方式:', { usePoints: usePoints.value, useBalance: useBalance.value, order_pay_type: order_pay_type.value })
let openid = "" let openid = ""
if (process.env.NODE_ENV === 'development') {
openid = uni.getStorageSync('DEV_APPID'); if (process.env.UNI_PLATFORM == "h5") {
} else { if (process.env.NODE_ENV === 'development') {
openid = uni.getStorageSync('AUTH_APPID'); openid = uni.getStorageSync('DEV_APPID');
} else {
openid = uni.getStorageSync('AUTH_APPID');
}
} else if(process.env.UNI_PLATFORM == "mp-weixin") {
const {
envVersion
} = uni.getAccountInfoSync().miniProgram;
if (envVersion == "release") {
openid = uni.getStorageSync('DEV_APPID');
} else {
openid = uni.getStorageSync('AUTH_APPID');
}
}else{
//app
} }
course_api.createExcellencourseMixedOrder(courseId.value, order_pay_type.value, openid).then(res => { course_api.createExcellencourseMixedOrder(courseId.value, order_pay_type.value, openid).then(res => {
console.log('创建订单:', res) console.log('创建订单:', res)
@ -313,15 +330,13 @@ const updatePaymentMethod = () => {
} }
} }
onLoad((options) => {
courseId.value = options.id // App-Plus
console.log('课程ID:', options.id)
})
// //
onMounted(() => { onMounted(() => {
//
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const options = currentPage.options || {}
courseId.value = options.id
console.log('课程ID:', options.id)
getSystemInfo() getSystemInfo()
getCourseInfo() getCourseInfo()
}) })

View File

@ -63,6 +63,8 @@
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import course_api from "@/api/course_api.js" import course_api from "@/api/course_api.js"
import { onLoad } from '@dcloudio/uni-app'
// //
const statusBarHeight = ref(0) const statusBarHeight = ref(0)
@ -150,18 +152,17 @@ const goBack = () => {
uni.navigateBack() uni.navigateBack()
} }
// onLoad((options) => {
onMounted(() => {
getSystemInfo()
//
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const options = currentPage.options || {}
is_commented.value = options.is_commented is_commented.value = options.is_commented
courseId.value = options.id courseId.value = options.id
console.log('课程ID:', options.id) console.log('课程ID:', options.id)
}) })
//
onMounted(() => {
getSystemInfo()
})
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@ -122,6 +122,7 @@
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import course_api from "@/api/course_api.js" import course_api from "@/api/course_api.js"
import { onLoad } from '@dcloudio/uni-app'
const invoice_id = ref('') const invoice_id = ref('')
@ -312,15 +313,14 @@ const loadInvoiceData = () => {
}) })
} }
onLoad((options) => {
invoice_id.value = options.invoice_id // App-Plus
console.log('发票ID:', options.invoice_id)
})
onMounted(() => { onMounted(() => {
getSystemInfo() getSystemInfo()
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const options = currentPage.options || {}
invoice_id.value = options.invoice_id
if (!invoice_id.value) { if (!invoice_id.value) {
hasError.value = true hasError.value = true
isLoading.value = false isLoading.value = false

View File

@ -67,8 +67,8 @@
</view> </view>
<!-- 剩余时间仅未支付订单显示 --> <!-- 剩余时间仅未支付订单显示 -->
<view class="remaining-time" v-if="order.remainingTime && activeTab === 'unpaid'"> <view class="remaining-time" v-if="order.expire_time && activeTab === 'unpaid'">
<text class="time-text">剩余时间: {{ order.remainingTime }}</text> <text class="time-text">剩余时间: {{ countdownDisplay[order.id] || formatCountdown(order.expire_time) }}</text>
</view> </view>
<!-- 操作按钮 --> <!-- 操作按钮 -->
@ -105,8 +105,9 @@
</template> </template>
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted, onUnmounted } from 'vue'
import course_api from "@/api/course_api.js" import course_api from "@/api/course_api.js"
import { requestPayment } from "@/utils/payment.js"
// //
const statusBarHeight = ref(0) const statusBarHeight = ref(0)
@ -114,6 +115,10 @@ const navBarHeight = ref(88)
const activeTab = ref('paid') // "" const activeTab = ref('paid') // ""
// //
const orderList = ref([]) const orderList = ref([])
//
const countdownTimer = ref(null)
//
const countdownDisplay = ref({})
// //
const currentOrderList = computed(() => { const currentOrderList = computed(() => {
@ -136,7 +141,70 @@ const goBack = () => {
uni.navigateBack() uni.navigateBack()
} }
//
const formatCountdown = (timestamp) => {
if (!timestamp) return ''
const now = Math.floor(Date.now() / 1000) //
const expireTime = parseInt(timestamp) //
const remainingSeconds = expireTime - now
if (remainingSeconds <= 0) {
return '已过期'
}
const days = Math.floor(remainingSeconds / 86400)
const hours = Math.floor((remainingSeconds % 86400) / 3600)
const minutes = Math.floor((remainingSeconds % 3600) / 60)
const seconds = remainingSeconds % 60
if (days > 0) {
return `${days}${hours.toString().padStart(2, '0')}小时${minutes.toString().padStart(2, '0')}分钟`
} else if (hours > 0) {
return `${hours}小时${minutes.toString().padStart(2, '0')}分钟${seconds.toString().padStart(2, '0')}`
} else if (minutes > 0) {
return `${minutes}分钟${seconds.toString().padStart(2, '0')}`
} else {
return `${seconds}`
}
}
//
const updateCountdownDisplay = () => {
const currentList = orderList.value[activeTab.value] || []
currentList.forEach(order => {
if (order.expire_time) {
countdownDisplay.value[order.id] = formatCountdown(order.expire_time)
}
})
}
//
const startCountdown = () => {
if (countdownTimer.value) {
clearInterval(countdownTimer.value)
}
//
updateCountdownDisplay()
countdownTimer.value = setInterval(() => {
updateCountdownDisplay()
}, 1000)
}
//
const stopCountdown = () => {
if (countdownTimer.value) {
clearInterval(countdownTimer.value)
countdownTimer.value = null
}
}
const switchTab = (tab) => { const switchTab = (tab) => {
//
stopCountdown()
activeTab.value = tab activeTab.value = tab
console.log('切换到标签:', tab) console.log('切换到标签:', tab)
getOrderList() getOrderList()
@ -157,12 +225,14 @@ const copyOrderNumber = (orderNumber) => {
const getSecondaryButtonText = (status) => { const getSecondaryButtonText = (status) => {
switch (status) { switch (status) {
case 'pending': case 'created':
return '取消订单' return '取消订单'
case 'timeout': case 'overtime':
return '支付超时' return '支付超时'
case 'failed': case 'failed':
return '支付失败' return '支付失败'
case 'canceled':
return '已取消'
default: default:
return '查看订单' return '查看订单'
} }
@ -170,11 +240,13 @@ const getSecondaryButtonText = (status) => {
const getPrimaryButtonText = (status) => { const getPrimaryButtonText = (status) => {
switch (status) { switch (status) {
case 'pending': case 'canceled':
return '继续支付' return '已取消'
case 'timeout': case 'overtime':
case 'failed': case 'failed':
return '查看课程' return '查看课程'
case 'created':
return '继续支付'
default: default:
return '进入学习' return '进入学习'
} }
@ -182,7 +254,7 @@ const getPrimaryButtonText = (status) => {
const handleSecondaryAction = (order) => { const handleSecondaryAction = (order) => {
switch (order.status) { switch (order.status) {
case 'pending': case 'created':
cancelOrder(order) cancelOrder(order)
break break
case 'timeout': case 'timeout':
@ -196,7 +268,7 @@ const handleSecondaryAction = (order) => {
const handlePrimaryAction = (order) => { const handlePrimaryAction = (order) => {
switch (order.status) { switch (order.status) {
case 'pending': case 'created':
continuePayment(order) continuePayment(order)
break break
case 'timeout': case 'timeout':
@ -214,11 +286,8 @@ const cancelOrder = (order) => {
content: '确定要取消这个订单吗?', content: '确定要取消这个订单吗?',
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
uni.showToast({ //
title: '订单已取消', cancelExcellencourseOrder(order)
icon: 'success'
})
// API
} }
} }
}) })
@ -226,9 +295,8 @@ const cancelOrder = (order) => {
const continuePayment = (order) => { const continuePayment = (order) => {
console.log('继续支付订单:', order.id) console.log('继续支付订单:', order.id)
uni.navigateTo({ //
url: '/pages_course/course_payment/course_payment' payExcellencourseOrderContinue(order)
})
} }
const viewCourse = (order) => { const viewCourse = (order) => {
@ -290,11 +358,20 @@ const getOrderList = () => {
balancePayment: balanceCents > 0 ? toYuan(balanceCents) : null, balancePayment: balanceCents > 0 ? toYuan(balanceCents) : null,
pointsPayment: points > 0 ? points : null, pointsPayment: points > 0 ? points : null,
actualPayment: toYuan(item.pay_account), actualPayment: toYuan(item.pay_account),
status: item.order_status === 'paid' ? 'paid' : 'created' status: item.order_status,
expire_time: item.expire_time //
} }
}) })
orderList.value[activeTab.value] = mapped orderList.value[activeTab.value] = mapped
//
countdownDisplay.value = {}
//
if (activeTab.value === 'unpaid' && mapped.length > 0) {
startCountdown()
}
} else { } else {
uni.showToast({ title: res.msg || '获取订单失败', icon: 'none' }) uni.showToast({ title: res.msg || '获取订单失败', icon: 'none' })
} }
@ -303,11 +380,116 @@ const getOrderList = () => {
}) })
} }
const payExcellencourseOrderContinue = (order) => {
//
uni.showLoading({ title: '处理中...' })
let openid = ""
if (process.env.UNI_PLATFORM == "h5") {
if (process.env.NODE_ENV === 'development') {
openid = uni.getStorageSync('DEV_APPID');
} else {
openid = uni.getStorageSync('AUTH_APPID');
}
} else if(process.env.UNI_PLATFORM == "mp-weixin") {
const {
envVersion
} = uni.getAccountInfoSync().miniProgram;
if (envVersion == "release") {
openid = uni.getStorageSync('DEV_APPID');
} else {
openid = uni.getStorageSync('AUTH_APPID');
}
}else{
//app
}
course_api.payExcellencourseOrderContinue(order.id, openid).then(res => {
console.log('继续支付订单:', res)
uni.hideLoading()
if (res.code == 200) {
const payParams = res.data.order
console.log(payParams)
requestPayment(
payParams,
//
(res) => {
uni.showToast({ title: '支付成功', icon: 'success' })
//
getOrderList()
},
//
(err) => {
console.error('支付失败', err)
uni.showToast({ title: '支付失败或取消', icon: 'none' })
}
)
} else {
uni.showToast({
title: res.msg || '继续支付失败',
icon: 'none',
duration: 3000
})
}
}).catch(err => {
uni.hideLoading()
console.error('继续支付订单失败:', err)
uni.showToast({
title: '网络错误,请重试',
icon: 'none',
duration: 3000
})
})
}
const cancelExcellencourseOrder = (order) => {
//
uni.showLoading({ title: '取消中...' })
course_api.cancelExcellencourseOrder(order.id).then(res => {
console.log('取消订单:', res)
uni.hideLoading()
if (res.code == 200) {
uni.showToast({
title: '订单已取消',
icon: 'success',
duration: 2000
})
//
setTimeout(() => {
getOrderList()
}, 1500)
} else {
uni.showToast({
title: res.msg || '取消订单失败',
icon: 'none',
duration: 3000
})
}
}).catch(err => {
uni.hideLoading()
console.error('取消订单失败:', err)
uni.showToast({
title: '网络错误,请重试',
icon: 'none',
duration: 3000
})
})
}
// //
onMounted(() => { onMounted(() => {
getSystemInfo() getSystemInfo()
getOrderList() getOrderList()
}) })
onUnmounted(() => {
stopCountdown()
})
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@ -0,0 +1,144 @@
<template>
<view class="coupon-page">
<uni-nav-bar
left-icon="left"
title="积分券"
@clickLeft="goBack"
fixed
color="#8B2316"
height="140rpx"
:border="false"
backgroundColor="#ffffff"
/>
<!-- 顶部 tabs -->
<view class="tabs">
<view
v-for="(tab, i) in tabs"
:key="tab.value"
class="tab-item"
:class="{ active: activeTab === i }"
@click="setActiveTab(i)"
>
<text class="tab-text">{{ tab.label }}</text>
</view>
</view>
<!-- 列表 -->
<scroll-view scroll-y class="list" :show-scrollbar="false">
<view v-if="currentList.length" class="card-wrap">
<view :class="['coupon-card', { gray: activeTab !== 0 }]" v-for="(item, idx) in currentList" :key="idx">
<view class="card-top" style="display: flex; padding: 32rpx 28rpx;">
<view class="card-left">
<text class="points">{{ item.points }}</text>
<text class="points-unit">积分券</text>
</view>
<view class="card-right" style="text-align: center;">
<view class="title">{{ item.title }}</view>
</view>
</view>
<view class="card-bottom" style="display: flex; background-color: #fff;color: #000; padding: 32rpx 28rpx;">
<view class="expire">有效期{{ item.expire }}</view>
<button class="btn" v-if="activeTab === 0" @click="goExchange(item)">在线兑换</button>
</view>
</view>
</view>
<view v-else class="empty">暂无数据</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import navTo from '@/utils/navTo.js'
import api from '@/api/api.js'
const tabs = [
{ label: '未兑换', value: '1' },
{ label: '已兑换', value: '2' },
{ label: '已过期', value: '3' },
{ label: '已作废', value: '4' }
]
const activeTab = ref(0)
onMounted(() => {
getPointTicketList()
})
//
const currentList = ref([])
const goBack = () => {
uni.navigateBack()
}
const goExchange = (item) => {
// 线
uni.showModal({
title: '确认兑换',
content: `将使用${item.points}积分券进行兑换,是否继续?`,
confirmText: '确认兑换',
cancelText: '再想想',
success: (res) => {
if (res.confirm) {
api.pointTicketExchange({uuid: item.uuid}).then(res => {
console.log(res)
if (res.code === 200 || res.code === '200') {
uni.showToast({ title: '兑换成功', icon: 'success' })
getPointTicketList()
}
})
}
}
})
}
const getPointTicketList = () => {
api.pointTicketlist({page: 1, status: activeTab.value+1}).then(res => {
const rows = (res && res.data && res.data.list ? res.data.list : []).map(r => ({
uuid: r.uuid,
points: r.point,
title: '肝胆相照',
expire: formatDate(r.end_date)
}))
currentList.value = rows
})
}
const setActiveTab = (i) => {
activeTab.value = i
getPointTicketList()
}
const formatDate = (seconds) => {
if (!seconds) return ''
const d = new Date(seconds * 1000)
const y = d.getFullYear()
const m = `${d.getMonth() + 1}`.padStart(2, '0')
const day = `${d.getDate()}`.padStart(2, '0')
return `${y}${m}${day}`
}
</script>
<style scoped>
.coupon-page{background:#f5f5f5;min-height:100vh}
.tabs{display:flex;align-items:center;justify-content:space-around;height:88rpx;background:#fff;border-bottom:1px solid #f0f0f0}
.tab-item{flex:1;display:flex;align-items:center;justify-content:center}
.tab-text{font-size:28rpx;color:#999}
.tab-item.active .tab-text{color:#8B2316;font-weight:600}
.list{height:calc(100vh - 88rpx - 140rpx);}
.card-wrap{padding:24rpx}
.coupon-card{display:flex;flex-direction: column; background:linear-gradient(90deg,#ff7381, #ff6a7a);border-radius:16rpx;color:#fff;position:relative;margin-bottom:24rpx}
.coupon-card.gray{background:#e5e5e5;color:#666}
.card-left{width:220rpx;display:flex;flex-direction:column;align-items:center;justify-content:center;border-right:2rpx solid rgba(255,255,255,.5)}
.points{font-size:80rpx;line-height:1}
.points-unit{font-size:28rpx;margin-top:12rpx}
.card-right{flex:1;padding-left:28rpx;display:flex;flex-direction:column;justify-content:center}
.title{font-size:40rpx;font-weight:600}
.expire{font-size:26rpx;opacity:.95;height:64rpx;line-height:64rpx;flex:3}
.btn{border: 1px solid #ff4b5a;flex:1;height:64rpx;line-height:64rpx;padding:0 28rpx;background:#fff;color:#ff4b5a;border-radius:100rpx;font-size:28rpx}
.empty{padding:120rpx 0;text-align:center;color:#999}
</style>

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,4 +1,5 @@
import pageUrl from './pageUrl' import pageUrl from './pageUrl'
import BASE_URL from './config.js';
function navTo(obj) { function navTo(obj) {
let token = ''; let token = '';
@ -8,13 +9,19 @@ function navTo(obj) {
}else{ }else{
token = uni.getStorageSync('DEV_AUTH_TOKEN_App'); token = uni.getStorageSync('DEV_AUTH_TOKEN_App');
} }
}else if(process.env.UNI_PLATFORM == "mp-weixin") {
const { envVersion } = uni.getAccountInfoSync().miniProgram;
if (envVersion == "release") {
token = uni.getStorageSync('AUTH_TOKEN_App');
}else{
token = uni.getStorageSync('DEV_AUTH_TOKEN_App');
}
}else{ }else{
const { envVersion } = uni.getAccountInfoSync().miniProgram; if (BASE_URL.indexOf('dev') == -1) {
if (envVersion == "release") {
token = uni.getStorageSync('AUTH_TOKEN_App'); token = uni.getStorageSync('AUTH_TOKEN_App');
}else{ } else {
token = uni.getStorageSync('DEV_AUTH_TOKEN_App'); token = uni.getStorageSync('DEV_AUTH_TOKEN_App');
} }
} }
if (!token) { if (!token) {
// let page_url = pageUrl(); // let page_url = pageUrl();

View File

@ -63,12 +63,7 @@ export function requestPayment(orderInfo, successCallback, failCallback) {
uni.requestPayment({ uni.requestPayment({
provider: provider, // 可选值wxpay、alipay、appleiap 等 provider: provider, // 可选值wxpay、alipay、appleiap 等
orderInfo: orderInfo.orderInfo, // 支付宝传 orderInfo微信可能传其它参数 orderInfo: orderInfo,
timeStamp: orderInfo.timestamp,
nonceStr: orderInfo.noncestr,
package: orderInfo.package_str,
signType: orderInfo.signType || 'RSA',
paySign: orderInfo.sign,
success: (res) => { success: (res) => {
console.log(`${provider} 支付成功`, res); console.log(`${provider} 支付成功`, res);
successCallback && successCallback(res); successCallback && successCallback(res);

View File

@ -33,6 +33,13 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
} else { } else {
token = uni.getStorageSync('DEV_AUTH_TOKEN_App'); token = uni.getStorageSync('DEV_AUTH_TOKEN_App');
} }
}else{
if (BASE_URL.indexOf('dev') == -1) {
token = uni.getStorageSync('AUTH_TOKEN_App');
} else {
token = uni.getStorageSync('DEV_AUTH_TOKEN_App');
}
} }
let header = { let header = {
'content-type': contentType, 'content-type': contentType,
@ -66,6 +73,7 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
if(token){ if(token){
header['Authorization']='Bearer ' +token; header['Authorization']='Bearer ' +token;
let userInfo= uni.getStorageSync('userInfo') let userInfo= uni.getStorageSync('userInfo')
console.log(userInfo)
defaultData = { defaultData = {
version: '4.0.0', version: '4.0.0',
user_uuid:userInfo.uuid, user_uuid:userInfo.uuid,
@ -106,7 +114,7 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
}; };
if(url.indexOf('manager/getSystemTimeStamp')!=-1){ if(url.indexOf('manager/getSystemTimeStamp')!=-1){
e(res) e(res)
}else if (res.data.code == 200 || res.data.code ==1){ }else if (res.data.code == 200 || res.data.code == 1 || res.data.code == "1" || res.data.code == "200"){
e(res.data) e(res.data)
}else if (res.data.code == 401 || res.data.code == 403 || res.data.code == }else if (res.data.code == 401 || res.data.code == 403 || res.data.code ==
405 || res.data.code == 406 || res.data.code == 37006) { 405 || res.data.code == 406 || res.data.code == 37006) {