孙旺 11 сар өмнө
parent
commit
66653362c6

+ 1 - 12
src/App.vue

@@ -6,7 +6,6 @@ import {
   getToken
 } from '@/utils/auth'
 const { proxy } = getCurrentInstance();
-import usePermissionStore from '@/stores/permission.js';
 
 onLaunch(() => {
   initApp()
@@ -23,17 +22,7 @@ async function checkLogin () {
   console.log('检测是否登录开始!')
   if (getToken()) {
     console.log('已登录!')
-    await usePermissionStore().GetPermis()
-    //判断用户是否有任一菜单权限
-    if (usePermissionStore().permissions_menu && usePermissionStore().permissions_menu.length > 0) {
-      // 开发模式下取消免登录,直接跳转调试页面,生产免登录跳转主页
-      // if (process.env.NODE_ENV == 'production') {
-      if (process.env.NODE_ENV == 'development') {
-        proxy.$tab.reLaunch('/pages/globalPages/home')
-      }
-    } else {
-      proxy.$modal.msg('该用户无权限~')
-    }
+    proxy.$tab.reLaunch('/pages/home')
   } else {
     console.log('未登录!')
   }

+ 6 - 8
src/config.js

@@ -1,12 +1,10 @@
 // 应用全局配置
 export default {
-	// baseUrl: process.env.NODE_ENV == 'production' ?
-	baseUrl:'https://api.mxrvending.com:9050',
-	// 	'https://ai.tanbin.vip',
-	 //baseUrl: 'https://api.mxrvending.com:9050',
-	//baseUrl:'http://119.96.194.20:9050',
-	//mock数据
-	// baseUrl: 'http://119.96.213.127:9010/mock',
+	baseUrl: process.env.NODE_ENV == 'production' ? 'https://api.mxrvending.com:9050' : 'http://119.96.194.20:9050',
+	// 生产环境
+	// baseUrl: 'https://api.mxrvending.com:9050',
+	//测试环境
+	// baseUrl: 'http://119.96.194.20:9050',
 	// 应用信息
 	appInfo: {
 		// 应用名称
@@ -18,4 +16,4 @@ export default {
 		// 官方网站
 		site_url: 'http://www.xyvending.com/',
 	},
-}
+}

+ 4 - 1
src/main.js

@@ -3,12 +3,15 @@ import App from './App.vue'
 import * as Pinia from 'pinia'
 import plugins from './plugins' // plugins
 import uviewPlus from 'uview-plus'
-
+import request from "@/utils/request.js";
+import scrollHeight from "@/utils/scrollHeight.js"
 export function createApp() {
   const app = createSSRApp(App)
   app.use(uviewPlus)
   app.use(Pinia.createPinia())
   app.use(plugins)
+  app.config.globalProperties.request = request;
+  app.config.globalProperties.scrollHeight = scrollHeight;
   return {
     app,
     Pinia,

+ 6 - 0
src/pages.json

@@ -21,6 +21,12 @@
 			"style": {
 				"navigationBarTitleText": "首页"
 			}
+		},
+		{
+			"path": "pages/setting",
+			"style": {
+				"navigationBarTitleText": "设置"
+			}
 		}
 	],
 	"globalStyle": {

+ 246 - 54
src/pages/home.vue

@@ -1,15 +1,15 @@
 <template>
 	<view class="container">
 		<view class="top">
-			<view class="name">合作商家:肇庆</view>
-			<view class="rest">余额:15000</view>
+			<!-- <view class="name">合作商家:肇庆</view> -->
+			<view class="rest">余额:{{total.balance||'0'}}</view>
 			<view class="flex">
 				<view class="total">
-					累计:12313
+					累计:{{total.sumBalance||'0'}}
 				</view>
-				<view class="guarantee">保证金:123123</view>
+				<view class="guarantee">保证金:{{total.refundVouchBalance||'0'}}</view>
 			</view>
-			<view class="setting">
+			<view class="setting" @click="$tab.navigateTo('/pages/setting')">
 				设置
 			</view>
 		</view>
@@ -17,23 +17,113 @@
 			<up-tabs :activeStyle="{fontSize:'32rpx',color:'#333',fontWeight:'bold'}" :list="tabList" :current="current"
 				@click="tabClick"></up-tabs>
 		</view>
-		<scroll-view class="scrollview" :scroll-with-animation="true" scroll-y lower-threshold="100"
+		<scroll-view ref="scrollview" :scroll-with-animation="true" scroll-y lower-threshold="100"
 			@scrolltolower="scrolltolower" :style="{height:fullHeight}">
-			<view class="scroll-content">
-				
+			<view class="scroll-content" v-if="list&&list.length>0">
+				<block v-for="(item,index) in list" :key="item.id">
+					<view class="list-item flex justify-between" v-if="current==0">
+						<view class="time">
+							{{item.updateTime}}
+						</view>
+						<view class="val">
+							{{item.balance}}
+						</view>
+					</view>
+
+					<view class="list-item flex justify-between" v-else>
+						<view class="time">
+							<view class="status">
+								{{item.status}}
+							</view>
+							<view class="time">
+								{{item.updateTime}}
+							</view>
+						</view>
+						<view class="val">
+							{{item.balance}}
+						</view>
+					</view>
+				</block>
+				<view class="load-more" style="padding:24rpx;">
+					<u-loadmore v-if="list.length>10" :status="loadmoreStatus" />
+				</view>
+			</view>
+
+			<view v-else class='empty'>
+				<u-empty mode="data" text="数据为空"></u-empty>
 			</view>
 		</scroll-view>
-		
-		<view class="btn safe-bottom">
+
+		<view class="btn safe-bottom" @click="open">
 			申请提现
 		</view>
+
+		<up-popup :show="show" @close="close" @open="open" mode="center" :round="10">
+			<view class="pop-content">
+				<view class="pop-title">
+					申请提现
+				</view>
+				<view class="pop-input">
+					<up-input placeholder="请输入提现金额" type="number" border="surround" v-model="balance"></up-input>
+					<view class="max">
+						最大可提现金额:{{$xy.delMoney(total.balance-total.refundVouchBalance-total.applyBalance)}}
+					</view>
+				</view>
+				<view class="pop-btn flex justify-end">
+					<view class="pop-btns close" @click="close">
+						取消
+					</view>
+					<view class="pop-btns submit" @click="submit">
+						确定
+					</view>
+				</view>
+			</view>
+		</up-popup>
 	</view>
 </template>
 
 <script setup>
+	const {
+		proxy
+	} = getCurrentInstance();
+
+	let scrollview = ref(null)
 	let fullHeight = ref(0)
-	let current = ref(0)
 
+	console.log(123)
+
+	onBeforeMount(() => {
+		//统计数据
+		getTotal()
+		//获取列表
+		reset()
+		getList()
+	})
+
+	onMounted(async () => {
+		//scroll高度
+		fullHeight.value = await proxy.scrollHeight(scrollview)
+	})
+
+	//-----------------------------------------统计
+	let total = ref({
+		balance: 0,
+		sumBalance: 0,
+		refundVouchBalance: 0,
+		applyBalance: 0
+	})
+	/**
+	 * 统计数据
+	 */
+	function getTotal() {
+		proxy.request({
+			url: '/merc/merc-draw-balance/info'
+		}).then((res) => {
+			total.value = res
+		})
+	}
+
+	//-----------------------------------------tab
 	let tabList = reactive([{
 			name: '账单'
 		},
@@ -41,50 +131,99 @@
 			name: '提现'
 		},
 	]);
+	let current = ref(0)
 
-	// 定义方法  
+	/**
+	 * @param {Object} item
+	 * tab点击
+	 */
 	function tabClick(item) {
+		if (current.value == item.index) return
 		current.value = item.index
+		reset()
+		getList()
 	}
 
-	onMounted(() => {
-		const instance = getCurrentInstance();
-		const query = uni.createSelectorQuery().in(instance);
-		query.select(".scrollview").boundingClientRect((r) => {
-			uni.getSystemInfo({
-				success(res) {
-					// 针对iPhone X等机型底部安全距离做适配
-					const model = res.model;
-					const modelInclude = [
-						"iPhone X",
-						'iPhone XR',
-						"iPhone XS",
-						"iPhone XS MAX",
-						"iPhone 12/13 mini",
-						"iPhone 12/13 (Pro)",
-						"iPhone 12/13 Pro Max",
-						"iPhone 14 Pro Max"
-					];
-					let safeDistance = modelInclude.includes(model)
-					//动态设置商品区域高度
-					console.log(res.windowHeight, r.top)
-					// data.screenWidht = data1.right;
-
-					let h = 0;
-					if (safeDistance) {
-
-						h = res.windowHeight - r.top;
-					} else {
-						h = res.windowHeight - r.top;
-					}
-					fullHeight += h + "px";
+	//-----------------------------------------分页
+	let page = ref(1);
+	let size = ref(10);
+	let loadmoreStatus = ref('loadmore')
+	let list = ref([])
 
+	/**
+	 * 账单
+	 */
+	function getList() {
+		let url = current.value == 0 ? '/merc/merc-draw-balance-bill/copartnerPage' : '/merc/merc-draw-apply/copartnerPage'
+		proxy.request({
+			url: url,
+			data: {
+				page: {
+					current: page.value,
+					size: size.value
+				}
+			}
+		}).then(res => {
+			let data = res.records;
 
-					//console.log("--------",searchMenu.searchMenu_body_style);
-				},
-			});
-		}).exec();
-	})
+			if (data.length < 10) {
+				loadmoreStatus.value = "nomore"
+			} else {
+				loadmoreStatus.value = "loadmore"
+			}
+			list.value = list.value.concat(data)
+		})
+	}
+
+	function reset() {
+		loadmoreStatus.value == 'loadmore'
+		page.value = 1;
+		size.value = 10;
+		list.value = [];
+	}
+
+	/**
+	 * @param {Object} e
+	 * 滑动到底
+	 */
+	function scrolltolower(e) {
+		if (loadmoreStatus.value == 'nomore') return
+		page.value++
+		getpage()
+	}
+
+	//-----------------------------------------申请提现
+	let balance = ref(null)
+	let show = ref(false)
+
+	function open() {
+		show.value = true
+	}
+
+	function close() {
+		show.value = false
+		balance.value = ''
+	}
+
+	/**
+	 * 提现提交
+	 */
+	function submit() {
+		if (!balance.value) {
+			proxy.$modal.msg('请输入提现金额')
+			return
+		}
+		proxy.request({
+			url: '/merc/merc-draw-apply/apply',
+			data: {
+				"balance": proxy.$xy.delMoneyL(balance.value),
+				"remarks": ""
+			}
+		}).then((res) => {
+			close()
+			proxy.$modal.msg('申请成功')
+		})
+	}
 </script>
 
 <style lang="scss">
@@ -97,8 +236,8 @@
 			margin-left: 24rpx;
 			box-shadow: rgb(229, 229, 229) 0px 5px 20px -5px;
 			margin-top: 20rpx;
-			
-			.name{
+
+			.name {
 				font-size: 34rpx;
 				font-weight: bold;
 			}
@@ -137,16 +276,69 @@
 		.scrollview {
 			padding-bottom: 130rpx;
 		}
-		
-		.btn{
+
+		.scroll-content {
+			.list-item {
+				background-color: red;
+			}
+		}
+
+		.empty {
+			padding-top: 40%;
+		}
+
+		.btn {
 			position: fixed;
-			width:702rpx;
-			left:24rpx;
+			width: 702rpx;
+			left: 24rpx;
 			background-color: #2C6FF3;
 			color: #fff;
 			line-height: 88rpx;
 			border-radius: 88rpx;
 			text-align: center;
 		}
+
+		.pop-content {
+			width: 690rpx;
+			height: 600rpx;
+			padding: 24rpx;
+
+			.pop-title {
+				text-align: center;
+				line-height: 80rpx;
+				font-size: 34rpx;
+				font-weight: bold;
+			}
+
+			.pop-input {
+				margin-top: 40rpx;
+
+				.max {
+					line-height: 90rpx;
+					color: red;
+				}
+			}
+
+			.pop-btn {
+				position: absolute;
+				right: 20rpx;
+				bottom: 24rpx;
+
+				.pop-btns {
+					width: 120rpx;
+					line-height: 60rpx;
+					border: 1rpx solid #2C6FF3;
+					text-align: center;
+					border-radius: 60rpx;
+					color: #2C6FF3;
+					margin-left: 20rpx;
+
+					&.submit {
+						background-color: #2C6FF3;
+						color: #fff;
+					}
+				}
+			}
+		}
 	}
 </style>

+ 5 - 34
src/pages/login.vue

@@ -112,42 +112,13 @@ async function pwdLogin (params) {
     uni.setStorageSync('account', '')
   }
 
-  await userStore.Login(loginForm.value)
-
-  await permissionStore.GetPermis()
-  //判断用户是否有任一菜单权限
-
-  console.log('permissionStore.permissions_menu=================', permissionStore.permissions_menu)
-  if (permissionStore.permissions_menu && permissionStore.permissions_menu !=
-    '[]') {
-    proxy.$tab.reLaunch('/pages/globalPages/home')
-  } else {
-    proxy.$modal.msg('该用户无权限~')
-  }
-}
-
-// 获取系统id
-function getSysId () {
-  return new Promise((resolve, reject) => {
-    proxy.request({
-      url: '/authorize/sys-system/list',
-      data: {}
-    }).then(res => {
-      let sysId = 381638941857029; //默认系统id
-      for (var i = 0; i < res.length; i++) {
-        let item = res[i];
-        if (item.code == 'xy_merc_mini') {
-          sysId = item.id
-          console.log('系统id:', sysId)
-        }
-      }
-      uni.setStorageSync('sysId', sysId)
-      resolve(res)
-    }).catch(err => {
-      reject(err)
-    })
+  await userStore.Login(loginForm.value).then(res=>{
+	  proxy.$tab.reLaunch('/pages/home')
+  }).catch(err=>{
+	  console.log('登录失败')
   })
 }
+
 </script>
 <style lang="scss" scoped>
 .txt {

+ 173 - 0
src/pages/setting.vue

@@ -0,0 +1,173 @@
+<template>
+	<view class="container">
+		<view class="top">
+			<view class="item flex justify-between align-center">
+				<view class="key">
+					合作商家:
+				</view>
+				<view class="value">
+					-
+				</view>
+			</view>
+			<view class="item flex justify-between align-center">
+				<view class="key">
+					收款支付宝:
+				</view>
+				<view class="value">
+					{{aliNo}}
+				</view>
+			</view>
+			<view class="item flex justify-between align-center" style="border-bottom: none;" @click="open">
+				<view class="key">
+					修改密码:
+				</view>
+				<up-icon name="arrow-right"></up-icon>
+			</view>
+		</view>
+
+		<up-popup :show="show" @close="close" @open="open" mode="center" :round="10">
+			<view class="pop-content">
+				<view class="pop-title">
+					修改密码
+				</view>
+				<view class="pop-input">
+					<up-input placeholder="请输入新密码" border="surround" type="password" v-model="password"></up-input>
+				</view>
+				<view class="pop-btn flex justify-end">
+					<view class="pop-btns close" @click="close">
+						取消
+					</view>
+					<view class="pop-btns submit" @click="submit">
+						确定
+					</view>
+				</view>
+			</view>
+		</up-popup>
+	</view>
+</template>
+
+<script setup>
+	const {
+		proxy
+	} = getCurrentInstance();
+
+	onBeforeMount(() => {
+		//获取初始数据
+		getAli()
+	})
+
+	//-----------------------------------------支付宝提现号
+	let aliNo = ref(null)
+	
+	/**
+	 * 统计数据
+	 */
+	function getAli() {
+		proxy.request({
+			url: '/merc/merc-account-ratio-info/queryInfo'
+		}).then((res) => {
+			aliNo.value = res.accountAliDrawId
+		})
+	}
+
+	//-----------------------------------------修改密码
+	let show = ref(false)
+	let password = ref(null)
+
+	function open() {
+		show.value = true
+	}
+
+	function close() {
+		show.value = false
+		password.value = ''
+	}
+	/**
+	 * 修改密码
+	 */
+	function submit() {
+		if (!password.value) {
+			password.$modal.msg('请输入新密码')
+			return
+		}
+		proxy.request({
+			url: '/merc/merc-account-ratio-info/editPassword',
+			data: {
+				"password": password.value,
+			}
+		}).then((res) => {
+			close()
+			proxy.$modal.msg('修改成功')
+		})
+	}
+</script>
+
+<style lang="scss">
+	.container {
+		.top {
+			position: relative;
+			width: 702rpx;
+			padding: 24rpx;
+			margin-left: 24rpx;
+			box-shadow: rgb(229, 229, 229) 0px 5px 20px -5px;
+			margin-top: 20rpx;
+
+			.item {
+				border-bottom: 1rpx solid #eee;
+				line-height: 100rpx;
+
+				.key {
+					font-size: 28rpx;
+					font-weight: bold;
+				}
+
+				.value {
+					font-size: 28rpx;
+				}
+			}
+		}
+
+		.pop-content {
+			width: 690rpx;
+			height: 600rpx;
+			padding: 24rpx;
+
+			.pop-title {
+				text-align: center;
+				line-height: 80rpx;
+				font-size: 34rpx;
+				font-weight: bold;
+			}
+
+			.pop-input {
+				margin-top: 40rpx;
+
+				.max {
+					line-height: 90rpx;
+					color: red;
+				}
+			}
+
+			.pop-btn {
+				position: absolute;
+				right: 20rpx;
+				bottom: 24rpx;
+
+				.pop-btns {
+					width: 120rpx;
+					line-height: 60rpx;
+					border: 1rpx solid #2C6FF3;
+					text-align: center;
+					border-radius: 60rpx;
+					color: #2C6FF3;
+					margin-left: 20rpx;
+
+					&.submit {
+						background-color: #2C6FF3;
+						color: #fff;
+					}
+				}
+			}
+		}
+	}
+</style>

+ 5 - 0
src/plugins/xy.js

@@ -13,4 +13,9 @@ export default {
     }
     return newMoney
   },
+  
+  //金额元转分,解决浮点数精度问题
+  delMoneyL(money) {
+  	return Math.round(Number(money) * 100)
+  },
 }

+ 86 - 80
src/stores/user.js

@@ -1,92 +1,98 @@
-import { defineStore } from 'pinia'
+import {
+	defineStore
+} from 'pinia'
 
 import config from '@/config'
 import storage from '@/utils/storage'
 import constant from '@/utils/constant'
-import { getToken, setToken, removeToken } from '@/utils/auth'
+import {
+	getToken,
+	setToken,
+	removeToken
+} from '@/utils/auth'
 import request from '../utils/request.js'
 
 const useUserStore = defineStore('user', {
-  state: () => ({
-    token: getToken(),
-    name: storage.get(constant.name),
-    avatar: storage.get(constant.avatar),
-    roles: storage.get(constant.roles),
-    permissions: storage.get(constant.permissions),
-  }),
+	state: () => ({
+		token: getToken(),
+		name: storage.get(constant.name),
+		avatar: storage.get(constant.avatar),
+		roles: storage.get(constant.roles),
+		permissions: storage.get(constant.permissions),
+	}),
 
-  actions: {
-    // 登录
-    Login(userInfo) {
-      return new Promise((resolve, reject) => {
-        request({
-          url: '/merc/merc-account-ratio-info/login',
-          data: {
-            loginName: userInfo.username.trim(),
-            password: userInfo.password,
-          },
-          method: 'POST',
-          headers: {
-            isToken: false,
-          },
-        })
-          .then((res) => {
-            setToken(res)
-            this.token = res
-            // this.name = res.mercName
-            // storage.set(constant.name, res.mercName)
-            resolve(res)
-          })
-          .catch((err) => {
-            reject(err)
-          })
-      })
-    },
+	actions: {
+		// 登录
+		Login(userInfo) {
+			return new Promise((resolve, reject) => {
+				request({
+						url: '/merc/merc-account-ratio-info/login',
+						data: {
+							account: userInfo.username.trim(),
+							password: userInfo.password,
+						},
+						method: 'POST',
+						headers: {
+							isToken: false,
+						},
+					})
+					.then((res) => {
+						setToken(res)
+						this.token = res
+						// this.name = res.mercName
+						// storage.set(constant.name, res.mercName)
+						resolve(res)
+					})
+					.catch((err) => {
+						reject(err)
+					})
+			})
+		},
 
-    // 获取用户信息
-    // GetInfo() {
-    //   return new Promise((resolve, reject) => {
-    //     getInfo()
-    //       .then((res) => {
-    //         const user = res.user
-    //         const avatar =
-    //           user == null || user.avatar == '' || user.avatar == null
-    //             ? ''
-    //             : baseUrl + user.avatar
-    //         const username =
-    //           user == null || user.userName == '' || user.userName == null
-    //             ? ''
-    //             : user.userName
-    //         if (res.roles && res.roles.length > 0) {
-    //           this.roles = res.roles
-    //           storage.set(constant.roles, res.roles)
-    //           this.permissions = res.permissions
-    //           storage.set(constant.permissions, res.permissions)
-    //         } else {
-    //           this.roles = ['ROLE_DEFAULT']
-    //           storage.set(constant.roles, ['ROLE_DEFAULT'])
-    //         }
-    //         resolve(res)
-    //       })
-    //       .catch((error) => {
-    //         reject(error)
-    //       })
-    //   })
-    // },
+		// 获取用户信息
+		// GetInfo() {
+		//   return new Promise((resolve, reject) => {
+		//     getInfo()
+		//       .then((res) => {
+		//         const user = res.user
+		//         const avatar =
+		//           user == null || user.avatar == '' || user.avatar == null
+		//             ? ''
+		//             : baseUrl + user.avatar
+		//         const username =
+		//           user == null || user.userName == '' || user.userName == null
+		//             ? ''
+		//             : user.userName
+		//         if (res.roles && res.roles.length > 0) {
+		//           this.roles = res.roles
+		//           storage.set(constant.roles, res.roles)
+		//           this.permissions = res.permissions
+		//           storage.set(constant.permissions, res.permissions)
+		//         } else {
+		//           this.roles = ['ROLE_DEFAULT']
+		//           storage.set(constant.roles, ['ROLE_DEFAULT'])
+		//         }
+		//         resolve(res)
+		//       })
+		//       .catch((error) => {
+		//         reject(error)
+		//       })
+		//   })
+		// },
 
-    // 退出系统
-    LogOut() {
-      return new Promise((resolve, reject) => {
-        this.roles = ''
-        storage.set(constant.roles, '')
-        this.permissions = ''
-        storage.set(constant.permissions, '')
-        removeToken()
-        storage.clean()
-        resolve('退出登录成功~')
-      })
-    },
-  },
+		// 退出系统
+		LogOut() {
+			return new Promise((resolve, reject) => {
+				this.roles = ''
+				storage.set(constant.roles, '')
+				this.permissions = ''
+				storage.set(constant.permissions, '')
+				removeToken()
+				storage.clean()
+				resolve('退出登录成功~')
+			})
+		},
+	},
 })
 
-export default useUserStore
+export default useUserStore

+ 134 - 147
src/utils/request.js

@@ -1,167 +1,154 @@
 import useUserStore from '@/stores/user.js'
 import config from '@/config'
-import { getToken } from '@/utils/auth'
+import {
+	getToken
+} from '@/utils/auth'
 import errorCode from '@/utils/errorCode'
-import { toast, showConfirm, tansParams } from '@/utils/common'
+import {
+	toast,
+	showConfirm,
+	tansParams
+} from '@/utils/common'
 
 let timeout = 10000
 const baseUrl = config.baseUrl
 
 const request = (config) => {
-  // 是否需要设置 token
-  const isToken = (config.headers || {}).isToken === false
-  config.header = config.header || {}
-  if (getToken() && !isToken) {
-    config.header['satoken'] = getToken()
-    config.header['sysId'] = uni.getStorageSync('sysId')
-  }
+	// 是否需要设置 token
+	const isToken = (config.headers || {}).isToken === false
+	config.header = config.header || {}
+	if (getToken() && !isToken) {
+		config.header['satoken'] = getToken()
+		config.header['sysId'] = uni.getStorageSync('sysId')
+	}
 
-  // get请求映射params参数
-  if (config.params) {
-    let url = config.url + '?' + tansParams(config.params)
-    url = url.slice(0, -1)
-    config.url = url
-  }
+	// get请求映射params参数
+	if (config.params) {
+		let url = config.url + '?' + tansParams(config.params)
+		url = url.slice(0, -1)
+		config.url = url
+	}
 
-  return new Promise((resolve, reject) => {
-    uni
-      .request({
-        method: config.method || 'post',
-        timeout: config.timeout || timeout,
-        url: config.baseUrl || baseUrl + config.url,
-        data: config.data,
-        header: config.header,
-        dataType: 'json',
-      })
-      .then((response) => {
-        const { data } = response
-        saveLogs(config.url, config.data, data.data)
-        const code = data.code || 404
-        const msg = errorCode[code] || data.msg || errorCode['default']
-        if (code === 501) {
-          let pages = getCurrentPages()
-          let currentPage = pages[pages.length - 1].route
-          if (currentPage != 'pages/login') {
-            toast('登录状态已过期,请重新登陆!')
-            reject('无效的会话,或者会话已过期,请重新登录。')
-            useUserStore()
-              .LogOut()
-              .then((res) => {
-                uni.reLaunch({
-                  url: '/pages/login',
-                })
-              })
-          }
-        } else if (code === 500) {
-          toast(msg.substr(0, 50))
-          reject(msg)
-        } else if (code !== 200) {
-          toast(msg)
-          reject(code)
-        } else if (code === 404) {
-          toast('请求超时')
-          reject(code)
-        }
-        resolve(data.data)
-      })
-      .catch((error) => {
-        saveLogs(config.url, config.data, error)
-        uni.hideLoading()
-        let { message } = error
-        if (message === 'Network Error') {
-          message = '网络连接超时'
-        } else if (message.includes('timeout')) {
-          message = '网络连接超时'
-        } else if (message.includes('Request failed with status code')) {
-          message = '系统接口' + message.substr(message.length - 3) + '异常'
-        }
-        toast(message)
-        reject(error)
-      })
-  })
-}
-
-function saveLogs(url, params, res) {
-  let arr = []
-  let obj = {
-    url: url,
-    time: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss'),
-    params: JSON.stringify(params) || '无',
-    res: JSON.stringify(res).substr(0, 1000),
-  }
-  if (uni.getStorageSync('logs')) {
-    let arr = JSON.parse(uni.getStorageSync('logs'))
-    arr.unshift(obj)
-    if (arr.length > 30) {
-      arr.pop()
-    }
-    uni.setStorageSync('logs', JSON.stringify(arr))
-  } else {
-    arr.unshift(obj)
-    uni.setStorageSync('logs', JSON.stringify(arr))
-  }
+	return new Promise((resolve, reject) => {
+		uni.request({
+				method: config.method || 'post',
+				timeout: config.timeout || timeout,
+				url: config.baseUrl || baseUrl + config.url,
+				data: config.data,
+				header: config.header,
+				dataType: 'json',
+			})
+			.then((response) => {
+				const {
+					data
+				} = response
+				const code = data.code || 404
+				const msg = errorCode[code] || data.msg || errorCode['default']
+				if (code === 501) {
+					let pages = getCurrentPages()
+					let currentPage = pages[pages.length - 1].route
+					if (currentPage != 'pages/login') {
+						toast('登录状态已过期,请重新登陆!')
+						reject('无效的会话,或者会话已过期,请重新登录。')
+						useUserStore()
+							.LogOut()
+							.then((res) => {
+								uni.reLaunch({
+									url: '/pages/login',
+								})
+							})
+					} else {
+						toast(msg)
+					}
+				} else if (code === 500) {
+					toast(msg.substr(0, 50))
+					reject(msg)
+				} else if (code !== 200) {
+					toast(msg)
+					reject(code)
+				} else if (code === 404) {
+					toast('请求超时')
+					reject(code)
+				}
+				resolve(data.data)
+			})
+			.catch((error) => {
+				uni.hideLoading()
+				let {
+					message
+				} = error
+				if (message === 'Network Error') {
+					message = '网络连接超时'
+				} else if (message.includes('timeout')) {
+					message = '网络连接超时'
+				} else if (message.includes('Request failed with status code')) {
+					message = '系统接口' + message.substr(message.length - 3) + '异常'
+				}
+				toast(message)
+				reject(error)
+			})
+	})
 }
 
 // 验证是否为blob格式
 async function blobValidate(data) {
-  try {
-    const text = await data.text()
-    JSON.parse(text)
-    return false
-  } catch (error) {
-    return true
-  }
+	try {
+		const text = await data.text()
+		JSON.parse(text)
+		return false
+	} catch (error) {
+		return true
+	}
 }
 
 export function downLoadReq(config) {
-  uni.showLoading({
-    title: '加载中',
-  })
-  // 是否需要设置 token
-  const isToken = (config.headers || {}).isToken === false
-  config.header = config.header || {}
-  if (getToken() && !isToken) {
-    config.header['satoken'] = getToken()
-    config.header['sysId'] = uni.getStorageSync('sysId')
-  }
+	uni.showLoading({
+		title: '加载中',
+	})
+	// 是否需要设置 token
+	const isToken = (config.headers || {}).isToken === false
+	config.header = config.header || {}
+	if (getToken() && !isToken) {
+		config.header['satoken'] = getToken()
+		config.header['sysId'] = uni.getStorageSync('sysId')
+	}
 
-  // get请求映射params参数
-  if (config.params) {
-    let url = config.url + '?' + tansParams(config.params)
-    url = url.slice(0, -1)
-    config.url = url
-  }
-  return new Promise((resolve, reject) => {
-    uni
-      .request({
-        method: config.method || 'get',
-        timeout: config.timeout || timeout,
-        url: config.baseUrl || baseUrl + config.url,
-        data: config.data,
-        header: config.header,
-        dataType: 'json',
-      })
-      .then(async (response) => {
-        let data = response.data
-        uni.hideLoading()
-        const isLogin = await blobValidate(data)
-        if (isLogin) {
-          wx.getFileSystemManager().readFile({
-            filePath: data, //选择图片返回的相对路径
-            encoding: 'base64', //这个是很重要的
-            success: (res) => {
-              //成功的回调
-            },
-            fail: (err) => {},
-          })
-        } else {
-        }
-        resolve(data)
-      })
-      .catch((r) => {
-        reject(r)
-      })
-  })
+	// get请求映射params参数
+	if (config.params) {
+		let url = config.url + '?' + tansParams(config.params)
+		url = url.slice(0, -1)
+		config.url = url
+	}
+	return new Promise((resolve, reject) => {
+		uni
+			.request({
+				method: config.method || 'get',
+				timeout: config.timeout || timeout,
+				url: config.baseUrl || baseUrl + config.url,
+				data: config.data,
+				header: config.header,
+				dataType: 'json',
+			})
+			.then(async (response) => {
+				let data = response.data
+				uni.hideLoading()
+				const isLogin = await blobValidate(data)
+				if (isLogin) {
+					wx.getFileSystemManager().readFile({
+						filePath: data, //选择图片返回的相对路径
+						encoding: 'base64', //这个是很重要的
+						success: (res) => {
+							//成功的回调
+						},
+						fail: (err) => {},
+					})
+				} else {}
+				resolve(data)
+			})
+			.catch((r) => {
+				reject(r)
+			})
+	})
 }
 
-export default request
+export default request

+ 33 - 0
src/utils/scrollHeight.js

@@ -0,0 +1,33 @@
+export default async function(el) {
+	return new Promise((resolve, reject) => {
+		const top = el.value.$el.getBoundingClientRect().top
+		uni.getSystemInfo({
+			success(res) {
+				// 针对iPhone X等机型底部安全距离做适配
+				const model = res.model;
+				const modelInclude = [
+					"iPhone X",
+					'iPhone XR',
+					"iPhone XS",
+					"iPhone XS MAX",
+					"iPhone 12/13 mini",
+					"iPhone 12/13 (Pro)",
+					"iPhone 12/13 Pro Max",
+					"iPhone 14 Pro Max"
+				];
+				let safeDistance = modelInclude.includes(model)
+				//动态设置商品区域高度
+				let h = 0;
+				if (safeDistance) {
+					h = res.windowHeight - top;
+				} else {
+					h = res.windowHeight - top;
+				}
+				resolve(`${h}px`)
+			},
+			fail(err) {
+				reject(err)
+			}
+		});
+	})
+}

+ 1 - 1
vite.config.js

@@ -1 +1 @@
-import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import AutoImport from "unplugin-auto-import/vite";

export default defineConfig({
  plugins: [
    uni(),
    AutoImport({
      imports: ["vue", "uni-app"],
      dts: "autoconfig/auto-import.js",
    }),
  ],
});

+import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import AutoImport from "unplugin-auto-import/vite";

export default defineConfig({
  plugins: [
    uni(),
    AutoImport({
      imports: ["vue", "uni-app"],
      dts: false,
    }),
  ],
});