代码优化

master
wayn 1 year ago
parent 06a3cb5666
commit cc1c6a7d9d

@ -3,12 +3,4 @@ ENV = 'development'
# base api
VUE_APP_BASE_API = '/dev-api'
VUE_APP_BASE_PATH = '/mall'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
# It only does one thing by converting all import() to require().
# This configuration can significantly increase the speed of hot updates,
# when you have a large number of pages.
# Detail: https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
VUE_CLI_BABEL_TRANSPILE_MODULES = true
VUE_APP_BASE_URL = 'http://localhost:82'

@ -3,4 +3,4 @@ ENV = 'production'
# base api
VUE_APP_BASE_API = '/mobile-api'
VUE_APP_BASE_PATH = '/mall'
VUE_APP_BASE_URL = 'http://localhost:82'

@ -11,7 +11,15 @@ export function getGoodsList(query) {
export function getHomeData(data) {
return request({
url: '/home/index',
method: 'post',
method: 'get',
data
})
}
export function getMallConfig(data) {
return request({
url: '/home/mallConfig',
method: 'get',
data
})
}

@ -12,6 +12,7 @@
<span class="comment_name">{{ name }}</span>
<van-rate
v-model="score"
readonly
:size="15"
:color="variables.red"
void-icon="star"

@ -48,6 +48,10 @@ service.interceptors.response.use(
})
})
}
// 订单轮询
if (res.code === 5002) {
return Promise.reject(new Error(res.msg || 'Error'))
}
Toast.fail(res.msg)
return Promise.reject(new Error(res.msg || 'Error'))
} else {

@ -17,8 +17,7 @@
:rules="[
{
validator: checkPhone,
required: true,
message: '请填写正确的手机号!',
required: true
},
]"
/>
@ -32,7 +31,7 @@
name="密码"
label="密码"
placeholder="请输入密码"
:rules="[{ required: true, message: '请填写密码!' }]"
:rules="[{ required: true }]"
/>
<div style="margin: 36px">

@ -19,6 +19,7 @@
:stock-num="stockNum"
:name="name"
:attr="attributes"
:freight-limit="mallConfig.freightLimit"
@input="isSkuShow = $event"
/>
@ -51,6 +52,7 @@
<script>
import { getDetail } from '@/api/detail'
import { getMallConfig } from '@/api/home'
import { getCommentList, getCommentTagNum } from '@/api/comment'
import Swiper from './modules/Swiper'
import Overview from './modules/Overview'
@ -86,6 +88,7 @@ export default {
banner: [],
goods: {},
info: {},
mallConfig: {},
name: '',
//
stockNum: 1,
@ -104,8 +107,15 @@ export default {
mounted() {
this.getGoodsDetail()
this.getCommentInfo()
this.getMallConfig()
},
methods: {
getMallConfig() {
getMallConfig().then(res => {
const { map } = res
this.mallConfig = map
})
},
getGoodsDetail() {
getDetail(this.goodsId).then((res) => {
const goods = res.map

@ -15,7 +15,7 @@
:value="selectedAddress.address || '选择收货地址'"
@click="handleAddress"
/>
<van-cell title="运费" value="88元" />
<van-cell title="运费" :value="`满${freightLimit}元免运费`" />
</van-cell-group>
</div>
<!-- <van-button block @click="onSelectSku">
@ -98,6 +98,10 @@ export default {
type: Number,
default: 4
},
freightLimit: {
type: Number,
default: 88
},
attr: {
type: Array,
default() {

@ -3,7 +3,7 @@
<Header />
<Swiper :banner-list="bannerList" />
<Category :cate-list="cateList" />
<Session :session-list="sessionList" />
<!-- <Session :session-list="sessionList" /> -->
<Goods-limit
v-model="isLoading"
title-name="新品上线"
@ -38,7 +38,7 @@ import Swiper from './modules/Swiper'
import Goods from './modules/GoodsVantCard'
import GoodsLimit from './modules/GoodsLimit'
import Category from './modules/Category'
import Session from './modules/Session'
// import Session from './modules/Session'
import Skeleton from './modules/Skeleton'
export default {
@ -47,13 +47,14 @@ export default {
Header,
Swiper,
Category,
Session,
// Session,
Goods,
GoodsLimit,
Skeleton
},
data() {
return {
mallConfig: {},
bannerList: [],
cateList: [],
sessionList: [],

@ -2,7 +2,7 @@
<div class="list-item">
<h3 class="title">
<van-icon name="shop-o" />
<span class="title__name">熊猫商城自营</span>
<span class="title__name">商城自营</span>
</h3>
<div v-for="(item, idx) in goodsList" :key="idx" class="item">
<image-pic width="80" height="80" fit="fill" :src="item.picUrl" />
@ -24,10 +24,10 @@
</div>
<van-cell-group>
<van-cell title="商品金额">
<span class="red">{{ amount }} </span>
<span class="red">{{ goodsAmount }} </span>
</van-cell>
<van-cell title="费">
<span class="red">0 </span>
<van-cell title="费">
<span class="red">{{ freightPrice }} </span>
</van-cell>
<van-cell title="优惠券">
<span class="red">不可用</span>
@ -38,7 +38,7 @@
</van-cell-group>
<van-submit-bar
:price="amount * 100"
:price="orderTotalAmount * 100"
label="总计:"
button-text="提交订单"
:disabled="false"
@ -55,10 +55,12 @@ export default {
data() {
return {
message: '',
amount: 0,
goodsAmount: 0,
orderTotalAmount: 0,
goodsList: [],
orderSn: undefined,
actualPrice: 0,
freightPrice: 0,
retryCount: 6, //
retryInterval: 300 //
}
@ -75,9 +77,11 @@ export default {
getGoodsList() {
this.goodsList = []
getCheckedGoods().then((res) => {
const { data, amount } = res.map
const { data, orderTotalAmount, goodsAmount, freightPrice } = res.map
this.goodsList = data
this.amount = amount
this.goodsAmount = goodsAmount
this.orderTotalAmount = orderTotalAmount
this.freightPrice = freightPrice
})
},
onSubmit() {

@ -14,6 +14,7 @@
<div>下单时间: {{ orderInfo.createTime }}</div>
<div>支付方式: {{ orderInfo.payTypeText }}</div>
<div>支付时间: {{ orderInfo.payTime }}</div>
<div> : {{ orderInfo.freightPrice | yuan }}</div>
<div>订单金额: {{ orderInfo.orderPrice | yuan }}</div>
<div>实付金额: {{ orderInfo.actualPrice | yuan }}</div>
<div>收货地址: {{ orderInfo.address }}</div>

@ -2,7 +2,7 @@
const path = require('path')
const port = process.env.port || process.env.npm_config_port || 4949
const mockUrl = 'http://127.0.0.1:82'
const baseUrl = process.env.VUE_APP_BASE_URL
function resolve(dir) {
return path.join(__dirname, dir)
@ -23,12 +23,17 @@ module.exports = {
},
proxy: {
'/dev-api': {
target: mockUrl,
target: baseUrl,
pathRewrite: {
'^/dev-api': '/'
},
secure: false,
changeOrigin: true
},
'upload': {
target: baseUrl,
secure: false,
changeOrigin: true
}
}
},

Loading…
Cancel
Save