风格统一样式修改
						commit
						dbeb6eea6b
					
				|  | @ -38,7 +38,7 @@ | ||||||
|               </view> |               </view> | ||||||
|               <view class="check-box ss-flex ss-col-center ss-p-l-10"> |               <view class="check-box ss-flex ss-col-center ss-p-l-10"> | ||||||
|                 <view class="userInfo-money ss-m-r-10" v-if="item.value === 'wallet'"> |                 <view class="userInfo-money ss-m-r-10" v-if="item.value === 'wallet'"> | ||||||
|                   余额: {{ fen2yuan(userInfo.money) }}元 |                   余额: {{ fen2yuan(userWallet.money) }}元 | ||||||
|                 </view> |                 </view> | ||||||
|                 <radio |                 <radio | ||||||
|                   :value="item.value" |                   :value="item.value" | ||||||
|  | @ -83,7 +83,7 @@ | ||||||
|   import PayChannelApi from '@/sheep/api/pay/channel'; |   import PayChannelApi from '@/sheep/api/pay/channel'; | ||||||
|   import { getPayMethods } from '@/sheep/platform/pay'; |   import { getPayMethods } from '@/sheep/platform/pay'; | ||||||
| 
 | 
 | ||||||
|   const userInfo = computed(() => sheep.$store('user').userInfo); |   const userWallet = computed(() => sheep.$store('user').userWallet); | ||||||
| 
 | 
 | ||||||
|   // 检测支付环境 |   // 检测支付环境 | ||||||
|   const state = reactive({ |   const state = reactive({ | ||||||
|  | @ -189,6 +189,8 @@ | ||||||
|       state.orderType = options.orderType; |       state.orderType = options.orderType; | ||||||
|     } |     } | ||||||
|     setOrder(id); |     setOrder(id); | ||||||
|  |     // 刷新钱包的缓存 | ||||||
|  |     sheep.$store('user').getWallet(); | ||||||
|   }); |   }); | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ | ||||||
|     ]"> |     ]"> | ||||||
| 			<view class=""> | 			<view class=""> | ||||||
| 				<view class="num-title">当前余额(元)</view> | 				<view class="num-title">当前余额(元)</view> | ||||||
| 				<view class="wallet-num">{{ fen2yuan(userInfo.money) }}</view> | 				<view class="wallet-num">{{ fen2yuan(userWallet.balance) }}</view> | ||||||
| 			</view> | 			</view> | ||||||
| 			<button class="ss-reset-button log-btn" @tap="sheep.$router.go('/pages/pay/recharge-log')"> | 			<button class="ss-reset-button log-btn" @tap="sheep.$router.go('/pages/pay/recharge-log')"> | ||||||
|         充值记录 |         充值记录 | ||||||
|  | @ -48,7 +48,7 @@ | ||||||
|   import { fen2yuan } from '@/sheep/hooks/useGoods'; |   import { fen2yuan } from '@/sheep/hooks/useGoods'; | ||||||
|   import PayWalletApi from '@/sheep/api/pay/wallet'; |   import PayWalletApi from '@/sheep/api/pay/wallet'; | ||||||
| 
 | 
 | ||||||
| 	const userInfo = computed(() => sheep.$store('user').userInfo); | 	const userWallet = computed(() => sheep.$store('user').userWallet); | ||||||
| 	const statusBarHeight = sheep.$platform.device.statusBarHeight * 2; | 	const statusBarHeight = sheep.$platform.device.statusBarHeight * 2; | ||||||
| 	const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png'); | 	const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png'); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -52,7 +52,6 @@ | ||||||
|         /> |         /> | ||||||
|       </uni-list> |       </uni-list> | ||||||
|     </view> |     </view> | ||||||
|     <!-- TODO 芋艿:统一的配置界面 --> |  | ||||||
|     <view class="set-footer ss-flex-col ss-row-center ss-col-center"> |     <view class="set-footer ss-flex-col ss-row-center ss-col-center"> | ||||||
|       <view class="agreement-box ss-flex ss-col-center ss-m-b-40"> |       <view class="agreement-box ss-flex ss-col-center ss-m-b-40"> | ||||||
|         <view class="ss-flex ss-col-center ss-m-b-10"> |         <view class="ss-flex ss-col-center ss-m-b-10"> | ||||||
|  | @ -99,6 +98,7 @@ | ||||||
| <script setup> | <script setup> | ||||||
|   import sheep from '@/sheep'; |   import sheep from '@/sheep'; | ||||||
|   import { computed, reactive } from 'vue'; |   import { computed, reactive } from 'vue'; | ||||||
|  |   import AuthUtil from '@/sheep/api/member/auth'; | ||||||
| 
 | 
 | ||||||
|   const appInfo = computed(() => sheep.$store('app').info); |   const appInfo = computed(() => sheep.$store('app').info); | ||||||
|   const isLogin = computed(() => sheep.$store('user').isLogin); |   const isLogin = computed(() => sheep.$store('user').isLogin); | ||||||
|  | @ -123,10 +123,12 @@ | ||||||
|         if (!res.confirm) { |         if (!res.confirm) { | ||||||
|           return; |           return; | ||||||
|         } |         } | ||||||
|         const result = await sheep.$store('user').logout(); |         const { code } = await AuthUtil.logout(); | ||||||
|         if (result) { |         if (code !== 0) { | ||||||
|           sheep.$router.go('/pages/index/user'); |           return; | ||||||
|         } |         } | ||||||
|  |         sheep.$store('user').logout(); | ||||||
|  |         sheep.$router.go('/pages/index/user'); | ||||||
|       }, |       }, | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  | @ -140,10 +142,12 @@ | ||||||
|         if (!res.confirm) { |         if (!res.confirm) { | ||||||
|           return; |           return; | ||||||
|         } |         } | ||||||
|         const result = await sheep.$store('user').logout(); |         const { code } = await AuthUtil.logout(); | ||||||
|         if (result) { |         if (code !== 0) { | ||||||
|           sheep.$router.go('/pages/index/user'); |           return; | ||||||
|         } |         } | ||||||
|  |         sheep.$store('user').logout(); | ||||||
|  |         sheep.$router.go('/pages/index/user'); | ||||||
|       }, |       }, | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ | ||||||
|           /> |           /> | ||||||
|         </view> |         </view> | ||||||
|         <view class="ss-flex ss-row-between ss-col-center ss-m-t-64"> |         <view class="ss-flex ss-row-between ss-col-center ss-m-t-64"> | ||||||
|           <view class="money-num">{{ state.showMoney ? fen2yuan(userInfo.money) : '*****' }}</view> |           <view class="money-num">{{ state.showMoney ? fen2yuan(userWallet.balance) : '*****' }}</view> | ||||||
|           <button class="ss-reset-button topup-btn" @tap="sheep.$router.go('/pages/pay/recharge')"> |           <button class="ss-reset-button topup-btn" @tap="sheep.$router.go('/pages/pay/recharge')"> | ||||||
|             充值 |             充值 | ||||||
|           </button> |           </button> | ||||||
|  | @ -122,7 +122,8 @@ | ||||||
|       value: '2', |       value: '2', | ||||||
|     }, |     }, | ||||||
|   ]; |   ]; | ||||||
|   const userInfo = computed(() => sheep.$store('user').userInfo); | 
 | ||||||
|  |   const userWallet = computed(() => sheep.$store('user').userWallet); | ||||||
| 
 | 
 | ||||||
|   // 格式化时间段 |   // 格式化时间段 | ||||||
|   const dateFilterText = computed(() => { |   const dateFilterText = computed(() => { | ||||||
|  | @ -167,6 +168,8 @@ | ||||||
|     state.date = [state.today, state.today]; |     state.date = [state.today, state.today]; | ||||||
|     getLogList(); |     getLogList(); | ||||||
|     getSummary(); |     getSummary(); | ||||||
|  |     // 刷新钱包的缓存 | ||||||
|  |     sheep.$store('user').getWallet(); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   // 处理 tab 切换 |   // 处理 tab 切换 | ||||||
|  |  | ||||||
|  | @ -1,18 +1,6 @@ | ||||||
| import request from '@/sheep/request'; | import request from '@/sheep/request'; | ||||||
| 
 | 
 | ||||||
| export default { | export default { | ||||||
|   // 系统初始化
 |  | ||||||
|   init: (templateId) => |  | ||||||
|     request({ |  | ||||||
|       url: 'init', |  | ||||||
|       params: { |  | ||||||
|         templateId, |  | ||||||
|       }, |  | ||||||
|       custom: { |  | ||||||
|         showError: false, |  | ||||||
|         showLoading: false, |  | ||||||
|       }, |  | ||||||
|     }), |  | ||||||
|   // 自定义页面
 |   // 自定义页面
 | ||||||
|   page: (id) => |   page: (id) => | ||||||
|     request({ |     request({ | ||||||
|  |  | ||||||
|  | @ -1,10 +0,0 @@ | ||||||
| import request from '@/sheep/request'; |  | ||||||
| import request2 from '@/sheep/request2'; |  | ||||||
| 
 |  | ||||||
| export default { |  | ||||||
|   faq: () => |  | ||||||
|     request({ |  | ||||||
|       url: 'data/faq', |  | ||||||
|       method: 'GET', |  | ||||||
|     }), |  | ||||||
| }; |  | ||||||
|  | @ -1,14 +0,0 @@ | ||||||
| import request2 from '@/sheep/request2'; |  | ||||||
| 
 |  | ||||||
| export default { |  | ||||||
|   decorate: () => |  | ||||||
|     request2({ |  | ||||||
|       url: 'promotion/decorate/list?page=1', |  | ||||||
|       method: 'GET', |  | ||||||
|     }), |  | ||||||
|   spids: () => |  | ||||||
|     request2({ |  | ||||||
|       url: 'product/spu/page?recommendType=best&pageNo=1&pageSize=10', |  | ||||||
|       method: 'GET', |  | ||||||
|     }), |  | ||||||
| }; |  | ||||||
|  | @ -1,6 +1,19 @@ | ||||||
| import request from '@/sheep/request'; | import request from '@/sheep/request'; | ||||||
| 
 | 
 | ||||||
| const AuthUtil = { | const AuthUtil = { | ||||||
|  |   // 使用手机 + 密码登录
 | ||||||
|  |   login: (data) => { | ||||||
|  |     return request({ | ||||||
|  |       url: '/app-api/member/auth/login', | ||||||
|  |       method: 'POST', | ||||||
|  |       data, | ||||||
|  |       custom: { | ||||||
|  |         showSuccess: true, | ||||||
|  |         loadingMsg: '登录中', | ||||||
|  |         successMsg: '登录成功', | ||||||
|  |       }, | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|   // 使用手机 + 验证码登录
 |   // 使用手机 + 验证码登录
 | ||||||
|   smsLogin: (data) => { |   smsLogin: (data) => { | ||||||
|     return request({ |     return request({ | ||||||
|  |  | ||||||
|  | @ -1,6 +1,17 @@ | ||||||
| import request from '@/sheep/request'; | import request from '@/sheep/request'; | ||||||
| 
 | 
 | ||||||
| const UserApi = { | const UserApi = { | ||||||
|  |   // 获得基本信息
 | ||||||
|  |   getUserInfo: () => { | ||||||
|  |     return request({ | ||||||
|  |       url: '/app-api/member/user/get', | ||||||
|  |       method: 'GET', | ||||||
|  |       custom: { | ||||||
|  |         showLoading: false, | ||||||
|  |         auth: true, | ||||||
|  |       }, | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|   // 修改基本信息
 |   // 修改基本信息
 | ||||||
|   updateUser: (data) => { |   updateUser: (data) => { | ||||||
|     return request({ |     return request({ | ||||||
|  |  | ||||||
|  | @ -1,16 +1,6 @@ | ||||||
| import request from '@/sheep/request'; | import request from '@/sheep/request'; | ||||||
| 
 | 
 | ||||||
| export default { | export default { | ||||||
| 	// 预支付
 |  | ||||||
| 	prepay: (data) => |  | ||||||
| 		request({ |  | ||||||
| 			url: 'pay/prepay', |  | ||||||
| 			method: 'POST', |  | ||||||
| 			data, |  | ||||||
| 			custom: { |  | ||||||
| 				loadingMsg: '支付中', |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 	// 发起提现
 | 	// 发起提现
 | ||||||
| 	withdraw: { | 	withdraw: { | ||||||
| 		list: (params) => | 		list: (params) => | ||||||
|  |  | ||||||
|  | @ -1,6 +1,17 @@ | ||||||
| import request from '@/sheep/request'; | import request from '@/sheep/request'; | ||||||
| 
 | 
 | ||||||
| const PayWalletApi = { | const PayWalletApi = { | ||||||
|  |   // 获取钱包
 | ||||||
|  |   getPayWallet() { | ||||||
|  |     return request({ | ||||||
|  |       url: '/app-api/pay/wallet/get', | ||||||
|  |       method: 'GET', | ||||||
|  |       custom: { | ||||||
|  |         showLoading: false, | ||||||
|  |         auth: true, | ||||||
|  |       }, | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|   // 获得钱包流水分页
 |   // 获得钱包流水分页
 | ||||||
|   getWalletTransactionPage: (params) => { |   getWalletTransactionPage: (params) => { | ||||||
|     const queryString = Object.keys(params) |     const queryString = Object.keys(params) | ||||||
|  |  | ||||||
|  | @ -57,6 +57,17 @@ const CouponApi = { | ||||||
|       params: { id }, |       params: { id }, | ||||||
|     }); |     }); | ||||||
|   }, |   }, | ||||||
|  |   // 获得未使用的优惠劵数量
 | ||||||
|  |   getUnusedCouponCount: () => { | ||||||
|  |     return request({ | ||||||
|  |       url: '/app-api/promotion/coupon/get-unused-count', | ||||||
|  |       method: 'GET', | ||||||
|  |       custom: { | ||||||
|  |         showLoading: false, | ||||||
|  |         auth: true, | ||||||
|  |       }, | ||||||
|  |     }); | ||||||
|  |   } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export default CouponApi; | export default CouponApi; | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| import request2 from '@/sheep/request2'; |  | ||||||
| import request from '@/sheep/request'; | import request from '@/sheep/request'; | ||||||
| 
 | 
 | ||||||
| const OrderApi = { | const OrderApi = { | ||||||
|  | @ -26,14 +25,14 @@ const OrderApi = { | ||||||
|     const queryString = Object.keys(data2) |     const queryString = Object.keys(data2) | ||||||
|       .map((key) => key + '=' + data2[key]) |       .map((key) => key + '=' + data2[key]) | ||||||
|       .join('&'); |       .join('&'); | ||||||
|     return request2({ |     return request({ | ||||||
|       url: `trade/order/settlement?${queryString}`, |       url: `trade/order/settlement?${queryString}`, | ||||||
|       method: 'GET', |       method: 'GET', | ||||||
|     }); |     }); | ||||||
|   }, |   }, | ||||||
|   // 创建订单
 |   // 创建订单
 | ||||||
|   createOrder: (data) => { |   createOrder: (data) => { | ||||||
|     return request2({ |     return request({ | ||||||
|       url: `trade/order/create`, |       url: `trade/order/create`, | ||||||
|       method: 'POST', |       method: 'POST', | ||||||
|       data, |       data, | ||||||
|  | @ -41,7 +40,7 @@ const OrderApi = { | ||||||
|   }, |   }, | ||||||
|   // 获得订单
 |   // 获得订单
 | ||||||
|   getOrder: (id) => { |   getOrder: (id) => { | ||||||
|     return request2({ |     return request({ | ||||||
|       url: `trade/order/get-detail`, |       url: `trade/order/get-detail`, | ||||||
|       method: 'GET', |       method: 'GET', | ||||||
|       params: { |       params: { | ||||||
|  | @ -62,7 +61,7 @@ const OrderApi = { | ||||||
|   }, |   }, | ||||||
|   // 确认收货
 |   // 确认收货
 | ||||||
|   receiveOrder: (id) => { |   receiveOrder: (id) => { | ||||||
|     return request2({ |     return request({ | ||||||
|       url: `/app-api/trade/order/receive`, |       url: `/app-api/trade/order/receive`, | ||||||
|       method: 'PUT', |       method: 'PUT', | ||||||
|       params: { |       params: { | ||||||
|  | @ -72,7 +71,7 @@ const OrderApi = { | ||||||
|   }, |   }, | ||||||
|   // 取消订单
 |   // 取消订单
 | ||||||
|   cancelOrder: (id) => { |   cancelOrder: (id) => { | ||||||
|     return request2({ |     return request({ | ||||||
|       url: `/app-api/trade/order/cancel`, |       url: `/app-api/trade/order/cancel`, | ||||||
|       method: 'DELETE', |       method: 'DELETE', | ||||||
|       params: { |       params: { | ||||||
|  | @ -82,7 +81,7 @@ const OrderApi = { | ||||||
|   }, |   }, | ||||||
|   // 删除订单
 |   // 删除订单
 | ||||||
|   deleteOrder: (id) => { |   deleteOrder: (id) => { | ||||||
|     return request2({ |     return request({ | ||||||
|       url: `/app-api/trade/order/delete`, |       url: `/app-api/trade/order/delete`, | ||||||
|       method: 'DELETE', |       method: 'DELETE', | ||||||
|       params: { |       params: { | ||||||
|  | @ -90,9 +89,20 @@ const OrderApi = { | ||||||
|       }, |       }, | ||||||
|     }); |     }); | ||||||
|   }, |   }, | ||||||
|  |   // 获得交易订单数量
 | ||||||
|  |   getOrderCount: () => { | ||||||
|  |     return request({ | ||||||
|  |       url: '/app-api/trade/order/get-count', | ||||||
|  |       method: 'GET', | ||||||
|  |       custom: { | ||||||
|  |         showLoading: false, | ||||||
|  |         auth: true, | ||||||
|  |       }, | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|   // 创建单个评论
 |   // 创建单个评论
 | ||||||
|   createOrderItemComment: (data) => { |   createOrderItemComment: (data) => { | ||||||
|     return request2({ |     return request({ | ||||||
|       url: `/app-api/trade/order/item/create-comment`, |       url: `/app-api/trade/order/item/create-comment`, | ||||||
|       method: 'POST', |       method: 'POST', | ||||||
|       data, |       data, | ||||||
|  |  | ||||||
|  | @ -3,100 +3,8 @@ import request2 from '@/sheep/request2'; | ||||||
| import $platform from '@/sheep/platform'; | import $platform from '@/sheep/platform'; | ||||||
| 
 | 
 | ||||||
| export default { | export default { | ||||||
| 	getUnused: () => |  | ||||||
| 		request2({ |  | ||||||
| 			url: 'promotion/coupon/get-unused-count', |  | ||||||
| 			method: 'GET', |  | ||||||
| 			custom: { |  | ||||||
| 				showLoading: false, |  | ||||||
| 				auth: true, |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 	profile: () => |  | ||||||
| 		request2({ |  | ||||||
| 			url: 'member/user/get', |  | ||||||
| 			method: 'GET', |  | ||||||
| 			custom: { |  | ||||||
| 				showLoading: false, |  | ||||||
| 				auth: true, |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 	balance: () => |  | ||||||
| 		request2({ |  | ||||||
| 			url: '/app-api/pay/wallet/get', |  | ||||||
| 			method: 'GET', |  | ||||||
| 			custom: { |  | ||||||
| 				showLoading: false, |  | ||||||
| 				auth: true, |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 	// 账号登录
 |  | ||||||
| 	accountLogin: (data) => |  | ||||||
| 		request({ |  | ||||||
| 			url: '/user/api/user/accountLogin', |  | ||||||
| 			method: 'POST', |  | ||||||
| 			data, |  | ||||||
| 			custom: { |  | ||||||
| 				showSuccess: true, |  | ||||||
| 				loadingMsg: '登录中', |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 	// 短信登录
 |  | ||||||
| 	smsLogin: (data) => |  | ||||||
| 		request({ |  | ||||||
| 			url: '/user/api/user/smsLogin', |  | ||||||
| 			method: 'POST', |  | ||||||
| 			data, |  | ||||||
| 			custom: { |  | ||||||
| 				showSuccess: true, |  | ||||||
| 				loadingMsg: '登录中', |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 	// 短信注册
 |  | ||||||
| 	smsRegister: (data) => |  | ||||||
| 		request({ |  | ||||||
| 			url: '/user/api/user/smsRegister', |  | ||||||
| 			method: 'POST', |  | ||||||
| 			data, |  | ||||||
| 			custom: { |  | ||||||
| 				showSuccess: true, |  | ||||||
| 				loadingMsg: '正在注册', |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 
 | 
 | ||||||
| 	// 绑定、更换手机号
 |  | ||||||
| 	changeMobile: (data) => |  | ||||||
| 		request({ |  | ||||||
| 			url: '/user/api/user/changeMobile', |  | ||||||
| 			method: 'POST', |  | ||||||
| 			data, |  | ||||||
| 			custom: { |  | ||||||
| 				showSuccess: true, |  | ||||||
| 				loadingMsg: '验证中', |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 
 | 
 | ||||||
| 	// 更新小程序信息
 |  | ||||||
| 	updateMpUserInfo: (data) => |  | ||||||
| 		request({ |  | ||||||
| 			url: '/user/api/user/updateMpUserInfo', |  | ||||||
| 			method: 'POST', |  | ||||||
| 			data, |  | ||||||
| 		}), |  | ||||||
| 
 |  | ||||||
| 	// 第三方授权信息
 |  | ||||||
| 	thirdOauthInfo: () => |  | ||||||
| 		request({ |  | ||||||
| 			url: '/user/api/user/thirdOauth', |  | ||||||
| 			method: 'GET', |  | ||||||
| 			params: { |  | ||||||
| 				provider: $platform.provider, |  | ||||||
| 				platform: $platform.platform, |  | ||||||
| 			}, |  | ||||||
| 			custom: { |  | ||||||
| 				showLoading: false, |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 
 | 
 | ||||||
| 	// 添加分享记录
 | 	// 添加分享记录
 | ||||||
| 	addShareLog: (data) => | 	addShareLog: (data) => | ||||||
|  | @ -116,30 +24,8 @@ export default { | ||||||
| 				params, | 				params, | ||||||
| 			}), | 			}), | ||||||
| 	}, | 	}, | ||||||
| 	// 账号登出
 |  | ||||||
| 	logout: (data) => |  | ||||||
| 		request({ |  | ||||||
| 			url: '/user/api/user/logout', |  | ||||||
| 			method: 'POST', |  | ||||||
| 			data, |  | ||||||
| 		}), |  | ||||||
| 	// 账号注销
 |  | ||||||
| 	logoff: (data) => |  | ||||||
| 		request({ |  | ||||||
| 			url: '/user/api/user/logoff', |  | ||||||
| 			method: 'POST', |  | ||||||
| 			data, |  | ||||||
| 		}), |  | ||||||
| 
 | 
 | ||||||
| 	address: { | 	address: { | ||||||
| 		// default: () =>
 |  | ||||||
| 		// 	request({
 |  | ||||||
| 		// 		url: 'user/address/default',
 |  | ||||||
| 		// 		method: 'GET',
 |  | ||||||
| 		// 		custom: {
 |  | ||||||
| 		// 			showError: false,
 |  | ||||||
| 		// 		},
 |  | ||||||
| 		// 	}),
 |  | ||||||
| 		default: () => | 		default: () => | ||||||
| 			request2({ | 			request2({ | ||||||
| 				url: 'member/address/get-default', | 				url: 'member/address/get-default', | ||||||
|  | @ -278,33 +164,5 @@ export default { | ||||||
| 					auth: true, | 					auth: true, | ||||||
| 				}, | 				}, | ||||||
| 			}), | 			}), | ||||||
| 	}, | 	} | ||||||
| 	//数量接口
 |  | ||||||
| 	// data: () =>
 |  | ||||||
| 	//   request({
 |  | ||||||
| 	//     url: 'user/user/data',
 |  | ||||||
| 	//     method: 'GET',
 |  | ||||||
| 	//     custom: {
 |  | ||||||
| 	//       showLoading: false,
 |  | ||||||
| 	//       auth: true,
 |  | ||||||
| 	//     },
 |  | ||||||
| 	//   }),
 |  | ||||||
| 	data: () => |  | ||||||
| 		request2({ |  | ||||||
| 			url: 'trade/order/get-count', |  | ||||||
| 			method: 'GET', |  | ||||||
| 			custom: { |  | ||||||
| 				showLoading: false, |  | ||||||
| 				auth: true, |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| 	data2: () => |  | ||||||
| 		request2({ |  | ||||||
| 			url: 'trade/after-sale/get-applying-count', |  | ||||||
| 			method: 'GET', |  | ||||||
| 			custom: { |  | ||||||
| 				showLoading: false, |  | ||||||
| 				auth: true, |  | ||||||
| 			}, |  | ||||||
| 		}), |  | ||||||
| }; | }; | ||||||
|  | @ -21,8 +21,8 @@ | ||||||
|       labelWidth="140" |       labelWidth="140" | ||||||
|       labelAlign="center" |       labelAlign="center" | ||||||
|     > |     > | ||||||
|       <uni-forms-item name="account" label="账号"> |       <uni-forms-item name="mobile" label="账号"> | ||||||
|         <uni-easyinput placeholder="请输入账号" v-model="state.model.account" :inputBorder="false"> |         <uni-easyinput placeholder="请输入账号" v-model="state.model.mobile" :inputBorder="false"> | ||||||
|           <template v-slot:right> |           <template v-slot:right> | ||||||
|             <button class="ss-reset-button forgot-btn" @tap="showAuthModal('resetPassword')"> |             <button class="ss-reset-button forgot-btn" @tap="showAuthModal('resetPassword')"> | ||||||
|               忘记密码 |               忘记密码 | ||||||
|  | @ -48,10 +48,11 @@ | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
| <script setup> | <script setup> | ||||||
|   import { computed, watch, ref, reactive, unref } from 'vue'; |   import { ref, reactive, unref } from 'vue'; | ||||||
|   import sheep from '@/sheep'; |   import sheep from '@/sheep'; | ||||||
|   import { account, password } from '@/sheep/validate/form'; |   import { mobile, password } from '@/sheep/validate/form'; | ||||||
|   import { showAuthModal, closeAuthModal } from '@/sheep/hooks/useModal'; |   import { showAuthModal, closeAuthModal } from '@/sheep/hooks/useModal'; | ||||||
|  |   import AuthUtil from '@/sheep/api/member/auth'; | ||||||
| 
 | 
 | ||||||
|   const accountLoginRef = ref(null); |   const accountLoginRef = ref(null); | ||||||
| 
 | 
 | ||||||
|  | @ -63,19 +64,20 @@ | ||||||
|       default: false, |       default: false, | ||||||
|     }, |     }, | ||||||
|   }); |   }); | ||||||
|  | 
 | ||||||
|   // 数据 |   // 数据 | ||||||
|   const state = reactive({ |   const state = reactive({ | ||||||
|     model: { |     model: { | ||||||
|       account: '', // 账号 |       mobile: '', // 账号 | ||||||
|       password: '', // 密码 |       password: '', // 密码 | ||||||
|     }, |     }, | ||||||
|     rules: { |     rules: { | ||||||
|       account, |       mobile, | ||||||
|       password, |       password, | ||||||
|     }, |     }, | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   // 1.账号登录 |   // 账号登录 | ||||||
|   async function accountLoginSubmit() { |   async function accountLoginSubmit() { | ||||||
|     // 表单验证 |     // 表单验证 | ||||||
|     const validate = await unref(accountLoginRef) |     const validate = await unref(accountLoginRef) | ||||||
|  | @ -93,12 +95,10 @@ | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // 提交数据 |     // 提交数据 | ||||||
|     sheep.$api.user.accountLogin(state.model).then((res) => { |     const { code, data } = await AuthUtil.login(state.model); | ||||||
|       if (res.error === 0) { |     if (code === 0) { | ||||||
|         // sheep.$store('user').getInfo(); |       closeAuthModal(); | ||||||
|         closeAuthModal(); |     } | ||||||
|       } |  | ||||||
|     }); |  | ||||||
|   } |   } | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -9,11 +9,11 @@ | ||||||
|     > |     > | ||||||
|       <uni-badge |       <uni-badge | ||||||
|         class="uni-badge-left-margin" |         class="uni-badge-left-margin" | ||||||
|         :text="numData.order_num[item.type]" |         :text="numData.orderCount[item.count]" | ||||||
|         absolute="rightTop" |         absolute="rightTop" | ||||||
|         size="small" |         size="small" | ||||||
|       > |       > | ||||||
|         <image class="item-icon" :src="sheep.$url.static(item.icon)" mode="aspectFit"></image> |         <image class="item-icon" :src="sheep.$url.static(item.icon)" mode="aspectFit" /> | ||||||
|       </uni-badge> |       </uni-badge> | ||||||
|       <view class="menu-title ss-m-t-28">{{ item.title }}</view> |       <view class="menu-title ss-m-t-28">{{ item.title }}</view> | ||||||
|     </view> |     </view> | ||||||
|  | @ -34,6 +34,7 @@ | ||||||
|       icon: '/static/img/shop/order/no_pay.png', |       icon: '/static/img/shop/order/no_pay.png', | ||||||
|       path: '/pages/order/list', |       path: '/pages/order/list', | ||||||
|       type: 'unpaid', |       type: 'unpaid', | ||||||
|  |       count: 'unpaidCount', | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|       title: '待收货', |       title: '待收货', | ||||||
|  | @ -41,6 +42,7 @@ | ||||||
|       icon: '/static/img/shop/order/no_take.png', |       icon: '/static/img/shop/order/no_take.png', | ||||||
|       path: '/pages/order/list', |       path: '/pages/order/list', | ||||||
|       type: 'noget', |       type: 'noget', | ||||||
|  |       count: 'deliveredCount', | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|       title: '待评价', |       title: '待评价', | ||||||
|  | @ -48,6 +50,7 @@ | ||||||
|       icon: '/static/img/shop/order/no_comment.png', |       icon: '/static/img/shop/order/no_comment.png', | ||||||
|       path: '/pages/order/list', |       path: '/pages/order/list', | ||||||
|       type: 'nocomment', |       type: 'nocomment', | ||||||
|  |       count: 'uncommentedCount', | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|       title: '售后单', |       title: '售后单', | ||||||
|  | @ -55,6 +58,7 @@ | ||||||
|       icon: '/static/img/shop/order/change_order.png', |       icon: '/static/img/shop/order/change_order.png', | ||||||
|       path: '/pages/order/aftersale/list', |       path: '/pages/order/aftersale/list', | ||||||
|       type: 'aftersale', |       type: 'aftersale', | ||||||
|  |       count: 'afterSaleCount', | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|       title: '全部订单', |       title: '全部订单', | ||||||
|  | @ -65,7 +69,6 @@ | ||||||
|   ]; |   ]; | ||||||
| 
 | 
 | ||||||
|   const numData = computed(() => sheep.$store('user').numData); |   const numData = computed(() => sheep.$store('user').numData); | ||||||
|   console.log('更换后的yuda订单数量',numData) |  | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <style lang="scss" scoped> | <style lang="scss" scoped> | ||||||
|  |  | ||||||
|  | @ -23,18 +23,17 @@ | ||||||
| 			</view> | 			</view> | ||||||
| 		</view> | 		</view> | ||||||
| 
 | 
 | ||||||
|     <!-- TODO @芋艿:用户接入 --> |  | ||||||
| 		<!-- 提示绑定手机号 先隐藏 yudao 需要再修改 --> | 		<!-- 提示绑定手机号 先隐藏 yudao 需要再修改 --> | ||||||
| 		<!--    <view | 		<view | ||||||
|       class="bind-mobile-box ss-flex ss-row-between ss-col-center" |       class="bind-mobile-box ss-flex ss-row-between ss-col-center" | ||||||
|       v-if="isLogin && !userInfo.verification?.mobile" |       v-if="isLogin && !userInfo.mobile" | ||||||
|     > |     > | ||||||
|       <view class="ss-flex"> |       <view class="ss-flex"> | ||||||
|         <text class="cicon-mobile-o"></text> |         <text class="cicon-mobile-o" /> | ||||||
|         <view class="mobile-title ss-m-l-20"> 点击绑定手机号确保账户安全 </view> |         <view class="mobile-title ss-m-l-20"> 点击绑定手机号确保账户安全 </view> | ||||||
|       </view> |       </view> | ||||||
|       <button class="ss-reset-button bind-btn" @tap="onBind">去绑定</button> |       <button class="ss-reset-button bind-btn" @tap="onBind">去绑定</button> | ||||||
|     </view> --> |     </view> | ||||||
| 	</view> | 	</view> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
| 		<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center" | 		<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center" | ||||||
| 			@tap="sheep.$router.go('/pages/user/wallet/money')"> | 			@tap="sheep.$router.go('/pages/user/wallet/money')"> | ||||||
| 			<view class="value-box ss-flex ss-col-bottom"> | 			<view class="value-box ss-flex ss-col-bottom"> | ||||||
| 				<view class="value-text ss-line-1">{{ fen2yuan(userInfo.money) || '0.00' }}</view> | 				<view class="value-text ss-line-1">{{ fen2yuan(userWallet.balance) || '0.00' }}</view> | ||||||
| 				<view class="unit-text ss-m-l-6">元</view> | 				<view class="unit-text ss-m-l-6">元</view> | ||||||
| 			</view> | 			</view> | ||||||
| 			<view class="menu-title ss-m-t-28">账户余额</view> | 			<view class="menu-title ss-m-t-28">账户余额</view> | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| 		<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center" | 		<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center" | ||||||
| 			@tap="sheep.$router.go('/pages/user/wallet/score')"> | 			@tap="sheep.$router.go('/pages/user/wallet/score')"> | ||||||
| 			<view class="value-box ss-flex ss-col-bottom"> | 			<view class="value-box ss-flex ss-col-bottom"> | ||||||
| 				<view class="value-text">{{ userInfo.point || '0.00' }}</view> | 				<view class="value-text">{{ userInfo.point || 0 }}</view> | ||||||
| 				<view class="unit-text ss-m-l-6">个</view> | 				<view class="unit-text ss-m-l-6">个</view> | ||||||
| 			</view> | 			</view> | ||||||
| 			<view class="menu-title ss-m-t-28">积分</view> | 			<view class="menu-title ss-m-t-28">积分</view> | ||||||
|  | @ -23,15 +23,14 @@ | ||||||
|         }) |         }) | ||||||
|       "> |       "> | ||||||
| 			<view class="value-box ss-flex ss-col-bottom"> | 			<view class="value-box ss-flex ss-col-bottom"> | ||||||
| 				<view class="value-text">{{ numData.coupons_num || '0.00' }}</view> | 				<view class="value-text">{{ numData.unusedCouponCount }}</view> | ||||||
| 				<view class="unit-text ss-m-l-6">张</view> | 				<view class="unit-text ss-m-l-6">张</view> | ||||||
| 			</view> | 			</view> | ||||||
| 			<view class="menu-title ss-m-t-28">优惠券</view> | 			<view class="menu-title ss-m-t-28">优惠券</view> | ||||||
| 		</view> | 		</view> | ||||||
| 		<view class="menu-item ss-flex-col ss-row-center ss-col-center menu-wallet" | 		<view class="menu-item ss-flex-col ss-row-center ss-col-center menu-wallet" | ||||||
| 			@tap="sheep.$router.go('/pages/user/wallet/money')"> |           @tap="sheep.$router.go('/pages/user/wallet/money')"> | ||||||
| 			<image class="item-icon" :src="sheep.$url.static('/static/img/shop/user/wallet_icon.png')" mode="aspectFit"> | 			<image class="item-icon" :src="sheep.$url.static('/static/img/shop/user/wallet_icon.png')" mode="aspectFit" /> | ||||||
| 			</image> |  | ||||||
| 			<view class="menu-title ss-m-t-30">我的钱包</view> | 			<view class="menu-title ss-m-t-30">我的钱包</view> | ||||||
| 		</view> | 		</view> | ||||||
| 	</view> | 	</view> | ||||||
|  | @ -41,13 +40,11 @@ | ||||||
| 	/** | 	/** | ||||||
| 	 * 装修组件 - 订单菜单组 | 	 * 装修组件 - 订单菜单组 | ||||||
| 	 */ | 	 */ | ||||||
| 	import { | 	import { computed } from 'vue'; | ||||||
| 		computed, |  | ||||||
| 		ref |  | ||||||
| 	} from 'vue'; |  | ||||||
| 	import sheep from '@/sheep'; | 	import sheep from '@/sheep'; | ||||||
|   import { fen2yuan } from '../../hooks/useGoods'; |   import { fen2yuan } from '../../hooks/useGoods'; | ||||||
| 
 | 
 | ||||||
|  | 	const userWallet = computed(() => sheep.$store('user').userWallet); | ||||||
| 	const userInfo = computed(() => sheep.$store('user').userInfo); | 	const userInfo = computed(() => sheep.$store('user').userInfo); | ||||||
| 	const numData = computed(() => sheep.$store('user').numData); | 	const numData = computed(() => sheep.$store('user').numData); | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
|  | @ -94,8 +94,7 @@ http.interceptors.request.use( | ||||||
| 		if (config.url.indexOf('/app-api/') !== -1) { | 		if (config.url.indexOf('/app-api/') !== -1) { | ||||||
| 			config.header['Accept'] = '*/*' | 			config.header['Accept'] = '*/*' | ||||||
| 			config.header['tenant-id'] = '1'; | 			config.header['tenant-id'] = '1'; | ||||||
| 			config.header['terminal'] = '20'; |       config.header['terminal'] = '20'; | ||||||
| 			config.header['Authorization'] = 'Bearer test247'; |  | ||||||
| 		} | 		} | ||||||
| 		return config; | 		return config; | ||||||
| 	}, | 	}, | ||||||
|  | @ -109,14 +108,10 @@ http.interceptors.request.use( | ||||||
|  */ |  */ | ||||||
| http.interceptors.response.use( | http.interceptors.response.use( | ||||||
| 	(response) => { | 	(response) => { | ||||||
| 		// 自动设置登陆令牌
 |     // 约定:如果是 /auth/ 下的 URL 地址,并且返回了 accessToken 说明是登录相关的接口,则自动设置登陆令牌
 | ||||||
| 		if (response.header.authorization || response.header.Authorization) { |     if (response.config.url.indexOf('/member/auth/') >= 0 && response.data?.data?.accessToken) { | ||||||
| 			$store('user').setToken(response.header.authorization || response.header.Authorization); |       $store('user').setToken(response.data.data.accessToken); | ||||||
| 		} |     } | ||||||
| 		// TODO 芋艿:如果是登录的 API,则自动设置 token
 |  | ||||||
| 		if (response.data?.data?.accessToken) { |  | ||||||
| 			$store('user').setToken(response.data.data.accessToken); |  | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		response.config.custom.showLoading && closeLoading(); | 		response.config.custom.showLoading && closeLoading(); | ||||||
| 		if (response.data.error !== 0 && response.data.code !== 0) { | 		if (response.data.error !== 0 && response.data.code !== 0) { | ||||||
|  |  | ||||||
|  | @ -152,7 +152,7 @@ http.interceptors.response.use( | ||||||
| 					} else { | 					} else { | ||||||
| 						errorMessage = '请先登录'; | 						errorMessage = '请先登录'; | ||||||
| 					} | 					} | ||||||
| 					userStore.logout(true); | 					userStore.logout(); | ||||||
| 					showAuthModal(); | 					showAuthModal(); | ||||||
| 					break; | 					break; | ||||||
| 				case 403: | 				case 403: | ||||||
|  |  | ||||||
|  | @ -58,10 +58,10 @@ const _go = ( | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // 页面登录拦截
 |   // 页面登录拦截
 | ||||||
|   // if (nextRoute.meta?.auth && !$store('user').isLogin) {
 |   if (nextRoute.meta?.auth && !$store('user').isLogin) { | ||||||
|   //   showAuthModal();
 |     showAuthModal(); | ||||||
|   //   return;
 |     return; | ||||||
|   // }
 |   } | ||||||
| 
 | 
 | ||||||
|   url = page; |   url = page; | ||||||
|   if (!isEmpty(query)) { |   if (!isEmpty(query)) { | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ const app = defineStore({ | ||||||
|   actions: { |   actions: { | ||||||
|     // 获取Shopro应用配置和模板
 |     // 获取Shopro应用配置和模板
 | ||||||
|     async init(templateId = null) { |     async init(templateId = null) { | ||||||
|       //检查网络
 |       // 检查网络
 | ||||||
|       const networkStatus = await $platform.checkNetwork(); |       const networkStatus = await $platform.checkNetwork(); | ||||||
|       if (!networkStatus) { |       if (!networkStatus) { | ||||||
|         $router.error('NetworkError'); |         $router.error('NetworkError'); | ||||||
|  | @ -58,19 +58,36 @@ const app = defineStore({ | ||||||
| 
 | 
 | ||||||
|       // 加载装修配置
 |       // 加载装修配置
 | ||||||
|       await adaptTemplate(this.template, templateId) |       await adaptTemplate(this.template, templateId) | ||||||
|       const res = await appApi.init(templateId); |  | ||||||
|       if (res.error === 0) { |  | ||||||
|         this.info = res.data.app; |  | ||||||
|         this.platform = res.data.platform; |  | ||||||
| 
 | 
 | ||||||
|         // TODO 芋艿:未接入
 |       // TODO 芋艿:未来支持管理后台可配;对应 https://api.shopro.sheepjs.com/shop/api/init
 | ||||||
|         // this.template = res.data.template;
 |       if (true) { | ||||||
|         // this.has_wechat_trade_managed = res.data.has_wechat_trade_managed;
 |         this.info = { | ||||||
|         // if (!res.data.template) {
 |           name: '芋道商城', | ||||||
|         //   $router.error('TemplateError');
 |           logo: 'https://static.iocoder.cn/ruoyi-vue-pro-logo.png', | ||||||
|         // }
 |           version: '1.1.13', | ||||||
|         // TODO 芋艿:未接入
 |           copyright: '全部开源,个人与企业可 100% 免费使用', | ||||||
|         // this.chat = res.data.chat;
 |           copytime: 'Copyright© 2018-2024', | ||||||
|  | 
 | ||||||
|  |           cdnurl: 'https://file.sheepjs.com', // 云存储域名
 | ||||||
|  |           filesystem: 'qcloud', // 云存储平台
 | ||||||
|  |         }; | ||||||
|  |         this.platform = { | ||||||
|  |           share: { | ||||||
|  |             methods: [ "poster", "link" ], | ||||||
|  |             linkAddress: "https://shopro.sheepjs.com/#/", | ||||||
|  |             posterInfo: { | ||||||
|  |               "user_bg": "/static/img/shop/config/user-poster-bg.png", | ||||||
|  |               "goods_bg": "/static/img/shop/config/goods-poster-bg.png", | ||||||
|  |               "groupon_bg": "/static/img/shop/config/groupon-poster-bg.png" | ||||||
|  |             } | ||||||
|  |           }, | ||||||
|  |           bind_mobile: 0 | ||||||
|  |         }; | ||||||
|  |         this.chat = { | ||||||
|  |           chat_domain: "https://api.shopro.sheepjs.com/chat", | ||||||
|  |           room_id: "admin" | ||||||
|  |         } | ||||||
|  |         this.has_wechat_trade_managed = 0; | ||||||
| 
 | 
 | ||||||
|         // 加载主题
 |         // 加载主题
 | ||||||
|         const sysStore = sys(); |         const sysStore = sys(); | ||||||
|  |  | ||||||
|  | @ -85,9 +85,12 @@ const cart = defineStore({ | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     // 清空购物车
 |     // 清空购物车。注意,仅用于用户退出时,重置数据
 | ||||||
|     async emptyList() { |     emptyList() { | ||||||
|       await this.delete(this.list.map((item) => item.id)); |       this.list = []; | ||||||
|  |       this.selectedIds = []; | ||||||
|  |       this.isAllSelected = true; | ||||||
|  |       this.totalPriceSelected = 0; | ||||||
|     }, |     }, | ||||||
|   }, |   }, | ||||||
|   persist: { |   persist: { | ||||||
|  |  | ||||||
|  | @ -3,14 +3,13 @@ import { defineStore } from 'pinia'; | ||||||
| const modal = defineStore({ | const modal = defineStore({ | ||||||
|   id: 'modal', |   id: 'modal', | ||||||
|   state: () => ({ |   state: () => ({ | ||||||
|     auth: '', // 授权弹框 accountLogin|smsLogin|smsRegister|resetPassword|changeMobile|changePassword|changeUsername
 |     auth: '', // 授权弹框 accountLogin|smsLogin|resetPassword|changeMobile|changePassword|changeUsername
 | ||||||
|     share: false, // 分享弹框
 |     share: false, // 分享弹框
 | ||||||
|     menu: false, // 快捷菜单弹框
 |     menu: false, // 快捷菜单弹框
 | ||||||
|     advHistory: [], // 广告弹框记录
 |     advHistory: [], // 广告弹框记录
 | ||||||
|     lastTimer: { |     lastTimer: { | ||||||
|       // 短信验证码计时器,为了防止刷新请求做了持久化
 |       // 短信验证码计时器,为了防止刷新请求做了持久化
 | ||||||
|       smsLogin: 0, |       smsLogin: 0, | ||||||
|       smsRegister: 0, |  | ||||||
|       changeMobile: 0, |       changeMobile: 0, | ||||||
|       resetPassword: 0, |       resetPassword: 0, | ||||||
|       changePassword: 0, |       changePassword: 0, | ||||||
|  |  | ||||||
|  | @ -15,6 +15,10 @@ import { | ||||||
| } from '@/sheep/hooks/useModal'; | } from '@/sheep/hooks/useModal'; | ||||||
| import AuthUtil from '@/sheep/api/member/auth'; | import AuthUtil from '@/sheep/api/member/auth'; | ||||||
| import BrokerageApi from '@/sheep/api/trade/brokerage'; | import BrokerageApi from '@/sheep/api/trade/brokerage'; | ||||||
|  | import UserApi from '@/sheep/api/member/user'; | ||||||
|  | import PayWalletApi from '@/sheep/api/pay/wallet'; | ||||||
|  | import OrderApi from '@/sheep/api/trade/order'; | ||||||
|  | import CouponApi from '@/sheep/api/promotion/coupon'; | ||||||
| 
 | 
 | ||||||
| // 默认用户信息
 | // 默认用户信息
 | ||||||
| const defaultUserInfo = { | const defaultUserInfo = { | ||||||
|  | @ -22,20 +26,24 @@ const defaultUserInfo = { | ||||||
| 	nickname: '', // 昵称
 | 	nickname: '', // 昵称
 | ||||||
| 	gender: 0, // 性别
 | 	gender: 0, // 性别
 | ||||||
| 	mobile: '', // 手机号
 | 	mobile: '', // 手机号
 | ||||||
| 	money: '--', // 余额
 |   point: 0, // 积分
 | ||||||
| 	score: '--', // 积分  TODO 芋艿:改成 point
 |  | ||||||
| 	verification: {}, // 认证字段
 |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | // 默认钱包信息
 | ||||||
|  | const defaultUserWallet = { | ||||||
|  |   balance: 0, // 余额
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // 默认订单、优惠券等其他资产信息
 | // 默认订单、优惠券等其他资产信息
 | ||||||
| const defaultNumData = { | const defaultNumData = { | ||||||
| 	coupons_num: '--', |   unusedCouponCount: 0, | ||||||
| 	order_num: { |   orderCount: { | ||||||
| 		aftersale: 0, |     allCount: 0, | ||||||
| 		nocomment: 0, |     unpaidCount: 0, | ||||||
| 		noget: 0, |     undeliveredCount: 0, | ||||||
| 		nosend: 0, |     deliveredCount: 0, | ||||||
| 		unpaid: 0, |     uncommentedCount: 0, | ||||||
|  |     afterSaleCount: 0, | ||||||
| 	}, | 	}, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -43,55 +51,44 @@ const user = defineStore({ | ||||||
| 	id: 'user', | 	id: 'user', | ||||||
| 	state: () => ({ | 	state: () => ({ | ||||||
| 		userInfo: clone(defaultUserInfo), // 用户信息
 | 		userInfo: clone(defaultUserInfo), // 用户信息
 | ||||||
|  |     userWallet: clone(defaultUserWallet), // 用户钱包信息
 | ||||||
| 		isLogin: !!uni.getStorageSync('token'), // 登录状态
 | 		isLogin: !!uni.getStorageSync('token'), // 登录状态
 | ||||||
| 		numData: cloneDeep(defaultNumData), // 用户其他数据
 | 		numData: cloneDeep(defaultNumData), // 用户其他数据
 | ||||||
| 		lastUpdateTime: 0, // 上次更新时间
 | 		lastUpdateTime: 0, // 上次更新时间
 | ||||||
| 	}), | 	}), | ||||||
| 
 | 
 | ||||||
| 	actions: { | 	actions: { | ||||||
| 		// 获取个人信息
 | 		// 获取用户信息
 | ||||||
|     // TODO 芋艿:整理下;
 |  | ||||||
| 		async getInfo() { | 		async getInfo() { | ||||||
| 			const { | 			const { code, data } = await UserApi.getUserInfo(); | ||||||
| 				code, |       if (code !== 0) { | ||||||
| 				data |         return; | ||||||
| 			} = await userApi.profile(); |       } | ||||||
| 
 |       this.userInfo = data; | ||||||
| 			// 为了兼容 获取用户余额 可能还会用到其他参数
 |  | ||||||
| 			// 优惠券数量,积分数量 应该在这里
 |  | ||||||
| 			const { |  | ||||||
| 				code: code2, |  | ||||||
| 				data: data2 |  | ||||||
| 			} = await userApi.balance(); |  | ||||||
| 			if (code !== 0 || code2 != 0) return; |  | ||||||
| 			data.money = data2.balance; |  | ||||||
| 			this.userInfo = data; |  | ||||||
| 			// console.log(data2, '信息')
 |  | ||||||
| 			return Promise.resolve(data); | 			return Promise.resolve(data); | ||||||
| 		}, | 		}, | ||||||
| 
 | 
 | ||||||
|  |     // 获得用户钱包
 | ||||||
|  |     async getWallet() { | ||||||
|  |       const { code, data } = await PayWalletApi.getPayWallet(); | ||||||
|  |       if (code !== 0) { | ||||||
|  |         return; | ||||||
|  |       } | ||||||
|  |       this.userWallet = data; | ||||||
|  |     }, | ||||||
|  | 
 | ||||||
| 		// 获取订单、优惠券等其他资产信息
 | 		// 获取订单、优惠券等其他资产信息
 | ||||||
|     // TODO 芋艿:整理下;
 |     getNumData() { | ||||||
|     async getNumData() { |       OrderApi.getOrderCount().then(res => { | ||||||
| 			const { |         if (res.code === 0) { | ||||||
| 				code, |           this.numData.orderCount = res.data; | ||||||
| 				data |         } | ||||||
| 			} = await userApi.data(); |       }); | ||||||
| 			const data2 = await userApi.data2(); |       CouponApi.getUnusedCouponCount().then(res => { | ||||||
| 			let data3 = await userApi.getUnused(); |         if (res.code === 0) { | ||||||
| 			// console.log(data3.data, '优惠券')
 |           this.numData.unusedCouponCount = res.data; | ||||||
| 			if (code === 0 && data2.code === 0) { |         } | ||||||
| 				// console.log('订单数据', data);
 |       }); | ||||||
| 				this.numData = { |  | ||||||
| 					coupons_num: data3.data, |  | ||||||
| 					order_num: { |  | ||||||
| 						noget: data.deliveredCount, |  | ||||||
| 						unpaid: data.unpaidCount, |  | ||||||
| 						nocomment: data.uncommentedCount, |  | ||||||
| 						aftersale: data2.data |  | ||||||
| 					} |  | ||||||
| 				}; |  | ||||||
| 			} |  | ||||||
| 		}, | 		}, | ||||||
| 
 | 
 | ||||||
| 		// 添加分享记录
 | 		// 添加分享记录
 | ||||||
|  | @ -103,8 +100,8 @@ const user = defineStore({ | ||||||
| 			if (error === 0) uni.removeStorageSync('shareLog'); | 			if (error === 0) uni.removeStorageSync('shareLog'); | ||||||
| 		}, | 		}, | ||||||
| 
 | 
 | ||||||
| 		// 设置token
 | 		// 设置 token
 | ||||||
|     // TODO 芋艿:整理下;
 |     // TODO 芋艿:后续要支持访问令牌的刷新!!!
 | ||||||
|     setToken(token = '') { |     setToken(token = '') { | ||||||
| 			if (token === '') { | 			if (token === '') { | ||||||
| 				this.isLogin = false; | 				this.isLogin = false; | ||||||
|  | @ -117,42 +114,52 @@ const user = defineStore({ | ||||||
| 			return this.isLogin; | 			return this.isLogin; | ||||||
| 		}, | 		}, | ||||||
| 
 | 
 | ||||||
| 		// 更新用户相关信息 (手动限流 5秒之内不刷新)
 | 		// 更新用户相关信息 (手动限流,5 秒之内不刷新)
 | ||||||
|     // TODO 芋艿:整理下;
 |  | ||||||
|     async updateUserData() { |     async updateUserData() { | ||||||
| 			if (!this.isLogin) { | 			if (!this.isLogin) { | ||||||
| 				this.resetUserData(); | 				this.resetUserData(); | ||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
|  |       // 防抖,5 秒之内不刷新
 | ||||||
| 			const nowTime = new Date().getTime(); | 			const nowTime = new Date().getTime(); | ||||||
| 			if (this.lastUpdateTime + 5000 > nowTime) return; |       if (this.lastUpdateTime + 5000 > nowTime) { | ||||||
|  |         return; | ||||||
|  |       } | ||||||
|  |       this.lastUpdateTime = nowTime; | ||||||
|  | 
 | ||||||
|  |       // 获取最新信息
 | ||||||
| 			await this.getInfo(); | 			await this.getInfo(); | ||||||
|  |       this.getWallet(); | ||||||
| 			this.getNumData(); | 			this.getNumData(); | ||||||
| 			this.lastUpdateTime = nowTime; |  | ||||||
| 			return this.userInfo; | 			return this.userInfo; | ||||||
| 		}, | 		}, | ||||||
| 
 | 
 | ||||||
| 		// 重置用户默认数据
 | 		// 重置用户默认数据
 | ||||||
|     // TODO 芋艿:整理下;
 |  | ||||||
|     resetUserData() { |     resetUserData() { | ||||||
|  |       // 清空 token
 | ||||||
| 			this.setToken(); | 			this.setToken(); | ||||||
|  |       // 清空用户相关的缓存
 | ||||||
| 			this.userInfo = clone(defaultUserInfo); | 			this.userInfo = clone(defaultUserInfo); | ||||||
|  |       this.userWallet = clone(defaultUserWallet); | ||||||
| 			this.numData = cloneDeep(defaultNumData); | 			this.numData = cloneDeep(defaultNumData); | ||||||
| 			this.agentInfo = {}; |       // 清空购物车的缓存
 | ||||||
| 			cart().emptyList(); | 			cart().emptyList(); | ||||||
| 		}, | 		}, | ||||||
| 
 | 
 | ||||||
| 		// 登录后
 | 		// 登录后,加载各种信息
 | ||||||
|     // TODO 芋艿:整理下;
 |     // TODO 芋艿:整理下;
 | ||||||
|     async loginAfter() { |     async loginAfter() { | ||||||
| 			await this.updateUserData(); | 			await this.updateUserData(); | ||||||
|  | 
 | ||||||
|  |       // 加载购物车
 | ||||||
| 			cart().getList(); | 			cart().getList(); | ||||||
| 			// 登录后设置全局分享参数
 | 			// 登录后设置全局分享参数
 | ||||||
| 			$share.getShareInfo(); | 			$share.getShareInfo(); | ||||||
|  | 
 | ||||||
| 			// 提醒绑定手机号
 | 			// 提醒绑定手机号
 | ||||||
| 			// if (app().platform.bind_mobile && !this.userInfo.verification?.mobile) {
 | 			if (app().platform.bind_mobile && !this.userInfo.mobile) { | ||||||
| 			// 	showAuthModal('changeMobile');
 | 				showAuthModal('changeMobile'); | ||||||
| 			// }
 | 			} | ||||||
| 
 | 
 | ||||||
| 			// 添加分享记录
 | 			// 添加分享记录
 | ||||||
|       // TODO 芋艿:整理下;
 |       // TODO 芋艿:整理下;
 | ||||||
|  | @ -164,21 +171,11 @@ const user = defineStore({ | ||||||
| 			} | 			} | ||||||
| 		}, | 		}, | ||||||
| 
 | 
 | ||||||
| 		// 登出
 | 		// 登出系统
 | ||||||
|     // TODO 芋艿:整理下;
 |     async logout() { | ||||||
|     async logout(force = false) { |       this.resetUserData(); | ||||||
| 			if (!force) { |  | ||||||
| 				const { code } = AuthUtil.logout(); |  | ||||||
| 				if (code === 0) { |  | ||||||
| 					this.resetUserData(); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			if (force) { |  | ||||||
| 				this.resetUserData(); |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			return !this.isLogin; | 			return !this.isLogin; | ||||||
| 		}, | 		} | ||||||
| 	}, | 	}, | ||||||
| 	persist: { | 	persist: { | ||||||
| 		enabled: true, | 		enabled: true, | ||||||
|  |  | ||||||
|  | @ -22,24 +22,6 @@ export const mobile = { | ||||||
|   ], |   ], | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // 账户
 |  | ||||||
| export const account = { |  | ||||||
|   rules: [ |  | ||||||
|     { |  | ||||||
|       required: true, |  | ||||||
|       errorMessage: '请输入账号', |  | ||||||
|     }, |  | ||||||
|     { |  | ||||||
|       validateFunction: function (rule, value, data, callback) { |  | ||||||
|         if (value.length < 5) { |  | ||||||
|           callback('账号长度不能小于5位'); |  | ||||||
|         } |  | ||||||
|         return true; |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|   ], |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| // 密码
 | // 密码
 | ||||||
| export const password = { | export const password = { | ||||||
|   rules: [ |   rules: [ | ||||||
|  | @ -58,24 +40,6 @@ export const password = { | ||||||
|   ], |   ], | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // 昵称
 |  | ||||||
| export const username = { |  | ||||||
|   rules: [ |  | ||||||
|     { |  | ||||||
|       required: true, |  | ||||||
|       errorMessage: '请输入用户名', |  | ||||||
|     }, |  | ||||||
|     { |  | ||||||
|       validateFunction: function (rule, value, data, callback) { |  | ||||||
|         if (value.length < 5) { |  | ||||||
|           callback('用户名长度不能小于5位'); |  | ||||||
|         } |  | ||||||
|         return true; |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|   ], |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| // 短信验证码
 | // 短信验证码
 | ||||||
| export const code = { | export const code = { | ||||||
|   rules: [ |   rules: [ | ||||||
|  | @ -195,7 +159,6 @@ export default { | ||||||
|   realName, |   realName, | ||||||
|   password, |   password, | ||||||
|   code, |   code, | ||||||
|   account, |  | ||||||
|   taxNo, |   taxNo, | ||||||
|   taxName, |   taxName, | ||||||
| }; | }; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 落日晚风
						落日晚风