msb_beta
ch 2 years ago
parent d663e6d9da
commit 67c9765f68

@ -2,14 +2,14 @@
* @Author: ch
* @Date: 2022-03-17 17:42:32
* @LastEditors: ch
* @LastEditTime: 2022-04-29 17:06:35
* @LastEditTime: 2022-04-29 17:56:21
* @Description: 项目接口请求统一处理器返回一个需要token和不需要token的请求封装方法
*/
import MsbUniRequest from '@/common/plugins/msbUniRequest';
import $store from '@/common/store';
const ENV = 'prod';
const ENV = 'test';
const BASE_URL = {
'test' : 'https://k8s-horse-gateway.mashibing.cn',
'dev' : '',
@ -29,7 +29,8 @@ const successIntercept = (response, option) =>{
return result.data;
}
if(result.code === 'TOKEN_FAIL'){
uni.navigateTo({url : '/login'})
uni.navigateTo({url : '/login'});
$store.commit('SET_TOKEN', '');
return result;
}
return Promise.reject(result);
@ -106,13 +107,7 @@ MsbRequestTk.use('request', (option) => {
if(!token){
// 登录状态处理没有token直接跳转至登录
uni.redirectTo({
url: '/login',
success(res){
console.log(res,'s');
},
fail (e){
console.log(e,'e');
}
url: '/login'
});
return Promise.reject({message:'要先登录才能操作哦~'});
}else{

@ -25,24 +25,33 @@
<!-- 购物车商品列表 -->
<template v-else >
<UiWhiteBox class="cart-item" v-for="(item, index) in list" :key="index" >
<label class="cart-item--radio" @click.stop="handleCheckItem(item.id)">
<label class="cart-item--radio" @click.stop="handleCheckItem(item.id, item.status)">
<radio class="radio" color="#FF875B"
:checked="checkedIds.length ? checkedIds.includes(item.id) : false" />
:checked="checkedIds.length ? checkedIds.includes(item.id) : false"
:disabled="item.status !== 'normal'"/>
</label>
<image class="cart-item--image" :src="item.product.mainPicture" mode="scaleToFill"
@click="$Router.push(`/goodsDetail?id=${item.productId}`)"></image>
<view class="cart-item--content" @click="$Router.push(`/goodsDetail?id=${item.productId}`)">
<view class="cart-item--title">{{ item.product.name }}</view>
<view class="cart-item--props">{{ item.productSku.name }}</view>
<view class="cart-item--footer">
<UiMoney class="cart-item--price" :money="item.productSku.sellPrice" prefix></UiMoney>
<view class="cart-item--stepper">
<u-number-box :min="1" button-size="40rpx" bgColor="#F5F6FA"
:value="item.number" :max="item.maxBuyNum" @change="onChangeStepper($event, item)" >
<text slot="minus" class="cart-item--stepper-icon">-</text>
<text slot="plus" class="cart-item--stepper-icon">+</text>
</u-number-box>
<view class="cart-item--title" :class="item.status !== 'normal' && 'cart-item--title__disabled'">{{ item.product.name }}</view>
<view v-if="item.status === 'notSku'" class="cart-item--props"></view>
<view v-if="item.status === 'isDisable'" class="cart-item--props"></view>
<template v-if="item.status === 'normal'">
<view class="cart-item--props">{{ item.productSku.name }}</view>
<view class="cart-item--footer">
<UiMoney class="cart-item--price" :money="item.productSku.sellPrice" prefix></UiMoney>
<view class="cart-item--stepper">
<u-number-box :min="1" button-size="40rpx" bgColor="#F5F6FA"
:value="item.number" :max="item.maxBuyNum" @change="onChangeStepper($event, item)" >
<text slot="minus" class="cart-item--stepper-icon">-</text>
<text slot="plus" class="cart-item--stepper-icon">+</text>
</u-number-box>
</view>
</view>
</template>
<view>
<UiButton size="small" class="cart-item--reset-btn" type="line">重新选择</UiButton>
</view>
</view>
</UiWhiteBox>
@ -170,6 +179,9 @@ export default {
const maxBuyNum = singleBuyLimit ? Math.min(singleBuyLimit, stock || 1) : stock
return {
...item,
status : item.product.isEnable ?
(!item.productSku || item.productSku.stock == 0) ? 'notSku': 'normal' :
'isDisable',
maxBuyNum
}
});
@ -236,7 +248,10 @@ export default {
/**
* 选中商品
*/
handleCheckItem(cartId) {
handleCheckItem(cartId, status) {
if(status !== 'normal'){
return false;
}
const { checkedIds } = this
const index = checkedIds.findIndex(id => id === cartId)
index < 0 ? checkedIds.push(cartId) : checkedIds.splice(index, 1)
@ -246,8 +261,9 @@ export default {
* 全选事件
*/
handleCheckAll() {
const { checkedIds, list } = this
this.checkedIds = checkedIds.length === list.length ? [] : list.map(item => item.id)
const { checkedIds, list } = this;
this.checkedIds = checkedIds.length === list.length ? [] :
list.filter(i => i.status == 'normal').map(item => item.id);
},
/**
@ -374,6 +390,9 @@ export default {
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:2;
&__disabled{
color: $color-grey3;
}
}
@ -404,6 +423,10 @@ export default {
height:40rpx;
margin: 0 14rpx;
}
&--reset-btn{
margin-top: 22rpx;
float: right;
}
}
//

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-22 15:36:46
* @LastEditors: ch
* @LastEditTime: 2022-04-29 00:11:21
* @LastEditTime: 2022-04-29 17:12:13
* @Description: file content
-->
<template>
@ -24,8 +24,8 @@
</u-form-item>
</u--form>
<UiButton class="login--btn" type="gradual" size="max" @click="login"></UiButton>
<label class="login--agreement">
<radio class="radio" :checked="checked" @click="checked = !checked" color="#FF875B"/>
<label class="login--agreement" @click="checked = !checked">
<radio class="radio" :checked="checked" color="#FF875B"/>
同意<text class="link">用户协议</text><text class="link">隐私协议</text>首次登录将自动注册
</label>
</view>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-20 14:14:53
* @LastEditors: ch
* @LastEditTime: 2022-04-29 16:58:05
* @LastEditTime: 2022-04-29 17:25:32
* @Description: file content
-->
<template>
@ -86,29 +86,28 @@ export default {
},
onLoad(){
//
uni.$on('changeAddress',(item, type)=>{
if(type == 'submitOrder'){
this.address = item;
}
uni.$on('changeAddress',(item)=>{
this.address = item;
this.getBeforeOrder();
});
//
this.address = this.$store.state.address.find(i => i.isDefault) || {};
},
onShow(){
//
this.address = this.$store.state.address.find(i => i.isDefault) || {};
this.getBeforeOrder();
},
methods:{
/**
* 获取预订单信息将要提交的订单信息
*/
async getBeforeOrder(addressId){
async getBeforeOrder(){
const query = this.$Route.query;
let res = {};
//
if(query.mode === 'cart'){
res = await ApiGetBeforeCartOrder({
cartIds: query.ids,
recipientAddressId : addressId
recipientAddressId : this.address.id
})
}
//
@ -120,7 +119,7 @@ export default {
activityTimeId : query.activityTimeId,
// 1 2
activityType : query.activityType,
recipientAddressId : addressId
recipientAddressId : this.address.id
});
}
if(res.error){

Loading…
Cancel
Save