Skip to content

Commit

Permalink
新增优惠券
Browse files Browse the repository at this point in the history
  • Loading branch information
wayn111 committed Feb 18, 2025
1 parent 22370ad commit 8952fab
Show file tree
Hide file tree
Showing 31 changed files with 417 additions and 404 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
"vue-content-loader": "^0.2.3",
"vue-router": "^3.5.1",
"vue-scrollto": "^2.20.0",
"vuex": "^3.6.2"
"vuex": "^3.6.2",
"weixin-js-sdk": "^1.6.5"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.5.11",
"@vue/cli-plugin-eslint": "^4.5.11",
"@vue/cli-service": "^4.5.11",
"@vue/cli-service": "^4.5.19",
"babel-eslint": "^10.1.0",
"babel-plugin-import": "^1.13.3",
"cross-env": "^7.0.3",
Expand All @@ -46,13 +47,14 @@
"eslint-plugin-vue": "^6.2.2",
"less": "^3.13.1",
"less-loader": "^5.0.0",
"postcss-mobile-forever": "^0.0.1",
"postcss-px-to-viewport": "^1.1.1",
"postcss-preset-env": "^6.7.0",
"sass": "^1.32.10",
"sass-loader": "^9.0.3",
"svg-sprite-loader": "^4.2.1",
"svgo": "^1.3.2",
"vue-template-compiler": "^2.6.12"
"vue-template-compiler": "^2.6.12",
"mini-css-extract-plugin": "2.5.3"
},
"browserslist": [
"> 1%",
Expand Down
22 changes: 14 additions & 8 deletions postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ module.exports = {
plugins: {
// https://github.com/csstools/postcss-preset-env
'postcss-preset-env': {},
// https://github.com/wswmsword/postcss-mobile-forever
'postcss-mobile-forever': {
viewportWidth: file => /vant[\\/]/.test(file) ? 375 : 750,
maxDisplayWidth: 560,
// https://github.com/evrone/postcss-px-to-viewport/blob/master/README_CN.md
'postcss-px-to-viewport': {
unitToConvert: 'px',
viewportWidth: 750,
unitPrecision: 3,
propList: ['*'],
selectorBlackList: ['.ignore'],
rootContainingBlockSelectorList: ['van-popup--bottom'],
disableLandscape: true,
disableDesktop: true
viewportUnit: 'vw',
fontViewportUnit: 'vw',
selectorBlackList: ['.ignore', 'van'],
minPixelValue: 1,
mediaQuery: false,
replace: true,
exclude: [],
landscape: false,
landscapeUnit: 'vw',
landscapeWidth: 568
}
}
}
6 changes: 3 additions & 3 deletions src/api/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export function getCaptcha() {
})
}

export function getMailCode(data) {
export function getMobileCode(data) {
return request({
url: '/sendEmailCode',
url: '/genMobileCode',
method: 'post',
data,
timeout: 20000
timeout: 5000
})
}
23 changes: 23 additions & 0 deletions src/api/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,26 @@ export function orderConfirm(orderId) {
})
}

export function orderCoupon(data) {
return request({
url: `/coupon/list`,
method: 'get',
params: data
})
}

export function orderCouponMy(data) {
return request({
url: `/coupon/myList`,
method: 'get',
params: data
})
}

export function orderReceive(data) {
return request({
url: '/coupon/receive',
method: 'post',
data
})
}
39 changes: 27 additions & 12 deletions src/components/GoodsItem/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
<image-pic
fill="cover"
align="center"
width="180"
height="180"
width="150"
height="150"
:src="img"
/>
</div>
<p class="title">{{ title }}</p>
<!-- <p class="desc">{{ desc }}</p> -->
<div class="num">
<span class="num__now">¥{{ price | yuan }}</span>
<span class="num__old">¥{{ discount | yuan }}</span>
<span class="num__now">¥</span>{{ price | yuan }}
<!-- <span class="num__old">¥{{ discount | yuan }}</span> -->
</div>
<div class="desc">
已售:{{ virtualSales || 0 }}
</div>
<!-- <div class="btn-wrapper">
<van-button class="btn" size="small">立即购买</van-button>
Expand All @@ -24,7 +27,7 @@
<script>
export default {
// eslint-disable-next-line vue/require-prop-types
props: ['goodsId', 'img', 'title', 'desc', 'price', 'discount'],
props: ['goodsId', 'img', 'title', 'desc', 'price', 'discount', 'virtualSales'],
methods: {
onNavigate() {
this.$router.push({
Expand All @@ -42,17 +45,27 @@ export default {
position: relative;
width: 360px;
overflow: hidden;
border-top:1px solid #ebedf0;
border-right: 1px solid #ebedf0;
display: flex;
flex-direction: column;
align-items: center;
&:nth-child(2n+2){
border-right:none;
}
.pic {
display: block;
padding: 14px;
// background: #f5f5f5;
}
.title {
padding: 14px;
margin-bottom: 10px;
height:66px;
max-width: 320px;
font-size: $small;
color: $black;
text-align: center;
@include text-ellipsis;
@include text-multiple-ellipsis;
}
.desc {
padding: 14px;
Expand All @@ -63,14 +76,16 @@ export default {
@include text-ellipsis;
}
.num {
padding-bottom: 14px;
padding-bottom: 25px;
text-align: center;
font-size: 36px;
color: $black;
font-weight: 500;
text-decoration-line: underline;
text-decoration-color: #969799;
.num__now {
font-family: DIN-Medium, DIN;
font-size: 34px;
font-weight: 500;
color: $red;
margin-right: 10px;
font-size: 24px;
}
.num__old {
font-family: DIN-Medium, DIN;
Expand Down
6 changes: 3 additions & 3 deletions src/components/ProductItem/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<van-tag v-if="isHot" type="danger">热品</van-tag>
<van-tag type="success">7天可退</van-tag>
</div>
<div class="sale">
<!-- <div class="sale">
<span class="commom__num">评论2000+条</span>
<span class="praise__rate">70%好评</span>
</div>
</div> -->
</div>
<div class="desc__bottom__btn">
<van-button class="btn" size="mini" @click.stop="onAddCart">加入购物车</van-button>
Expand Down Expand Up @@ -74,7 +74,7 @@ export default {
width: 510px;
height: 240px;
.desc__top {
margin-top: 10px;
margin-top: 30px;
.desc__top__title {
font-size: $small;
color: $black;
Expand Down
4 changes: 3 additions & 1 deletion src/components/Wx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ export async function initWechatWebview() {
jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
})
wx.error(function(res) {
alert('wx error: ' + res)
// alert('wx error: ' + res)
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
})
} catch (e) {
console.log(e)
return false
}
return true
}
Vue.prototype.wxJsSdkInit = initWechatWebview
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import './permission'

// import vant
import '@/components/Vant'
import '@/components/Wx'
// import fontAwesome
import '@/components/fontAwesome'
// register common components globally
Expand Down
3 changes: 2 additions & 1 deletion src/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Toast } from 'vant'
import { getToken } from '@/utils/auth' // get token from cookie
import { pathMatcher } from '@/utils/index'

const whiteList = ['/login', '/registry', '/', '/index', '/category', '/detail/**', '/diamondGoodsList/**', '/search/**'] // 白名单
const whiteList = ['/login', '/registry', '/', '/index', '/category', '/detail/**', '/diamondGoodsList/**', '/search/**', '/order/coupon'] // 白名单

router.beforeEach(async(to, from, next) => {
// 设置标题
Expand Down Expand Up @@ -39,6 +39,7 @@ router.beforeEach(async(to, from, next) => {
}
} else {
if (pathMatcher(whiteList, to.path)) {
console.log(to.path)
next()
} else {
// 反之则去登录页面
Expand Down
22 changes: 21 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const routes = [
{
path: '/registry',
name: 'Registry',
component: () => import('@/views/auth/registry'),
component: () => import('@/views/auth/login'),
meta: {
title: '注册'
}
Expand Down Expand Up @@ -262,6 +262,26 @@ const routes = [
props: true,
component: () => import('@/views/order/payStatus')
},
// 优惠券
{
path: '/order/coupon',
name: 'coupon',
component: () => import('@/views/order/coupon'),
meta: {
title: '优惠券',
showTab: true
}
},
// 优惠券
{
path: '/order/my',
name: 'couponMy',
component: () => import('@/views/order/my'),
meta: {
title: '优惠券',
showTab: true
}
},
// 评论页面
{
path: '/goodsComment/:orderGoodsId/:goodsId',
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const mutations = {
const actions = {
// 登录
login({ commit }, userInfo) {
const { mobile, password } = userInfo
const { mobile, yzm } = userInfo
return new Promise((resolve, reject) => {
login({ mobile, password })
login({ mobile, yzm })
.then(res => {
const { data } = res
commit('SET_TOKEN', data)
Expand Down
3 changes: 3 additions & 0 deletions src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ service.interceptors.response.use(
if (res.code === 5001) {
return Promise.reject(new Error(res.msg || 'Error'))
}
if (res.code === 50148) {
return res
}
Toast.fail(res.msg)
return Promise.reject(new Error(res.msg || 'Error'))
} else {
Expand Down
Loading

0 comments on commit 8952fab

Please sign in to comment.