From 35b43ffd97b2f20b40674abda9af95a53a6d8264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=B0=91=E5=90=9B?= <476671688@qq.com> Date: Wed, 15 Nov 2023 19:59:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 47 ++++ api/api.js | 18 ++ api/order.js | 4 +- api/user.js | 1 + components/Header/index.vue | 17 +- components/Modal/index.vue | 2 +- components/PayPopup/index.vue | 2 +- components/Popup/index.vue | 7 +- components/Recommend/index.vue | 192 ++++++++++++++++ components/goodsComponents/Goods.vue | 20 +- components/order/order.vue | 4 +- components/reply/reply.vue | 13 +- hooks/usePage.js | 5 + hooks/useRouter.js | 3 + hooks/useScroll.js | 15 ++ pages/address/address.vue | 38 ++-- pages/collect/collect.vue | 1 + pages/createAddress/createAddress.vue | 183 ++++++++++------ .../discountCoupon/components/CouponItem.vue | 11 +- pages/evaluate/evaluate.vue | 1 + pages/footprint/footprint.vue | 1 + pages/goodsCategory/goodsCategory.vue | 2 +- pages/goodsDetail/goodsDetail.vue | 60 +++-- pages/goodsList/goodsList.vue | 3 +- pages/index/components/Recommend/index.vue | 92 ++------ pages/index/index.vue | 33 ++- pages/login/guid.vue | 197 +++++++++++++++-- pages/login/index.data.js | 7 +- pages/orderInfo/orderInfo.vue | 33 ++- pages/orderList/orderList.vue | 25 ++- pages/payStatus/index.vue | 75 ++++--- pages/refund/refund.vue | 11 +- pages/refundInfo/refundInfo.vue | 9 +- pages/selectRefundGood/selectRefundGood.vue | 139 +++++++++++- pages/shoppingCart/shoppingCart.vue | 21 +- .../submitOrder/components/coupon-select.vue | 27 ++- pages/submitOrder/submitOrder.vue | 15 +- pages/userInfo/index.utlis.js | 16 +- pages/userInfo/index.vue | 3 +- store/store.js | 3 +- utils/paymentUtils.js | 81 ++++--- utils/utils.js | 9 + utils/wechatUtils.js | 206 ++++++++++++++++++ 43 files changed, 1265 insertions(+), 387 deletions(-) create mode 100644 .gitignore create mode 100644 components/Recommend/index.vue create mode 100644 hooks/useScroll.js create mode 100644 utils/wechatUtils.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c93fccd --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/build +/unpackage/dist/dev +/unpackage/dist/static +/unpackage/dist/build/mp-alipay/ +/unpackage/dist/build/mp-weixin/ +/unpackage/dist/build/app-plus/ +/unpackage/dist/build/.automator +/unpackage/cache/ +/unpackage/cache/apk +/unpackage/release +/unpackage/res +/unpackage/resources +# misc +.DS_Store +.cache + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +.tmp* +.svn +.tags +*.sublime-* +sftp-config.json +logs +*.log +.idea* +.yo-rc.json +*.swo +*.swp +/deps +yarn.lock +dev-stats.json +.vscode +.idea +*.hbuilderx +.history diff --git a/api/api.js b/api/api.js index 8d9e1d0..c70db8b 100644 --- a/api/api.js +++ b/api/api.js @@ -144,3 +144,21 @@ const request = ['post', 'put', 'patch'].reduce((request, method) => { }) export default request + +export const upload = (options)=>{ + const token = cookie.get('accessToken') + return new Promise((resolve, reject)=>{ + uni.showLoading({title:'上传中'}) + uni.uploadFile({ + ...options, + header:{ + ...options.headers, + Authorization: 'Bearer ' + token.accessToken, + }, + url:options.url?`${VUE_APP_API_URL}${options.url}`:VUE_APP_API_URL+'/member/user/update-avatar', + success:(res)=>resolve(res), + fail:(err)=>reject(err), + complete:()=>uni.hideLoading() + }) + }) +} diff --git a/api/order.js b/api/order.js index b94ce92..9f452b4 100644 --- a/api/order.js +++ b/api/order.js @@ -149,8 +149,8 @@ export function orderExpress(data) { export const wechatPay = (data) => api.post(`/order/pay`, data) /** - * 检查h5支付 + * 检查支付 * @param data * @returns {*} */ -export const checkH5Pay = (data) => api.post(`/order/pay/orderQuery`, data) +export const checkPay = (data) => api.post(`/order/pay/orderQuery`, data) diff --git a/api/user.js b/api/user.js index 84c9b24..ea6bb7c 100644 --- a/api/user.js +++ b/api/user.js @@ -41,3 +41,4 @@ export function updateMobile(data) { * @returns {*} */ export const updateUserInfo = (data) => api.put(`/member/user/update-nickname?nickname=${ data.nickname }&birthday=${ data.birthday }&sex=${ data.sex }`) + diff --git a/components/Header/index.vue b/components/Header/index.vue index a2878bb..20d8b94 100644 --- a/components/Header/index.vue +++ b/components/Header/index.vue @@ -10,6 +10,7 @@ import { computed, defineProps, ref, toRefs, unref, watch } from "vue"; import { onLoad } from "@dcloudio/uni-app"; import { useRouter } from "@/hooks/useRouter"; import { createAnimation } from "@/utils/utils"; +import { useScroll } from "@/hooks/useScroll"; const HEADER_HEIGHT = 40 // header高度 @@ -66,10 +67,6 @@ const props = defineProps({ type: String, default: () => '#fff' }, - scrollTop: { - type: Number, - default: () => 0 - }, propUp: { type: Boolean, default: () => true @@ -94,7 +91,6 @@ const { textShadow, bgChangeByScroll, bgChangeColor, - scrollTop, propUp, showRight, leftWidth @@ -146,7 +142,7 @@ function getMenuInfo() { // scss全局变量 const scssVarStyle = computed(() => { return { - '--header-height': `${ HEADER_HEIGHT * 2 }rpx` + '--header-height': `${ HEADER_HEIGHT }px` } }) @@ -154,7 +150,7 @@ const scssVarStyle = computed(() => { const systemBarAreaStyle = computed(() => { return { width: '100%', - height: `${ unref(heightInfo).safeAreaInsets.top * 2 }rpx`, + height: `${ unref(heightInfo).statusBarHeight * 2 }rpx`, background: unref(systemBarAreaBg) } }) @@ -163,7 +159,7 @@ const systemBarAreaStyle = computed(() => { const headerAreaStyle = computed(() => { // 计算margin top // margin-top (导航条高度 - 胶囊高度) / 2 永远确保胶囊在header中央 - const marginTop = unref(menuInfo).height > 0 ? `-${ ((HEADER_HEIGHT - (unref(menuInfo).height)) / 2) * 2 }rpx` : 0 + const marginTop = unref(menuInfo).height > 0 ? `-${((HEADER_HEIGHT - unref(menuInfo).height))/2}px` : 0 return { width: '100%', background: unref(headerAreaBg), @@ -202,7 +198,7 @@ const scrollMaskStyle = computed(() => { // 总高度 const containerHeight = computed(() => { - return (unref(heightInfo).safeAreaInsets.top + HEADER_HEIGHT) * 2 + return (unref(heightInfo).statusBarHeight + HEADER_HEIGHT) }) let animation @@ -212,6 +208,7 @@ function doCreateAnimation() { animation = createAnimation(0, scrollEnd, 0, 1) } +const {scrollTop} = useScroll(); watch(scrollTop, () => { if (!bgChangeByScroll.value) return if (!animation) doCreateAnimation() @@ -289,7 +286,7 @@ onLoad(() => { diff --git a/components/Modal/index.vue b/components/Modal/index.vue index dcb1c53..934d45f 100644 --- a/components/Modal/index.vue +++ b/components/Modal/index.vue @@ -126,7 +126,7 @@ defineExpose({show, close}) text-align: center; height: 80rpx; line-height: 80rpx; - border: 1rpx solid #ee6d46; + border: 1px solid #ee6d46; background: #ee6d46; color: #fff; } diff --git a/components/PayPopup/index.vue b/components/PayPopup/index.vue index 4b87219..58560ed 100644 --- a/components/PayPopup/index.vue +++ b/components/PayPopup/index.vue @@ -52,7 +52,7 @@ async function handleSubmit() { close() } catch (e) { console.error(e) - push({url: '/pages/payStatus/index?type=2'}) + push({url: '/pages/payStatus/index'},{data:{type:2}}) toast({title: '支付失败了'}) close() } diff --git a/components/Popup/index.vue b/components/Popup/index.vue index d587b36..28d2b92 100644 --- a/components/Popup/index.vue +++ b/components/Popup/index.vue @@ -10,7 +10,7 @@ import { nextTick, ref, toRefs } from "vue"; import UniPopup from "@/components/uniComponents/UPopup/uni-popup/uni-popup.vue"; /** some javascript code in here */ -const emit = defineEmits(['open', 'close']) +const emit = defineEmits(['open', 'close', 'maskClick']) /** * @property {String} title 标题 * @property {String} mode 模式 @@ -73,6 +73,10 @@ const handlePopupChange = (e) => { if (!e.show) emit('close') } +const handleMaskClick = (e) => { + emit('maskClick') +} + defineExpose({ show, close @@ -86,6 +90,7 @@ defineExpose({ :is-mask-click="isMaskClick" background-color="#fff" @change="handlePopupChange" + @maskClick="handleMaskClick" class="y-popup" > diff --git a/components/Recommend/index.vue b/components/Recommend/index.vue new file mode 100644 index 0000000..7fc717e --- /dev/null +++ b/components/Recommend/index.vue @@ -0,0 +1,192 @@ + + + + + + + diff --git a/components/goodsComponents/Goods.vue b/components/goodsComponents/Goods.vue index 83ea826..ba1294d 100644 --- a/components/goodsComponents/Goods.vue +++ b/components/goodsComponents/Goods.vue @@ -9,6 +9,7 @@ import { toRefs } from "vue"; import { GOODS_ITEM_TYPE } from "@/components/goodsComponents/utils/index.type"; import { useRouter } from "@/hooks/useRouter"; +import { getRandom } from "@/utils/utils"; const props = defineProps({ goods: { @@ -21,17 +22,17 @@ const props = defineProps({ }, /** 图片比例 */ ratio: { - type: String, - default: () => "1/1" + type: [String,Boolean], + default: () => '1/1' }, infoPadding: { type: String, default: () => "0 0" }, /** title是否换行 */ - titleNowrap: { + titleWrap: { type: Boolean, - default: () => true + default: () => false }, /** title 文字大小 rpx */ titleSize: { @@ -53,7 +54,7 @@ const { imgWidth, ratio, infoPadding, - titleNowrap, + titleWrap, titleSize, row, } = toRefs(props) @@ -63,6 +64,7 @@ const {push} = useRouter() function toDetail() { push({url: '/pages/goodsDetail/goodsDetail'}, {data: {id: goods.value.id}}) } + diff --git a/pages/discountCoupon/components/CouponItem.vue b/pages/discountCoupon/components/CouponItem.vue index 527408f..5e0ddcc 100644 --- a/pages/discountCoupon/components/CouponItem.vue +++ b/pages/discountCoupon/components/CouponItem.vue @@ -39,10 +39,8 @@ const getCoupon = async () => { }); } -const goToProduct = () => { - push({ - url: '/pages/goodsList/goodsList' - }) +const goToProduct = (coupons) => { + push({url: '/pages/goodsList/goodsList'},{data: {couponId: coupons.id}}) } @@ -71,7 +69,7 @@ const goToProduct = () => { - 去使用 + 去使用 已使用 @@ -90,8 +88,7 @@ const goToProduct = () => { scoped lang="scss" > -.coupon-item{ - margin-bottom: 30rpx; +.coupon-item { width: 100%; aspect-ratio: 682/176; background: url("@/static/background/coupon-bg.png") no-repeat ; diff --git a/pages/evaluate/evaluate.vue b/pages/evaluate/evaluate.vue index 462c6a9..175194d 100644 --- a/pages/evaluate/evaluate.vue +++ b/pages/evaluate/evaluate.vue @@ -17,6 +17,7 @@ diff --git a/pages/footprint/footprint.vue b/pages/footprint/footprint.vue index da0d6da..62deec9 100644 --- a/pages/footprint/footprint.vue +++ b/pages/footprint/footprint.vue @@ -223,6 +223,7 @@ async function handleUnCollectSingle() { await unFootprintSingle(toDeleteItem) await refresh() await toast({title: '删除成功'}) + toDeleteItem = undefined } /** diff --git a/pages/goodsCategory/goodsCategory.vue b/pages/goodsCategory/goodsCategory.vue index 0be4805..2f4a409 100644 --- a/pages/goodsCategory/goodsCategory.vue +++ b/pages/goodsCategory/goodsCategory.vue @@ -6,7 +6,7 @@ > @@ -68,7 +62,7 @@ - + @@ -89,8 +83,9 @@ import Group from './components/Group/index.vue' import Live from './components/Live/index.vue' import NewProduct from './components/NewProduct/index.vue' import Seckill from './components/Seckill/index.vue' -import Recommend from './components/Recommend/index.vue' +import Recommend from "./components/Recommend/index.vue"; import UvIcon from "@/uni_modules/uv-icon/components/uv-icon/uv-icon.vue"; +import { useScroll } from "@/hooks/useScroll"; const main = useMainStore() const {push} = useRouter() @@ -118,19 +113,18 @@ function handleHeaderAnimation(numericalValue) { } } -const scrollTop = ref(0) +/*const scrollTop = ref(0) onPageScroll((e) => { scrollTop.value = e.scrollTop -}) +})*/ onLoad(() => { main.init() doGetHomeData() }) -onReachBottom(() => { - unref(recommendRef).onReachBottom && unref(recommendRef).onReachBottom(); -}) +useScroll() + diff --git a/pages/login/guid.vue b/pages/login/guid.vue index 55b59c1..7c8b05e 100644 --- a/pages/login/guid.vue +++ b/pages/login/guid.vue @@ -6,19 +6,96 @@ @update: 2023-11-08 16:20 -->