Compare commits

..

15 Commits

Author SHA1 Message Date
2bdbe5c962 2025-10-24
细节修改
2025-10-24 16:55:40 +08:00
e51649e559 2025-10-24
金融修改
2025-10-24 16:44:01 +08:00
b4ece2d3d5 2025-10-24
我的页面添加刷新
2025-10-24 16:02:33 +08:00
5769349d08 2025-10-24
我的订单修改
2025-10-24 15:56:41 +08:00
81dba82be3 2025-10-24
我的订单
2025-10-24 15:10:06 +08:00
d283a1cc58 2025-10-24
多商品支付页面修改
2025-10-24 09:54:23 +08:00
19e4c8bf08 2025-10-24
购物车
2025-10-23 17:25:39 +08:00
0e2dbdb9db 2025-10-23
商品搜索
2025-10-23 13:49:19 +08:00
397c73077b 领券页面提交 2025-10-23 10:21:37 +08:00
1f4c2c75eb 2025-10-23
支付页面
2025-10-23 10:18:06 +08:00
12910d0a1d 2025-10-21
支付页面修改
2025-10-21 16:14:16 +08:00
db65f73deb 2025-10-21
商品详情加入购物车与创建订单
支付页面70%
2025-10-21 15:25:55 +08:00
091b655a0f 2025-10-20
收货地址完成
2025-10-20 10:33:19 +08:00
448f281570 Merge remote-tracking branch 'origin/master' 2025-10-17 17:21:56 +08:00
a5a5534c36 2025-10-17
收货地址添加修改
2025-10-17 17:21:11 +08:00
44 changed files with 3327 additions and 676 deletions

14
.idea/UniappTool.xml generated Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="cn.fjdmy.uniapp.UniappProjectDataService">
<option name="basePath" value="$PROJECT_DIR$" />
<option name="generalBasePath" value="$PROJECT_DIR$" />
<option name="manifestPath" value="$PROJECT_DIR$/manifest.json" />
<option name="pagesPath" value="$PROJECT_DIR$/pages.json" />
<option name="scanNum" value="1" />
<option name="type" value="store" />
<option name="uniapp" value="true" />
<option name="uniappHx" value="true" />
<option name="vueVersion" value="3" />
</component>
</project>

6
.idea/jsLibraryMappings.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<excludedPredefinedLibrary name="uni-api" />
</component>
</project>

20
api/address.js Normal file
View File

@@ -0,0 +1,20 @@
import {
http
} from "../util/api"
// const baseURL = "http://192.168.0.12:3005/term"
const baseURL = "http://192.168.0.11:3000/api"
// 项目相关API
export const addressAPI = {
// 列表
getList: (params) => http.get(baseURL + '/addresses', params),
addAddress: (data) => http.post(baseURL + "/addresses", data),
getAddress: (id) => http.get(baseURL + `/addresses/${id}`),
editAddress: (data) => http.put(baseURL + `/addresses/${data.id}`, data),
delAddress: (id) => http.delete(baseURL + `/addresses/${id}`)
}
export default {
addressAPI
}

View File

@@ -1,7 +1,9 @@
import { http } from "../util/api";
const baseURL = "http://192.168.0.11:3000/api"
export const commonAPI = {
getRegion: () => http.get('/common/provinces'),
getRegion: () => http.get(baseURL + '/regions/provinces'),
}
export default {

12
api/coupon.js Normal file
View File

@@ -0,0 +1,12 @@
import {
http
} from "../util/api"
const baseURL = "http://192.168.0.11:3000"
export const coupon = {
get_coupon: (params = {}) => http.get(baseURL + '/api/coupon',params ),
post_coupon: (data = {}) => http.get(`${baseURL}/api/coupon/${data.user_id}`,{coupon_id:data.coupon_id} ),
}
export default {
coupon
}

View File

@@ -2,7 +2,8 @@ import {
http
} from "../util/api"
const baseURL = "http://192.168.0.15:3008"
// const baseURL = "http://192.168.0.15:3008" // 本地
const baseURL = "http://192.168.0.4:3008" // 测试服务器
// 项目相关API
export const financeAPI = {

View File

@@ -2,7 +2,8 @@ import {
http
} from "../util/api";
const baseURL = "http://192.168.0.15:3007"
// const baseURL = "http://192.168.0.15:3007" // 本地
const baseURL = "http://192.168.0.4:3007" // 测试服务器
export const groupAPI = {
getList: (params) => http.get(baseURL + '/group/list', params),

View File

@@ -2,12 +2,27 @@ import {
http
} from "../util/api";
const baseUrl = "http://192.168.0.26:3000"
const baseUrl = "http://192.168.0.11:3000"
export const mallAPI = {
getMallList: (params) => http.get(baseUrl + '/api/products', params),
getCategory: () => http.get(baseUrl + '/api/category'),
getMallDetail: (id) => http.get(baseUrl + '/api/products/' + id)
getMallDetail: (id) => http.get(baseUrl + '/api/products/' + id),
getRecommended: (id) => http.get(baseUrl + `/api/products/${id}/recommended`), // 推荐商品
payment: (data) => http.post(baseUrl + "/api/orders/confirm-payment", data), // 支付订单
getCouponList: (uid) => http.get(baseUrl + `/api/coupon/user/${uid}`), // 获取优惠券列表
// 购物车
getCartList: () => http.get(baseUrl + "/api/cart"), // 获取购物车列表
addCart: (data) => http.post(baseUrl + "/api/cart/add", data), // 添加购物车
editCartQuantity: (item) => http.put(baseUrl + `/api/cart/${item.id}`, {quantity: item.quantity}), // 修改数量
deleteCart: (id) => http.delete(baseUrl + `/api/cart/${id}`), // 删除
getOrderList: (params) => http.get(baseUrl + "/api/orders", params), // 获取订单列表
createOrder: (data) => http.post(baseUrl + `/api/orders/create-from-cart`, data), // 创建订单
getOrder: (orderId) => http.get(baseUrl + `/api/orders/pending-payment/${orderId}`), // 获取订单
cancelOrder: (orderId) => http.put(baseUrl + `/api/orders/${orderId}/cancel`), // 取消订单
confirmOrder: (orderId) => http.put(baseUrl + `/orders/${orderId}/confirm`), // 收货
}
export default {

View File

@@ -3,7 +3,8 @@ import {
} from "../util/api"
// const baseURL = "http://192.168.0.12:3005/chat"
const baseURL = "http://192.168.0.15:3007"
// const baseURL = "http://192.168.0.15:3007" // 本地
const baseURL = "http://192.168.0.4:3007" // 测试服务器
// 项目相关API
export const messageAPI = {

View File

@@ -3,7 +3,8 @@ import {
} from "../util/api"
// const baseURL = "http://192.168.0.12:3005/term"
const baseURL = "http://192.168.0.15:3006"
// const baseURL = "http://192.168.0.15:3006"
const baseURL = "http://192.168.0.4:3006"
// 项目相关API
export const programAPI = {

View File

@@ -2,6 +2,8 @@ import {
http
} from "../util/api"
const baseURL = "http://192.168.0.4:3000/api"
// 用户相关API
export const userAPI = {
// 获取用户列表
@@ -19,7 +21,9 @@ export const userAPI = {
delete: (id) => http.delete(`/users/${id}`),
// 获取用户统计
getStats: () => http.get('/users/stats/overview')
getStats: () => http.get('/users/stats/overview'),
getProfile: () => http.get(baseURL + '/user/profile')
}
export default {

View File

@@ -1,5 +1,5 @@
{
"name" : "jurong_circle_front_app",
"name" : "炬融圈",
"appid" : "__UNI__11908F8",
"description" : "",
"versionName" : "1.0.0",
@@ -18,9 +18,7 @@
},
/* */
"modules" : {
"Payment" : {},
"Record" : {},
"Camera" : {}
"Payment" : {}
},
/* */
"distribute" : {
@@ -55,6 +53,38 @@
"__platform__" : [ "android" ]
}
}
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
}
}
},

View File

@@ -4,7 +4,8 @@
"path": "pages/home/index",
"style": {
"navigationBarTitleText": "主页",
"navigationStyle": "custom"
"navigationStyle": "custom",
"enablePullDownRefresh": true
}
},
{
@@ -54,7 +55,7 @@
},
{
"path": "pages/finance/service",
"path": "pages/my/commonProblem",
"style": {
"navigationBarTitleText": "客服中心",
"navigationStyle": "custom"
@@ -75,13 +76,6 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/mall/mall",
"style": {
"navigationBarTitleText": "商城",
"navigationStyle": "custom"
}
},
{
"path": "pages/message/chat",
"style": {
@@ -135,13 +129,47 @@
"navigationBarTitleText": "商品详情",
"navigationStyle": "custom"
}
},
{
"path": "pages/home/pay",
"style": {
"navigationBarTitleText": "确认订单",
"backgroundColor": "#E4ECFF",
"enablePullDownRefresh": true
}
},
{
"path": "pages/my/order",
"style": {
"navigationBarTitleText": "我的订单",
"navigationStyle": "custom"
}
},
{
"path": "pages/home/mallSearch",
"style": {
"navigationBarTitleText": "搜索商品",
"navigationStyle": "custom"
}
},
{
"path": "pages/my/getCoupons",
"style": {
"navigationBarTitleText": "领券中心"
}
},
{
"path": "pages/my/car",
"style": {
"navigationBarTitleText": "购物车",
"navigationStyle": "custom"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
"backgroundColor": "#f5f8ff"
},
"uniIdRouter": {},
"tabBar": {

View File

@@ -1,6 +1,7 @@
<template>
<view class="finance-container">
<u-navbar :is-back="false" title="金融理财" :background="{ background: 'transparent' }" title-color="#FFFFFF"></u-navbar>
<u-navbar :is-back="false" title="金融理财" :border-bottom="false" :background="{ background: 'transparent' }"
title-color="#FFFFFF"></u-navbar>
<!-- 可滚动的内容区域 -->
<view class="content-container" :style="'height:'+height+'px'">
<view class="searchFilter" id="searchFilterId">
@@ -11,19 +12,18 @@
</view>
<view class="product-list" :style="'height:'+scrollHeight+'px'">
<scroll-view scroll-y="true" style="height: 100%;" v-if="productList.length!=0" @scrolltolower="loadData">
<view class="product-item" v-for="item in productList" :key="item.id">
<scroll-view scroll-y="true" style="height: 100%;" v-if="productList.length!=0"
@scrolltolower="loadData">
<view class="product-item" v-for="item in productList" :key="item.id"
@click="handleproduction(item)">
<view class="product-name">
{{item.name}}
{{item.productName}}
</view>
<view class="product-rate">
利率{{item.rate}}%
利率{{item.expectedReturnRate}}%
</view>
<view class="product-intro">
产品简介{{item.introduction}}
</view>
<view class="product-detail-link" @click="handleproduction(item)">
查看详情
公司{{item.company}}
</view>
</view>
<u-loadmore color="#666" :status="status" />
@@ -53,10 +53,10 @@
uni.getSystemInfo({
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance?.proxy).select("#tabbarId").boundingClientRect((data: any) => {
uni.createSelectorQuery().in(instance?.proxy).select("#tabbarId").boundingClientRect((data : any) => {
height.value = screenHeight - data.height
}).exec()
uni.createSelectorQuery().in(instance?.proxy).select("#searchFilterId").boundingClientRect((data: any) => {
uni.createSelectorQuery().in(instance?.proxy).select("#searchFilterId").boundingClientRect((data : any) => {
scrollHeight.value = height.value - data.height
}).exec()
}
@@ -76,62 +76,31 @@
// 加载数据
const loadData = () => {
if (status.value == 'nomore') return
financeAPI.getList(params.value).then(res => {
console.log('API返回数据:', res)
if (res.data && res.data.list) {
// 检查数据结构并映射字段
const mappedList = res.data.list.map((item: any, index: number) => ({
id: item.id || index,
name: item.productName || item.name || '未知产品',
rate: item.interestRate || item.rate || '0',
introduction: item.desc || item.introduction || item.productDesc || '暂无简介'
}))
productList.value = productList.value.concat(mappedList)
console.log('当前产品列表:', productList.value)
productList.value = productList.value.concat(res.data.list)
}
status.value = 'nomore'
uni.stopPullDownRefresh()
}).catch(err => {
console.error('API调用失败:', err)
status.value = 'nomore'
uni.stopPullDownRefresh()
})
}
// 查看详情 - 传递完整产品数据
const handleproduction = (item: any) => {
console.log('点击查看详情,产品数据:', item)
// 确保数据包含必要的字段
const productData = {
name: item.name || '未知产品',
rate: item.rate || '0',
introduction: item.introduction || '暂无简介'
}
console.log('准备传递的产品数据:', productData)
// 将产品数据转换为JSON字符串传递
const encodedData = encodeURIComponent(JSON.stringify(productData))
console.log('编码后的数据:', encodedData)
const handleproduction = (item : any) => {
uni.navigateTo({
url: `/pages/finance/production?productData=${encodedData}`
url: `/pages/finance/production?id=${item.id}`
})
}
// 查询
const handleSearch = () => {
params.value = {
page: 1,
size: defaultSize,
keyword: params.value.keyword
}
params.value.page = 1
productList.value = []
status.value = 'loadmore'
loadData()
}
@@ -199,12 +168,12 @@
// 移除产品简介显示 */
.product-intro {
font-size: 26rpx;
color: #666;
line-height: 1.5;
margin-bottom: 20rpx;
display: block; // 确保显示
}
font-size: 26rpx;
color: #666;
line-height: 1.5;
margin-bottom: 20rpx;
display: block; // 确保显示
}
.product-detail-link {
font-size: 24rpx;

View File

@@ -4,166 +4,95 @@
back-icon-color="#fff" title-color="#fff">
</u-navbar>
<!-- 产品头部信息 -->
<view class="product-header">
<view class="product-name">
{{ productInfo.name }}
{{ productInfo.productName }}
</view>
<view class="product-date">
开始时间{{ productInfo.startDate }}
产品代码{{ productInfo.productCode }}
</view>
<view class="product-date">
开始时间{{ productInfo.createDate }}
</view>
<view class="profit-info">
近期盈亏{{ productInfo.recentProfit }}
近期盈亏{{ productInfo.expectedReturnRate }}
</view>
</view>
<!-- 基本信息卡片 -->
<view class="card">
<u-row class="u-m-b-20">
<u-col span="6" class="card-name">所在地</u-col>
<u-col span="6" class="card-value">{{ productInfo.location }}</u-col>
<u-col span="6" class="card-name">风险等级</u-col>
<u-col span="6" class="card-value">{{ productInfo.riskLevel }}</u-col>
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" class="card-name">详细地址</u-col>
<u-col span="6" class="card-value">{{ productInfo.detailAddress }}</u-col>
<u-col span="6" class="card-name">产品类型</u-col>
<u-col span="6" class="card-value">{{ productInfo.productType }}</u-col>
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" class="card-name">联系人</u-col>
<u-col span="6" class="card-value">{{ productInfo.contactPerson }}</u-col>
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" class="card-name">结算方式</u-col>
<u-col span="6" class="card-value">{{ productInfo.settlementMethod }}</u-col>
</u-row>
<u-row>
<u-col span="6" class="card-name">产品企业</u-col>
<u-col span="6" class="card-value">{{ productInfo.company }}</u-col>
</u-row>
<u-row v-if="productInfo.user">
<u-col span="6" class="card-name">联系人</u-col>
<u-col span="6" class="card-value">{{ productInfo.user.username }}</u-col>
</u-row>
</view>
<!-- 产品需求 -->
<view class="card">
<view class="card-title">
产品需求<span>4</span>
<view class="icon">
<image style="width: 100%;height: 100%;" src="/static/icon/card-title-icon.png" mode=""></image>
</view>
项目介绍<span></span>
</view>
<view class="card-body">
<u-row class="sub-title u-m-b-20">
<u-col span="12">需求名称</u-col>
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" text-align="left" class="card-name">产品简介</u-col>
<u-col span="6" class="card-value">{{ productInfo.introduction }}</u-col>
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" text-align="left" class="card-name">限价</u-col>
<u-col span="6" class="card-value">详情</u-col>
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" text-align="left" class="card-name">时间</u-col>
<u-col span="6" class="card-value">详情</u-col>
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" text-align="left" class="card-name">其他要求</u-col>
<u-col span="6" class="card-value">详情</u-col>
</u-row>
</view>
</view>
<!-- 产品动态 -->
<view class="card">
<view class="card-title">
产品动态
</view>
<view class="card-body">
<u-row class="u-m-b-20">
<u-col span="6" text-align="left" class="card-name">发布时间</u-col>
<u-col span="6" class="card-value">{{ productInfo.publishDate }}</u-col>
</u-row>
<u-row>
<u-col span="6" text-align="left" class="card-name">年化增长</u-col>
<u-col span="6" class="card-value">{{ productInfo.rate }}%</u-col>
</u-row>
<view class="u-m-t-10 editor-content-view">
<view v-html="productInfo.introduction"></view>
</view>
</view>
<!-- 底部按钮 -->
<view class="bottom-actions">
<u-button class="consult-btn" @click="handleConsult">立即咨询</u-button>
<u-button hover-class="none" class="consult-btn" @click="handleConsult">立即咨询</u-button>
</view>
</view>
<u-toast ref="msgToast"></u-toast>
</template>
<script setup lang="ts">
import { ref } from 'vue';
<script setup>
import { ref, onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app'
import { financeAPI } from '../../api/finnancial';
const msgToast = ref()
// 产品信息响应式数据
const productInfo = ref({
name: '理财产品名称',
startDate: '2025/09/13',
recentProfit: 'XXXX',
location: '浙江-宁波',
detailAddress: 'xx区xx路xxx号',
contactPerson: 'XXX',
settlementMethod: '按月结算次月支付50%',
company: 'xxxx公司',
publishDate: '2025-09-13',
rate: '0',
introduction: '暂无简介'
})
// 立即咨询
const handleConsult = () => {
uni.navigateTo({
url: '/pages/finance/service'
});
msgToast.value.show({
title: '暂未开发,请耐心等待~'
})
}
onLoad((options) => {
console.log('=== 详情页面开始加载 ===')
console.log('接收到的参数:', options)
// 解析传递过来的产品数据
if (options.productData) {
try {
console.log('原始 productData:', options.productData)
// 解码数据
const decodedData = decodeURIComponent(options.productData)
console.log('解码后的数据:', decodedData)
// 解析JSON
const receivedData = JSON.parse(decodedData)
console.log('解析后的数据对象:', receivedData)
console.log('接收到的产品名称:', receivedData.name)
console.log('接收到的产品利率:', receivedData.rate)
console.log('接收到的产品简介:', receivedData.introduction)
// 直接更新产品信息
if (receivedData.name) {
productInfo.value.name = receivedData.name
}
if (receivedData.rate) {
productInfo.value.rate = receivedData.rate
}
if (receivedData.introduction) {
productInfo.value.introduction = receivedData.introduction
}
console.log('=== 更新后的产品信息 ===')
console.log('产品名称:', productInfo.value.name)
console.log('产品利率:', productInfo.value.rate)
console.log('产品简介:', productInfo.value.introduction)
} catch (error) {
console.error('解析产品数据失败:', error)
console.log('错误详情:', error.message)
}
} else {
console.log('未接收到 productData 参数')
}
// 产品信息响应式数据
const productInfo = ref({})
const id = ref()
const loadData = () => {
financeAPI.getProgram(id.value).then(res => {
productInfo.value = res.data
})
}
onLoad((val) => {
id.value = val.id
})
onMounted(() => {
loadData()
})
</script>
@@ -179,20 +108,20 @@
background: transparent;
color: #fff;
margin: 0 80rpx;
.product-name {
font-size: 36rpx;
font-weight: 600;
margin-bottom: 20rpx;
line-height: 1.4;
}
.product-date {
font-size: 28rpx;
margin-bottom: 15rpx;
opacity: 0.9;
}
.profit-info {
font-size: 28rpx;
opacity: 0.9;
@@ -214,7 +143,7 @@
margin-bottom: 25rpx;
padding-bottom: 15rpx;
border-bottom: 2rpx solid #f0f0f0;
span {
color: #666;
font-size: 28rpx;
@@ -226,7 +155,7 @@
background: #f8f9fa;
border-radius: 12rpx;
padding: 25rpx;
.sub-title {
font-size: 28rpx;
font-weight: 600;
@@ -261,7 +190,7 @@
padding: 20rpx 30rpx;
border-top: 1rpx solid #f0f0f0;
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
.consult-btn {
background: #1a5fd8;
color: #fff;
@@ -271,7 +200,7 @@
font-size: 32rpx;
font-weight: 500;
box-shadow: 0 4rpx 12rpx rgba(26, 95, 216, 0.3);
&:active {
background: #164db3;
transform: translateY(1rpx);

View File

@@ -1,9 +1,11 @@
<template>
<view class="message-container">
<scroll-view scroll-y="true" style="height: 100%;">
<scroll-view scroll-y="true" :style="'height:'+height+'px'" @scrolltolower="loadMallData"
:refresher-threshold="50" :refresher-triggered="isRefresher" refresher-background="transparent"
refresher-enabled="true" @refresherrefresh="reflash">
<view class="header-search">
<u-search :action-style="searchBtn" shape="square" bg-color="#CADBFF" placeholder="输入商品名称或商品种类"
v-model="keyword"></u-search>
v-model="keyword" @search="handleSearch" @custom="handleSearch"></u-search>
</view>
<view class="menu-list">
@@ -80,13 +82,12 @@
<view class="mall-title u-m-l-5 u-m-r-5">
{{item.name}}
</view>
<del class="u-m-l-5 u-m-r-5" style="white-space: nowrap;">{{item.price}}</del>
<view class="mall-price u-m-l-5 u-m-r-5" v-if="RDType(item.payment_methods)">
<image src="/static/icon/rongdou.png" class="icon" mode=""></image>
{{item.rongdou_price}}
</view>
<view class="mall-price u-m-l-5 u-m-r-5" v-if="pointsType(item.payment_methods)">
<u-icon name="integral"></u-icon>
<image src="/static/icon/jifen.png" class="icon" mode=""></image>
{{item.points_price}}
</view>
<view class="mall-tag u-m-l-5 u-m-r-5">
@@ -110,13 +111,12 @@
<view class="mall-title u-m-l-5 u-m-r-5">
{{item.name}}
</view>
<del class="u-m-l-5 u-m-r-5" style="white-space: nowrap;">{{item.price}}</del>
<view class="mall-price u-m-l-5 u-m-r-5" v-if="RDType(item.payment_methods)">
<image src="/static/icon/rongdou.png" class="icon" mode=""></image>
{{item.rongdou_price}}
</view>
<view class="mall-price u-m-l-5 u-m-r-5" v-if="pointsType(item.payment_methods)">
<u-icon name="integral"></u-icon>
<image src="/static/icon/jifen.png" class="icon" mode=""></image>
{{item.points_price}}
</view>
<view class="mall-tag u-m-l-5 u-m-r-5">
@@ -133,22 +133,36 @@
</view>
</template>
</u-waterfall>
<u-loadmore margin-top="20" :status="loadStatus"></u-loadmore>
</view>
<u-loadmore margin-top="20" :status="loadStatus" color="#fff"></u-loadmore>
<view class="box-div"></view>
</scroll-view>
</view>
<Tabbar id="tabbarId"></Tabbar>
<u-toast ref="msgToast" duration="6000" />
</template>
<script setup lang="ts">
import {
ref, onMounted
ref, onMounted, getCurrentInstance
} from 'vue';
import { mallAPI } from '../../api/mall';
import { getImageUrl } from '../../util/common';
const msgToast = ref()
const instance = getCurrentInstance();
const height = ref(0)
const loadHeight = () => {
uni.getSystemInfo({
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#tabbarId").boundingClientRect((data : any) => {
height.value = screenHeight - data.height
}).exec()
}
})
}
const keyword = ref('')
const searchBtn = {
@@ -160,6 +174,20 @@
boxShadow: '0px 4px 4px 0px #FFFFFF40 inset',
}
const iconWidth = "65%"
const handleSearch = () => {
if (!keyword.value) {
msgToast.value.show({
title: '请输入搜索词',
type: 'warning'
})
return
}
uni.navigateTo({
url: '/pages/home/mallSearch?search=' + keyword.value
})
keyword.value = ''
}
const handleCategory = () => {
uni.navigateTo({
@@ -167,11 +195,10 @@
})
}
const params = ref({
keyword: '',
page: 1,
limit: 5,
limit: 10,
category: ''
})
const mallList = ref([])
@@ -194,15 +221,25 @@
const loadMallData = () => {
if (loadStatus.value == 'nomore') return
mallAPI.getMallList(params.value).then((res) => {
console.log(res.data);
mallList.value = mallList.value.concat(res.data.products)
maxPage.value = res.data.pagination.pages
params.value.page++
if (maxPage.value < params.value.page) {
loadStatus.value = 'nomore'
}
}).finally(() => {
isRefresher.value = false
})
}
const isRefresher = ref(false)
const reflash = () => {
isRefresher.value = true
params.value.page = 1
params.value.category = ''
params.value.keyword = ''
loadStatus.value = 'loadmore'
loadMallData()
}
const handleCheck = (item : any) => {
uni.navigateTo({
@@ -211,6 +248,7 @@
}
onMounted(() => {
loadHeight()
loadMallData()
})
</script>
@@ -333,7 +371,7 @@
.box-div {
padding: 30rpx 0rpx;
padding: 60rpx 0rpx;
}
}
</style>

View File

@@ -15,7 +15,7 @@
</view>
</view>
<view class="menu-level2" v-if="categoryList[currentCate]?.relative.length!=0">
<view class="menu-item" v-for="item in categoryList[currentCate]?.relative">
<view class="menu-item" v-for="item in categoryList[currentCate]?.relative" @click="handleSearchCategory(item)">
<u-image v-if="item.img" :fade="false" :src="getImageUrl(item.img)" :width="iconWidth"
mode="widthFix"></u-image>
<view class="menu-text">
@@ -116,6 +116,12 @@
const handleChangeCategory = (index) => {
currentCate.value = index
}
const handleSearchCategory = (item) => {
uni.navigateTo({
url: '/pages/home/mallSearch?cate=' + item.name
})
}
const params = ref({
keyword: '',

View File

@@ -7,15 +7,101 @@
</template>
</u-navbar>
<scroll-view scroll-y="true" :style="'height:'+scrollHeight+'px'">
111
<view class="img-banner">
<u-swiper height="400" img-mode="aspectFit" mode="none" bg-color="transparent" :list="dataInfo.banner"
@change="handleChangeBanner" :current="currentBanner"></u-swiper>
</view>
<scroll-view scroll-x="true" class="img-sub-banner">
<image v-for="(item,index) in dataInfo.banner" :src="item" class="img-item"
:class="{active: currentBanner==index}" mode="aspectFit" @click="handleChangeBanner(index)">
</image>
</scroll-view>
<view class="mall-info">
<view class="name">
{{dataInfo.name}}
</view>
<view class="description">
{{dataInfo.description}}
</view>
<view class="price">
<view>
<view class="mall-price">
<image src="/static/icon/rongdou.png" class="icon" mode=""></image>
{{dataInfo.rongdou_price}}
</view>
<view class="mall-price">
<image src="/static/icon/jifen.png" class="icon" mode=""></image>
{{dataInfo.points_price}}
</view>
<view v-if="dataInfo.discount" class="discount-info">
<u-tag type="error" text="1折优惠" />
</view>
</view>
<view>
<view>已售{{dataInfo.sales}}</view>
<view style="color: red;">剩余{{dataInfo.stock}}</view>
</view>
</view>
<view class="rating">
评分<u-rate :disabled="true" :count="5" v-model="dataInfo.rating" active-color="#f7ba2a"></u-rate>
</view>
<view class="detail">
<h3>具体描述</h3>
<view v-html="dataInfo.details"></view>
</view>
<view class="recommend">
<h3>推荐商品</h3>
<view class="mall-list">
<u-waterfall v-model="recommendedList" ref="mallListRef">
<template v-slot:left="{leftList}">
<view class="mall-item u-m-r-10" v-for="(item, index) in leftList" :key="index"
@click="handleCheck(item)">
<u-lazy-load threshold="-450" border-radius="10" :image="getImageUrl(item.image)"
:index="index"></u-lazy-load>
<view class="mall-title u-m-l-5 u-m-r-5">
{{item.name}}
</view>
<view class="mall-price u-m-l-5 u-m-r-5">
<image src="/static/icon/rongdou.png" class="icon" mode=""></image>
{{item.price}}
</view>
<view class="mall-price u-m-l-5 u-m-r-5">
<image src="/static/icon/jifen.png" class="icon" mode=""></image>
{{item.points}}
</view>
</view>
</template>
<template v-slot:right="{rightList}">
<view class="mall-item u-m-l-10" v-for="(item, index) in rightList" :key="index"
@click="handleCheck(item)">
<u-lazy-load threshold="-450" border-radius="10" :image="getImageUrl(item.image)"
:index="index"></u-lazy-load>
<view class="mall-title u-m-l-5 u-m-r-5">
{{item.name}}
</view>
<view class="mall-price u-m-l-5 u-m-r-5">
<image src="/static/icon/rongdou.png" class="icon" mode=""></image>
{{item.price}}
</view>
<view class="mall-price u-m-l-5 u-m-r-5">
<image src="/static/icon/jifen.png" class="icon" mode=""></image>
{{item.points}}
</view>
</view>
</template>
</u-waterfall>
</view>
</view>
</view>
</scroll-view>
<view class="bottom-view" id="bottomViewId">
<view class="icon-btn">
<view class="item">
<!-- <view class="item">
<u-image width="100%" :fade="false" src="/static/mall/Home.png" mode="widthFix"></u-image>
店铺
</view>
</view> -->
<view class="item">
<u-image width="100%" :fade="false" src="/static/mall/Twitch.png" mode="widthFix"></u-image>
客服
@@ -26,19 +112,96 @@
</view>
</view>
<view class="text-btn">
<u-button class="add-car common" :hair-line="false" hover-class="none">加入购物车</u-button>
<u-button class="buy common" :hair-line="false" hover-class="none">领券购买</u-button>
<u-button class="add-car common" :hair-line="false" hover-class="none"
@click="handleBtn(0)">加入购物车</u-button>
<u-button class="buy common" :hair-line="false" hover-class="none" @click="handleBtn(1)">领券购买</u-button>
</view>
</view>
<u-popup v-model="showSure" mode="bottom" length="70%" :closeable="true">
<scroll-view scroll-y="true" style="height: 100%;">
<view class="sure-popup">
<view class="title">{{popTitle}}</view>
<!-- <view class="address">
<view class="text">
<image style="width: 40rpx;height: 40rpx;" src="/static/icon/Map pin2.png" mode=""></image>
<view class="u-m-l-10">张三 | </view>
<view class="u-m-l-10">浙江省 宁波市 海曙区</view>
</view>
<view class="right-icon">
<image style="width: 100%;height: 100%;" src="/static/icon/Chevron right Menu.png" mode="">
</image>
</view>
</view> -->
<view class="count-select u-p-l-10 u-p-r-10">
<view class="pre-view">
<u-image :src="getImageUrl(dataInfo.image_url)" height="100%" width="100%">
<template v-slot:error>
<view style="font-size: 24rpx;">暂无图片</view>
</template>
</u-image>
</view>
<view class="text">
<view>
实付<image src="/static/icon/rongdou.png" class="icon" mode=""></image>
{{dataInfo.price * order.count}}
<view>
<u-icon name="integral"></u-icon>
{{dataInfo.points * order.count}}
</view>
</view>
<view>
<u-number-box v-model="order.count" :max="dataInfo.stock" :min="1"></u-number-box>
</view>
</view>
</view>
<view class="spec-option" v-for="item in specNames">
<view class="title">
{{item + "("+specOptions.get(item).size+")"}}
</view>
<view class="option-list">
<view class="option-item" v-for="key in specOptions.get(item).keys()" :key="key"
:class="{active: isChose(key), unactive: !canChose(key)}"
@click="handleChangeSpec(key, item)">
{{specOptions.get(item).get(key)}}
</view>
</view>
</view>
<!-- <view class="spec-option">
<view class="title">
订单备注
</view>
<view class="">
<u-input type="textarea" :border="true" :height="100" v-model="order.orderNote"></u-input>
</view>
</view> -->
<view class="submit-btn">
<u-button @click="handleSubmit">{{popTitle}}</u-button>
</view>
</view>
</scroll-view>
</u-popup>
<u-toast ref="msgRef" />
</view>
</template>
<script setup lang="ts">
import { onMounted, ref, getCurrentInstance } from 'vue';
<script setup>
import {
onMounted,
ref,
getCurrentInstance
} from 'vue';
import {
onLoad
} from '@dcloudio/uni-app';
import { mallAPI } from '../../api/mall';
import {
mallAPI
} from '../../api/mall';
import {
getImageUrl,
arrayContainsAll
} from '../../util/common.js';
const instance = getCurrentInstance();
const scrollHeight = ref(0)
@@ -46,21 +209,251 @@
uni.getSystemInfo({
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#uNavbarId").boundingClientRect((data : any) => {
uni.createSelectorQuery().in(instance.proxy).select("#uNavbarId").boundingClientRect((
data) => {
scrollHeight.value = screenHeight - data.height
}).exec()
uni.createSelectorQuery().in(instance.proxy).select("#bottomViewId").boundingClientRect((data : any) => {
uni.createSelectorQuery().in(instance.proxy).select("#bottomViewId").boundingClientRect((
data) => {
scrollHeight.value = scrollHeight.value - data.height
}).exec()
}
})
}
const currentBanner = ref(0)
const handleChangeBanner = (index) => {
currentBanner.value = index
}
const handleCheck = (item) => {
uni.redirectTo({
url: '/pages/home/mallDetail?id=' + item.id
})
}
const msgRef = ref()
// 切换 加入购物车/确认购买
const showSure = ref(false)
const popTitle = ref('')
const flag = ref(0)
const handleBtn = (sign) => {
if (sign == 0) {
popTitle.value = '加入购物车'
flag.value = 0
} else if (sign == 1) {
popTitle.value = '确认购买'
flag.value = 1
}
showSure.value = true
}
const order = ref({
count: 1
})
const choseKeys = ref([])
const handleChangeSpec = (key, allKey) => {
if (!canChose(key)) return
if (choseKeys.value.includes(key)) {
// 取消选中
choseKeys.value = choseKeys.value.filter(item => item != key)
} else {
// console.log(choseKeys.value);
// console.log(specOptions.value.get(allKey));
// 清除选项
const keysArray = Array.from(specOptions.value.get(allKey).keys())
choseKeys.value = choseKeys.value.filter(item => {
if (keysArray.includes(item)) return false
return true
})
// 选中
choseKeys.value.push(key)
}
}
// 判断当前key是否可选
const canChose = (key) => {
// console.log("当前规格ID:", key);
// console.log("规格组合列表:", activeKeys.value);
// console.log("已选择的规格ID列表:", choseKeys.value);
// console.log("规格选项:", specOptions.value);
// 如果已经选中,肯定可选(因为可以取消选中)
if (isChose(key)) {
return true;
}
// 构建临时选择的key列表
let tempChoseKeys = [...choseKeys.value];
// 找到当前key所属的规格类别
let specCategory = '';
for (const [category, options] of specOptions.value.entries()) {
if (options.has(key)) {
specCategory = category;
break;
}
}
// 如果找到了所属规格类别,需要先移除同类别下已选的其他选项
if (specCategory) {
const sameCategoryKeys = Array.from(specOptions.value.get(specCategory).keys());
tempChoseKeys = tempChoseKeys.filter(item => !sameCategoryKeys.includes(item));
}
// 添加当前要判断的key
tempChoseKeys.push(key);
// 检查是否存在包含所有临时选择key的有效规格组合
const hasValidCombination = activeKeys.value.some(combination => {
return arrayContainsAll(combination, tempChoseKeys);
});
return hasValidCombination;
}
// 是否被选中
const isChose = (key) => {
return choseKeys.value.includes(key)
}
const handleSubmit = () => {
// 匹配规格
let specification = dataInfo.value.specifications.filter(item => {
let group = item.combination_key.split('-').map(Number)
if (arraysEqualUnordered(group, choseKeys.value)) return true
return false
})
let specificationId = null
if (specification.length != 0) {
specificationId = specification[0].id
} else {
msgRef.value.show({
title: '请选择规格',
type: 'warning'
})
return
}
// 立即购买
const cartItem = {
productId: dataInfo.value.id,
quantity: order.value.count,
specificationId: specificationId,
points: dataInfo.value.points,
name: dataInfo.value.name,
image: dataInfo.value.image,
stock: dataInfo.value.stock
}
if (flag.value == 0) {
// 加入购物车
mallAPI.addCart(cartItem).then(res => {
if (res.success) {
msgRef.value.show({
title: '已加入购物车',
type: 'success'
})
} else {
msgRef.value.show({
title: res.data.message || '添加到购物车失败',
type: 'error'
})
}
}).finally(() => {
order.value.count = 1
order.value.orderNote = ''
choseKeys.value = []
showSure.value = false
})
} else if (flag.value == 1) {
mallAPI.addCart(cartItem).then(res => {
if (res.success) {
const cartItemId = res.data?.cart_item_id || res.data?.id || res.data
?.cartItemId || res.id
if (!cartItemId) {
msgRef.value.show({
title: '无法获取购物车项ID',
type: 'error'
})
} else {
mallAPI.createOrder({
cart_item_ids: [cartItemId]
}).then(response => {
if (response.success) {
showSure.value = false
// 进入支付页面
uni.navigateTo({
url: '/pages/home/pay?preOrderId=' + response.data
.preOrderId
})
} else {
msgRef.value.show({
title: '操作失败',
type: 'error'
})
}
})
}
} else {
msgRef.value.show({
title: res.data.message || '添加到购物车失败',
type: 'error'
})
}
})
}
}
// 判断两个数组值是否相等
const arraysEqualUnordered = (arr1, arr2) => {
if (arr1.length !== arr2.length) return false;
const sorted1 = [...arr1].sort();
const sorted2 = [...arr2].sort();
return sorted1.every((item, index) => item === sorted2[index]);
}
const dataId = ref()
const dataInfo = ref({})
const recommendedList = ref([])
const specNames = ref(new Set())
const specOptions = ref(new Map())
const activeKeys = ref([])
const loadData = () => {
mallAPI.getMallDetail(dataId.value).then(res => {
console.log(res);
dataInfo.value = res.data.product
dataInfo.value.banner = []
if (dataInfo.value.images.length != 0) {
dataInfo.value.images.forEach(item => {
dataInfo.value.banner.push(getImageUrl(item))
})
}
loadSpec()
})
mallAPI.getRecommended(dataId.value).then(res => {
recommendedList.value = res.data.products
})
}
const loadSpec = () => {
dataInfo.value.specifications.forEach(specification => {
activeKeys.value.push(specification.combination_key)
specification.spec_details.forEach(detail => {
specNames.value.add(detail.spec_display_name)
let data = specOptions.value.get(detail.spec_display_name)
if (data == undefined) {
data = new Map()
data.set(detail.id, detail.display_value)
specOptions.value.set(detail.spec_display_name, data)
} else {
data.set(detail.id, detail.display_value)
specOptions.value.set(detail.spec_display_name, data)
}
})
})
}
@@ -80,13 +473,138 @@
height: 100vh;
background: linear-gradient(180deg, #2F75F9 0%, #F0F3FF 34.13%);
.collection {
width: 48rpx;
height: 48rpx;
margin-right: 24rpx;
}
.img-sub-banner {
padding: 12rpx 0;
background: #fff;
white-space: nowrap;
.img-item {
border-radius: 20rpx;
width: 128rpx;
height: 128rpx;
margin: 0 4rpx;
}
.active {
border: 1px solid #189eff;
}
}
.mall-info {
padding: 20rpx 34rpx;
.name {
font-weight: 650;
font-size: 20px;
leading-trim: NONE;
line-height: 46rpx;
letter-spacing: 0%;
}
.price {
display: flex;
justify-content: space-between;
align-items: center;
.mall-price {
font-size: 30rpx;
color: #305DEF;
margin-top: 10rpx;
.icon {
height: 30rpx;
width: 30rpx;
}
}
}
.detail {
margin-top: 20rpx;
border: 1rpx solid #fff;
padding: 10rpx 20rpx;
box-shadow: 1px 1px 2px 2px rgba(0, 0, 255, 0.2);
}
.recommend {
margin-top: 20rpx;
.mall-list {
margin-top: 20rpx;
.mall-item {
border-radius: 16rpx;
background: #F0F5FF;
position: relative;
margin-top: 20rpx;
box-shadow: 0px 4px 4px 0px #00000040;
padding-bottom: 10rpx;
.mall-title {
font-size: 30rpx;
margin-top: 10rpx;
color: $u-main-color;
}
.mall-price {
font-size: 30rpx;
color: $u-type-error;
margin-top: 10rpx;
.icon {
height: 30rpx;
width: 30rpx;
}
}
.mall-tag {
display: flex;
margin-top: 5px;
.mall-tag-owner {
background-color: $u-type-error;
color: #FFFFFF;
display: flex;
align-items: center;
padding: 4rpx 14rpx;
border-radius: 50rpx;
font-size: 20rpx;
line-height: 1;
}
.mall-tag-text {
margin-right: 10px;
border: 1px solid $u-type-primary;
color: $u-type-primary;
border-radius: 50rpx;
line-height: 1;
padding: 4rpx 14rpx;
display: flex;
align-items: center;
border-radius: 50rpx;
font-size: 20rpx;
}
}
.mall-shop {
font-size: 22rpx;
color: $u-tips-color;
margin-top: 5px;
}
}
}
}
}
.bottom-view {
position: absolute;
bottom: 0;
@@ -158,4 +676,101 @@
}
}
}
.sure-popup {
background: #F5F8FF;
padding-bottom: 20rpx;
height: 100%;
.title {
font-weight: 274;
font-style: Light;
font-size: 32rpx;
leading-trim: NONE;
line-height: 48rpx;
letter-spacing: 0%;
text-align: center;
}
.address {
display: flex;
align-items: center;
margin-top: 30rpx;
padding: 20rpx 10rpx;
justify-content: space-between;
.text {
display: flex;
align-items: center;
}
.right-icon {
width: 40rpx;
height: 40rpx;
}
}
.count-select {
display: flex;
margin-top: 10rpx;
.pre-view {
width: 160rpx;
height: 160rpx;
}
.text {
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: center;
}
.icon {
height: 30rpx;
width: 30rpx;
}
}
.spec-option {
margin: 20rpx 0;
padding: 0 20rpx;
.title {
font-weight: 700;
font-style: Bold;
font-size: 32rpx;
leading-trim: NONE;
line-height: 48rpx;
letter-spacing: 0%;
text-align: left;
}
.option-list {
display: flex;
.option-item {
background: #f2f3f5;
padding: 10rpx 20rpx;
margin: 20rpx 20rpx 20rpx 0;
}
.active {
border: 1rpx solid #ff6b35;
color: #ff6b35;
}
.unactive {
background: #D9D9D9;
}
}
}
.submit-btn {
padding: 0 20rpx;
position: absolute;
bottom: 20rpx;
width: 100%;
}
}
</style>

261
pages/home/mallSearch.vue Normal file
View File

@@ -0,0 +1,261 @@
<template>
<view class="search-container">
<u-navbar id="navBar" title="" :background="{ background: '#E4ECFF' }">
<view class="slot-wrap">
<u-search :show-action="false" placeholder="输入商品名称或商品种类" v-model="params.search" bgColor="#CADBFF"
@search="handleSearch"></u-search>
</view>
<template v-slot:right>
<u-icon class="more-dot-fill" name="more-dot-fill"></u-icon>
</template>
</u-navbar>
<view class="filter" id="filterFixed">
<view class="sort-menu">
<u-tabs :show-bar="false" :list="sortList" :is-scroll="false" v-model="currentSort"
@change="changeSort"></u-tabs>
</view>
<view class="icon" @click="viewType=!viewType">
<image style="width: 100%;height: 100%;" src="/static/icon/view-change.png" mode=""></image>
</view>
</view>
<scroll-view scroll-y="true" :style="'height:'+scrollHeight+'px'" class="scroll-view" @scrolltolower="loadData">
<view :class="viewType?'mall-list':'mall-list2'">
<view class="mall-item" v-for="item in mallList" @click="handleCheck(item)">
<view class="item-img">
<u-lazy-load style="width: 100%;height: 100%;" img-mode="widthFix"
:image="getImageUrl(item.image)" threshold="-450" border-radius="10"></u-lazy-load>
</view>
<view class="item-info">
<view>{{item.name}}</view>
<view>积分{{item.points_price}}</view>
<view>融豆{{item.rongdou_price}}</view>
</view>
</view>
</view>
<u-loadmore margin-top="20" :status="loadStatus"></u-loadmore>
<view class="box-div"></view>
</scroll-view>
</view>
<u-toast ref="msgToast" duration="6000" />
</template>
<script setup>
import {
ref,
computed,
getCurrentInstance,
onMounted,
reactive
} from 'vue';
import {
getImageUrl
} from '../../util/common.js'
import {
mallAPI
} from '../../api/mall';
import {
onLoad
} from '@dcloudio/uni-app'
const msgToast = ref()
const instance = getCurrentInstance();
const scrollHeight = ref(0)
const loadHeight = () => {
uni.getSystemInfo({
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#navBar").boundingClientRect((data) => {
scrollHeight.value = screenHeight - data.height
}).exec()
uni.createSelectorQuery().in(instance.proxy).select("#filterFixed").boundingClientRect((
data) => {
scrollHeight.value = scrollHeight.value - data.height
}).exec()
}
})
}
const viewType = ref(true)
const params = ref({
page: 1,
limit: 10,
category: '',
search: '',
sort: ''
})
const handleSearch = () => {
params.value.page = 1
loadStatus.value = 'loadmore'
mallList.value = []
loadData()
}
const sortList = reactive([{
name: '默认'
}, {
name: '价格高到低'
}, {
name: '价格低到高',
}, {
name: '销量',
}])
const currentSort = ref(0)
const changeSort = (val) => {
// sortprice_desc价格升序price_asc价格降序sales_desc销量升序
console.log(val);
switch (val) {
case 0:
params.value.sort = ''
break
case 1:
params.value.sort = 'price_desc'
break
case 2:
params.value.sort = 'price_asc'
break
case 2:
params.value.sort = 'sales_desc'
break
}
params.value.page = 1
loadStatus.value = 'loadmore'
mallList.value = []
loadData()
}
const handleCheck = (item) => {
uni.navigateTo({
url: '/pages/home/mallDetail?id=' + item.id
})
}
const mallList = ref([])
const loadStatus = ref('loadmore') // nomore
const maxPage = ref(1)
const loadData = () => {
if (loadStatus.value == 'nomore') return
mallAPI.getMallList(params.value).then((res) => {
mallList.value = mallList.value.concat(res.data.products)
maxPage.value = res.data.pagination.pages
params.value.page++
if (maxPage.value < params.value.page) {
loadStatus.value = 'nomore'
}
})
}
onLoad((val) => {
params.value.category = val.cate || ''
params.value.search = val.search || ''
})
onMounted(() => {
loadHeight()
loadData()
})
</script>
<style scoped lang="scss">
.search-container {
width: 100%;
height: 100%;
background: var(--Color, #E4ECFF);
.more-dot-fill {
width: 48rpx;
height: 48rpx;
margin-right: 24rpx;
}
.filter {
display: flex;
background: #fff;
align-items: center;
padding-right: 20rpx;
.sort-menu {
flex: 1;
}
.icon {
display: flex;
justify-content: center;
align-items: center;
width: 24rpx;
height: 24rpx;
}
}
.scroll-view {
.mall-list {
display: flex;
flex-wrap: wrap;
.mall-item {
width: 100%;
display: flex;
background: #F5F8FF;
margin: 8rpx 0;
padding: 20rpx;
.item-img {
width: 220rpx;
height: 220rpx;
margin-right: 66rpx;
}
.item-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
}
}
.mall-list2 {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 0 20rpx;
.mall-item {
width: 47%;
display: flex;
background: #F5F8FF;
margin: 8rpx 4rpx;
padding: 20rpx;
flex-direction: column;
align-items: center;
justify-content: center;
.item-img {
width: 100%;
}
.item-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
}
}
.box-div {
padding: 10rpx 0rpx;
}
}
}
</style>

618
pages/home/pay.vue Normal file
View File

@@ -0,0 +1,618 @@
<template>
<view class="pay-container">
<scroll-view scroll-y="true" style="height: 100%;">
<view class="scroll-container">
<view class="box-bg u-p-b-40">
<view class="address">
<view class="text" @click="handleSelectAddress">
<image style="width: 40rpx;height: 40rpx;" src="/static/icon/Map pin2.png" mode=""></image>
<view class="u-m-l-10">{{selectAddressLabel}}</view>
</view>
<view class="right-icon" @click="handleAddressManage">
<image style="width: 100%;height: 100%;" src="/static/icon/Chevron right Menu.png" mode="">
</image>
</view>
</view>
<view class="count-select u-p-l-10 u-p-r-10" v-for="item in dataInfo.items">
<view class="pre-view">
<u-image :src="getImageUrl(item.image_url)" height="100%" width="100%">
<template v-slot:error>
<view style="font-size: 24rpx;">暂无图片</view>
</template>
</u-image>
</view>
<view class="text">
{{item.product_name}}
<view>融豆{{item.rongdou_price}}</view>
<view>积分{{item.points_price}}</view>
<view>数量X{{item.quantity}}</view>
</view>
</view>
</view>
<view class="box-bg description u-m-t-20">
<view class="item">
<view class="title">
订单编号
</view>
<view class="value">
{{dataInfo.order_no}}
</view>
</view>
<view class="item">
<view class="title">
创建时间
</view>
<view class="value">
{{dataInfo.created_at}}
</view>
</view>
</view>
<view class="box-bg u-m-t-20 discount">
选择优惠券
<u-input class="u-m-t-20" :disabled="discountOptions.length==0"
:placeholder="discountOptions.length==0?'暂无优惠券':'请选择优惠券'" v-model="discountLabel" type="select"
:border="true" @click="handleSelectCoupon" />
<view class="u-m-t-10" style="font-weight: 500;font-size: 20rpx;">选择优惠券后自动换算扣除</view>
</view>
<view class="box-bg pay-method u-m-t-20" v-if="supportMethod.length!=0">
<view class="title u-m-b-20">
支付方式
</view>
<view class="item" v-if="supportMethod.includes('rongdou')" @click="handleChangeMethod(0)">
<view class="title">
融豆
</view>
<view class="value">
<u-checkbox v-model="rongdouChecked" shape="circle" active-color="#305def"></u-checkbox>
</view>
</view>
<view class="item" v-if="supportMethod.includes('points')" @click="handleChangeMethod(1)">
<view class="title">
积分
</view>
<view class="value">
<u-checkbox v-model="pointsChecked" shape="circle" active-color="#305def"></u-checkbox>
</view>
</view>
<view class="item" v-if="supportMethod.includes('mixed')" @click="handleChangeMethod(2)">
<view class="title">
融豆+积分
</view>
<view class="value">
<u-checkbox v-model="rpChecked" shape="circle" active-color="#305def"></u-checkbox>
</view>
</view>
<view class="item" v-if="supportMethod.includes('alipay')" @click="handleChangeMethod(3)">
<view class="title">
支付宝
</view>
<view class="value">
<u-checkbox v-model="alipayChecked" shape="circle" active-color="#305def"></u-checkbox>
</view>
</view>
<view class="item" v-if="supportMethod.includes('wechatpay')" @click="handleChangeMethod(4)">
<view class="title">
微信
</view>
<view class="value">
<u-checkbox v-model="wechatpayChecked" shape="circle" active-color="#305def"></u-checkbox>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="box-bottom" id="boxBottom">
<view class="text">
实际支付
<image v-if="rpChecked || pointsChecked" src="/static/icon/jifen.png" class="icon" mode=""></image>
<image v-else-if="rongdouChecked" src="/static/icon/rongdou.png" class="icon" mode=""></image>
<span v-else></span>
{{allPayNum}}
</view>
<view class="btn">
<u-button @click="handleSubmit">确认支付</u-button>
</view>
</view>
<!-- 地址选择 -->
<u-select v-model="showSelectAddress" :list="addressOptions" @confirm="confirm"></u-select>
<!-- 优惠券选择 -->
<u-select v-model="showDiscount" :list="discountOptions" @confirm="confirmDiscount"></u-select>
<!-- 关闭提示 -->
<u-modal @confirm="handleBack" v-model="showBack" content="是否关闭订单,确认返回后可在个人中心查看我的订单完成支付"
:show-cancel-button="true"></u-modal>
<!-- 消息提示 -->
<u-toast ref="msgRef" />
</view>
</template>
<script setup>
import {
computed,
onMounted,
ref,
getCurrentInstance
} from 'vue';
import {
onLoad,
onBackPress,
onPullDownRefresh
} from '@dcloudio/uni-app'
import {
mallAPI
} from '../../api/mall';
import {
addressAPI
} from '../../api/address'
import {
getImageUrl,
arrayContainsAll
} from '../../util/common.js'
const msgRef = ref()
const showBack = ref(false)
onBackPress((options) => {
if (options.from === 'navigateBack') {
return false;
} else {
showBack.value = true
return true;
}
})
const handleBack = () => {
uni.navigateBack();
}
// 收获地址
const showSelectAddress = ref(false)
const addressOptions = ref([])
const selectAddressId = ref()
const selectAddressLabel = ref()
const handleSelectAddress = () => {
// 地址信息
addressAPI.getList().then(res => {
addressOptions.value = res.data.map(item => {
if (item.is_default) {
selectAddressId.value = item.id
selectAddressLabel.value = item.receiver_name + " | " + item.province_name +
item
.city_name + item.district_name + item.detailed_address
}
return {
value: item.id,
label: item.receiver_name + " | " + item.province_name + item.city_name + item
.district_name + item.detailed_address
}
})
showSelectAddress.value = true
})
}
const confirm = (val) => {
selectAddressId.value = val[0].value
selectAddressLabel.value = val[0].label
}
const handleAddressManage = () => {
uni.navigateTo({
url: '/pages/my/shippingAddress'
})
}
// 优惠券
const showDiscount = ref(false)
const discountLabel = ref('')
const discountOptions = ref([])
const couponRecordId = ref()
const handleSelectCoupon = async () => {
await loadCoupon()
if (discountOptions.value.length == 0) return
showDiscount.value = true
}
const confirmDiscount = (val) => {
couponRecordId.value = val[0].value
discountLabel.value = val[0].label
calculateAllPay()
}
// 支付方式
const rongdouChecked = ref(false)
const pointsChecked = ref(false)
const rpChecked = ref(false)
const alipayChecked = ref(false)
const wechatpayChecked = ref(false)
const allPayNum = ref(null)
const clearChecked = () => {
rongdouChecked.value = false
pointsChecked.value = false
rpChecked.value = false
alipayChecked.value = false
wechatpayChecked.value = false
}
const handleChangeMethod = (val) => {
clearChecked()
if (val == 0) { // 融豆
rongdouChecked.value = true
}
if (val == 1) { // 积分
pointsChecked.value = true
}
if (val == 2) { // 融豆+积分
rpChecked.value = true
}
if (val == 3) { // 支付宝
alipayChecked.value = true
}
if (val == 4) { // 微信
wechatpayChecked.value = true
}
calculateAllPay() // 计算实际支付
}
// 计算实际支付
const calculateAllPay = () => {
allPayNum.value = 0
if (rongdouChecked.value) { // 融豆
dataInfo.value.items.forEach(item => {
allPayNum.value += item.rongdou_price * item.quantity
})
// 选择优惠券
if (couponRecordId.value) {
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
.couponInfo
handle1to1(couponInfo)
}
} else if (pointsChecked.value) { // 积分
dataInfo.value.items.forEach(item => {
allPayNum.value += item.points_price * item.quantity
})
// 选择优惠券
if (couponRecordId.value) {
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
.couponInfo
handle1to10000(couponInfo)
}
} else if (rpChecked.value) { // 融豆+积分
dataInfo.value.items.forEach(item => {
allPayNum.value += item.points_price * item.quantity
})
// 选择优惠券
if (couponRecordId.value) {
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
.couponInfo
handle1to10000(couponInfo)
}
} else if (alipayChecked.value) { // 支付宝
dataInfo.value.items.forEach(item => {
allPayNum.value += item.price * item.quantity
})
// 选择优惠券
if (couponRecordId.value) {
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
.couponInfo
handle1to1(couponInfo)
}
} else if (wechatpayChecked.value) { // 微信
dataInfo.value.items.forEach(item => {
allPayNum.value += item.price * item.quantity
})
// 选择优惠券
if (couponRecordId.value) {
let couponInfo = couponList.value.filter(item => item.couponInfo.id == couponRecordId.value)[0]
.couponInfo
handle1to1(couponInfo)
}
}
if (allPayNum.value < 0) allPayNum.value = 0
}
// 折扣计算
const handle1to1 = (couponInfo) => {
if (couponInfo.type == 'discount_for_a_amount') { // 满减
if (allPayNum.value > couponInfo.for_a_amount) {
allPayNum.value -= couponInfo.discount
}
} else if (couponInfo.type == 'deduction') { // 抵扣
allPayNum.value -= couponInfo.price
} else if (couponInfo.type == 'discount') { // 折扣
allPayNum.value *= couponInfo.precent * 0.01
}
}
// 折扣计算
const handle1to10000 = (couponInfo) => {
if (couponInfo.type == 'discount_for_a_amount') { // 满减
if (allPayNum.value > (couponInfo.for_a_amount * 10000)) {
allPayNum.value -= couponInfo.discount * 10000
}
} else if (couponInfo.type == 'deduction') { // 抵扣
allPayNum.value -= couponInfo.price * 10000
} else if (couponInfo.type == 'discount') { // 折扣
allPayNum.value = allPayNum.value * couponInfo.precent * 0.01
}
}
const isPay = ref(false)
const handleSubmit = () => {
if (isPay.value) {
msgRef.value.show({
title: '请不要重复支付',
type: 'error'
})
return
}
if (!selectAddressId.value) {
msgRef.value.show({
title: '请选择收货地址',
type: 'error'
})
return
}
const orderData = {
orderId: preOrderId.value,
addressId: selectAddressId.value,
pointsAmount: allPayNum.value,
beansAmount: allPayNum.value,
couponRecordId: couponRecordId.value
}
if (rongdouChecked.value) {
orderData.paymentMethod = 'beans'
handlePay(orderData)
return
}
if (pointsChecked.value) {
orderData.paymentMethod = 'points'
handlePay(orderData)
return
}
if (rpChecked.value) {
orderData.paymentMethod = 'mixed'
handlePay(orderData)
return
}
if (alipayChecked.value) {
msgRef.value.show({
title: '暂不支持支付宝支付',
type: 'primary'
})
return
}
if (wechatpayChecked.value) {
msgRef.value.show({
title: '暂不支持微信支付',
type: 'primary'
})
return
}
msgRef.value.show({
title: '请选择支付方式',
type: 'warning'
})
}
const handlePay = (orderData) => {
mallAPI.payment(orderData).then(res => {
if (res.success) {
msgRef.value.show({
title: '支付成功',
type: 'success'
})
isPay.value = true
setTimeout(() => {
uni.navigateBack()
}, 1000)
}
})
}
const dataInfo = ref({})
const couponList = ref({})
const supportMethod = ref([])
function getCommonPaymentMethods(data) {
if (!data.items || data.items.length === 0) {
return [];
}
return data.items
.map(item => item.payment_methods)
.reduce((common, current) =>
common.filter(method => current.includes(method))
);
}
const loadData = async () => {
// 订单信息
await mallAPI.getOrder(preOrderId.value).then(res => {
dataInfo.value = res.data
dataInfo.value.items.forEach(item => {
if (item.payment_methods.includes('rongdou') && item.payment_methods.includes(
'points')) item.payment_methods.push('mixed')
})
supportMethod.value = getCommonPaymentMethods(dataInfo.value)
})
uni.stopPullDownRefresh()
}
const loadCoupon = () => {
// 折扣信息
mallAPI.getCouponList(userId.value).then(res => {
couponList.value = res.coupon
// 排除已经使用的优惠券 和 排除商品不可使用的优惠券
let pIds = dataInfo.value.items.map(item => {
return item.product_id
})
couponList.value = couponList.value.filter(item => {
if (item.use_time == null && arrayContainsAll(item.couponInfo.products_id, pIds))
return true
return false
})
discountOptions.value = couponList.value.map(item => {
if (item.couponInfo.type === 'discount_for_a_amount') {
return {
value: item.coupon_id,
label: "满减券:满" + item.couponInfo.for_a_amount + "元减" + item.couponInfo
.discount + "元"
}
} else if (item.couponInfo.type === 'deduction') {
return {
value: item.coupon_id,
label: "抵扣券:抵扣" + item.couponInfo.price + "元"
}
} else if (item.couponInfo.type === 'discount') {
return {
value: item.coupon_id,
label: "折扣券:折扣" + item.couponInfo.precent + "%"
}
}
})
})
}
const preOrderId = ref()
const userId = ref()
// 刷新
onPullDownRefresh(async () => {
console.log(111);
loadData()
})
onLoad((val) => {
preOrderId.value = val.preOrderId
})
onMounted(() => {
userId.value = uni.getStorageSync("user").id
loadData()
loadCoupon()
})
</script>
<style lang="scss" scoped>
.pay-container {
width: 100%;
height: 100%;
background: #E4ECFF;
.scroll-container {
padding-bottom: 200rpx;
.box-bg {
background: #F5F8FF;
}
.address {
display: flex;
align-items: center;
padding: 20rpx 10rpx;
justify-content: space-between;
.text {
display: flex;
align-items: center;
// border: 1px solid #000;
flex: 1;
}
.right-icon {
width: 40rpx;
height: 40rpx;
}
}
.count-select {
display: flex;
margin-top: 10rpx;
.pre-view {
width: 160rpx;
height: 160rpx;
}
.text {
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: center;
}
.icon {
height: 30rpx;
width: 30rpx;
}
}
.description {
padding: 30rpx 40rpx;
.item {
display: flex;
justify-content: space-between;
margin-bottom: 30rpx;
}
}
.discount {
padding: 30rpx 40rpx;
}
.pay-method {
padding: 30rpx 40rpx;
.title {
font-weight: 400;
font-style: Regular;
font-size: 28rpx;
leading-trim: NONE;
line-height: 48rpx;
}
.item {
display: flex;
justify-content: space-between;
margin-bottom: 30rpx;
}
}
}
.box-bottom {
width: 100%;
padding: 20rpx 40rpx;
display: flex;
justify-content: space-between;
align-items: center;
position: absolute;
bottom: 0;
background: #F5F8FF;
.text {
display: flex;
align-items: center;
.icon {
height: 30rpx;
width: 30rpx;
}
}
.btn {}
}
}
</style>

View File

@@ -1,336 +0,0 @@
<template>
<view class="mall-container">
<u-navbar :is-fixed="false" title="商城好物" :background="{background: 'transparent' }" :border-bottom="false"
back-icon-color="#fff" title-color="#fff">
<template v-slot:right>
<image src="/static/icon/zhu.png" style="width: 50rpx;height: 50rpx;margin-right: 24rpx;" mode=""></image>
</template>
</u-navbar>
<view class="search">
<u-search @search="reloadMallData" placeholder="点击查询商品" v-model="params.keyword" :show-action="false"
bg-color="#FEEFCE" </u-search>
</view>
<view class="menu-list">
<view class="menu-item" v-for="(item, index) in menuList" @click="handleMenuChange(index)">
<view class="img-box">
<image class="img" :src="'/static/mall/'+(index+1)+'.png'" mode=""></image>
</view>
<view class="menu-text" :class="currentMenu==index?'menu-text-actice':''">
<view class="text" :class="currentMenu==index?'text-actice':''">
{{item}}
</view>
</view>
</view>
</view>
<view class="mall-list">
<u-waterfall v-model="mallList" ref="mallListRef">
<template v-slot:left="{leftList}">
<view class="mall-item u-m-r-10" v-for="(item, index) in leftList" :key="index">
<u-lazy-load threshold="-450" border-radius="10" :image="getImageUrl(item.image_url)"
:index="index"></u-lazy-load>
<view class="mall-title u-m-l-5 u-m-r-5">
{{item.name}}
</view>
<del class="u-m-l-5 u-m-r-5" style="white-space: nowrap;">{{item.price}}</del>
<view class="mall-price u-m-l-5 u-m-r-5" v-if="RDType(item.payment_methods)">
<image src="/static/icon/rongdou.png" class="icon" mode=""></image>
{{item.rongdou_price}}
</view>
<view class="mall-price u-m-l-5 u-m-r-5" v-if="pointsType(item.payment_methods)">
<u-icon name="integral"></u-icon>
{{item.points_price}}
</view>
<view class="mall-tag u-m-l-5 u-m-r-5">
<view class="mall-tag-text" v-if="RDType(item.payment_methods)">
融豆
</view>
<view class="mall-tag-owner" v-if="pointsType(item.payment_methods)">
积分
</view>
</view>
<view class="mall-shop u-m-l-5 u-m-r-5">
{{item.category}}
</view>
</view>
</template>
<template v-slot:right="{rightList}">
<view class="mall-item u-m-l-10" v-for="(item, index) in rightList" :key="index">
<u-lazy-load threshold="-450" border-radius="10" :image="getImageUrl(item.image_url)"
:index="index"></u-lazy-load>
<view class="mall-title u-m-l-5 u-m-r-5">
{{item.name}}
</view>
<del class="u-m-l-5 u-m-r-5" style="white-space: nowrap;">{{item.price}}</del>
<view class="mall-price u-m-l-5 u-m-r-5" v-if="RDType(item.payment_methods)">
<image src="/static/icon/rongdou.png" class="icon" mode=""></image>
{{item.rongdou_price}}
</view>
<view class="mall-price u-m-l-5 u-m-r-5" v-if="pointsType(item.payment_methods)">
<u-icon name="integral"></u-icon>
{{item.points_price}}
</view>
<view class="mall-tag u-m-l-5 u-m-r-5">
<view class="mall-tag-text" v-if="RDType(item.payment_methods)">
融豆
</view>
<view class="mall-tag-owner" v-if="pointsType(item.payment_methods)">
积分
</view>
</view>
<view class="mall-shop u-m-l-5 u-m-r-5">
{{item.category}}
</view>
</view>
</template>
</u-waterfall>
<u-loadmore margin-top="20" :status="loadStatus"></u-loadmore>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue';
import { onReachBottom } from '@dcloudio/uni-app'
import { mallAPI } from '../../api/mall';
import { getImageUrl } from '../../util/common';
const params = ref({
keyword: '',
page: 1,
size: 5,
category: ''
})
const mallList = ref([])
const mallListRef = ref()
const loadStatus = ref('loadmore') // nomore
const maxPage = ref(1)
// 积分兑换
const pointsType = (val : any) => {
if (val && val.indexOf("points") >= 0) return true
return false
}
// 融豆兑换
const RDType = (val : any) => {
if (val && val.indexOf("rongdou") >= 0) return true
return false
}
// 加载数据
const loadMallData = () => {
if (loadStatus.value == 'nomore') return
mallAPI.getMallList(params.value).then((res) => {
mallList.value = mallList.value.concat(res.data.products)
maxPage.value = res.data.pagination.pages
params.value.page++
if (maxPage.value < params.value.page) {
loadStatus.value = 'nomore'
}
})
}
// 清空选项
const clearData = () => {
params.value = {
keyword: params.value.keyword,
page: 1,
size: 5,
category: ''
}
menuCategoryMap(currentMenu.value)
maxPage.value = 1
mallList.value = []
mallListRef.value.clear()
loadStatus.value = 'loadmore'
}
// 重新加载
const reloadMallData = () => {
clearData()
loadMallData()
}
// 菜单映射
const menuCategoryMap = (val) => {
switch (val) {
case 0:
params.value.category = ''
break
case 1:
params.value.category = '服装配饰'
break
case 2:
params.value.category = '日用百货'
break
case 3:
params.value.category = '数码产品'
break
case 4:
params.value.category = '美妆饰品'
break
case 5:
params.value.category = '食品饮料'
break
}
}
// 菜单
const menuList = ["全部商品", "精美服饰", "日用百货", "电子数码", "美妆饰品", "食物饮品"]
const currentMenu = ref(0)
const handleMenuChange = (val : number) => {
currentMenu.value = val
menuCategoryMap(val)
reloadMallData()
}
// 上拉刷新
onReachBottom(() => {
loadMallData()
})
onMounted(() => {
loadMallData()
})
</script>
<style scoped lang="scss">
.mall-container {
width: 100%;
background: linear-gradient(180deg, #FFAE00 0%, #FFF0D0 40.87%, #FFFFFF 58.17%);
height: 100vh;
.search {
padding: 32rpx;
}
// 菜单
.menu-list {
display: flex;
margin: 0 30rpx;
overflow: hidden;
overflow-x: scroll;
.menu-item {
white-space: nowrap;
margin-right: 30rpx;
// border: 1px solid #FFAE00;
.img-box {
width: 100%;
display: flex;
justify-content: center;
.img {
width: 66rpx;
height: 66rpx;
}
}
.menu-text {
font-family: Work Sans;
font-weight: 700;
font-style: Bold;
font-size: 26rpx;
leading-trim: NONE;
line-height: 100%;
letter-spacing: -2%;
text-align: center;
color: #F7F7EF;
margin-top: 10rpx;
}
.menu-text-actice {
margin-top: 5rpx;
padding: 4rpx 10rpx 0;
color: #FA941F;
background-color: #fee9bb;
border-radius: 20rpx;
}
.text-actice {
padding: 2rpx 0rpx;
border-bottom: 4rpx solid #FA941F;
}
}
}
// 商城列表
.mall-list {
margin-top: 20rpx;
padding: 0 32rpx 20rpx;
.mall-item {
border-radius: 16rpx;
background-color: #ffffff;
position: relative;
margin-top: 20rpx;
box-shadow: 0px 4px 4px 0px #00000040;
padding-bottom: 10rpx;
.mall-title {
font-size: 30rpx;
margin-top: 10rpx;
color: $u-main-color;
}
.mall-price {
font-size: 30rpx;
color: $u-type-error;
margin-top: 10rpx;
.icon {
height: 30rpx;
width: 30rpx;
}
}
.mall-tag {
display: flex;
margin-top: 5px;
.mall-tag-owner {
background-color: $u-type-error;
color: #FFFFFF;
display: flex;
align-items: center;
padding: 4rpx 14rpx;
border-radius: 50rpx;
font-size: 20rpx;
line-height: 1;
}
.mall-tag-text {
margin-right: 10px;
border: 1px solid $u-type-primary;
color: $u-type-primary;
border-radius: 50rpx;
line-height: 1;
padding: 4rpx 14rpx;
display: flex;
align-items: center;
border-radius: 50rpx;
font-size: 20rpx;
}
}
.mall-shop {
font-size: 22rpx;
color: $u-tips-color;
margin-top: 5px;
}
}
}
}
</style>

297
pages/my/car.vue Normal file
View File

@@ -0,0 +1,297 @@
<template>
<view class="cart-container">
<u-navbar id="uNavbarId" back-text="购物车" :back-text-style="navBarTitle"
:background="{background: 'transparent' }" :border-bottom="false" back-icon-color="#000" title-color="#000">
<template v-slot:right>
<view class="right-menu">
<view @click="handleManage">
{{isManage?'退出管理':'管理'}}
</view>
</view>
</template>
</u-navbar>
<scroll-view scroll-y="true" :style="'height:'+scrollHeight+'px'">
<view class="cart-list">
<view class="cart-item" v-for="item in cartList">
<view class="left">
<u-checkbox v-model="item.isCheck" shape="circle" active-color="#305def"></u-checkbox>
<image style="height: 160rpx;width: 160rpx;" :src="getImageUrl(item.product.image_url)" mode="">
</image>
</view>
<u-row class="right">
<u-col :span="10">
<view>{{item.product.name}}</view>
<view>
<image class="icon" src="/static/icon/rongdou.png" mode=""></image>
{{item.product.rongdou_price}}
</view>
<view>
<image class="icon" src="/static/icon/jifen.png" mode=""></image>
{{item.product.points_price}}
</view>
<view>
<u-number-box bg-color="#E3ECFF" v-model="item.quantity"
@change="handleChangeQuantity(item)" :min="1"
:max="item.product.stock"></u-number-box>
</view>
</u-col>
<u-col :span="2" text-align="right">
<template v-if="!isManage">
x{{item.quantity}}
</template>
<template v-else>
<image @click="handleDeleteCart([item])" style="width: 40rpx;height: 40rpx;"
src="/static/icon/delete.png" mode="">
</image>
</template>
</u-col>
</u-row>
</view>
<view class="box-div">
</view>
</view>
</scroll-view>
<view class="box-bottom" id="boxBottom">
<u-checkbox v-model="isAllCheck" shape="circle" @change="handleSelectAll">全选</u-checkbox>
<view class="right">
合计
<image class="icon" src="/static/icon/rongdou.png" mode=""></image>
{{rongdou}}
<image class="icon" src="/static/icon/jifen.png" mode=""></image>
{{point}}
<u-button class="u-m-l-10" @click="handleSubmit">{{isManage?'删除':'结算'}}</u-button>
</view>
</view>
<!-- 确认是否删除 -->
<u-modal v-model="showDel" content="是否删除选中的商品" :show-cancel-button="true" @confirm="handleDel"></u-modal>
<!-- 提示 -->
<u-toast ref="msgRef" />
</view>
</template>
<script setup>
import {
computed,
onMounted,
ref,
getCurrentInstance
} from 'vue';
import {
mallAPI
} from '../../api/mall.js';
import {
getImageUrl
} from '../../util/common.js';
import {
onShow
} from '@dcloudio/uni-app'
const msgRef = ref()
const instance = getCurrentInstance();
const scrollHeight = ref(0)
const loadHeight = () => {
uni.getSystemInfo({
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#uNavbarId").boundingClientRect((
data) => {
scrollHeight.value = screenHeight - data.height
}).exec()
uni.createSelectorQuery().in(instance.proxy).select("#boxBottom").boundingClientRect((
data) => {
scrollHeight.value = scrollHeight - data.height
}).exec()
}
})
}
const navBarTitle = {
fontWeight: '510',
fontStyle: 'Medium',
fontSize: '40rpx',
lineHeight: '52px'
}
const isManage = ref(false)
const handleManage = () => {
isManage.value = !isManage.value
}
const isAllCheck = computed(() => {
if (cartList.value.length == 0) return false
let tmpData = cartList.value.filter(item => item.isCheck)
calculate()
if (tmpData.length == cartList.value.length) return true
else return false
})
const handleSelectAll = () => {
if (isAllCheck.value) cartList.value.forEach(item => item.isCheck = false)
else cartList.value.forEach(item => item.isCheck = true)
calculate()
}
const handleChangeQuantity = (item) => {
mallAPI.editCartQuantity(item)
}
const showDel = ref(false)
const delItems = ref([])
const handleDeleteCart = (items) => {
delItems.value = items
showDel.value = true
}
const handleDel = async () => {
for (var i = 0; i < delItems.value.length; i++) {
await mallAPI.deleteCart(delItems.value[i].id)
}
loadData()
msgRef.value.show({
title: '删除成功',
type: 'success'
})
}
const handleSubmit = () => {
if (isManage.value) {
// 删除
delItems.value = cartList.value.filter(item => item.isCheck)
showDel.value = true
} else {
// 支付
const ids = cartList.value.map(item => item.id)
mallAPI.createOrder({
cart_item_ids: ids
}).then(response => {
if (response.success) {
// 进入支付页面
uni.navigateTo({
url: '/pages/home/pay?preOrderId=' + response.data.preOrderId
})
} else {
msgRef.value.show({
title: '操作失败',
type: 'error'
})
}
})
}
}
const rongdou = ref(0)
const point = ref(0)
const calculate = () => {
rongdou.value = 0
point.value = 0
cartList.value.forEach(item => {
if (item.isCheck) {
rongdou.value += item.quantity * item.product.rongdou_price
point.value += item.quantity * item.product.points_price
}
})
}
const cartList = ref([])
const loadData = () => {
mallAPI.getCartList().then(res => {
cartList.value = res.data.items
cartList.value.forEach(item => item.isCheck = false)
})
}
onShow(() => {
loadData()
})
onMounted(() => {
loadHeight()
})
</script>
<style lang="scss" scoped>
.cart-container {
width: 100%;
height: 100vh;
background: linear-gradient(180deg, #E3E8FF 0%, #FFFFFF 100%);
background-blend-mode: lighten;
.right-menu {
display: flex;
margin-right: 24rpx;
font-family: Work Sans;
font-weight: 500;
font-style: Medium;
font-size: 32rpx;
leading-trim: NONE;
line-height: 100%;
letter-spacing: -2%;
.del-text {
color: red;
}
.add-text {
color: #305DEF;
}
}
.cart-list {
.cart-item {
display: flex;
background: #E3ECFF;
padding: 20rpx;
margin-bottom: 10rpx;
.left {
display: flex;
justify-content: center;
}
.right {
flex: 1;
margin-left: 20rpx;
.icon {
width: 30rpx;
height: 30rpx;
}
}
}
.box-div {
padding: 60rpx 0;
}
}
.box-bottom {
width: 100%;
padding: 20rpx 40rpx;
display: flex;
justify-content: space-between;
align-items: center;
position: absolute;
bottom: 0;
background: #F5F8FF;
.right {
display: flex;
justify-content: flex-end;
align-items: center;
.icon {
width: 30rpx;
height: 30rpx;
}
}
}
}
</style>

295
pages/my/getCoupons.vue Normal file
View File

@@ -0,0 +1,295 @@
<template>
<view class="content">
<view class="coupons">
<view class="red_envelope"></view>
<view class="title">满减券每日限量</view>
<view class="list">
<view class="list_box" v-for="(item,index) in discount_for_a_amount" :key="index">
<view class="l_left"><text></text>{{item.discount}}</view>
<view class="l_cont">
<view class="lt_top">{{item.for_a_amount}}可用</view>
<view class="lt_footer">消费后次日领</view>
</view>
<view class="l_right" v-if="!item.got" @click="receive_coupon(item.id)">立即领券</view>
<view class="l_right l_right_y" v-else>已领取</view>
</view>
<!-- <view class="list_box1">
<view class="l_left"><text></text>5</view>
<view class="l_cont">
<view class="lt_top">满20可用</view>
<view class="lt_footer">神券商家可有 消费后次日领</view>
</view>
<view class="l_right"></view>
</view> -->
</view>
</view>
<view class="coupons coupons1">
<view class="title">代金券天天领</view>
<view class="red_envelope"></view>
<view class="list">
<view class="list_box2" v-for="(item,index) in deduction" :key='index' >
<view class="l2_top"><text></text>{{item.price}}</view>
<view class="l2_title">无门槛</view>
<view class="l_right" v-if="!item.got" @click="receive_coupon(item.id)">立即领券</view>
<view class="l_right l_right_y" v-else>已领取</view>
</view>
</view>
</view>
<view class="coupons">
<view class="title">全场促销折扣券</view>
<view class="list">
<view class="list_box" v-for="(item,index) in discount" :key="index">
<view class="l_left">{{(item.precent/10).toFixed(0)}}<text></text></view>
<view class="l_cont">
<view class="lt_top">指定商品折上折</view>
<view class="lt_footer">神券商家可有 消费后次日领</view>
</view>
<view class="l_right" v-if="!item.got" @click="receive_coupon(item.id)">立即领券</view>
<view class="l_right l_right_y" v-else>已领取</view>
</view>
<!-- <view class="list_box1">
<view class="l_left"><text></text>5</view>
<view class="l_cont">
<view class="lt_top">满20可用</view>
<view class="lt_footer">神券商家可有 消费后次日领</view>
</view>
<view class="l_right"></view>
</view> -->
</view>
</view>
</view>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { coupon } from '@/api/coupon.js'
let discount_for_a_amount = ref([]) // 满减券
let deduction = ref([]) // 抵扣券
let discount = ref([]) // 折扣券
const data_get_coupon = async () => {
let user = uni.getStorageSync('user')
let { coupon: data } : any = await coupon.get_coupon({ user_id: user.id })
discount_for_a_amount.value = data.filter((item : any) => {
return item.type === 'discount_for_a_amount'
})
deduction.value = data.filter((item : any) => {
return item.type === 'deduction'
})
discount.value = data.filter((item : any) => {
return item.type === 'discount'
})
}
const receive_coupon = async (id : any) => {
console.log(id, 'id')
let user = uni.getStorageSync('user')
let coupon_id = id
console.log({ user_id: user.id, coupon_id })
let data = await coupon.post_coupon({ user_id: user.id, coupon_id })
console.log(data)
data_get_coupon()
}
onMounted(() => {
data_get_coupon()
})
</script>
<style scoped lang="scss">
.content {
height: 100vh;
width: 100%;
background: url('@/static/my/bg.jpg') no-repeat transparent;
background-size: 100% 100%;
padding: 20rpx;
.coupons {
margin-top: 50rpx;
position: relative;
border-radius: 15rpx;
background-color: #fff;
padding: 10rpx;
width: 100%;
.red_envelope {
width: 220rpx;
height: 220rpx;
background: url('@/static/my/red_envelope.png') no-repeat transparent;
background-size: 100% 100%;
position: absolute;
top: -50rpx;
left: -25rpx;
z-index: 1;
}
.title {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 30rpx;
color: #305def;
font-weight: bold;
}
.list {
position: relative;
z-index: 1;
padding: 10rpx;
.list_box {
padding-left: 10rpx;
padding-right: 10rpx;
margin-top: 20rpx;
align-items: center;
height: 132rpx;
background: url('@/static/my/gr.png') no-repeat transparent;
background-size: 100% 100%;
color: #305def;
display: flex;
justify-content: space-between;
.l_left {
font-weight: bold;
font-size: 50rpx;
text {
font-size: 20rpx;
}
}
.l_cont {
.lt_top {
font-size: 30rpx;
font-weight: bold;
}
.lt_footer {
font-size: 24rpx;
}
}
.l_right {
width: 180rpx;
padding: 10rpx 20rpx;
background-color: #305def;
color: #fff;
text-align: center;
border-radius: 30rpx;
}
}
.list_box1 {
margin-top: 20rpx;
align-items: center;
height: 132rpx;
padding: 10rpx;
background: url('@/static/my/grc.png') no-repeat transparent;
background-size: 100% 100%;
color: #7e91b4;
display: flex;
.l_left {
margin-left: 30rpx;
font-weight: bold;
font-size: 50rpx;
text {
font-size: 20rpx;
}
}
.l_cont {
margin-left: 40rpx;
.lt_top {
font-size: 30rpx;
font-weight: bold;
}
.lt_footer {
font-size: 24rpx;
}
}
.l_right {
margin-left: 90rpx;
width: 110rpx;
height: 100rpx;
background: url('@/static/my/over.png') no-repeat transparent;
background-size: 100% 100%;
}
}
}
}
.coupons1 {
.red_envelope {
width: 150rpx;
height: 150rpx;
background: url('@/static/my/logo.png') no-repeat transparent;
background-size: 100% 100%;
position: absolute;
top: -50rpx;
left: -10rpx;
z-index: 1;
}
.list {
display: flex;
flex-wrap: wrap;
margin-top: 20rpx;
}
.list_box2 {
margin-bottom: 20rpx;
margin-right: 25rpx;
width: 200rpx;
height: 180rpx;
background: url('@/static/my/bg1.png') no-repeat transparent;
background-size: 100% 100%;
color: #305def;
display: flex;
flex-direction: column;
align-items: center;
.l2_top {
margin-top: 10rpx;
font-size: 40rpx;
font-weight: bold;
text {
font-size: 20rpx;
}
}
.l2_title {
font-size: 24rpx;
}
.l_right {
margin-top: 30rpx;
width: 140rpx;
padding: 10rpx 20rpx;
background-color: #305def;
color: #fff;
font-size: 16rpx;
text-align: center;
border-radius: 30rpx;
}
.l2_footer {
font-size: 24rpx;
margin-top: 30rpx;
}
&:nth-child(3n) {
margin-right: 0rpx;
}
}
}
.l_right_y{
background-color: #92ACFF !important;
}
}
</style>

View File

@@ -1,6 +1,7 @@
<template>
<view class="my-container">
<scroll-view scroll-y="true" style="height: 100%;">
<scroll-view scroll-y="true" style="height: 100%;" :refresher-threshold="50" :refresher-triggered="isRefresher"
refresher-background="transparent" refresher-enabled="true" @refresherrefresh="reflash">
<view v-if="user!=null">
<view class="header">
<view class="header-user">
@@ -9,6 +10,10 @@
</view>
<view class="header-username u-m-l-20">
{{user.real_name}}
<view>
<u-tag class="u-m-r-20 u-m-t-10" :text="Math.abs(user.balance)" type="warning"></u-tag>
<u-tag :text="user.points"></u-tag>
</view>
</view>
</view>
<view class="header-setting">
@@ -41,12 +46,12 @@
我的兑换
</view>
</view>
<view class="item">
<view class="item" @click="shop_car">
<view class="count">
283
{{totalCartCount}}
</view>
<view class="title">
我的收藏
购物车
</view>
</view>
</view>
@@ -83,7 +88,7 @@
</view>
<view class="menu-list">
<view class="menu-item">
<view class="menu-item" @click="navigatorSrc">
<u-image src="/static/my/01.png" width="40%" mode="widthFix"></u-image>
<view class="menu-text">
领券中心
@@ -101,7 +106,7 @@
我的客户
</view>
</view>
<view class="menu-item">
<view class="menu-item" @click="navigatoCommonProblem">
<u-image src="/static/my/04.png" width="40%" mode="widthFix"></u-image>
<view class="menu-text">
常见问题
@@ -119,7 +124,7 @@
收货地址
</view>
</view>
<view class="menu-item">
<view class="menu-item" @click="handleOrder">
<u-image src="/static/my/07.png" width="40%" mode="widthFix"></u-image>
<view class="menu-text">
我的订单
@@ -134,6 +139,11 @@
</view>
<u-button class="u-m-t-20" @click="loginOut">退出登录</u-button>
<view class="box-div">
</view>
</view>
</scroll-view>
</view>
@@ -144,18 +154,54 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { getImageUrl } from '../../util/common';
import {
authAPI
} from '../../api/auth.js';
import {
onShow
} from '@dcloudio/uni-app';
import {
mallAPI
} from '../../api/mall.js'
const user = ref()
const isRefresher = ref(false)
const reflash = () => {
isRefresher.value = true
loadData()
}
const handleShippingAddress = () => {
uni.navigateTo({
url: '/pages/my/shippingAddress'
})
}
const handleOrder = () => {
uni.navigateTo({
url: '/pages/my/order'
})
}
const totalCartCount = ref(0)
const loadData = () => {
authAPI.me().then(res => {
user.value = res.user
}).finally(() => {
isRefresher.value = false
})
mallAPI.getCartList().then(res => {
totalCartCount.value = res.data.items.length
})
}
onShow(() => {
loadData()
})
onMounted(() => {
user.value = uni.getStorageSync("user")
console.log(user.value);
})
const loginOut = () => {
@@ -164,6 +210,22 @@
url: '/pages/login/login'
})
}
const navigatorSrc = () => {
uni.navigateTo({
url: '/pages/my/getCoupons'
})
}
//购物车跳转
const shop_car = () => {
uni.navigateTo({
url: '/pages/my/car'
})
}
const navigatoCommonProblem = () => {
uni.navigateTo({
url: '/pages/my/commonProblem'
})
}
</script>
<style scoped lang="scss">
@@ -327,5 +389,11 @@
}
}
}
.box-div {
padding: 60rpx 0rpx;
}
}
</style>

543
pages/my/order.vue Normal file
View File

@@ -0,0 +1,543 @@
<template>
<view class="order-container">
<u-navbar id="navBar" title="" :border-bottom="false" :background="{ background: '#F5F8FF' }">
<view class="slot-wrap">
<u-search :show-action="false" placeholder="搜索订单" v-model="params.search" bgColor="#CADBFF"
@search="handleSearch"></u-search>
</view>
<template v-slot:right>
<u-icon class="more-dot-fill" name="more-dot-fill"></u-icon>
</template>
</u-navbar>
<view class="box-tabs" id="tabsId">
<u-tabs bg-color="#F5F8FF" :show-bar="false" :list="tabList" :is-scroll="false"
v-model="currentTab"></u-tabs>
<view class="menu-list">
<!-- 'pending'待发货,'paid','shipped'已发货,'delivered','cancelled'已取消,'pre_order'预订单状态未选择地址和支付方式,'completed'已收货 -->
<view class="menu-item" :class="currentMenu==''?'active':''" @click="handleChangeMenu('')">全部订单</view>
<view class="menu-item" :class="currentMenu=='pending'?'active':''"
@click="handleChangeMenu('pending')">待发货</view>
<view class="menu-item" :class="currentMenu=='pre_order'?'active':''"
@click="handleChangeMenu('pre_order')">待支付</view>
<view class="menu-item" :class="currentMenu=='shipped'?'active':''"
@click="handleChangeMenu('shipped')">已发货</view>
<view class="menu-item" :class="currentMenu=='completed'?'active':''"
@click="handleChangeMenu('completed')">已完成</view>
<view class="menu-item" :class="currentMenu=='cancelled'?'active':''"
@click="handleChangeMenu('cancelled')">已取消</view>
</view>
</view>
<scroll-view scroll-y="true" class="scroll-view" :style="'height:'+scrollHeight+'px'" @scrolltolower="loadData">
<template v-if="currentTab==0">
111
</template>
<template v-if="currentTab==1">
<view class="order-list" v-for="orderItem in orderList">
<view class="u-m-l-20">订单号{{orderItem.order_no}}</view>
<view class="order-item" v-for="item in orderItem.items">
<view class="item-left">
<image style="width: 100%;height: 100%;" :src="getImageUrl(item.image_url)" mode="">
</image>
</view>
<view class="item-right">
<u-row>
<u-col :span="10">
<view>{{item.product_name}}</view>
<view style="display: flex;align-items: center;">
<image class="icon" src="/static/icon/rongdou.png" mode=""></image>
{{item.rongdou_price}}
</view>
<view style="display: flex;align-items: center;">
<image class="icon" src="/static/icon/jifen.png" mode=""></image>
{{item.points_price}}
</view>
</u-col>
<u-col :span="2" text-align="right">
<view>X{{item.quantity}}</view>
</u-col>
</u-row>
</view>
</view>
<view class="operate-btns">
<!-- 待发货 -->
<template v-if="orderItem.status=='pending'">
<u-button hover-class="none" class="operate-btn"
@click="handelCancel(orderItem)">取消订单</u-button>
</template>
<!-- 已支付 -->
<!-- <template v-if="orderItem.status=='paid'">
<u-button hover-class="none" class="operate-btn">取消订单</u-button>
</template> -->
<!-- 已发货 -->
<template v-if="orderItem.status=='shipped'">
<u-button hover-class="none" class="operate-btn"
@click="handleReceive(orderItem)">确认收货</u-button>
</template>
<!-- 已取消 -->
<!-- <template v-if="orderItem.status=='cancelled'">
<u-button hover-class="none" class="operate-btn">查看详情</u-button>
</template> -->
<!-- 待支付 -->
<template v-if="orderItem.status=='pre_order'">
<u-button hover-class="none" class="operate-btn"
@click="handelCancel(orderItem)">取消订单</u-button>
<u-button hover-class="none" class="operate-btn"
@click="handlePay(orderItem)">立即支付</u-button>
</template>
<!-- 完成 -->
<!-- <template v-if="orderItem.status=='completed'">
<u-button hover-class="none" class="operate-btn">评价</u-button>
</template> -->
<u-button hover-class="none" class="operate-btn"
@click="handleOrderDetail(orderItem)">查看详情</u-button>
</view>
</view>
<u-loadmore margin-top="20" :status="loadStatus"></u-loadmore>
<view class="box-view"></view>
</template>
<template v-if="currentTab==2">
222
</template>
</scroll-view>
</view>
<!-- 取消订单提示 -->
<u-modal @confirm="confirmCancel" v-model="showCancel" content="是否取消订单" :show-cancel-button="true"></u-modal>
<!-- 收货提示 -->
<u-modal @confirm="confirmReceive" v-model="showReceive" content="是否确认收到商品" :show-cancel-button="true"></u-modal>
<!-- 详情 -->
<u-modal v-model="showDetail" title="订单详情">
<view class="slot-content">
<view class="info-title">
订单信息
</view>
<view class="info-item">
<view class="info-name">订单号</view>
<view class="info-value">{{detailInfo.order_no}}</view>
</view>
<view class="info-item">
<view class="info-name">用户名</view>
<view class="info-value">{{detailInfo.username}}</view>
</view>
<view class="info-item">
<view class="info-name">下单时间</view>
<view class="info-value">{{detailInfo.created_at}}</view>
</view>
<view class="info-item">
<view class="info-name">更新时间</view>
<view class="info-value">{{detailInfo.updated_at}}</view>
</view>
<view class="info-item">
<view class="info-name">订单状态</view>
<!-- <view class="info-value">{{detailInfo.status}}</view> -->
<u-tag v-if="detailInfo.status=='pending'" text="待发货"></u-tag>
<u-tag v-if="detailInfo.status=='shipped'" text="已发货"></u-tag>
<u-tag v-if="detailInfo.status=='cancelled'" text="已取消"></u-tag>
<u-tag v-if="detailInfo.status=='pre_order'" text="预订单"></u-tag>
<u-tag v-if="detailInfo.status=='completed'" text="已收货"></u-tag>
</view>
<view class="info-item" v-if="detailInfo.address">
<view class="info-name">收货信息</view>
<view class="info-value">
{{detailInfo.address.recipient_name + " " + detailInfo.address.detail_address}}
</view>
</view>
<view class="info-title">
商品信息
</view>
<view class="order-item" v-for="item in detailInfo.items">
<view class="item-left">
<image style="width: 100%;height: 100%;" :src="getImageUrl(item.image_url)" mode="">
</image>
</view>
<view class="item-right">
<u-row>
<u-col :span="10">
<view>{{item.product_name}}</view>
<view style="display: flex;align-items: center;">
<image class="icon" src="/static/icon/rongdou.png" mode=""></image>
{{item.rongdou_price}}
</view>
<view style="display: flex;align-items: center;">
<image class="icon" src="/static/icon/jifen.png" mode=""></image>
{{item.points_price}}
</view>
</u-col>
<u-col :span="2" text-align="right">
<view>X{{item.quantity}}</view>
</u-col>
</u-row>
</view>
</view>
<view class="info-title">
费用明细
</view>
<view class="info-item">
<view class="info-name">商品总计</view>
<view class="info-value">
<image class="icon" src="/static/icon/rongdou.png" mode=""></image>
{{detailInfo.total_rongdou}}
</view>
</view>
<view class="info-item">
<view class="info-name">实付</view>
<view class="info-value" v-if="detailInfo.real_rongdou">
<image class="icon" src="/static/icon/rongdou.png" mode=""></image>
{{detailInfo.real_rongdou}}
</view>
<view class="info-value" v-else-if="detailInfo.real_points">
<image class="icon" src="/static/icon/jifen.png" mode=""></image>
{{detailInfo.real_points}}
</view>
</view>
</view>
</u-modal>
<!-- 消息提示 -->
<u-toast ref="msgRef" />
</template>
<script setup>
import {
ref,
onMounted,
getCurrentInstance,
computed,
watch
} from 'vue';
import {
onLoad,
onShow
} from '@dcloudio/uni-app'
import {
mallAPI
} from '../../api/mall';
import {
getImageUrl
} from '../../util/common.js'
const msgRef = ref()
const instance = getCurrentInstance();
const scrollHeight = ref(0)
const loadHeight = () => {
uni.getSystemInfo({
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#navBar").boundingClientRect((data) => {
scrollHeight.value = screenHeight - data.height
}).exec()
uni.createSelectorQuery().in(instance.proxy).select("#tabsId").boundingClientRect((
data) => {
scrollHeight.value = scrollHeight.value - data.height
}).exec()
}
})
}
const navBarTitle = {
fontWeight: '510',
fontStyle: 'Medium',
fontSize: '40rpx',
lineHeight: '52px'
}
const handleSearch = () => {
msgRef.value.show({
title: '暂无功能,请期待~'
})
}
const tabList = ref([{
name: '项目订单'
}, {
name: '商品订单'
}, {
name: '理财产品',
}])
const currentTab = ref(1)
const currentMenu = ref(0)
watch(currentTab, (val) => {
if (val == 0 || val === 2) {
msgRef.value.show({
title: '暂无功能,请期待~'
})
currentTab.value = 1
return
}
loadData()
})
const handleChangeMenu = (val) => {
currentMenu.value = val
clearData()
params.value.status = val
loadData()
}
// 取消订单
const showCancel = ref(false)
const cancelId = ref()
const handelCancel = (item) => {
showCancel.value = true
cancelId.value = item.id
}
const confirmCancel = () => {
mallAPI.cancelOrder(cancelId.value).then(res => {
msgRef.value.show({
title: '取消成功',
type: 'success'
})
clearData()
loadData()
})
}
// 收货
const showReceive = ref(false)
const receiveId = ref()
const handleReceive = (item) => {
showReceive.value = true
receiveId.value = item.id
}
const confirmReceive = () => {
mallAPI.confirmOrder(receiveId.value).then(res => {
msgRef.value.show({
title: '收货成功',
type: 'success'
})
clearData()
loadData()
})
}
// 进入支付页面
const handlePay = (item) => {
uni.navigateTo({
url: '/pages/home/pay?preOrderId=' + item.id
})
}
// 详情
const showDetail = ref(false)
const detailInfo = ref({})
const allPay = computed(() => {
let data = 0
detailInfo.value.items.forEach(item => {
data += item.rongdou_price * item.quantity
})
return data
})
// 查看详情
const handleOrderDetail = (item) => {
showDetail.value = true
detailInfo.value = item
}
const params = ref({
page: 1,
limit: 10,
search: '',
status: ''
})
const loadStatus = ref('loadmore')
const maxPage = ref(1)
const orderList = ref([])
const loadData = () => {
if (currentTab.value == 0) {
// 项目订单
} else if (currentTab.value == 1) {
// 商品订单
if (loadStatus.value == 'nomore') return
mallAPI.getOrderList(params.value).then(res => {
orderList.value = orderList.value.concat(res.data.orders)
maxPage.value = res.data.pagination.pages
params.value.page++
if (maxPage.value < params.value.page) {
loadStatus.value = 'nomore'
}
console.log(orderList.value);
})
} else if (currentTab.value == 2) {
// 理财产品
}
}
const clearData = () => {
loadStatus.value = 'loadmore'
params.value.page = 1
params.value.search = ''
orderList.value = []
}
onShow(() => {
clearData()
loadData()
})
onMounted(() => {
loadHeight()
})
</script>
<style lang="scss" scoped>
.order-container {
width: 100%;
height: 100vh;
background: var(--Color, #E4ECFF);
background-blend-mode: lighten;
.more-dot-fill {
width: 48rpx;
height: 48rpx;
margin-right: 24rpx;
}
.box-tabs {
background: #F5F8FF;
.menu-list {
display: flex;
font-weight: 400;
font-size: 26rpx;
line-height: 100%;
padding: 20rpx 20rpx;
overflow-x: auto;
white-space: nowrap;
.menu-item {
background: #DFDFDF;
border-radius: 12rpx;
padding: 12rpx 20rpx;
color: #676767;
margin: 0 10rpx;
}
.active {
background: #93B2FF80;
color: #305DEF;
}
}
}
.scroll-view {
.order-list {
background: #F5F8FF;
margin: 10rpx 0;
padding: 20rpx 0;
.order-item {
display: flex;
padding: 20rpx;
.item-left {
width: 160rpx;
height: 160rpx;
}
.item-right {
flex: 1;
.icon {
width: 30rpx;
height: 30rpx;
}
}
}
.operate-btns {
display: flex;
justify-content: flex-end;
.operate-btn {
margin: 10rpx;
width: 136rpx;
height: 52rpx;
background: #D4D9EA;
font-weight: 400;
font-size: 24rpx;
line-height: 100%;
border: none;
}
}
.box-view {
height: 20rpx;
}
}
}
}
.slot-content {
padding: 10rpx 20rpx 20rpx;
.icon {
width: 30rpx;
height: 30rpx;
}
.info-title {
font-weight: 400;
font-size: 30rpx;
line-height: 100%;
margin: 30prx 0;
}
.info-item {
display: flex;
justify-content: space-between;
align-items: center;
margin: 20rpx 0;
.info-name {
font-weight: 400;
font-size: 24rpx;
line-height: 100%;
}
.info-value {
max-width: 50%;
font-weight: 400;
font-size: 24rpx;
line-height: 100%;
display: flex;
align-items: center;
}
}
.order-item {
display: flex;
padding: 20rpx;
.item-left {
width: 160rpx;
height: 160rpx;
}
.item-right {
flex: 1;
font-weight: 400;
font-size: 24rpx;
line-height: 100%;
}
}
}
</style>

View File

@@ -10,18 +10,18 @@
<view v-if="isManage" class="u-m-l-10 del-text" @click="showDelModel">
删除
</view>
<view class="u-m-l-10 add-text">
<view class="u-m-l-10 add-text" @click="handleAdd">
新增地址
</view>
</view>
</template>
</u-navbar>
<scroll-view scroll-y="true" :style="'height:'+scrollHeight+'px'" @scrolltolower="loadData">
<scroll-view scroll-y="true" :style="'height:'+scrollHeight+'px'">
<view class="data-list">
<view class="data-item" v-for="item in dataList" @click="handleClick(item)">
<view class="item-text">
<view class="address u-m-b-18">
{{item.province + item.city + item.district}}
{{item.province_name + " " + item.city_name + " " + item.district_name}}
</view>
<view class="specific-address u-m-b-18">
{{item.detailed_address}}
@@ -34,7 +34,8 @@
</view>
</view>
<view class="item-icon">
<image v-if="!isManage" style="width: 100%;height: 100%;" src="/static/icon/Edit.png" mode="">
<image v-if="!isManage" @click="handleEdit(item)" style="width: 100%;height: 100%;"
src="/static/icon/Edit.png" mode="">
</image>
<template v-else>
<image v-if="!isIncludeId(item.id)" style="width: 100%;height: 100%;"
@@ -44,18 +45,85 @@
</template>
</view>
</view>
<u-loadmore :status="status" />
</view>
</scroll-view>
<!-- 新增/修改 -->
<u-popup v-model="showForm" mode="bottom" length="60%" class="form-popup" @close="form={label:0}">
<view class="form">
<view class="form-item u-m-b-30">
<view class="item-title">
<image class="must-icon" src="/static/my/must.png" mode=""></image>
<u-input v-model="form.regionLabel" type="select" placeholder="请选择省市区" @click="openProvince" />
</view>
</view>
<view class="form-item">
<view class="item-title">
<image class="must-icon" src="/static/my/must.png" mode=""></image>详细地址与门牌号
</view>
<view class="item-value">
<u-input v-model="form.detailed_address" maxlength="30" placeholder="请输入详细地址与门牌号" type="text" />
</view>
</view>
<view class="form-item">
<view class="item-title">
<image class="must-icon" src="/static/my/must.png" mode=""></image>收货人名字
</view>
<view class="item-value">
<u-input v-model="form.recipient_name" maxlength="10" placeholder="请输入收货人名字" type="text" />
</view>
</view>
<view class="form-item">
<view class="item-title">
<image class="must-icon" src="/static/my/must.png" mode=""></image>手机号
</view>
<view class="item-value">
<u-input v-model="form.phone" maxlength="11" type="number" placeholder="请输入收货人手机号" />
</view>
</view>
<view class="form-item">
<view class="item-title">
标签
</view>
<view class="item-tag u-m-t-10">
<span :class="{active:form.label==0}" @click="handleChangeTag(0)"></span>
<span :class="{active:form.label==1}" @click="handleChangeTag(1)">公司</span>
<span :class="{active:form.label==2}" @click="handleChangeTag(2)">学校</span>
</view>
</view>
<view class="form-item">
<view class="item-title">
<span class="u-m-r-10">是否设置为默认地址</span><u-checkbox v-model="form.is_default"
:disabled="false"></u-checkbox>
</view>
</view>
</view>
<u-button class="submit" hover-class="none" @click="handleSubmit">确定</u-button>
</u-popup>
<!-- 省市区 -->
<u-select v-model="showRegitionPicker" :list="regionOptions" mode="mutil-column-auto" label-name="label"
value-name="code" child-name="children" @confirm="handleRegion"></u-select>
<!-- 确认是否删除 -->
<u-modal v-model="showDel" content="是否删除选中的地址" :show-cancel-button="true" @confirm="handleDel"></u-modal>
<!-- 提示 -->
<u-toast ref="msgRef" />
</view>
</template>
<script setup lang="ts">
import { computed, getCurrentInstance, onMounted, ref } from 'vue'
import { addressAPI } from '../../api/address'
<script setup>
import {
computed,
getCurrentInstance,
onMounted,
ref
} from 'vue'
import {
addressAPI
} from '../../api/address'
import {
commonAPI
} from '../../api/common'
const navBarTitle = {
fontWeight: '510',
@@ -63,10 +131,42 @@ import { addressAPI } from '../../api/address'
fontSize: '40rpx',
lineHeight: '52px'
}
const msgRef = ref()
const isManage = ref(false)
const showDel = ref(false)
const showForm = ref(false)
const showRegitionPicker = ref(false)
const form = ref({
label: 0
})
const handleAdd = () => {
showForm.value = true
}
const handleEdit = (item) => {
let data = {
id: item.id,
regionLabel: item.province_name + '/' + item.district_name + '/' + item.city_name,
province_code: item.province,
city_code: item.city,
district_code: item.district,
detailed_address: item.detailed_address,
recipient_name: item.receiver_name,
phone: item.receiver_phone,
is_default: item.is_default
}
if (item.label == '家') {
data.label = 0
}
if (item.label == '公司') {
data.label = 1
}
if (item.label == '学校') {
data.label = 2
}
form.value = data
showForm.value = true
}
const handleManage = () => {
if (isManage.value) {
ids.value = []
@@ -76,8 +176,59 @@ import { addressAPI } from '../../api/address'
const showDelModel = () => {
showDel.value = true
}
const handleDel = () => {
const handleDel = async () => {
// TODO 删除
for (var i = 0; i < ids.value.length; i++) {
await addressAPI.delAddress(ids.value[i])
}
msgRef.value.show({
title: '删除成功',
type: 'success'
})
isManage.value = false
ids.value = []
loadData()
}
// 打开省市区选择
const openProvince = () => {
showRegitionPicker.value = true
}
// 选择省市区
const handleRegion = (e) => {
form.value.regionLabel = e[0].label + "/" + e[1].label + "/" + e[2].label
form.value.province_code = e[0].value
form.value.city_code = e[1].value
form.value.district_code = e[2].value
}
const handleChangeTag = (val) => {
form.value.label = val
}
// 确认提交
const handleSubmit = () => {
if (form.value.id != null) {
addressAPI.editAddress(form.value).then(res => {
if (res.success) {
msgRef.value.show({
title: '修改成功',
type: 'success'
})
showForm.value = false
loadData()
}
})
} else {
addressAPI.addAddress(form.value).then(res => {
if (res.success) {
msgRef.value.show({
title: '添加成功',
type: 'success'
})
showForm.value = false
loadData()
}
})
}
}
const scrollHeight = ref(0)
@@ -86,39 +237,33 @@ import { addressAPI } from '../../api/address'
uni.getSystemInfo({
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#uNavbarId").boundingClientRect((data : any) => {
uni.createSelectorQuery().in(instance.proxy).select("#uNavbarId").boundingClientRect((
data) => {
scrollHeight.value = screenHeight - data.height
}).exec()
}
})
}
const defaultSize = 10
const params = ref({
page: 1,
size: defaultSize,
keyword: ''
})
const status = ref('loadmore')
const maxPage = ref()
const dataList = ref([])
const regionOptions = ref([])
const loadData = () => {
if (status.value == 'nomore') return
addressAPI.getList(params.value).then(res => {
console.log(res);
}).finally(() => {
uni.stopPullDownRefresh()
addressAPI.getList().then((res) => {
dataList.value = res.data
})
commonAPI.getRegion().then(res => {
regionOptions.value = res.data
})
}
const ids = ref([])
const handleClick = (item : any) => {
const handleClick = (item) => {
if (isManage.value) { // 开始管理
ids.value.push(item.id)
}
}
const isIncludeId = (id : any) => {
const isIncludeId = (id) => {
return ids.value.includes(id);
}
@@ -199,5 +344,62 @@ import { addressAPI } from '../../api/address'
}
}
}
.form-popup {
.form {
padding: 30rpx 28rpx;
.form-item {
margin-bottom: 20rpx;
line-height: 100%;
.item-title {
display: flex;
align-items: center;
font-weight: 400;
font-size: 24rpx;
.must-icon {
width: 24rpx;
height: 24rpx;
}
}
.item-value {}
.item-tag {
font-weight: 400;
font-size: 26rpx;
line-height: 100%;
letter-spacing: -2%;
span {
padding: 0 20rpx;
background: #D9D9D9;
border-radius: 12rpx;
margin-left: 16rpx;
}
.active {
background: #BFCEFF;
color: #305DEF;
}
}
}
}
.submit {
position: absolute;
bottom: 10rpx;
width: 248rpx;
left: 0;
right: 0;
text-align: center;
background: #7B99FF;
border: none;
border-radius: 24rpx;
color: #fff;
}
}
}
</style>

View File

@@ -51,7 +51,7 @@
<view class="icon">
<image style="width: 100%;height: 100%;" src="/static/icon/card-title-icon.png" mode=""></image>
</view>
项目需求<span>4</span>
项目简介<span></span>
</view>
<view class="u-m-t-10 editor-content-view">
<view v-html="program.introduction"></view>

BIN
static/icon/Map pin2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/icon/delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

BIN
static/icon/jifen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 158 KiB

BIN
static/icon/view-change.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

BIN
static/my/bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
static/my/bg1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
static/my/gr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
static/my/grc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
static/my/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
static/my/must.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

BIN
static/my/over.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
static/my/red_envelope.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -8,9 +8,6 @@ const token = uni.getStorageSync('token')
const commonHeaders = {
'Content-Type': 'application/json'
}
if (token) {
commonHeaders['Authorization'] = `Bearer ${token}`
}
// 请求队列用于管理loading
let requestQueue = 0
@@ -68,7 +65,6 @@ const request = (config) => {
// }
let requestUrl = url
let queryString = ''
if (Object.keys(params).length > 0) {
@@ -78,6 +74,11 @@ const request = (config) => {
requestUrl += (requestUrl.includes('?') ? '&' : '?') + queryString
}
const currToken = uni.getStorageSync('token')
if (currToken) {
commonHeaders.Authorization = `Bearer ${currToken}`
}
// 合并请求头
const requestHeader = {
...commonHeaders,
@@ -207,6 +208,10 @@ const handleError = (errorInfo) => {
})
// uToast.warning(data.message || '您的账户尚未激活,请完成支付后再使用')
}
} else if (!data.success) {
uni.redirectTo({
url: '/pages/login/login'
})
} else {
// uToast.error(data.message || '权限不足')
uni.showToast({

View File

@@ -5,6 +5,12 @@ export const validatePhone = (phone) => {
};
// arr1是否包含arr2
export const arrayContainsAll = (arr1, arr2) => {
return arr2.every(item => arr1.includes(item));
}
export const getImageUrl = (imagePath) => {
if (!imagePath) return ''
// 如果图片路径以/uploads开头直接返回原路径
@@ -12,7 +18,7 @@ export const getImageUrl = (imagePath) => {
if (imagePath.startsWith('/uploads')) {
return `${baseURL}/jurongquan${imagePath}`
}
if (imagePath.startsWith('http')) return imagePath
// const baseURL = "http://192.168.1.43:3000"
@@ -31,40 +37,40 @@ export const getUserInfo = () => {
* @returns {string|boolean} - 脱敏后的电话号码无效则返回false
*/
export function maskPhoneNumber(phone) {
// 检查是否为字符串
if (typeof phone !== 'string') {
return phone;
}
// 检查是否为字符串
if (typeof phone !== 'string') {
return phone;
}
// 移除所有非数字字符
const cleaned = phone.replace(/\D/g, '');
// 移除所有非数字字符
const cleaned = phone.replace(/\D/g, '');
// 验证常见的电话号码格式
// 支持: 11位手机号(中国大陆)、带区号的固定电话
const phoneRegex = /^(1[3-9]\d{9})$|^(\d{3,4}-\d{7,8})$|^(\d{3,4}\d{7,8})$/;
// 验证常见的电话号码格式
// 支持: 11位手机号(中国大陆)、带区号的固定电话
const phoneRegex = /^(1[3-9]\d{9})$|^(\d{3,4}-\d{7,8})$|^(\d{3,4}\d{7,8})$/;
if (!phoneRegex.test(cleaned) && !phoneRegex.test(phone)) {
return phone; // 不是有效的电话号码
}
if (!phoneRegex.test(cleaned) && !phoneRegex.test(phone)) {
return phone; // 不是有效的电话号码
}
// 根据不同格式进行脱敏
if (cleaned.length === 11) {
// 手机号: 保留前3位和后4位中间4位用*代替
return cleaned.replace(/^(\d{3})(\d{4})(\d{4})$/, '$1****$3');
} else if (phone.includes('-')) {
// 带区号的固定电话: 区号不变,号码中间用*代替
const [areaCode, number] = phone.split('-');
if (number.length <= 4) {
return `${areaCode}-****`;
}
return `${areaCode}-${number.substr(0, 2)}****${number.substr(-2)}`;
} else {
// 不带区号的固定电话
if (cleaned.length <= 4) {
return '****';
}
return `${cleaned.substr(0, 2)}****${cleaned.substr(-2)}`;
}
// 根据不同格式进行脱敏
if (cleaned.length === 11) {
// 手机号: 保留前3位和后4位中间4位用*代替
return cleaned.replace(/^(\d{3})(\d{4})(\d{4})$/, '$1****$3');
} else if (phone.includes('-')) {
// 带区号的固定电话: 区号不变,号码中间用*代替
const [areaCode, number] = phone.split('-');
if (number.length <= 4) {
return `${areaCode}-****`;
}
return `${areaCode}-${number.substr(0, 2)}****${number.substr(-2)}`;
} else {
// 不带区号的固定电话
if (cleaned.length <= 4) {
return '****';
}
return `${cleaned.substr(0, 2)}****${cleaned.substr(-2)}`;
}
}
/**
@@ -73,48 +79,48 @@ export function maskPhoneNumber(phone) {
* @returns {string} - 脱敏后的姓名
*/
export function maskName(name) {
// 检查输入是否为有效字符串
if (!name || typeof name !== 'string') {
return '';
}
// 检查输入是否为有效字符串
if (!name || typeof name !== 'string') {
return '';
}
// 去除前后空格
const trimmedName = name.trim();
// 去除前后空格
const trimmedName = name.trim();
// 检查是否为英文姓名(包含空格)
if (trimmedName.includes(' ')) {
const parts = trimmedName.split(' ').filter(part => part);
// 检查是否为英文姓名(包含空格)
if (trimmedName.includes(' ')) {
const parts = trimmedName.split(' ').filter(part => part);
// 处理英文名:名全显,姓只显首字母
if (parts.length >= 2) {
const firstName = parts.slice(0, -1).join(' ');
const lastName = parts[parts.length - 1];
return `${firstName} ${lastName.charAt(0)}*`;
}
}
// 处理英文名:名全显,姓只显首字母
if (parts.length >= 2) {
const firstName = parts.slice(0, -1).join(' ');
const lastName = parts[parts.length - 1];
return `${firstName} ${lastName.charAt(0)}*`;
}
}
// 处理中文姓名
const length = trimmedName.length;
// 处理中文姓名
const length = trimmedName.length;
switch (length) {
case 1:
// 单字名,不脱敏
return trimmedName;
case 2:
// 双字名,隐藏第二个字
return `${trimmedName[0]}*`;
case 3:
// 三字名,隐藏中间字
return `${trimmedName[0]}*${trimmedName[2]}`;
case 4:
// 四字名(如复姓),隐藏中间两个字
return `${trimmedName[0]}**${trimmedName[3]}`;
default:
// 更长的姓名,显示首尾各两个字,中间用*代替
if (length > 4) {
return `${trimmedName.substr(0, 2)}${'*'.repeat(length - 4)}${trimmedName.substr(-2)}`;
}
}
switch (length) {
case 1:
// 单字名,不脱敏
return trimmedName;
case 2:
// 双字名,隐藏第二个字
return `${trimmedName[0]}*`;
case 3:
// 三字名,隐藏中间字
return `${trimmedName[0]}*${trimmedName[2]}`;
case 4:
// 四字名(如复姓),隐藏中间两个字
return `${trimmedName[0]}**${trimmedName[3]}`;
default:
// 更长的姓名,显示首尾各两个字,中间用*代替
if (length > 4) {
return `${trimmedName.substr(0, 2)}${'*'.repeat(length - 4)}${trimmedName.substr(-2)}`;
}
}
return trimmedName;
return trimmedName;
}