Browse Source

1、修复bug

2、新增充值
3、优化
master
梁欣 2 months ago
parent
commit
a3ff6e6d34
  1. 3
      src/api/chargePackage.js
  2. 1
      src/api/shop.js
  3. 4
      src/manifest.json
  4. 6
      src/pages.json
  5. 299
      src/pages/shop/checkout.vue
  6. 7
      src/pages/signUp/info.vue
  7. 4
      src/pages/signUp/self.vue
  8. 92
      src/pages/user/balance.vue
  9. 10
      src/pages/user/user.vue
  10. BIN
      src/static/image/balance-bg.png
  11. BIN
      src/static/image/balance.png

3
src/api/chargePackage.js

@ -0,0 +1,3 @@
import http from './index.js';
import {SERVER_API_URL} from "@/config";
export const listChargePackage = () => http.get(`/shop/charge-package`)

1
src/api/shop.js

@ -26,3 +26,4 @@ export const messageInfoReq = (id) => http.get(`/shop/message/${id}`)
export const messageReadReq = (data) => http.post(`/shop/message/read`, data) export const messageReadReq = (data) => http.post(`/shop/message/read`, data)
export const messageHasUnreadReq = (data) => http.post(`/shop/message/has-unread`, data) export const messageHasUnreadReq = (data) => http.post(`/shop/message/has-unread`, data)
export const messageUnreadNumReq = (data) => http.post(`/shop/message/unread-num`, data) export const messageUnreadNumReq = (data) => http.post(`/shop/message/unread-num`, data)
export const newChargeOrderReq = (data) => http.post(`/shop/order/charge-order`, data)

4
src/manifest.json

@ -3,8 +3,8 @@
"appid" : "__UNI__06C03D0", "appid" : "__UNI__06C03D0",
//__UNI__06C03D0 //__UNI__06C03D0
"description" : "", "description" : "",
"versionName" : "1.34.3",
"versionCode" : "252",
"versionName" : "1.35.0",
"versionCode" : "254",
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {

6
src/pages.json

@ -650,6 +650,12 @@
"style": { "style": {
"navigationBarTitleText": "详情" "navigationBarTitleText": "详情"
} }
},
{
"path": "pages/user/balance",
"style": {
"navigationBarTitleText": "钱包"
}
} }
], ],
"tabBar": { "tabBar": {

299
src/pages/shop/checkout.vue

@ -1,67 +1,70 @@
<template> <template>
<view class="min-height bg-gray p-20">
<header-item title="结算台"></header-item>
<view class="card my-20 flex justify-between items-center" @click="toAddress">
<view class="flex justify-start items-center">
<uv-icon name="map"/>
<view class="ml-15 flex flex-col justify-start items-start text-25">
<text v-if="!address">点击选择地址</text>
<template v-else>
<view class="text-35 u-line-1">{{ address.name }}</view>
<view class="my-20">
<uv-text :text="address.phone" size="25rpx" color="#bbb"/>
</view>
<text style="color: #666666;" class="text-25">{{ address.fullAddress }}</text>
</template>
</view>
<view class="min-height bg-gray p-20">
<header-item title="结算台"></header-item>
<view class="card my-20 flex justify-between items-center" @click="toAddress">
<view class="flex justify-start items-center">
<uv-icon name="map"/>
<view class="ml-15 flex flex-col justify-start items-start text-25">
<text v-if="!address">点击选择地址</text>
<template v-else>
<view class="text-35 u-line-1">{{ address.name }}</view>
<view class="my-20">
<uv-text :text="address.phone" size="25rpx" color="#bbb"/>
</view> </view>
<uv-icon name="arrow-right"/>
<text style="color: #666666;" class="text-25">{{ address.fullAddress }}</text>
</template>
</view> </view>
<template v-if="cartData && cartData.goods">
<view class="card flex justify-between mb-20">
<view class="flex justify-start items-start">
<uv-image radius="15" :src="cartData.goods.image" width="150rpx" height="150rpx"/>
<view class="flex justify-start items-start flex-col">
<text class="text-30 font-bold">{{ cartData.goods.goodsName }}</text>
<text class="text-25 text-gray mt-20">{{ cartData.spec }}</text>
</view>
</view>
<view class="flex justify-end items-end flex-col">
<text class="text-35">{{
cartData.price
}}{{ `${cartData.point > 0 ? ` +${cartData.point}积分` : ''}` }}
</text>
<text class="text-25 text-gray mt-20">x{{ cartData.cartNum }}</text>
<text class="text-25 text-gray mt-20">小计: {{ cartData.totalPrice }}</text>
</view>
</view>
<view class="card flex justify-between mb-20">
<uv-cell-group :border="false">
<uv-cell title="商品总价" :value="`¥${cartData.totalPrice}`"></uv-cell>
<uv-cell title="商品数量" :value="`x${cartData.cartNum}`"></uv-cell>
<uv-cell v-if="cartData.point > 0" title="使用积分" :value="`${cartData.point}积分`"
:border="false"></uv-cell>
</uv-cell-group>
</view>
<view class="card flex justify-between mb-20" v-if="cartData.totalPrice > 0">
<uv-cell-group :border="false">
<!-- <uv-cell isLink @click="payMethod = 'wechat' " title="微信支付" icon="/static/image/wechat-pay.png"-->
<!-- :rightIcon="payMethod === 'wechat' ? '/static/image/radio-checked.png' : '/static/image/radio.png'"></uv-cell>-->
<uv-cell isLink @click="selectPayMethod('alipay')" title="支付宝支付"
icon="/static/image/alipay-pay.png" :border="false"
:rightIcon="payMethod === 'alipay' ? '/static/image/radio-checked.png' : '/static/image/radio.png'"></uv-cell>
</uv-cell-group>
</view>
</template>
<view class="footer">
<view class="p-20">
<uv-button :text="payStr" :disabled="!canPay || disabled"
:custom-style="{background: COLORS.LINEAR, width: '100%', color: 'white'}"
shape="circle"
@click="action"></uv-button>
</view>
</view>
<uv-icon name="arrow-right"/>
</view>
<template v-if="cartData && cartData.goods">
<view class="card flex justify-between mb-20">
<view class="flex justify-start items-start">
<uv-image radius="15" :src="cartData.goods.image" width="150rpx" height="150rpx"/>
<view class="flex justify-start items-start flex-col">
<text class="text-30 font-bold">{{ cartData.goods.goodsName }}</text>
<text class="text-25 text-gray mt-20">{{ cartData.spec }}</text>
</view>
</view>
<view class="flex justify-end items-end flex-col">
<text class="text-35">{{
cartData.price
}}{{ `${cartData.point > 0 ? ` +${cartData.point}积分` : ''}` }}
</text>
<text class="text-25 text-gray mt-20">x{{ cartData.cartNum }}</text>
<text class="text-25 text-gray mt-20">小计: {{ cartData.totalPrice }}</text>
</view> </view>
</view>
<view class="card flex justify-between mb-20">
<uv-cell-group :border="false">
<uv-cell title="商品总价" :value="`¥${cartData.totalPrice}`"></uv-cell>
<uv-cell title="商品数量" :value="`x${cartData.cartNum}`"></uv-cell>
<uv-cell v-if="cartData.point > 0" title="使用积分" :value="`${cartData.point}积分`"
:border="false"></uv-cell>
</uv-cell-group>
</view>
<view class="card flex justify-between mb-20" v-if="cartData.totalPrice > 0">
<uv-cell-group :border="false">
<!-- <uv-cell isLink @click="payMethod = 'wechat' " title="微信支付" icon="/static/image/wechat-pay.png"-->
<!-- :rightIcon="payMethod === 'wechat' ? '/static/image/radio-checked.png' : '/static/image/radio.png'"></uv-cell>-->
<uv-cell isLink @click="selectPayMethod('balance')" :title="`余额支付(余额:${userInfo.balance}元)`"
icon="/static/image/balance.png" :border="false"
:rightIcon="payMethod === 'balance' ? '/static/image/radio-checked.png' : '/static/image/radio.png'"></uv-cell>
<uv-cell isLink @click="selectPayMethod('alipay')" title="支付宝支付"
icon="/static/image/alipay-pay.png" :border="false"
:rightIcon="payMethod === 'alipay' ? '/static/image/radio-checked.png' : '/static/image/radio.png'"></uv-cell>
</uv-cell-group>
</view>
</template>
<view class="footer">
<view class="p-20">
<uv-button :text="payStr" :disabled="!canPay || disabled"
:custom-style="{background: COLORS.LINEAR, width: '100%', color: 'white'}"
shape="circle"
@click="action"></uv-button>
</view>
</view> </view>
</view>
</template> </template>
<script setup> <script setup>
@ -70,26 +73,26 @@ import HeaderItem from "@/components/HeaderItem.vue";
import {addOrderReq, cartListReq} from "@/api/shop"; import {addOrderReq, cartListReq} from "@/api/shop";
import {onLoad} from "@dcloudio/uni-app"; import {onLoad} from "@dcloudio/uni-app";
import * as COLORS from "@/config/color"; import * as COLORS from "@/config/color";
import {userDetailReq} from "@/api/user";
import {getUser, userDetailReq} from "@/api/user";
import {toast} from "@/uni_modules/uv-ui-tools/libs/function"; import {toast} from "@/uni_modules/uv-ui-tools/libs/function";
import {userAddressDefaultReq} from "@/api/address"; import {userAddressDefaultReq} from "@/api/address";
const address = ref() const address = ref()
const toAddress = () => { const toAddress = () => {
uni.navigateTo({
url: '/pages/user/address/list?isSelect=1',
events: {
select: res => {
address.value = res
}
}
})
uni.navigateTo({
url: '/pages/user/address/list?isSelect=1',
events: {
select: res => {
address.value = res
}
}
})
} }
const cartData = ref() const cartData = ref()
const getCartList = async () => { const getCartList = async () => {
const {data} = await cartListReq(cartId.value)
cartData.value = data
const {data} = await cartListReq(cartId.value)
cartData.value = data
} }
const payStr = ref('立即支付') const payStr = ref('立即支付')
@ -97,97 +100,109 @@ const payMethod = ref('')
const canPay = ref(true) const canPay = ref(true)
const disabled = ref(false) const disabled = ref(false)
const userInfo = ref({})
const getUserInfo = async () => {
const {data} = await getUser()
userInfo.value = data
}
getUserInfo()
const userDetail = ref() const userDetail = ref()
const getUserDetail = async () => { const getUserDetail = async () => {
const {data} = await userDetailReq()
userDetail.value = data
if (cartData.value.totalPrice === 0) {
if (cartData.value.point > 0) {
if (userDetail.value.point >= cartData.value.point) payStr.value = '使用积分0元支付'
else {
payStr.value = '积分不足,无法支付'
canPay.value = false
}
}
} else {
payStr.value = '立即支付'
if (!payMethod.value) canPay.value = false
const {data} = await userDetailReq()
userDetail.value = data
if (cartData.value.totalPrice === 0) {
if (cartData.value.point > 0) {
if (userDetail.value.point >= cartData.value.point) payStr.value = '使用积分0元支付'
else {
payStr.value = '积分不足,无法支付'
canPay.value = false
}
} }
} else {
payStr.value = '立即支付'
if (!payMethod.value) canPay.value = false
}
} }
const selectPayMethod = (method) => { const selectPayMethod = (method) => {
payMethod.value = method
canPay.value = true
if (method === 'balance' && userInfo.value.balance < cartData.value.totalPrice) return toast('余额不足,无法支付')
payMethod.value = method
canPay.value = true
} }
const action = async () => { const action = async () => {
if (!address.value) return toast('请先选择地址')
if (!payMethod.value && cartData.value.totalPrice > 0) return toast('请先选择支付方式')
disabled.value = true
const {data} = await addOrderReq({
realName: address.value.name,
phone: address.value.phone,
address: address.value.fullAddress,
orderId: null,
totalPrice: cartData.value.totalPrice,
type: 0,
payType: payMethod.value ? (payMethod.value === 'alipay' ? 3 : 1) : 2,
goodsList: [
{
goodsId: cartData.value.goods.goodsId,
goodsName: cartData.value.goods.goodsName,
cartNum: cartData.value.cartNum,
price: cartData.value.price,
image: cartData.value.goods.image,
point: cartData.value.point,
skuName: cartData.value.spec,
}
]
}).catch(() => {
disabled.value = false
})
if (!address.value) return toast('请先选择地址')
if (!payMethod.value && cartData.value.totalPrice > 0) return toast('请先选择支付方式')
disabled.value = true
let payType = 2
if (payMethod.value === 'alipay') payType = 3
else if (payMethod.value === 'wechat') payType = 1
else if (payMethod.value === 'balance') payType = 0
const {data} = await addOrderReq({
realName: address.value.name,
phone: address.value.phone,
address: address.value.fullAddress,
orderId: null,
totalPrice: cartData.value.totalPrice,
type: 0,
payType,
goodsList: [
{
goodsId: cartData.value.goods.goodsId,
goodsName: cartData.value.goods.goodsName,
cartNum: cartData.value.cartNum,
price: cartData.value.price,
image: cartData.value.goods.image,
point: cartData.value.point,
skuName: cartData.value.spec,
}
]
}).catch(() => {
disabled.value = false disabled.value = false
if (data && data.noNeedPay !== undefined && data.noNeedPay === 1) {
toast('支付成功')
await uni.redirectTo({url: '/pages/user/order/list?tab=1'})
} else {
uni.requestPayment({
provider: payMethod.value,
orderInfo: data,
success: async (res) => {
console.log('success', payMethod.value, res, payMethod.value === 'alipay')
if (payMethod.value === 'alipay') {
const rawData = JSON.parse(res.rawdata)
// console.log(res.errMsg, parseInt(rawData.resultCode), rawData.resultCode)
if (res.errMsg === 'requestPayment:ok' && parseInt(rawData.resultStatus) === 9000) {
toast('支付成功')
await uni.redirectTo({url: '/pages/user/order/list?tab=1'})
} else {
toast('支付失败')
}
}
})
disabled.value = false
if (data && data.noNeedPay !== undefined && data.noNeedPay === 1) {
toast('支付成功')
await uni.redirectTo({url: '/pages/user/order/list?tab=1'})
} else {
uni.requestPayment({
provider: payMethod.value,
orderInfo: data,
success: async (res) => {
console.log('success', payMethod.value, res, payMethod.value === 'alipay')
if (payMethod.value === 'alipay') {
const rawData = JSON.parse(res.rawdata)
// console.log(res.errMsg, parseInt(rawData.resultCode), rawData.resultCode)
if (res.errMsg === 'requestPayment:ok' && parseInt(rawData.resultStatus) === 9000) {
toast('支付成功')
await uni.redirectTo({url: '/pages/user/order/list?tab=1'})
} else {
toast('支付失败')
}
}
},
complete: async (res) => {
console.log('complete', res)
},
})
}
},
complete: async (res) => {
console.log('complete', res)
},
})
}
} }
const userDefaultAddress = ref() const userDefaultAddress = ref()
const getUserDefaultAddress = async () => { const getUserDefaultAddress = async () => {
const {data} = await userAddressDefaultReq()
userDefaultAddress.value = data
if(userDefaultAddress.value) address.value = userDefaultAddress.value
const {data} = await userAddressDefaultReq()
userDefaultAddress.value = data
if (userDefaultAddress.value) address.value = userDefaultAddress.value
} }
const cartId = ref(null) const cartId = ref(null)
onLoad(async option => { onLoad(async option => {
cartId.value = option.id
await getCartList()
await getUserDetail()
await getUserDefaultAddress()
cartId.value = option.id
await getCartList()
await getUserDetail()
await getUserDefaultAddress()
}) })
</script> </script>

7
src/pages/signUp/info.vue

@ -339,7 +339,8 @@
</view> </view>
<uv-gap height="100rpx"/> <uv-gap height="100rpx"/>
</uv-popup> </uv-popup>
<uv-picker ref="picker" :columns="[workTypeList, workTypeList[workTypeIndex].children]" @change="changeWorkType" @confirm="confirmWorkType"
<uv-picker ref="picker" :columns="[workTypeList, workTypeList[workTypeIndex].children]" @change="changeWorkType"
@confirm="confirmWorkType"
keyName="title" title="选择工种"/> keyName="title" title="选择工种"/>
<uv-popup ref="conditionPicker" mode="bottom" round="15" closeable> <uv-popup ref="conditionPicker" mode="bottom" round="15" closeable>
<view class="p-50"> <view class="p-50">
@ -771,6 +772,10 @@ const join = async () => {
if (workDateEndJudge.value && !form.value.workDateEnd) { if (workDateEndJudge.value && !form.value.workDateEnd) {
return $toast('请选择从业结束日期') return $toast('请选择从业结束日期')
} }
if (workDateEndJudge.value && form.value.workDateEnd) {
if (dayjs(form.value.workDateStart).isAfter(form.value.workDateEnd))
return $toast('从业开始日期不能晚于从业结束日期')
}
if (!form.value.idCardFront) { if (!form.value.idCardFront) {
return $toast('请上传身份证正面') return $toast('请上传身份证正面')
} }

4
src/pages/signUp/self.vue

@ -860,6 +860,10 @@ const join = async () => {
if (workDateEndJudge.value && !form.value.workDateEnd) { if (workDateEndJudge.value && !form.value.workDateEnd) {
return $toast('请选择从业结束日期') return $toast('请选择从业结束日期')
} }
if (workDateEndJudge.value && form.value.workDateEnd) {
if (dayjs(form.value.workDateStart).isAfter(form.value.workDateEnd))
return $toast('从业开始日期不能晚于从业结束日期')
}
if (!form.value.idCardFront) { if (!form.value.idCardFront) {
return $toast('请上传身份证正面') return $toast('请上传身份证正面')
} }

92
src/pages/user/balance.vue

@ -0,0 +1,92 @@
<template>
<view class="bg-gray-light min-height p-20">
<view class="rounded">
<view class="p-50 rounded-top bg text-white flex flex-col justify-center items-center">
<text class="text-25">当前余额</text>
<text class="mt-30 text-40 font-bold">{{ userInfo.balance }}</text>
</view>
<view class="font-bold py-20 border-bottom">充值套餐</view>
<view class="flex justify-start items-start flex-wrap">
<view v-for="(item, index) in chargePackageList" :key="index" class="w-50p">
<view :class="[packageId === item.id ? 'selected' : '']"
@click="packageId = item.id"
class="border rounded mr-10 mb-10 flex flex-col justify-center items-center p-20">
<text class="font-bold text-35">{{ item.amount }}</text>
<text v-if="item.sendAmount && item.sendAmount > 0" class="text-25">{{ item.sendAmount }}</text>
</view>
</view>
</view>
<view class="mt-20">
<uv-button :disabled="!packageId" type="primary" shape="circle" @click="doCharge">立即充值</uv-button>
</view>
</view>
</view>
</template>
<script setup>
import {ref} from 'vue'
import {getUser} from "@/api/user";
import {listChargePackage} from "@/api/chargePackage";
import {toast} from "@/uni_modules/uv-ui-tools/libs/function";
import {newChargeOrderReq} from "@/api/shop";
const userInfo = ref({})
const getUserDetail = async () => {
const {data} = await getUser()
userInfo.value = data
}
getUserDetail()
const chargePackageList = ref([])
const getChargePackageList = async () => {
const {data} = await listChargePackage()
chargePackageList.value = data
}
getChargePackageList()
const packageId = ref(0)
const doCharge = async () => {
uni.showLoading({title: '正在提交'})
const {data} = await newChargeOrderReq({
type: 3,
payType: 3,
chargePackageId: packageId.value,
})
uni.requestPayment({
provider: 'alipay',
orderInfo: data,
success: async (res) => {
packageId.value = null
uni.hideLoading()
// if (payMethod.value === 'alipay') {
const rawData = JSON.parse(res.rawdata)
// console.log(res.errMsg, parseInt(rawData.resultCode), rawData.resultCode)
if (res.errMsg === 'requestPayment:ok' && parseInt(rawData.resultStatus) === 9000) {
toast('支付成功')
await getUserDetail()
} else {
toast('支付失败')
}
// }
},
complete: async (res) => {
console.log('complete', res)
uni.hideLoading()
packageId.value = null
},
})
}
</script>
<style scoped>
.bg {
background: url("https://oss.wsdns.cn/20250316/430511e96efe4ecb9f27e10f75d27389.png") 700rpx 220rpx;
}
.selected {
border: 1px solid #3c9cff;
background-color: #f3f8ff;
color: #007dff;
}
</style>

10
src/pages/user/user.vue

@ -32,7 +32,15 @@
</view> </view>
<!-- 五分一 --> <!-- 五分一 -->
<view class="layout-quarter"> <view class="layout-quarter">
<view class="quarter-item" @click="$jump('/pages/user/sign')">
<!-- #ifdef APP-PLUS -->
<view class="quarter-item" @click="$jump('/pages/user/balance')">
<view class="icon">
<image src="@/static/image/balance.png" style="width: 48rpx; height: 48rpx"/>
</view>
<view class="text">钱包</view>
</view>
<!-- #endif -->
<view class="quarter-item" @click="$jump('/pages/user/sign')">
<view class="icon"> <view class="icon">
<image src="@/static/image/u-1.png" style="width: 48rpx; height: 48rpx"/> <image src="@/static/image/u-1.png" style="width: 48rpx; height: 48rpx"/>
</view> </view>

BIN
src/static/image/balance-bg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
src/static/image/balance.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Loading…
Cancel
Save