提交 3b58d490 authored 作者: 刘旭's avatar 刘旭

提交完成代码

上级 8c65f22b
import { request } from '@/utils/request' import { request } from '@/utils/request';
// 产品线加入购物车 // 产品线加入购物车
export const addProductLineCart = (data: any) => request('/wx/productLine/cart', 'POST', data) export const addProductLineCart = (data: any) => request('/wx/productLine/cart', 'POST', data);
// 产品线收藏 // 产品线收藏
export const productLineCollect = (data: any) => request('/wx/productLine/collect', 'POST', data) export const productLineCollect = (data: any) => request('/wx/productLine/collect', 'POST', data);
// 产品线取消收藏或重新收藏 // 产品线取消收藏或重新收藏
export const delProductLineCollect = (data: any) => request('/wx/collect/addordelete', 'POST', data) export const delProductLineCollect = (data: any) =>
request('/wx/collect/addordelete', 'POST', data);
// 产品线点击购买 // 产品线点击购买
export const productLineByuNow = (data: any) => request('/wx/cart/fastadd', 'POST', data) export const productLineByuNow = (data: any) => request('/wx/cart/fastadd', 'POST', data);
// 产品线点击购买后获取数据 // 产品线点击购买后获取数据
export const getProductLineByuNowData = (data: any) => request('/wx/cart/checkout', 'GET', data) export const getProductLineByuNowData = (data: any) => request('/wx/cart/checkout', 'GET', data);
// 产品线点击购买后获取数据 // 产品线点击购买后获取数据
export const getProductLineIndex = (data: any) => request('/wx/productLine/index', 'GET', data) export const getProductLineIndex = (data: any) => request('/wx/productLine/index', 'GET', data);
\ No newline at end of file
// 产品线-删除组成商品
export const getProductLineItemDelete = (data: any) =>
request('/wx/productLine/item/delete', 'POST', data);
// 产品线-组成商品重新选择规格
export const getProductLineItemReadd = (data: any) =>
request('/wx/productLine/item/readd', 'POST', data);
// 产品线-删除组成商品
export const getProductLineItemAdd = (data: any) =>
request('/wx/productLine/item/add', 'POST', data);
// 产品线-删除组成商品
export const getProductLineReAdd = (data: any) =>
request('/wx/productLine/reAdd', 'POST', data);
...@@ -23,3 +23,9 @@ export const consigneeList = (data?: any) => request('/wx/address/consignee', 'G ...@@ -23,3 +23,9 @@ export const consigneeList = (data?: any) => request('/wx/address/consignee', 'G
// 查询每个状态订单数 // 查询每个状态订单数
export const orderCount = () => request('/wx/user/index', 'GET'); export const orderCount = () => request('/wx/user/index', 'GET');
// 更新发货地址
export const resetWorkAddr = (data: any) => request('/wx/auth/reset_work_addr', 'POST', data);
// 更新手机号
export const resetMobile = (data: any) => request('/wx/auth/reset_mobile', 'POST', data);
...@@ -24,20 +24,23 @@ ...@@ -24,20 +24,23 @@
v-if="type === 0" v-if="type === 0"
width="140rpx" width="140rpx"
height="200rpx" height="200rpx"
:src=" :src="baseUrl + item.picUrl"
item.picUrl?.split('http').length > 1
? item.picUrl
: baseUrl + item.picUrl
"
class="img" class="img"
></u-image> ></u-image>
</u-col> </u-col>
<u-col :span="delCircle ? 7 : 5" class="details"> <u-col
<view>{{ item.goodsName }}</view> :span="delCircle ? 7 : 5"
<view class="details"
class="b-tag" @tap="
:style="delCircle ? 'margin-bottom: 26%;' : 'margin-bottom: 40%;'" delCircle
? () => {
return;
}
: togoods(item)
"
> >
<view>{{ item.goodsName }}</view>
<view class="b-tag">
<block <block
v-for="(item1, index1) in item.specifications?.length" v-for="(item1, index1) in item.specifications?.length"
:key="index1" :key="index1"
...@@ -50,6 +53,19 @@ ...@@ -50,6 +53,19 @@
/> />
</block> </block>
</view> </view>
<view v-if="item.partList?.length !== 0" class="b-tag">
<block
v-for="(item1, index1) in item.partList?.length"
:key="index1"
>
<u-tag
:text="item.partList[index1]"
type="warning"
size="mini"
style="margin: 8rpx 8rpx 8rpx 0;"
/>
</block>
</view>
</u-col> </u-col>
<u-col v-if="delCircle" :span="1"> <u-col v-if="delCircle" :span="1">
<view class="circle" @tap="deleteCart(index)"> <view class="circle" @tap="deleteCart(index)">
...@@ -85,16 +101,21 @@ ...@@ -85,16 +101,21 @@
v-if="type === 0" v-if="type === 0"
width="140rpx" width="140rpx"
height="200rpx" height="200rpx"
:src=" :src="baseUrl + item.picUrl"
item.picUrl?.split('http').length > 1
? item.picUrl
: baseUrl + item.picUrl
"
class="img" class="img"
></u-image> ></u-image>
</u-col> </u-col>
<u-col :span="7"> <u-col :span="7">
<view class="details"> <view
class="details"
@tap="
item.deleted
? () => {
return;
}
: togoods(item)
"
>
<view>{{ item.goodsName }}</view> <view>{{ item.goodsName }}</view>
<view style="color: #ccc; margin-top: 20%;"> <view style="color: #ccc; margin-top: 20%;">
{{ item.message }} {{ item.message }}
...@@ -250,7 +271,6 @@ const tapOptions = () => { ...@@ -250,7 +271,6 @@ const tapOptions = () => {
let flag = cartList.value.every((item: any) => { let flag = cartList.value.every((item: any) => {
return item.checked === false; return item.checked === false;
}); });
console.log(flag);
if (flag) if (flag)
return uni.showToast({ return uni.showToast({
title: '请先选择购买商品', title: '请先选择购买商品',
...@@ -279,6 +299,15 @@ const tapOptions = () => { ...@@ -279,6 +299,15 @@ const tapOptions = () => {
} }
}; };
let togoods = (data: any) => {
if (type.value === 0)
uni.navigateTo({ url: '../goods/index?id=' + data.goodsId + '&cartId=' + data.id });
else
uni.reLaunch({
url: '../productLine/productLine?id=' + data.goodsId + '&cartId=' + data.id,
});
};
// 确认删除 // 确认删除
const onConfirm = () => { const onConfirm = () => {
if (delIds.value) { if (delIds.value) {
...@@ -302,14 +331,6 @@ const onConfirm = () => { ...@@ -302,14 +331,6 @@ const onConfirm = () => {
checkedGoods.value = getCheckedList(cartList.value); checkedGoods.value = getCheckedList(cartList.value);
totalPrice.value = res.data.data.cartTotal.checkedGoodsAmount.toFixed(2); totalPrice.value = res.data.data.cartTotal.checkedGoodsAmount.toFixed(2);
showModel.show = false; showModel.show = false;
// 批量删除后,check的name属性没有更新,需要刷新当前页面
// uni.reLaunch({
// url: '../cart/index',
// success() {
// type.value = 2;
// initCartIndex(type.value);
// },
// });
} }
}); });
} }
...@@ -338,6 +359,7 @@ const valChange = (e: any, item: any) => { ...@@ -338,6 +359,7 @@ const valChange = (e: any, item: any) => {
goodsId: item.goodsId, goodsId: item.goodsId,
id: item.id, id: item.id,
ids: item.ids, ids: item.ids,
productId: item.productId,
}).then((res: any) => { }).then((res: any) => {
if (res.data.code === 200) initCartIndex(type.value); if (res.data.code === 200) initCartIndex(type.value);
}); });
...@@ -394,7 +416,7 @@ const getCheckedList = (goods: any) => { ...@@ -394,7 +416,7 @@ const getCheckedList = (goods: any) => {
onShow(() => { onShow(() => {
initCartIndex(type.value); initCartIndex(type.value);
type.value = 0; // type.value = 0;
}); });
</script> </script>
...@@ -406,6 +428,7 @@ onShow(() => { ...@@ -406,6 +428,7 @@ onShow(() => {
background-color: #fff; background-color: #fff;
.details { .details {
width: 55%; width: 55%;
min-height: 200rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: self-start !important; align-items: self-start !important;
......
...@@ -40,6 +40,11 @@ let detailId = ref() ...@@ -40,6 +40,11 @@ let detailId = ref()
let selectedGoodsItem = ref('') let selectedGoodsItem = ref('')
let selectedGoodsSum = ref(1) let selectedGoodsSum = ref(1)
let emits = defineEmits(['selected', 'addProduct', 'close-sku','partsClose']) let emits = defineEmits(['selected', 'addProduct', 'close-sku','partsClose'])
let props = defineProps({
cartId : {
type: Number
}
})
watch([selectedGoodsItem, selectedGoodsSum],(newVal)=> { watch([selectedGoodsItem, selectedGoodsSum],(newVal)=> {
if(newVal) { if(newVal) {
...@@ -160,7 +165,7 @@ let addCartFn = (obj: any) => { ...@@ -160,7 +165,7 @@ let addCartFn = (obj: any) => {
specifications = shop.selectShop.sku_name_arr specifications = shop.selectShop.sku_name_arr
specificationCustom = shop.customArr specificationCustom = shop.customArr
} }
addCart({ let data = {
goodsId: detailId.value, goodsId: detailId.value,
number: selectShop.buy_num, number: selectShop.buy_num,
productId: productId, productId: productId,
...@@ -168,7 +173,9 @@ let addCartFn = (obj: any) => { ...@@ -168,7 +173,9 @@ let addCartFn = (obj: any) => {
specifications, specifications,
specificationCustom, specificationCustom,
partIds: partsIds.value partIds: partsIds.value
}).then((res: any) => { }
if(props.cartId) data = { ...{id: props.cartId }, ...data }
addCart(data).then((res: any) => {
if(res.data.code === 200) { if(res.data.code === 200) {
uni.showToast({ uni.showToast({
title: '已添加至购物车', title: '已添加至购物车',
...@@ -198,7 +205,7 @@ let addCarts = (selectShop: any) => { ...@@ -198,7 +205,7 @@ let addCarts = (selectShop: any) => {
}; };
// 立即购买 // 立即购买
let buyNow = (selectShop: any) => { let buyNow = (selectShop: any) => {
console.log(selectShop, selectShop.sku_name_arr ,' selectShop.sku_name_arr'); // console.log(selectShop, selectShop.sku_name_arr ,' selectShop.sku_name_arr');
let productId: any = getProductId(selectShop.sku_name_arr) let productId: any = getProductId(selectShop.sku_name_arr)
let shop = custom(selectShop) let shop = custom(selectShop)
let specifications: any = [] let specifications: any = []
......
...@@ -74,7 +74,6 @@ ...@@ -74,7 +74,6 @@
show-with-animation show-with-animation
lazy-load lazy-load
selectable selectable
@imgtap="imgtap"
/> />
<u-empty v-else text="暂无数据" mode="data" /> <u-empty v-else text="暂无数据" mode="data" />
</view> </view>
...@@ -112,7 +111,12 @@ ...@@ -112,7 +111,12 @@
</u-popup> </u-popup>
</view> </view>
<goodsSku ref="goodsSkuRef" @selected="selected" @partsClose="partsClose"></goodsSku> <goodsSku
ref="goodsSkuRef"
:cartId="cartId"
@selected="selected"
@partsClose="partsClose"
></goodsSku>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
...@@ -153,8 +157,10 @@ const buttonGroup = ref([ ...@@ -153,8 +157,10 @@ const buttonGroup = ref([
]); ]);
const detailId = ref() const detailId = ref()
const cartId = ref() // 判断是否从购物车进去修改购物车信息的购物车Id
onLoad((options: any) => { onLoad((options: any) => {
if(typeof options.cartId !== 'undefined') cartId.value = options.cartId
detailId.value = options.id detailId.value = options.id
// 在结算中返回时使用 // 在结算中返回时使用
uni.setStorage({ uni.setStorage({
...@@ -183,13 +189,6 @@ let selectedGoods = computed(() => { ...@@ -183,13 +189,6 @@ let selectedGoods = computed(() => {
} else return '' } else return ''
}) })
// #ifdef H5
const imgtap = () => {
}
// #endif
const selected = (data: any) => { const selected = (data: any) => {
selectedGoodsItem.value = data[0] selectedGoodsItem.value = data[0]
selectedGoodsSum.value = data[1] selectedGoodsSum.value = data[1]
...@@ -303,7 +302,7 @@ const initDetails = (id: number) => { ...@@ -303,7 +302,7 @@ const initDetails = (id: number) => {
res.data.data.info.detail = res.data.data.info.detail.replace(/<img/g,"<img style='display: block'") res.data.data.info.detail = res.data.data.info.detail.replace(/<img/g,"<img style='display: block'")
res.data.data.info.detail = res.data.data.info.detail.replace(/<video/g,"<video preload='auto'") res.data.data.info.detail = res.data.data.info.detail.replace(/<video/g,"<video preload='auto'")
detailData.value = res.data.data; detailData.value = res.data.data;
console.log(detailData.value, '商品详情数据'); // console.log(detailData.value, '商品详情数据');
} }
}); });
} }
...@@ -581,6 +580,7 @@ const initParts = (id: number) => { ...@@ -581,6 +580,7 @@ const initParts = (id: number) => {
.right { .right {
padding: 20rpx 0; padding: 20rpx 0;
font-weight: 600;
// overflow: hidden; // overflow: hidden;
// text-overflow: ellipsis; /* 超出部分省略号 */ // text-overflow: ellipsis; /* 超出部分省略号 */
// word-break: break-all; /* break-all(允许在单词内换行。) */ // word-break: break-all; /* break-all(允许在单词内换行。) */
......
...@@ -216,6 +216,10 @@ initIndex(); ...@@ -216,6 +216,10 @@ initIndex();
</script> </script>
<style lang="scss"> <style lang="scss">
// page {
// filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
// -webkit-filter: grayscale(100%);
// }
.grid { .grid {
padding: 16rpx; padding: 16rpx;
.grid-text { .grid-text {
......
...@@ -18,7 +18,7 @@ import { reactive } from 'vue'; ...@@ -18,7 +18,7 @@ import { reactive } from 'vue';
import { login } from '@/api/login'; import { login } from '@/api/login';
import inputLogin from '@/components/inputLogin.vue'; import inputLogin from '@/components/inputLogin.vue';
let inputData = reactive({ let inputData = reactive({
inputValue: '15616168157' as any, inputValue: '13517855555' as any,
iconfont: 'icon-a-ziyuan16', iconfont: 'icon-a-ziyuan16',
placeholder: '手机号码', placeholder: '手机号码',
type: 'text', type: 'text',
...@@ -64,9 +64,7 @@ let clickNextStep = () => { ...@@ -64,9 +64,7 @@ let clickNextStep = () => {
let initLogin = async (mobile: number, password: string) => { let initLogin = async (mobile: number, password: string) => {
uni.clearStorage(); uni.clearStorage();
let res: any = await login({ mobile, password }); let res: any = await login({ mobile, password });
console.log(res, 'res');
if (res.data.code === 200) { if (res.data.code === 200) {
console.log('2000');
uni.setStorage({ uni.setStorage({
key: 'token', key: 'token',
data: res.data.data.token, data: res.data.data.token,
...@@ -103,7 +101,7 @@ let initLogin = async (mobile: number, password: string) => { ...@@ -103,7 +101,7 @@ let initLogin = async (mobile: number, password: string) => {
duration: 2000, duration: 2000,
}); });
} }
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
</view> </view>
<view class="sum-price"> <view class="sum-price">
<!-- <text>{{ item.price.toFixed(2) }}</text> -->
<text></text> <text></text>
<text style="color: #969799; font-size: 12px;">x{{ item.number }}</text> <text style="color: #969799; font-size: 12px;">x{{ item.number }}</text>
</view> </view>
...@@ -55,10 +54,6 @@ ...@@ -55,10 +54,6 @@
<!-- list --> <!-- list -->
<view class="list"> <view class="list">
<!-- <view class="item-list">
<view class="label">商品金额</view>
<view class="item-price">{{ buyNowData?.goodsTotalPrice.toFixed(2) }}</view>
</view> -->
<view class="item-list-end"> <view class="item-list-end">
<view class="label">订单备注</view> <view class="label">订单备注</view>
<u-input v-model="remarks" /> <u-input v-model="remarks" />
...@@ -68,12 +63,6 @@ ...@@ -68,12 +63,6 @@
<!-- 提交订单 --> <!-- 提交订单 -->
<view class="footer"> <view class="footer">
<view> <view>
<!-- <text style="font-size: 30rpx;">总计</text>
<text
style="margin-right: 24rpx; color: #ee0a24; font-size: 30rpx; font-weight: 600;"
>
{{ buyNowData?.orderTotalPrice.toFixed(2) }}
</text> -->
<u-button type="error" size="medium" shape="circle" @tap="onsubmit">结算</u-button> <u-button type="error" size="medium" shape="circle" @tap="onsubmit">结算</u-button>
</view> </view>
</view> </view>
...@@ -81,12 +70,12 @@ ...@@ -81,12 +70,12 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onShow, onLoad } from '@dcloudio/uni-app'; import { onLoad, onBackPress } from '@dcloudio/uni-app';
import { ref } from 'vue'; import { ref } from 'vue';
import { checkoutCart, orderSubmit } from '@/api/index'; import { checkoutCart, orderSubmit } from '@/api/index';
import config from '@/utils/config'; import config from '@/utils/config';
let baseUrl = config.baseUrl; const baseUrl = config.baseUrl;
const buyNowId = ref(); const buyNowId = ref();
const buyNowData = ref(); const buyNowData = ref();
const remarks = ref(); // 订单备注 const remarks = ref(); // 订单备注
...@@ -114,8 +103,17 @@ onLoad((options: any) => { ...@@ -114,8 +103,17 @@ onLoad((options: any) => {
console.log(type.value, '.type'); console.log(type.value, '.type');
}); });
onShow(() => { onBackPress((options: any) => {
if (options.from === 'backbutton' && type.value === 'productLineCart') {
let pages = getCurrentPages(); // 当前页面
let beforePage: any = pages[pages.length - 2]; // 上一页
beforePage.type = 2; // 执行上一页的onLoad方法
}
if (options.from === 'backbutton' && type.value === 'cart') {
let pages = getCurrentPages(); // 当前页面
let beforePage: any = pages[pages.length - 2]; // 上一页
beforePage.type = 0; // 执行上一页的onLoad方法
}
}); });
// 设置地址 // 设置地址
...@@ -127,6 +125,12 @@ const tapAddresss = () => { ...@@ -127,6 +125,12 @@ const tapAddresss = () => {
// 结算 // 结算
const onsubmit = () => { const onsubmit = () => {
if (uni.getStorageSync('addressId') === 0)
return uni.showToast({
title: '请设置收货地址',
icon: 'none',
});
console.log(uni.getStorageSync('addressId') === 0);
let types = 0; let types = 0;
if (type.value === 'productline' || type.value === 'productLineCart') types = 2; if (type.value === 'productline' || type.value === 'productLineCart') types = 2;
else types = 0; else types = 0;
...@@ -167,6 +171,10 @@ const initCheckoutCart = (cartId: number, types: number) => { ...@@ -167,6 +171,10 @@ const initCheckoutCart = (cartId: number, types: number) => {
}).then((res: any) => { }).then((res: any) => {
if (res.data.code === 200) { if (res.data.code === 200) {
buyNowData.value = res.data.data; buyNowData.value = res.data.data;
uni.setStorage({
key: 'addressData',
data: res.data.data.checkedAddress,
});
let storage: any = { let storage: any = {
addressId: res.data.data.addressId, addressId: res.data.data.addressId,
cartId: res.data.data.cartId, cartId: res.data.data.cartId,
...@@ -179,13 +187,13 @@ const initCheckoutCart = (cartId: number, types: number) => { ...@@ -179,13 +187,13 @@ const initCheckoutCart = (cartId: number, types: number) => {
data: el, data: el,
}); });
}); });
console.log(buyNowData.value, '购买数据'); // console.log(buyNowData.value, '购买数据');
} }
}); });
}; };
const init = (type: string) => { const init = () => {
switch (type) { switch (type.value) {
case 'cart': case 'cart':
buyNowId.value = 0; buyNowId.value = 0;
initCheckoutCart(buyNowId.value, 0); initCheckoutCart(buyNowId.value, 0);
......
<template> <template>
<!-- <u-navbar back-text="" title="订单详情" title-color="#000"></u-navbar> -->
<view class="container"> <view class="container">
<block v-for="(item, index) in detailData"> <block v-for="(item, index) in detailData">
<view> <view>
...@@ -29,59 +28,9 @@ ...@@ -29,59 +28,9 @@
/> />
</block> </block>
</view> </view>
<view class="sum-price">
<view style="display: flex; flex-direction: column;">
<view
style="display: flex; flex-direction: row; align-items: center; margin-bottom: 10rpx;"
>
<text>设置单价:</text>
<u-input
v-model="item.unitPrice"
type="number"
height="50"
placeholder="请输入单价"
style="width: 200rpx;"
/>
</view>
<view
style="display: flex; flex-direction: row; align-items: center; margin-bottom: 10rpx;"
>
<text>合同报价:</text>
<u-input
v-model="item.contractQuotation"
type="number"
:disabled="true"
height="50"
placeholder=""
style="width: 200rpx;"
/>
</view>
<view style="margin-bottom: 10rpx;">
金额:¥{{
item.unitPrice
? (Number(item.unitPrice) * item.number).toFixed(2)
: 0
}}
</view>
<view style="margin-bottom: 10rpx;">
含税金额:¥{{
item.unitPrice
? (
Number(item.unitPrice) * item.number +
Number(item.unitPrice) *
item.number *
tax *
0.01
).toFixed(2)
: 0
}}
</view>
</view>
<text style="color: #969799; font-size: 12px;">x{{ item.number }}</text> <text style="color: #969799; font-size: 12px;">x{{ item.number }}</text>
</view> </view>
</view> </view>
</view>
<u-line v-if="detailData.length > 1" color="#e8e8e8" /> <u-line v-if="detailData.length > 1" color="#e8e8e8" />
</view> </view>
</block> </block>
...@@ -103,11 +52,6 @@ ...@@ -103,11 +52,6 @@
</view> </view>
</view> </view>
</view> </view>
<view style="height: 100rpx;"></view>
<view class="footer">
<text>商品总价:¥{{ totlePirce }}</text>
<text>含税商品总价:¥{{ taxTotlePirce }}</text>
</view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
...@@ -115,8 +59,7 @@ import { ref, computed } from 'vue'; ...@@ -115,8 +59,7 @@ import { ref, computed } from 'vue';
import { onLoad, onBackPress } from '@dcloudio/uni-app'; import { onLoad, onBackPress } from '@dcloudio/uni-app';
import config from '@/utils/config'; import config from '@/utils/config';
import { useCurrentStore } from '@/store/useStore'; import { useCurrentStore } from '@/store/useStore';
// import { getOrderPdf } from '@/api/cart'; import { orderDetail } from '@/api/index';
import { orderDetail, getTax } from '@/api/index';
let baseUrl = config.baseUrl; let baseUrl = config.baseUrl;
let currentStore = useCurrentStore(); let currentStore = useCurrentStore();
...@@ -140,7 +83,6 @@ onLoad((options: any) => { ...@@ -140,7 +83,6 @@ onLoad((options: any) => {
console.log(res, '订单详情信息'); console.log(res, '订单详情信息');
}); });
// initPdf(options.orderId); // 查询pdf详细资料 // initPdf(options.orderId); // 查询pdf详细资料
initTax(); // 查询税率
}); });
// 返回首页 // 返回首页
...@@ -152,24 +94,8 @@ let toIndex = () => { ...@@ -152,24 +94,8 @@ let toIndex = () => {
// 生成报价 // 生成报价
let generateQuote = () => { let generateQuote = () => {
let data = [] as any;
let flag = true;
detailData.value.map((item: any) => {
if (typeof item.unitPrice === 'undefined') {
flag = false;
return uni.showToast({
title: `请填写 ${item.goodsName} 单价`,
icon: 'none',
});
} else
data.push({
goodsName: item.goodsName,
unitPrice: item.unitPrice,
});
});
if (flag)
uni.navigateTo({ uni.navigateTo({
url: `./quotation?orderId=${orderId.value}&data=${JSON.stringify(data)}`, url: `./quotation?orderId=${orderId.value}`,
}); });
}; };
...@@ -229,13 +155,6 @@ let download = () => { ...@@ -229,13 +155,6 @@ let download = () => {
// }); // });
// }; // };
// 获取税率
let initTax = () => {
getTax().then((res: any) => {
if (res.data.code === 200) tax.value = Number(res.data.data.mall_tax_rate);
});
};
onBackPress((options: any) => { onBackPress((options: any) => {
if (options.from === 'navigateBack') { if (options.from === 'navigateBack') {
return false; return false;
......
...@@ -62,12 +62,20 @@ ...@@ -62,12 +62,20 @@
</view> </view>
</view> </view>
</u-popup> </u-popup>
<search-popup
ref="searchPopupRef"
:show="showSearchPopup"
@search-close="searchClose"
@cateGoryGoods="cateGoryGoods"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import { getCatalogIndex, getGoodsList } from '@/api/category'; import { getCatalogIndex, getGoodsList } from '@/api/category';
import config from '@/utils/config'; import config from '@/utils/config';
import searchPopup from './searchPopup.vue';
let baseUrl = config.baseUrl; let baseUrl = config.baseUrl;
...@@ -85,6 +93,8 @@ const listQuery = ref({ ...@@ -85,6 +93,8 @@ const listQuery = ref({
let status = ref('loadmore'); let status = ref('loadmore');
let total = ref(0); let total = ref(0);
let emits = defineEmits(['close', 'categoryData']); let emits = defineEmits(['close', 'categoryData']);
const showSearchPopup = ref(false);
const searchPopupRef = ref();
let props = defineProps({ let props = defineProps({
show: { show: {
...@@ -94,7 +104,10 @@ let props = defineProps({ ...@@ -94,7 +104,10 @@ let props = defineProps({
}); });
const search = (val: any) => { const search = (val: any) => {
uni.navigateTo({ url: '../index/search?keyword=' + val.value }); // if (!val.value) return;
searchPopupRef.value.searchQuery.keyword = val.value;
searchPopupRef.value.initList();
showSearchPopup.value = true;
}; };
const cateGoryGoods = (row: any) => { const cateGoryGoods = (row: any) => {
...@@ -145,7 +158,7 @@ const initIndex = () => { ...@@ -145,7 +158,7 @@ const initIndex = () => {
if (listQuery.value.categoryId === 0) if (listQuery.value.categoryId === 0)
listQuery.value.categoryId = categoryList.value[0].id; listQuery.value.categoryId = categoryList.value[0].id;
initGoodsList(listQuery.value); initGoodsList(listQuery.value);
console.log(categoryList.value, '分类数据'); // console.log(categoryList.value, '分类数据');
} }
}); });
}; };
...@@ -165,9 +178,13 @@ let handleClose = () => { ...@@ -165,9 +178,13 @@ let handleClose = () => {
emits('close', false); emits('close', false);
}; };
const searchClose = () => {
showSearchPopup.value = false;
};
defineExpose({ defineExpose({
initIndex, initIndex,
currentSubCategoryData currentSubCategoryData,
}); });
</script> </script>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
@touchstart="handleTouchstart($event, index)" @touchstart="handleTouchstart($event, index)"
@touchmove.prevent="handleTouchmove($event, index)" @touchmove.prevent="handleTouchmove($event, index)"
@touchend="handleTouchend" @touchend="handleTouchend"
@tap="handleTap(index)" @tap="handleTap(index, item)"
style="width: 100%; height: 100%;" style="width: 100%; height: 100%;"
> >
<!-- 自定义内容 --> <!-- 自定义内容 -->
...@@ -142,7 +142,7 @@ export default { ...@@ -142,7 +142,7 @@ export default {
// console.log(tempArray, 'tempArray'); // console.log(tempArray, 'tempArray');
return tempArray; return tempArray;
}, },
handleTap(index) { handleTap(index, item) {
let that = this; let that = this;
// console.log(that.controlsArray, index); // console.log(that.controlsArray, index);
if (index == that.controlsArray.length - 1) return; if (index == that.controlsArray.length - 1) return;
...@@ -155,7 +155,7 @@ export default { ...@@ -155,7 +155,7 @@ export default {
uni.showActionSheet({ uni.showActionSheet({
itemList: ['修改规格', '复制', '删除'], itemList: ['修改规格', '复制', '删除'],
success: function(res) { success: function(res) {
that.sheetChange(res.tapIndex); that.sheetChange(res.tapIndex, item);
}, },
fail: function(res) { fail: function(res) {
console.log(res.errMsg); console.log(res.errMsg);
...@@ -163,7 +163,7 @@ export default { ...@@ -163,7 +163,7 @@ export default {
}); });
}, },
// 点击选择操作 // 点击选择操作
sheetChange(index) { sheetChange(index, item) {
let that = this; let that = this;
switch (index) { switch (index) {
case 0: case 0:
...@@ -173,7 +173,7 @@ export default { ...@@ -173,7 +173,7 @@ export default {
that.$emit('sheet-copy', that.sheetIndex); that.$emit('sheet-copy', that.sheetIndex);
break; break;
case 2: case 2:
that.$emit('sheet-del', that.sheetIndex); that.$emit('sheet-del', that.sheetIndex, item);
break; break;
} }
}, },
......
<template>
<u-popup
v-model="show"
mode="bottom"
length="90%"
:mask-close-able="false"
closeable
@close="handleClose"
>
<view>
<view
style="width: 90%; height: 50px; position: fixed; top: 0; z-index: 1; background-color: #fff;"
>
<uni-search-bar
v-model="searchQuery.keyword"
placeholder="输入搜索商品"
bgColor="#EEEEEE"
clearButton="auto"
cancelButton="none"
@confirm="search"
/>
</view>
<view style="height: 120rpx"></view>
<view v-if="searchList.length !== 0">
<goodsItem
v-for="item in searchList"
:src="item.picUrl"
:name="item.name"
:brief="item.brief"
:counterPrice="item.counterPrice"
:retailPrice="item.retailPrice"
@tap="searchGoods(item)"
/>
<view style="padding-bottom: 40rpx;">
<u-loadmore :status="status" icon-type="flower" @loadmore="loadMore" />
</view>
</view>
<view v-else><u-loadmore status="nomore" icon-type="flower" /></view>
</view>
</u-popup>
</template>
<script lang="ts" setup>
import { ref, reactive } from 'vue';
import { getGoodsList } from '@/api/category';
import goodsItem from '@/components/goodsItem.vue';
let props = defineProps({
show: {
type: Boolean,
default: false,
},
});
let emits = defineEmits(['search-close', 'cateGoryGoods']);
let searchQuery = reactive({
keyword: '',
page: 1,
limit: 10,
categoryId: 0,
});
let status = ref('loadmore');
let total = ref(0);
let searchList = ref([] as any);
let search = (val: any) => {
searchList.value = [];
searchQuery.page = 1;
searchQuery.keyword = val.value;
initList();
};
let searchGoods = (item: any) => {
emits('search-close', false);
emits('cateGoryGoods', item);
};
// 点击加载更多 status = loadmore 时生效
let loadMore = () => {
// 判断是否还有下一页数据
if (searchQuery.page * searchQuery.limit >= total.value) return (status.value = 'nomore');
// // 判断是否正在请求其它数据,如果是,则不发起额外的请求
if (status.value === 'loading') return;
searchQuery.page += 1;
initList();
};
let initList = () => {
status.value = 'loading';
getGoodsList(searchQuery).then((res: any) => {
if (res.data.data.total > 10) status.value = 'loadmore';
else status.value = 'nomore';
if (res.data.code === 200) {
total.value = res.data.data.total;
searchList.value = [...searchList.value, ...res.data.data.list];
}
});
};
let handleClose = () => {
searchList.value = [];
emits('search-close', false);
};
defineExpose({
searchQuery,
initList,
});
</script>
<style></style>
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<view class="u-menu-wrap"> <view class="u-menu-wrap">
<view style="position: fixed; left: 8rpx; top: 6%;"> <view style="position: fixed; left: 8rpx; top: 6%;">
<drag-and-drop-sort <drag-and-drop-sort
v-if="flag"
ref="dragRef" ref="dragRef"
style="display: flex; justify-content: center;" style="display: flex; justify-content: center;"
:controlsList="lineList" :controlsList="lineList"
...@@ -31,7 +32,18 @@ ...@@ -31,7 +32,18 @@
:show-line="scope.row?.show" :show-line="scope.row?.show"
:line-color="scope.row?.show ? '#0000f0' : ''" :line-color="scope.row?.show ? '#0000f0' : ''"
style="margin-left: 20rpx;" style="margin-left: 20rpx;"
></u-section> >
<template
v-if="item?.isSubmit || scope.row.isSubmit !== undefined"
#right
>
<u-icon
name="error-circle-fill"
color="#ff0000"
style="margin-right: 4rpx;"
/>
</template>
</u-section>
<view v-else class="add"> <view v-else class="add">
<u-icon <u-icon
name="plus" name="plus"
...@@ -46,16 +58,13 @@ ...@@ -46,16 +58,13 @@
<view class="left-cates" /> <view class="left-cates" />
<view class="right-cates"> <view class="right-cates">
<view style="width: 80px;"> <view style="width: 80px;">
<!-- <view style="height: 88rpx;"></view> -->
<block v-for="(item, index) in lineList"> <block v-for="(item, index) in lineList">
<u-image <u-image
v-if="index != lineList.length - 1" v-if="index != lineList.length - 1"
width="160rpx" width="160rpx"
mode="widthFix" mode="widthFix"
:src=" :src="baseUrl + item.url"
item.url.split('http').length > 1
? item.url
: baseUrl + item.url
"
></u-image> ></u-image>
</block> </block>
</view> </view>
...@@ -97,10 +106,17 @@ ...@@ -97,10 +106,17 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref, nextTick } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { indexDetails } from '@/api/index'; import { indexDetails } from '@/api/index';
import { useStore } from '@/store/useStore'; import { useStore } from '@/store/useStore';
import { addProductLineCart, productLineCollect, delProductLineCollect } from '@/api/productLine'; import {
addProductLineCart,
productLineCollect,
delProductLineCollect,
getProductLineIndex,
getProductLineReAdd,
} from '@/api/productLine';
import config from '@/utils/config'; import config from '@/utils/config';
import dragAndDropSort from './components/drag-and-drop-sort.vue'; import dragAndDropSort from './components/drag-and-drop-sort.vue';
import categoryPopup from './components/categoryPopup.vue'; import categoryPopup from './components/categoryPopup.vue';
...@@ -123,6 +139,7 @@ let model = ref({ ...@@ -123,6 +139,7 @@ let model = ref({
show: false, show: false,
content: '确定重置所选产品?', content: '确定重置所选产品?',
}); });
let flag = ref(false);
let options = ref([ let options = ref([
{ {
...@@ -147,10 +164,60 @@ let buttonGroup = ref([ ...@@ -147,10 +164,60 @@ let buttonGroup = ref([
}, },
]); ]);
let cartId = ref(); // 修改的产品线id
let lineId = ref(); // 修改的产品线id
onLoad((options: any) => {
// 修改产品线时使用
if (typeof options.cartId !== 'undefined') {
cartId.value = options.cartId;
flag.value = false;
lineId.value = options.id;
// 把加入购物车变成禁用状态
// buttonGroup.value[0].backgroundColor = '#ccc';
initProductLine(options.id);
} else {
flag.value = true;
}
});
// 修改产品线数据初始化
let initProductLine = (lineId: number) => {
store.$patch({
lineData: [{ show: false, status: 0 }],
});
lineList.value = store.lineData;
// 获取产品线详细数据
getProductLineIndex({ lineId }).then((res: any) => {
if (res.data.code === 200) {
// 处理数据
res.data.data.cartList.forEach((item: any) => {
item['name'] = item.goodsName;
item['show'] = false;
item['url'] = item.picUrl;
item['status'] = 1;
});
// 合并数据
store.$patch({
lineData: [...res.data.data.cartList, ...lineList.value],
});
lineList.value = store.lineData;
store.title = res.data.data.lineName;
setTitleRef.value.title = store.title;
// 处理子组件数据更新延迟问题
nextTick(() => {
flag.value = true;
console.log(res.data.data.cartList, store.lineData, lineList.value);
});
}
});
};
let addTabs = () => { let addTabs = () => {
categoryRef.value.currentSubCategoryData = []; categoryRef.value.currentSubCategoryData = [];
showPopup.value = true; showPopup.value = true;
categoryRef.value.initIndex(); categoryRef.value.initIndex();
// console.log(store.lineData);
}; };
// 获取sku隐藏方式 '' 加入后 mask 点击mask部分, close 点击关闭按钮 // 获取sku隐藏方式 '' 加入后 mask 点击mask部分, close 点击关闭按钮
...@@ -166,8 +233,14 @@ let closeSku = (val: string) => { ...@@ -166,8 +233,14 @@ let closeSku = (val: string) => {
if (lineList.value.length === 2) index = 0; if (lineList.value.length === 2) index = 0;
let data = lineList.value[index]; let data = lineList.value[index];
lineList.value.splice(index, 1); lineList.value.splice(index, 1);
lineList.value.splice(editIndex.value.index, 0, data); if (lineId.value) {
console.log(lineList.value, 'lineList.value'); lineEdit.value.productId = data.productId;
lineEdit.value.specificationCustom = data.specificationCustom;
lineEdit.value.specifications = data.specifications;
lineEdit.value.number = data.number;
lineList.value.splice(editIndex.value.index, 0, lineEdit.value);
} else lineList.value.splice(editIndex.value.index, 0, data);
console.log(lineEdit.value);
} }
store.$patch({ store.$patch({
lineData: lineList.value, lineData: lineList.value,
...@@ -182,10 +255,16 @@ let closeSku = (val: string) => { ...@@ -182,10 +255,16 @@ let closeSku = (val: string) => {
let editIndex = ref(); let editIndex = ref();
let editFlag = ref(false); let editFlag = ref(false);
let lineEdit = ref(); // 记录产品线修改的数据
// 产品修改 // 产品修改
let sheetEdit = (index: number) => { let sheetEdit = (index: number) => {
editFlag.value = true; editFlag.value = true;
let data = lineList.value[index]; let data = lineList.value[index];
if (lineId.value) {
data.updateTime = null;
lineEdit.value = data;
}
editIndex.value = { editIndex.value = {
index, index,
data, data,
...@@ -196,8 +275,16 @@ let sheetEdit = (index: number) => { ...@@ -196,8 +275,16 @@ let sheetEdit = (index: number) => {
initDetails(data.goodsId); initDetails(data.goodsId);
}; };
let lineDelete = ref([] as any); // 记录产品线删除数据
// 产品删除 // 产品删除
let sheetDel = (index: number) => { let sheetDel = (index: number) => {
if (lineId.value) {
if (lineList.value[index].hasOwnProperty('deleted')) {
lineList.value[index].deleted = true;
lineDelete.value.push(lineList.value[index]);
}
}
lineList.value.splice(index, 1); lineList.value.splice(index, 1);
store.$patch({ store.$patch({
lineData: lineList.value, lineData: lineList.value,
...@@ -206,16 +293,29 @@ let sheetDel = (index: number) => { ...@@ -206,16 +293,29 @@ let sheetDel = (index: number) => {
// 产品复制 // 产品复制
let sheetCopy = (index: number) => { let sheetCopy = (index: number) => {
flag.value = false;
lineList.value.splice(index, 0, lineList.value[index]); lineList.value.splice(index, 0, lineList.value[index]);
dragRef.value.initControlsPosition(); // 避免splice改变原数组
console.log(lineList.value); let lineInfos = JSON.parse(JSON.stringify(lineList.value));
// lineList.value.forEach((item: any, i: number) => { lineInfos[index].show = false;
// if (index + 1 == i) item.show = true; lineList.value = lineInfos;
// else item.show = false; store.$patch({
// }); lineData: lineInfos,
});
// 通过购物车进入操作时进入
if (lineId.value) {
if (lineList.value[index + 1].hasOwnProperty('deleted'))
delete lineList.value[index + 1].deleted;
if (lineList.value[index + 1].hasOwnProperty('updateTime'))
delete lineList.value[index + 1].updateTime;
if (lineList.value[index + 1].hasOwnProperty('id')) delete lineList.value[index + 1].id;
store.$patch({ store.$patch({
lineData: lineList.value, lineData: lineList.value,
}); });
}
nextTick(() => {
flag.value = true;
});
}; };
// 商品加入购物车等左侧事件 // 商品加入购物车等左侧事件
...@@ -296,6 +396,33 @@ let buttonClick = (e: any) => { ...@@ -296,6 +396,33 @@ let buttonClick = (e: any) => {
// 加入购物车 // 加入购物车
let addCart = () => { let addCart = () => {
complete().then((data: any) => { complete().then((data: any) => {
// 判断是否有失效商品
if (
data.item.some((item: any) => {
return !item.isSubmit && item.isSubmit !== undefined;
})
)
return uni.showToast({
title: '请先删除带红色图标的失效商品',
icon: 'none',
});
if (lineId.value) {
// 修改
data['lineId'] = lineId.value;
// 把删除的数据添加进去
if (lineDelete.value.length !== 0) {
lineDelete.value.map((item: any) => {
data.item.push(item);
});
}
getProductLineReAdd(data).then((res: any) => {
if (res.data.code === 200) {
lineDelete.value = [];
reload();
}
});
} else {
// 添加到购物车
addProductLineCart(data).then((res: any) => { addProductLineCart(data).then((res: any) => {
if (res.data.code === 200) { if (res.data.code === 200) {
uni.showToast({ uni.showToast({
...@@ -305,12 +432,23 @@ let addCart = () => { ...@@ -305,12 +432,23 @@ let addCart = () => {
reload(); reload();
} }
}); });
}
}); });
}; };
// 立即购买 // 立即购买
let buyNow = () => { let buyNow = () => {
complete().then((data: any) => { complete().then((data: any) => {
// 判断是否有失效商品
if (
data.item.some((item: any) => {
return !item.isSubmit && item.isSubmit !== undefined;
})
)
return uni.showToast({
title: '请先删除带红色图标的失效商品',
icon: 'none',
});
addProductLineCart(data).then((res: any) => { addProductLineCart(data).then((res: any) => {
if (res.data.code === 200) { if (res.data.code === 200) {
if (!uni.getStorageSync('addressId')) { if (!uni.getStorageSync('addressId')) {
...@@ -383,6 +521,7 @@ let addProduct = (data: any, productId: number, specifications: any, specificati ...@@ -383,6 +521,7 @@ let addProduct = (data: any, productId: number, specifications: any, specificati
show: false, show: false,
status: 1, status: 1,
}); });
store.$patch({ store.$patch({
lineData: lineList.value, lineData: lineList.value,
}); });
...@@ -401,6 +540,7 @@ let initDetails = (id: number) => { ...@@ -401,6 +540,7 @@ let initDetails = (id: number) => {
if (res.data.code === 200) { if (res.data.code === 200) {
uni.hideLoading(); uni.hideLoading();
detailData.value = res.data.data; detailData.value = res.data.data;
// console.log(detailData.value, 'detailData.value');
goodsSkuRef.value.init(detailData.value, id); goodsSkuRef.value.init(detailData.value, id);
goodsSkuRef.value.skuKey = true; goodsSkuRef.value.skuKey = true;
goodsSkuRef.value.skuMode = 5; goodsSkuRef.value.skuMode = 5;
......
...@@ -2,36 +2,45 @@ ...@@ -2,36 +2,45 @@
<view class="wrap"> <view class="wrap">
<view class="top"> <view class="top">
<view class="item"> <view class="item">
<view class="left">收货人</view> <view class="left">客户名称</view>
<u-select v-model="showSelect" :list="selectList" @confirm="onConfirm"></u-select> <u-select v-model="showSelect" :list="selectList" @confirm="onConfirm"></u-select>
<input <input
:disabled="true" :disabled="true"
v-model="addressData.name" v-model="addressData.name"
placeholder-class="line" placeholder-class="line"
placeholder="请填写收货人姓名" placeholder="请填写客户名称"
@tap="showSelect = true" @tap="showSelect = true"
/> />
</view> </view>
<view class="item"> <view class="item">
<view class="left">联系人</view> <view class="left">采购员</view>
<input <input
type="text" type="text"
v-model="addressData.contactName" v-model="addressData.contactName"
placeholder-class="line" placeholder-class="line"
placeholder="请填写联系人" placeholder="请填写采购员"
/> />
</view> </view>
<view class="item"> <view class="item">
<view class="left">手机号码</view> <view class="left">采购手机号</view>
<input <input
v-model="addressData.tel" v-model="addressData.tel"
type="text" type="text"
placeholder-class="line" placeholder-class="line"
placeholder="请填写收货人手机号" placeholder="请填写采购手机号"
/>
</view>
<view class="item">
<view class="left">采购邮箱</view>
<input
v-model="addressData.customerEmail"
type="text"
placeholder-class="line"
placeholder="请填写采购邮箱"
/> />
</view> </view>
<view class="item" @tap="showRegionPicker"> <view class="item" @tap="showRegionPicker">
<view class="left">所在地</view> <view class="left">所在地</view>
<input <input
v-model="addressDetails" v-model="addressDetails"
disabled disabled
...@@ -99,6 +108,7 @@ let addressData = ref({ ...@@ -99,6 +108,7 @@ let addressData = ref({
isDefault: false, isDefault: false,
name: '', name: '',
contactName: '', contactName: '',
customerEmail: '',
customerCode: '', customerCode: '',
postalCode: '', postalCode: '',
province: '', province: '',
...@@ -169,12 +179,18 @@ let confirmModel = () => { ...@@ -169,12 +179,18 @@ let confirmModel = () => {
let addressSave = () => { let addressSave = () => {
if (!addressData.value.name) if (!addressData.value.name)
return uni.showToast({ return uni.showToast({
title: '请输入收货人', title: '请输入客户名称',
icon: 'none', icon: 'none',
}); });
if (!addressData.value.contactName) if (!addressData.value.contactName)
return uni.showToast({ return uni.showToast({
title: '请输入联系人', title: '请输入采购员',
icon: 'none',
});
let emailReg = /^[a-zA-Z0-9]+([-_.][A-Za-zd]+)*@([a-zA-Z0-9]+[-.])+[A-Za-zd]{2,5}$/
if (!emailReg.test(addressData.value.customerEmail))
return uni.showToast({
title: '邮箱为空或格式不对',
icon: 'none', icon: 'none',
}); });
let reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; let reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
...@@ -233,7 +249,7 @@ let addressDel = () => { ...@@ -233,7 +249,7 @@ let addressDel = () => {
border-bottom: solid 2rpx $u-border-color; border-bottom: solid 2rpx $u-border-color;
.left { .left {
width: 180rpx; width: 200rpx;
} }
input { input {
......
<template> <template>
<view> <view>
<view class="address" v-for="(res, index) in siteList" :key="res.id"> <view class="address" v-for="(res, index) in siteList" :key="res.id">
<view class="item" @tap="setAddress(res.id)"> <u-row>
<u-col :span="11">
<view
class="item"
@tap="
pagePathFlag
? setAddress(res)
: () => {
return;
}
"
>
<view class="top"> <view class="top">
<u-row style="width: 100%;">
<u-col :span="5">
<view class="name">{{ res.name }}</view> <view class="name">{{ res.name }}</view>
</u-col>
<u-col :span="4">
<view class="phone">{{ res.tel }}</view> <view class="phone">{{ res.tel }}</view>
</u-col>
<u-col :span="3" style="text-align: end;">
<u-tag <u-tag
v-show="res.isDefault" v-show="res.isDefault"
text="默认" text="默认"
type="error" type="error"
size="mini" size="mini"
style="margin-left: 20rpx;"
/> />
</u-col>
</u-row>
</view> </view>
<view class="bottom"> <view class="bottom">
{{ res.province + res.city + res.county + res.addressDetail }} {{ res.province + res.city + res.county + res.addressDetail }}
</view> </view>
</view> </view>
</u-col>
<u-col :span="1">
<u-icon name="edit-pen" color="#3b3b3b" :size="40" @tap="addressEdit(res)" /> <u-icon name="edit-pen" color="#3b3b3b" :size="40" @tap="addressEdit(res)" />
</u-col>
</u-row>
</view> </view>
<view class="addSite" @tap="toAddSite"> <view class="addSite" @tap="toAddSite">
...@@ -31,10 +53,21 @@ ...@@ -31,10 +53,21 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import { addressList } from '@/api/index'; import { addressList } from '@/api/index';
const siteList = ref([] as any); const siteList = ref([] as any);
// 判断上个页面是否是 我的 页面
const pagePathFlag = ref(false);
onShow(() => {
let pages = getCurrentPages();
let pagePath: any = pages[pages.length - 2]; //上个页面
if (pagePath.route === 'pages/profile/index') return (pagePathFlag.value = false);
else return (pagePathFlag.value = true);
});
const toAddSite = () => { const toAddSite = () => {
uni.navigateTo({ uni.navigateTo({
url: './addSite', url: './addSite',
...@@ -42,13 +75,22 @@ const toAddSite = () => { ...@@ -42,13 +75,22 @@ const toAddSite = () => {
}; };
// 设置地址 // 设置地址
const setAddress = (id: any) => { const setAddress = (item: any) => {
setTimeout(() => { setTimeout(() => {
uni.setStorage({ uni.setStorage({
key: 'addressId', key: 'addressId',
data: id, data: item.id,
success() { success() {
uni.navigateBack(); let pages = getCurrentPages(); // 当前页面
let beforePage: any = pages[pages.length - 2]; // 上一页
console.log(beforePage);
uni.navigateBack({
success: function() {
if (beforePage.route === 'pages/order/quotation')
beforePage.addressData = item;
else beforePage.init(); // 执行上一页的onLoad方法
},
});
}, },
}); });
}, 50); }, 50);
...@@ -69,9 +111,8 @@ const initAddressLit = () => { ...@@ -69,9 +111,8 @@ const initAddressLit = () => {
initAddressLit(); initAddressLit();
uni.$on('initAddress', () => { uni.$on('initAddress', () => {
initAddressLit() initAddressLit();
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -82,19 +123,14 @@ page { ...@@ -82,19 +123,14 @@ page {
.address { .address {
padding: 40rpx 20rpx; padding: 40rpx 20rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
} }
.item { .item {
.top { .top {
display: flex;
font-weight: bold; font-weight: bold;
font-size: 34rpx; font-size: 34rpx;
.phone { .phone {
margin-left: 60rpx; font-size: 32rpx;
} }
.tag { .tag {
......
...@@ -29,9 +29,16 @@ ...@@ -29,9 +29,16 @@
</u-cell-item> </u-cell-item>
<u-cell-item icon="" title="姓名" :value="userData.nickName" @click="setName"></u-cell-item> <u-cell-item icon="" title="姓名" :value="userData.nickName" @click="setName"></u-cell-item>
<u-cell-item icon="" title="密码设置" :value="userData.pwd" @click="setPwd"></u-cell-item> <u-cell-item icon="" title="密码设置" :value="userData.pwd" @click="setPwd"></u-cell-item>
<u-cell-item icon="" title="手机号" :value="userData.mobile"></u-cell-item> <u-cell-item icon="" title="手机号" :value="userData.mobile" @click="setTel"></u-cell-item>
<u-cell-item icon="" title="编码" value="七妹"></u-cell-item> <u-cell-item icon="" title="编码" :value="userData.username"></u-cell-item>
<u-cell-item icon="" title="邮箱" :value="userData.email" @click="setEmail"></u-cell-item> <u-cell-item icon="" title="邮箱" :value="userData.email" @click="setEmail"></u-cell-item>
<u-cell-item
icon=""
title="发货地址"
:value="userData.workAddr"
:value-style="{ marginLeft: '17%' }"
@tap="setAddr"
></u-cell-item>
</u-cell-group> </u-cell-group>
<u-button style="margin-top: 100rpx;" @tap="openModel">退出当前用户</u-button> <u-button style="margin-top: 100rpx;" @tap="openModel">退出当前用户</u-button>
...@@ -42,9 +49,9 @@ ...@@ -42,9 +49,9 @@
show-cancel-button show-cancel-button
></u-modal> ></u-modal>
<!-- 修改用户名 --> <!-- 修改名 -->
<u-popup v-model="options.showPopup" mode="center" height="22%" width="80%"> <u-popup v-model="options.showPopup" mode="center" width="80%">
<view style="padding: 30rpx; height: 100%; margin-top: 0%;"> <view style="padding: 30rpx; margin-top: 0%;">
<view style="font-size: 34rpx; width: 100%; text-align: center; margin-bottom: 20rpx;"> <view style="font-size: 34rpx; width: 100%; text-align: center; margin-bottom: 20rpx;">
{{ title }} {{ title }}
</view> </view>
...@@ -60,8 +67,8 @@ ...@@ -60,8 +67,8 @@
</u-popup> </u-popup>
<!-- 修改密码 --> <!-- 修改密码 -->
<u-popup v-model="options.showPopupPwd" mode="center" height="30%" width="80%"> <u-popup v-model="options.showPopupPwd" mode="center" width="80%">
<view style="padding: 30rpx; height: 100%; margin-top: 0%;"> <view style="padding: 30rpx; margin-top: 0%;">
<view style="font-size: 34rpx; width: 100%; text-align: center; margin-bottom: 20rpx;"> <view style="font-size: 34rpx; width: 100%; text-align: center; margin-bottom: 20rpx;">
设置密码 设置密码
</view> </view>
...@@ -92,36 +99,74 @@ ...@@ -92,36 +99,74 @@
</u-button> </u-button>
</view> </view>
</u-popup> </u-popup>
<!-- 修改地址 -->
<u-popup v-model="options.showPopupAddr" mode="center" width="90%">
<view style="padding: 30rpx; margin-top: 0%;">
<view style="font-size: 34rpx; width: 100%; text-align: center; margin-bottom: 20rpx;">
{{ title }}
</view>
<u-form label-width="155">
<u-form-item label="选择地址">
<u-input
v-model="temporaryAddr"
:disabled="true"
:border="true"
clearable
placeholder="请选择地址"
@tap="options.showSelectAddr = true"
/>
</u-form-item>
<u-form-item label="详细信息">
<u-input
v-model="detailAddr"
type="textarea"
:border="true"
clearable
placeholder="请输入详细信息"
/>
</u-form-item>
</u-form>
<u-button :maxlength="11" type="error" style="margin-top: 8%;" @tap="addrSave">
保存
</u-button>
</view>
</u-popup>
<u-picker mode="region" ref="uPicker" v-model="options.showSelectAddr" @confirm="selectAddr" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, getCurrentInstance } from 'vue'; import { ref, reactive, getCurrentInstance } from 'vue';
import { getAuthInfo, resetNickName, resetByMobile, resetEmail } from '@/api/profile'; import { getAuthInfo, resetNickName, resetByMobile, resetEmail, resetWorkAddr, resetMobile } from '@/api/profile';
import config from '@/utils/config'; import config from '@/utils/config';
let ctx: any = getCurrentInstance(); let ctx: any = getCurrentInstance();
let $u = ctx.appContext.config.globalProperties.$u; let $u = ctx.appContext.config.globalProperties.$u; // uview方法
let title = ref('') let title = ref('')
let label = ref('') let label = ref('')
let userData = ref({ let userData = ref({
avatar: '', avatar: '',
nickName: '', nickName: '',
mobile: '', mobile: '',
phone: '', email: '',
email: '' workAddr: '',
}); } as any); // 用户信息
let uploadRef = ref() let uploadRef = ref()
let action = ref(config.baseUrl + '/wx/auth/reset_avatar'); let action = ref(config.baseUrl + '/wx/auth/reset_avatar');
let headers = ref({ Authorization: uni.getStorageSync('token') }); let headers = ref({ Authorization: uni.getStorageSync('token') });
let nameValue = ref(''); let nameValue = ref('');
let oldPwd = ref(''); let oldPwd = ref(''); // 旧密码
let newPwd = ref(''); let newPwd = ref(''); // 新密码
let fileList = ref([]); let fileList = ref([]); // 头像数据
let temporaryAddr = ref('') // 临时地址
let detailAddr = ref('') // 详细地址信息
let options = reactive({ let options = reactive({
show: false, show: false,
content: '确定退出当前用户', content: '确定退出当前用户',
showPopup: false, showPopup: false,
showPopupPwd: false, showPopupPwd: false,
showPopupAddr: false,
showSelectAddr: false,
}); });
let openModel = () => { let openModel = () => {
...@@ -143,6 +188,18 @@ let setPwd = () => { ...@@ -143,6 +188,18 @@ let setPwd = () => {
options.showPopupPwd = true; options.showPopupPwd = true;
}; };
let setTel = () => {
label.value = '手机号:'
title.value = '设置手机号'
nameValue.value = userData.value.mobile
options.showPopup = true;
};
let setAddr = () => {
title.value = '设置地址'
options.showPopupAddr = true;
};
let success = (res: any) => { let success = (res: any) => {
if(res.code === 200) { if(res.code === 200) {
init(); init();
...@@ -173,7 +230,18 @@ let nameSave = () => { ...@@ -173,7 +230,18 @@ let nameSave = () => {
} }
}); });
}) })
break break;
case '手机号:':
save(() => {
resetMobile({ mobile: nameValue.value }).then((res: any) => {
if (res.data.code === 200) {
nameValue.value = '';
options.showPopup = false;
init();
}
});
})
break;
} }
}; };
...@@ -189,6 +257,31 @@ let save = (func: Function) => { ...@@ -189,6 +257,31 @@ let save = (func: Function) => {
} }
} }
let selectAddr = (e: any) => {
temporaryAddr.value = e.province.name + e.city.name + e.area.name
}
// 保存地址
let addrSave = () => {
if (!temporaryAddr.value)
return uni.showToast({
title: '请选择地址',
icon: 'none',
});
if (!detailAddr.value)
return uni.showToast({
title: '请输入收货地址',
icon: 'none',
});
let workAddr = temporaryAddr.value + detailAddr.value
resetWorkAddr({ workAddr }).then((res: any) => {
if(res.data.code) {
options.showPopupAddr = false
init()
}
})
}
let pwdSave = () => { let pwdSave = () => {
if (!oldPwd.value) if (!oldPwd.value)
return uni.showToast({ return uni.showToast({
...@@ -229,10 +322,19 @@ const toLogin = () => { ...@@ -229,10 +322,19 @@ const toLogin = () => {
}); });
}; };
// 初始化数据
let init = () => { let init = () => {
getAuthInfo().then((res: any) => { getAuthInfo().then((res: any) => {
if (res.data.code === 200) { if (res.data.code === 200) {
userData.value = res.data.data; userData.value = res.data.data;
var reg = /.+?(省|市|自治区|自治州|县|区)/g; // 省市区的正则
let addr = userData.value.workAddr.match(reg)
temporaryAddr.value = addr[0] + addr[1] + addr[2]
addr.map((item: any, i: number) => {
if(i > 2) {
detailAddr.value += item
}
})
} }
}); });
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论