msb_beta
ch 2 years ago
parent d663e6d9da
commit 67c9765f68

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

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

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

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

Loading…
Cancel
Save