接口对接完成
This commit is contained in:
parent
3ccdc86f3c
commit
b50031b59e
7
env/.env
vendored
7
env/.env
vendored
@ -5,7 +5,7 @@ VITE_APP_TITLE=uniapp-vue3模板项目
|
||||
VITE_APP_ENV=development
|
||||
|
||||
# 接口地址
|
||||
VITE_API_BASE_URL=https://test.shop.lihaink.cn
|
||||
VITE_API_BASE_URL=http://www.caipu.com:8545
|
||||
|
||||
# 端口号
|
||||
VITE_APP_PORT=9527
|
||||
@ -14,10 +14,11 @@ VITE_APP_PORT=9527
|
||||
VITE_APP_PROXY=true
|
||||
|
||||
# API代理前缀
|
||||
VITE_API_PREFIX= https://test.shop.lihaink.cn
|
||||
VITE_API_PREFIX= http://www.caipu.com:8545
|
||||
|
||||
# 删除console
|
||||
VITE_DROP_CONSOLE=false
|
||||
|
||||
# Tencent Map Key
|
||||
VITE_APP_MAP_KEY= "SMJBZ-WCHK4-ZPZUA-DSIXI-XDDVQ-XWFX7"
|
||||
VITE_APP_MAP_KEY= "IOUBZ-HCDW3-KP53C-RFNVK-QAZ7O-EQFKM"
|
||||
# SMJBZ-WCHK4-ZPZUA-DSIXI-XDDVQ-XWFX7
|
||||
|
2
env/.env.development
vendored
2
env/.env.development
vendored
@ -2,7 +2,7 @@
|
||||
VITE_APP_ENV=development
|
||||
|
||||
# 接口地址
|
||||
VITE_API_BASE_URL=https://test.shop.lihaink.cn
|
||||
VITE_API_BASE_URL=http://www.caipu.com:8545
|
||||
|
||||
# 删除console
|
||||
VITE_DROP_CONSOLE=false
|
||||
|
2
env/.env.production
vendored
2
env/.env.production
vendored
@ -2,7 +2,7 @@
|
||||
VITE_APP_ENV=production
|
||||
|
||||
# 接口地址
|
||||
VITE_API_BASE_URL=https://test.shop.lihaink.cn
|
||||
VITE_API_BASE_URL=http://www.caipu.com:8545
|
||||
|
||||
# 删除console
|
||||
VITE_DROP_CONSOLE=true
|
||||
|
@ -20,5 +20,8 @@ export const goodsMenu = (data:any) => get('/api/config', { data, custom: { toas
|
||||
/** 登录 post 实列 */
|
||||
export const goodsLogin = (data:any) => post('/api/auth/login', { data, custom: { toast: false } });
|
||||
|
||||
//公共请求接口
|
||||
export const commonPost = (url:any,data:any) => post(url, { data, custom: { toast: false } });
|
||||
export const commonGet = (url:any,data:any) => get(url, { data, custom: { toast: false } });
|
||||
|
||||
|
||||
|
@ -19,10 +19,11 @@ export interface LoginReqPassword {
|
||||
}
|
||||
|
||||
export interface LoginRes {
|
||||
token: string;
|
||||
user_id: number;
|
||||
user_name: string;
|
||||
avatar: string;
|
||||
user_id?: string;
|
||||
user_name?: string;
|
||||
avatar?: string;
|
||||
token?: string;
|
||||
user?: any;
|
||||
}
|
||||
|
||||
export interface LoginByCodeReq {
|
||||
|
@ -91,7 +91,7 @@ export default function useLocation() {
|
||||
const getAddress = (latitude: number, longitude: number) => {
|
||||
return new Promise<AddressInfo>((resolve, reject) => {
|
||||
// console.log('getAddress', `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${map_key}`);
|
||||
// #ifdef APP-PLUS
|
||||
|
||||
uni.request({
|
||||
url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${map_key}`,
|
||||
success: (res: any) => {
|
||||
@ -125,13 +125,7 @@ export default function useLocation() {
|
||||
reject(err);
|
||||
},
|
||||
});
|
||||
// #endif
|
||||
|
||||
// #ifndef APP-PLUS
|
||||
// 其他平台可以使用uni.getLocation的geocode参数获取(仅App和微信小程序支持)
|
||||
// 或者使用其他地图服务的API
|
||||
reject(new Error('当前平台不支持地址解析'));
|
||||
// #endif
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -50,11 +50,20 @@
|
||||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "",
|
||||
"appid" : "wxdee751952c8c2027",
|
||||
"setting" : {
|
||||
"urlCheck" : false
|
||||
"urlCheck" : false,
|
||||
"minified" : true,
|
||||
"postcss" : true,
|
||||
"es6" : true
|
||||
},
|
||||
"usingComponents" : true
|
||||
"usingComponents" : true,
|
||||
"permission" : {
|
||||
"scope.userLocation" : {
|
||||
"desc" : "获取您的位置"
|
||||
}
|
||||
},
|
||||
"requiredPrivateInfos" : [ "getLocation", "chooseAddress" , "chooseLocation" ]
|
||||
},
|
||||
"mp-alipay" : {
|
||||
"usingComponents" : true
|
||||
@ -77,7 +86,7 @@
|
||||
"sdkConfigs" : {
|
||||
"maps" : {
|
||||
"tencent" : {
|
||||
"key" : "SMJBZ-WCHK4-ZPZUA-DSIXI-XDDVQ-XWFX7"
|
||||
"key" : "IOUBZ-HCDW3-KP53C-RFNVK-QAZ7O-EQFKM"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,13 +64,29 @@
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "goods/pay_order",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "goods/order",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "goods/order_detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -22,33 +22,32 @@
|
||||
<up-navbar class="" style="" :autoBack="true" bgColor="#00000000" :fixed="true" titleColor="#595757FF"
|
||||
leftIconColor="#FFFFFFFF">
|
||||
</up-navbar>
|
||||
<up-swiper height="480rpx" :list="list4" keyName="url" :autoplay="false"></up-swiper>
|
||||
<up-swiper v-if="imageList" height="480rpx" :list="imageList" keyName="url" :autoplay="false"></up-swiper>
|
||||
|
||||
<view class="detail_box">
|
||||
<up-cell class=" " style="" title="青椒泡椒肉丁"
|
||||
label="现在是毛豆大上市的季节,煮毛豆炒青豆都好吃,特别营养。毛豆中还含有丰富的食物纤维,不仅能改善便秘,还有利于血压和胆固醇的降低。">
|
||||
<up-cell class=" " style="" :title="matchedItems_sc.name" :label="matchedItems_sc.intro">
|
||||
</up-cell>
|
||||
<view class="p-2">
|
||||
<view class="flex box-border flex-row pb-2 ps-2 pe-2" style="" @click="addCart">
|
||||
<up-text class="" size="28rpx" :text="'食材配置'" :flex1="true" align="left" wordWrap="normal"
|
||||
:show="true" lines="1" decoration="none">
|
||||
</up-text>
|
||||
<up-text class="" color="#59CB56" size="28rpx" text="加入食谱清单" :flex1="true" prefixIcon="plus"
|
||||
align="right" wordWrap="normal" :show="true"
|
||||
iconStyle="font-size: 28rpx;font-weight: bold;margin-right:10rpx;color: #59CB56;"
|
||||
decoration="none">
|
||||
<view class="flex box-border flex-row pb-2 ps-2 pe-2" style="">
|
||||
|
||||
<up-text color="#59CB56" size="33rpx" :text="`食材配置`" :flex1="true" align="left" wordWrap="normal"
|
||||
:show="true" prefixIcon="" iconStyle="font-size:28rpx;color:#59CB56;margin-right:10rpx;"
|
||||
lines="1" decoration="none">
|
||||
</up-text>
|
||||
<view v-if="is_add" @click="addCart">
|
||||
<u-icon slot="right" label="加入食谱清单" size="42rpx" name="plus-circle" color="#59CB56"
|
||||
labelColor="#59CB56"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<z-paging :fixed="false" height="calc(100vh - 900rpx)" width="calc(100vw - 50rpx)"
|
||||
:paging-style="{ 'background-color': '#FFFFFFFF', 'padding': '20rpx' }" ref="pagingRefSC"
|
||||
v-model="matchedItems_sc" class="fv-page flex-col ">
|
||||
<view class="flex" style="padding:20rpx" v-for="(item, index) in goods_list_detail"
|
||||
:paging-style="{ 'background-color': '#FFFFFFFF', 'padding': '20rpx' }" class="fv-page flex-col ">
|
||||
<view class="flex" style="padding:20rpx" v-for="(item, index) in matchedItems_sc.dishesProduct"
|
||||
:key="index">
|
||||
<up-text class="" size="26rpx" color="#9b9b9b" :text="item.name + item.label" :flex1="true"
|
||||
<up-text class="" size="26rpx" color="#9b9b9b" :text="item.product.name" :flex1="true"
|
||||
align="left" wordWrap="normal" :show="true" lines="1" decoration="none">
|
||||
</up-text>
|
||||
<up-text class="" color="#9b9b9b" size="24rpx" :text="item.num + item.unit_name" :flex1="true"
|
||||
<up-text class="" color="#9b9b9b" size="24rpx" :text="item.nums + item.unit.name" :flex1="true"
|
||||
align="right" wordWrap="normal" :show="true"
|
||||
iconStyle="font-size: 28rpx;font-weight: bold;margin-right:10rpx;color: #59CB56;"
|
||||
decoration="none">
|
||||
@ -59,7 +58,7 @@
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex box-border flex-sub-cart" @click="addCart">
|
||||
<view class="flex box-border flex-sub-cart" @click="addCart" v-if="is_add">
|
||||
<u-icon custom-style="margin: 20rpx;" size="80rpx" slot="right" color="#59CB56"
|
||||
name="shopping-cart-fill"></u-icon>
|
||||
<u-text class=""
|
||||
@ -71,164 +70,86 @@
|
||||
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { reactive } from 'vue';
|
||||
// import { ref, reactive, watch, computed,
|
||||
// onBeforeMount, onMounted, onBeforeUnmount, onUnmounted,
|
||||
// onBeforeUpdate, onUpdated, nextTick, defineProps, toRaw } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
const matchedItems_sc =ref([])
|
||||
// 页面加载
|
||||
onLoad((options) => {
|
||||
// loadData()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
})
|
||||
// 使用 reactive 创建响应式对象数组
|
||||
const list4 = reactive([
|
||||
{
|
||||
url: 'https://cdn.uviewui.com/uview/resources/video.mp4',
|
||||
title: '昨夜星辰昨夜风,画楼西畔桂堂东',
|
||||
poster: 'https://cdn.uviewui.com/uview/swiper/swiper1.png'
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { CommonApi, UserApi } from "@/api";
|
||||
import { setToken, getToken, isLogin } from '@/utils/auth';
|
||||
import { image } from "@/uni_modules/uview-plus/libs/function/test";
|
||||
import { url } from "inspector";
|
||||
export default defineComponent({
|
||||
data () {
|
||||
return {
|
||||
search: {
|
||||
id: 0,
|
||||
},
|
||||
is_add: 0, //是否显示购物车
|
||||
matchedItems_sc: [],
|
||||
imageList: [],
|
||||
};
|
||||
},
|
||||
{
|
||||
url: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
title: '身无彩凤双飞翼,心有灵犀一点通',
|
||||
// 注意:这里看起来有个错误,url 应该是一个视频或图片的URL,但这里却给了一个图片URL
|
||||
// 如果这是一个视频对象,你需要确保 url 是正确的视频文件URL
|
||||
onLoad (option) {
|
||||
// console.log(option);
|
||||
this.search.id = option.id;
|
||||
this.is_add = option.is_add | 0;
|
||||
this.getCategoryList()
|
||||
},
|
||||
{
|
||||
url: 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
|
||||
title: '谁念西风独自凉,萧萧黄叶闭疏窗,沉思往事立残阳',
|
||||
// 同样,这里看起来 url 应该是一个视频或图片的URL,但给的是一个图片URL
|
||||
// 需要根据实际需求修正这个值
|
||||
},
|
||||
]);
|
||||
function changeSC(){
|
||||
created () {
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getCategoryList () {
|
||||
CommonApi.commonGet('/api/dishes/detail', this.search).catch((res) => {
|
||||
if (res.code === 1) {
|
||||
this.matchedItems_sc = res.data;
|
||||
//轮播图是数组
|
||||
this.imageList = res.data.image ? [{
|
||||
url: res.data.image,
|
||||
title: res.data.name,
|
||||
poster: res.data.image
|
||||
}] : [];
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
//加入购物车
|
||||
addCart () {
|
||||
CommonApi.commonPost('/api/cart/add', {
|
||||
buy_now: false,
|
||||
dishes_id: this.search.id,
|
||||
}).catch((res) => {
|
||||
if (res.code === 1) {
|
||||
uni.$u.toast('加入购物车成功');
|
||||
uni.switchTab({
|
||||
url: '/pages/tab/list/index'
|
||||
});
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
const goods_list_detail = [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
}, {
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
}, {
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
}, {
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
}, {
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
}, {
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
];
|
||||
});
|
||||
// const imageList = reactive([
|
||||
// {
|
||||
// url: 'https://cdn.uviewui.com/uview/resources/video.mp4',
|
||||
// title: '昨夜星辰昨夜风,画楼西畔桂堂东',
|
||||
// poster: 'https://cdn.uviewui.com/uview/swiper/swiper1.png'
|
||||
// },
|
||||
// {
|
||||
// url: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
// title: '身无彩凤双飞翼,心有灵犀一点通',
|
||||
// // 注意:这里看起来有个错误,url 应该是一个视频或图片的URL,但这里却给了一个图片URL
|
||||
// // 如果这是一个视频对象,你需要确保 url 是正确的视频文件URL
|
||||
// },
|
||||
// {
|
||||
// url: 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
|
||||
// title: '谁念西风独自凉,萧萧黄叶闭疏窗,沉思往事立残阳',
|
||||
// // 同样,这里看起来 url 应该是一个视频或图片的URL,但给的是一个图片URL
|
||||
// // 需要根据实际需求修正这个值
|
||||
// },
|
||||
// ]);
|
||||
|
||||
//加入购物车
|
||||
function addCart () {
|
||||
uni.switchTab({
|
||||
url: '/pages/tab/list/index'
|
||||
});
|
||||
}
|
||||
</script>
|
240
src/pages/common/goods/goods.vue
Normal file
240
src/pages/common/goods/goods.vue
Normal file
@ -0,0 +1,240 @@
|
||||
<template>
|
||||
<view >
|
||||
<view class="address-window popup-main bg-f" :class="address.address==true?'on':''">
|
||||
<view class='title font-500'>选择地址<text class='iconfont icon-ic_close popup-close' @tap='close'></text></view>
|
||||
<scroll-view scroll-y="true" class='list'>
|
||||
<view class='item acea-row row-between-wrapper' :class='active==index?"t-color":""' v-for="(item,index) in addressList"
|
||||
@tap='tapAddress(index,item.address_id)' :key='index'>
|
||||
<text class='iconfont icon-ic_location5' :class='active==index?"t-color":""'></text>
|
||||
<view class='address'>
|
||||
<view class='name font-bold' :class='active==index?"t-color":""'>{{item.real_name}}<text class='phone'>{{item.phone}}</text></view>
|
||||
<view class='line1'>{{item.province}}{{item.city}}{{item.district}}{{item.street || ''}}{{item.detail}}</view>
|
||||
</view>
|
||||
<text class='iconfont icon-complete' :class='active==index?"t-color":""'></text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<!-- 无地址 -->
|
||||
<view class='pictrue' v-if="!is_loading && !addressList.length">
|
||||
<image :src="`${domain}/static/images/noAddress.png`"></image>
|
||||
<view>暂无地址</view>
|
||||
</view>
|
||||
<view class='addressBnt' @tap='goAddressPages'>添加新地址</view>
|
||||
</view>
|
||||
<view class='mask' catchtouchmove='true' :hidden='address.address==false' @tap='close'></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// import { getAddressList } from '@/api/user.js';
|
||||
// import {
|
||||
// orderAddressLst,
|
||||
// }from "@/api/order";
|
||||
// import { mapGetters } from "vuex";
|
||||
// import { HTTP_REQUEST_URL } from '@/config/app';
|
||||
export default {
|
||||
props: {
|
||||
pagesUrl: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
uid: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
tourist_unique_key: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
address: {
|
||||
type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
address: true,
|
||||
addressId: 0,
|
||||
};
|
||||
}
|
||||
},
|
||||
isLog: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
// computed: mapGetters(['viewColor']),
|
||||
data() {
|
||||
return {
|
||||
domain: '',
|
||||
active: 0,
|
||||
//地址列表
|
||||
addressList: [
|
||||
{
|
||||
province: '广东省',
|
||||
city: '广州市',
|
||||
district: '天河区',
|
||||
street: '东风路',
|
||||
detail: '123号',
|
||||
real_name: '张三',
|
||||
phone: '13811111111',
|
||||
address_id: 1,
|
||||
|
||||
},
|
||||
{
|
||||
province: '广东省',
|
||||
city: '广州市',
|
||||
district: '天河区',
|
||||
street: '东风路',
|
||||
detail: '123号',
|
||||
real_name: '张三',
|
||||
phone: '13811111111',
|
||||
address_id: 1,
|
||||
|
||||
},
|
||||
{
|
||||
province: '广东省',
|
||||
city: '广州市',
|
||||
district: '天河区',
|
||||
street: '东风路',
|
||||
detail: '123号',
|
||||
real_name: '张三',
|
||||
phone: '13811111111',
|
||||
address_id: 1,
|
||||
|
||||
}
|
||||
],
|
||||
is_loading: true
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
tapAddress: function(index, addressid) {
|
||||
this.active = index;
|
||||
this.$emit('OnChangeAddress', addressid);
|
||||
},
|
||||
close: function() {
|
||||
this.$emit('changeClose');
|
||||
// this.$emit('changeTextareaStatus');
|
||||
},
|
||||
goAddressPages: function() {
|
||||
this.$emit('changeClose');
|
||||
// this.$emit('changeTextareaStatus');
|
||||
uni.navigateTo({
|
||||
url: this.pagesUrl
|
||||
});
|
||||
},
|
||||
getAddressList: function() {
|
||||
let that = this;
|
||||
// orderAddressLst({
|
||||
// page: 1,
|
||||
// limit: 5,
|
||||
// uid: that.uid,
|
||||
// tourist_unique_key: that.tourist_unique_key,
|
||||
// }).then(res => {
|
||||
// let addressList = res.data.list;
|
||||
// //处理默认选中项
|
||||
// for (let i = 0; i < res.data.list.length; i++) {
|
||||
// if (addressList[i].address_id == that.address.addressId) {
|
||||
// that.active = i;
|
||||
// }
|
||||
// }
|
||||
// that.$set(that, 'addressList', addressList);
|
||||
// that.is_loading = false;
|
||||
// })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
|
||||
/* #ifndef APP-NVUE */
|
||||
// 由于uView是基于nvue环境进行开发的,此环境中普通元素默认为flex-direction: column;
|
||||
// 所以在非nvue中,需要对元素进行重置为flex-direction: column; 否则可能会表现异常
|
||||
view, scroll-view, swiper-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
flex-basis: auto;
|
||||
align-items: stretch;
|
||||
align-content: flex-start;
|
||||
}
|
||||
/* #endif */
|
||||
|
||||
// 隐藏scroll-view的滚动条
|
||||
::-webkit-scrollbar {
|
||||
display: none;
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
-webkit-appearance: none;
|
||||
background: transparent;
|
||||
}
|
||||
.address-window .title {
|
||||
height: 123rpx;
|
||||
line-height: 123rpx;
|
||||
}
|
||||
.address-window .title .iconfont {
|
||||
position: absolute;
|
||||
right: 28rpx;
|
||||
top: 30rpx;
|
||||
}
|
||||
.address-window .list{
|
||||
max-height: 650rpx;
|
||||
}
|
||||
.address-window .list .item {
|
||||
margin-left: 30rpx;
|
||||
padding-right: 30rpx;
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
height: 129rpx;
|
||||
font-size: 25rpx;
|
||||
color: #333;
|
||||
}
|
||||
.address-window .list .item .iconfont {
|
||||
font-size: 37rpx;
|
||||
color: #2c2c2c;
|
||||
}
|
||||
.address-window .list .item .iconfont.icon-complete {
|
||||
font-size: 30rpx;
|
||||
color: #fff;
|
||||
}
|
||||
.address-window .list .item .address {
|
||||
width: 560rpx;
|
||||
}
|
||||
.address-window .list .item .address .name {
|
||||
font-size: 28rpx;
|
||||
color: #282828;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
.address-window .list .item .address .name .phone {
|
||||
margin-left: 18rpx;
|
||||
}
|
||||
.address-window .addressBnt {
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
width: 690rpx;
|
||||
height: 88rpx;
|
||||
border-radius: 50rpx;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
margin: 85rpx auto;
|
||||
background-color: var(--view-theme);
|
||||
}
|
||||
.address-window .pictrue {
|
||||
text-align: center;
|
||||
}
|
||||
.address-window .pictrue image,.address-window .pictrue uni-image {
|
||||
width: 414rpx;
|
||||
height: 305rpx;
|
||||
}
|
||||
.address-window .pictrue view{
|
||||
color: #999;
|
||||
}
|
||||
.t-color {
|
||||
color: var(--view-theme)!important;
|
||||
}
|
||||
</style>
|
@ -1,507 +0,0 @@
|
||||
|
||||
|
||||
<style>
|
||||
.flex {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.flex-sub {
|
||||
flex: 1;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
/* height: 100%; */
|
||||
bottom: 20rpx;
|
||||
position: fixed;
|
||||
border: 1px solid #59cb56;
|
||||
border-radius: 40rpx;
|
||||
background-color: #ffffffdc;
|
||||
}
|
||||
.u-cell__body {
|
||||
padding: 0rpx 30rpx !important;
|
||||
}
|
||||
.ellipsis {
|
||||
white-space: nowrap; /* 防止文字换行 */
|
||||
overflow: hidden; /* 隐藏超出部分的文字 */
|
||||
text-overflow: ellipsis; /* 在末尾显示省略号 */
|
||||
width: 280rpx; /* 确保元素有宽度 */
|
||||
}
|
||||
.flex-column {
|
||||
position: static;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
color: rgb(51, 51, 51);
|
||||
background: rgb(255, 255, 255);
|
||||
border-radius: 0px;
|
||||
border-color: rgb(255, 255, 255);
|
||||
border-width: 0px;
|
||||
border-style: solid;
|
||||
}
|
||||
.flex-row {
|
||||
position: static;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
color: rgb(51, 51, 51);
|
||||
border-radius: 0px;
|
||||
border-color: rgb(255, 255, 255);
|
||||
border-width: 0px;
|
||||
border-style: solid;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view>
|
||||
<up-navbar
|
||||
class=" "
|
||||
:autoBack="true"
|
||||
style="font-weight: bold;"
|
||||
leftIcon="arrow-left"
|
||||
title="提交订单"
|
||||
titleColor="#303133"
|
||||
bgColor="#FFFFFFFF"
|
||||
titleWidth="600rpx"
|
||||
height="80rpx"
|
||||
leftIconSize="40rpx"
|
||||
leftIconColor="#303133"
|
||||
:safeAreaInsetTop="true"
|
||||
:placeholder="true"
|
||||
:fixed="true"
|
||||
></up-navbar>
|
||||
|
||||
<view
|
||||
class="flex box-border flex-row p-4"
|
||||
style=""
|
||||
>
|
||||
<up-checkbox-group>
|
||||
<up-checkbox
|
||||
class=""
|
||||
shape="circle"
|
||||
activeColor="#59CB56"
|
||||
v-model:checked="aloneChecked"
|
||||
@change="handleAllCheckChange"
|
||||
>
|
||||
</up-checkbox>
|
||||
</up-checkbox-group>
|
||||
<up-text
|
||||
class=""
|
||||
size="24rpx"
|
||||
:text="'食谱清单('+checkboxValueNum+')'"
|
||||
:flex1="true"
|
||||
align="left"
|
||||
wordWrap="normal"
|
||||
:show="true"
|
||||
iconStyle="22rpx"
|
||||
decoration="none"
|
||||
>
|
||||
</up-text>
|
||||
<up-text
|
||||
class=""
|
||||
size="24rpx"
|
||||
text="删除已选"
|
||||
:flex1="true"
|
||||
prefixIcon="trash"
|
||||
align="right"
|
||||
wordWrap="normal"
|
||||
:show="true"
|
||||
type="#59CB56"
|
||||
iconStyle="font-size: 36rpx;font-weight: bold;"
|
||||
decoration="none"
|
||||
>
|
||||
</up-text>
|
||||
</view>
|
||||
|
||||
|
||||
<view
|
||||
class="flex box-border flex-sub"
|
||||
>
|
||||
<u-text
|
||||
class=""
|
||||
style="margin: 0rpx 0rpx 0rpx 20rpx;"
|
||||
color="#59CB56"
|
||||
size="26rpx"
|
||||
:text="'共计'+checkboxValueNum+'件'"
|
||||
:flex1="true"
|
||||
align="left"
|
||||
wordWrap="normal"
|
||||
:show="true"
|
||||
iconStyle="26rpx"
|
||||
decoration="none"
|
||||
>
|
||||
</u-text>
|
||||
<up-button
|
||||
class=""
|
||||
style=""
|
||||
text="提交订单"
|
||||
type="primary"
|
||||
color="#59CB56"
|
||||
shape="circle"
|
||||
size="normal"
|
||||
custom-style="width:200rpx"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
</up-button>
|
||||
</view>
|
||||
<z-paging
|
||||
|
||||
ref="pagingRefSC"
|
||||
v-model="matchedItems_sc"
|
||||
@query="changeSC('')"
|
||||
style="bottom: 100rpx;top:180rpx"
|
||||
class="fv-page flex-col px-4"
|
||||
>
|
||||
<view
|
||||
v-for="(item, index) in matchedItems_sc"
|
||||
:key="index"
|
||||
>
|
||||
<u-cell>
|
||||
<template #icon>
|
||||
<up-image
|
||||
class="flex flex-row"
|
||||
style="border:1px solid #59CB56;border-radius: 100%;"
|
||||
:src="item.image"
|
||||
mode="aspectFill"
|
||||
width="120rpx"
|
||||
height="120rpx"
|
||||
shape="square"
|
||||
:lazyLoad="true"
|
||||
duration="500"
|
||||
bgColor="#f3f4f6NaN"
|
||||
:showMenuByLongpress="true"
|
||||
>
|
||||
</up-image>
|
||||
</template>
|
||||
<template #title>
|
||||
<view class="h-60 flex">
|
||||
<text
|
||||
class=" ellipsis"
|
||||
style="font-size: 24rpx;font-weight: bold;"
|
||||
>营养:{{ item.name }}</text>
|
||||
<up-text
|
||||
class="text-black"
|
||||
size="24rpx"
|
||||
:text="item.num+item.unit_name"
|
||||
:flex1="true"
|
||||
suffixIcon=""
|
||||
align="right"
|
||||
wordWrap="normal"
|
||||
:show="true"
|
||||
type="#59CB56"
|
||||
iconStyle="font-size: 36rpx;font-weight: bold;"
|
||||
decoration="none"
|
||||
>
|
||||
</up-text>
|
||||
</view>
|
||||
</template>
|
||||
<template #label>
|
||||
<view class="h-60 flex">
|
||||
<text
|
||||
class=" text-gray ellipsis"
|
||||
style="font-size: 22rpx;"
|
||||
>菜谱:{{ item.label }}</text>
|
||||
<!-- <up-text
|
||||
class="text-black"
|
||||
size="24rpx"
|
||||
text="编辑数量"
|
||||
:flex1="true"
|
||||
prefixIcon="edit-pen"
|
||||
align="right"
|
||||
wordWrap="normal"
|
||||
:show="true"
|
||||
iconStyle="font-size: 36rpx;font-weight: bold;"
|
||||
decoration="none"
|
||||
>
|
||||
</up-text> -->
|
||||
</view>
|
||||
|
||||
</template>
|
||||
</u-cell>
|
||||
|
||||
</view>
|
||||
</z-paging>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<!-- 食谱清单 -->
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
watch,
|
||||
computed,
|
||||
onBeforeMount,
|
||||
onMounted,
|
||||
onBeforeUnmount,
|
||||
onUnmounted,
|
||||
onBeforeUpdate,
|
||||
onUpdated,
|
||||
nextTick,
|
||||
defineProps,
|
||||
toRaw,
|
||||
} from "vue";
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import { func } from "@/uni_modules/uview-plus/libs/function/test";
|
||||
|
||||
// 页面加载
|
||||
onLoad((options) => {
|
||||
// loadData();
|
||||
});
|
||||
|
||||
onShow(() => {});
|
||||
|
||||
// function loadData(pageNo: number, pageSize: number) {
|
||||
// console.log('[ pageNo ] >', pageNo);
|
||||
// console.log('[ pageSize ] >', pageSize);
|
||||
// // 这里的pageNo和pageSize会自动计算好,直接传给服务器即可
|
||||
// // 这里的请求只是演示,请替换成自己的项目的网络请求,并在网络请求回调中通过pagingRef.value.complete(请求回来的数组)将请求结果传给z-paging
|
||||
// setTimeout(() => {
|
||||
// // 1秒之后停止刷新动画
|
||||
// const list = [];
|
||||
// for (let i = 0; i < 30; i++)
|
||||
// list.push(urls[uni.$u.random(0, urls.length - 1)]);
|
||||
|
||||
// pagingRef.value?.complete(list);
|
||||
// }, 1000);
|
||||
// // this.$request
|
||||
// // .queryList({ pageNo, pageSize })
|
||||
// // .then(res => {
|
||||
// // // 请勿在网络请求回调中给dataList赋值!!只需要调用complete就可以了
|
||||
// // pagingRef.value.complete(res.data.list);
|
||||
// // })
|
||||
// // .catch(res => {
|
||||
// // // 如果请求失败写pagingRef.value.complete(false),会自动展示错误页面
|
||||
// // // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
|
||||
// // // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
|
||||
// // pagingRef.value.complete(false);
|
||||
// // });
|
||||
// }
|
||||
// export default {
|
||||
// data() {
|
||||
// return {
|
||||
// pageNo: 1,
|
||||
// pageSize: 10,
|
||||
// total: 0,
|
||||
// list: [],
|
||||
// loading: false,
|
||||
// finished: false,
|
||||
// paging: true,
|
||||
// };
|
||||
// },
|
||||
// methods: {
|
||||
// loadData() {
|
||||
// this.loading = true;
|
||||
// // 这里的pageNo和pageSize会自动计算好,直接传给服务器即可
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
const goods_list = [
|
||||
{
|
||||
id: 1,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
},
|
||||
];
|
||||
// const menu_list =[{'name':'食谱清单','icon':'photo'},{'name':'食菜配置','icon':'photo'}]
|
||||
const menu_list = [{ name: "食谱清单" }, { name: "食菜配置" }];
|
||||
const listLoading = ref(false);
|
||||
const dataPage = ref({
|
||||
page: 0,
|
||||
limit: 10,
|
||||
total: 0,
|
||||
});
|
||||
//索引对象
|
||||
const keyword_sp = ref("");
|
||||
const keyword_sc = ref("");
|
||||
// 食谱分页器
|
||||
const pagingRefSP = ref<InstanceType<typeof zPaging> | null>(null);
|
||||
const pagingRefSC = ref<InstanceType<typeof zPaging> | null>(null);
|
||||
function changeSC(e) {
|
||||
// console.log(e);
|
||||
try {
|
||||
// 创建正则表达式进行匹配,忽略大小写
|
||||
const regex = new RegExp(e, "i");
|
||||
// 直接对 goods_list 使用 filter 进行匹配,并赋值给 matchedItems_sp.value
|
||||
matchedItems_sc.value = goods_list.filter((item) => regex.test(item.name));
|
||||
} catch (error) {
|
||||
console.error("匹配过程中发生错误:", error);
|
||||
matchedItems_sc.value = []; // 发生错误时,将 matchedItems 清空
|
||||
}
|
||||
// console.log(matchedItems_sc.value);
|
||||
pagingRefSC.value?.complete([]);
|
||||
pagingRefSC.value?.complete(matchedItems_sc.value);
|
||||
}
|
||||
function changeSP(e) {
|
||||
// console.log(e);
|
||||
try {
|
||||
// 创建正则表达式进行匹配,忽略大小写
|
||||
const regex = new RegExp(e, "i");
|
||||
// 直接对 goods_list 使用 filter 进行匹配,并赋值给 matchedItems_sp.value
|
||||
matchedItems_sp.value = goods_list.filter((item) => regex.test(item.name));
|
||||
// console.log(matchedItems_sp.value);
|
||||
} catch (error) {
|
||||
console.error("匹配过程中发生错误:", error);
|
||||
matchedItems_sp.value = []; // 发生错误时,将 matchedItems 清空
|
||||
}
|
||||
pagingRefSP.value?.complete([]);
|
||||
pagingRefSP.value?.complete(matchedItems_sp.value);
|
||||
}
|
||||
// 食谱checkbox
|
||||
const checkboxValueNum = ref(0);
|
||||
const checkboxValue = reactive([]);
|
||||
const matchedItems_sp = reactive(goods_list);
|
||||
const matchedItems_sc = reactive(goods_list);
|
||||
const aloneChecked = ref(false);
|
||||
function checkboxChange(e) {
|
||||
checkboxValue.length = 0;
|
||||
e.forEach((item) => {
|
||||
if (!checkboxValue.includes(item)) {
|
||||
checkboxValue.push(item);
|
||||
}
|
||||
});
|
||||
console.log(checkboxValue);
|
||||
checkboxValueNum.value = checkboxValue.length;
|
||||
}
|
||||
function handleAllCheckChange(e) {
|
||||
checkboxValue.length = 0;
|
||||
if (e) {
|
||||
// 如果全选, 将所有 matchedItems_sp 的 id 添加到 checkboxValue
|
||||
matchedItems_sp.forEach((item) => {
|
||||
if (!checkboxValue.includes(item.id)) {
|
||||
checkboxValue.push(item.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log(e);
|
||||
console.log(checkboxValue);
|
||||
checkboxValueNum.value = checkboxValue.length;
|
||||
}
|
||||
// // 加载数据
|
||||
// const loadData = (refresh = false) => {
|
||||
// listLoading.value = true;
|
||||
// // 请求接口
|
||||
// listLoading.value = false;
|
||||
// };
|
||||
const currentTab1 = ref(0);
|
||||
// 切换tab
|
||||
function changeTab(e) {
|
||||
console.log(e);
|
||||
}
|
||||
//点击详情
|
||||
function handleClick(value) {
|
||||
console.log(value);
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/goods/detail?id=${value.name}`
|
||||
});
|
||||
}
|
||||
//提交订单
|
||||
function handleSubmit() {
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/goods/order`
|
||||
});
|
||||
}
|
||||
</script>
|
@ -2,261 +2,166 @@
|
||||
.ellipsis {
|
||||
/* 在末尾显示省略号 */
|
||||
width: 420rpx;
|
||||
|
||||
/* 防止文字换行 */
|
||||
overflow: hidden;
|
||||
|
||||
/* 隐藏超出部分的文字 */
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
/* 确保元素有宽度 */
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<up-navbar class=" " :autoBack="true" style="font-weight: bold;" leftIcon="arrow-left" title="提交订单"
|
||||
titleColor="#303133" bgColor="#FFFFFFFF" titleWidth="600rpx" height="80rpx" leftIconSize="40rpx"
|
||||
leftIconColor="#303133" :safeAreaInsetTop="true" :placeholder="true" :fixed="true"></up-navbar>
|
||||
<view class="address_box">
|
||||
<view class=" pt-2 pb-2 ps-2 pe-2" style="">
|
||||
<text class="ellipsis"
|
||||
style="display: inline-block;width: calc(100% - 100rpx);margin: 0rpx 0rpx 0rpx 40rpx;text-align:left;">江阳区学校2016工作室放假咯解fafsf方法
|
||||
<span>18181941463</span> </text>
|
||||
</view>
|
||||
<view class="flex box-border flex-row pb-2 ps-2 pe-2" style="" @click="getopenLocation">
|
||||
<up-text class="" size="26rpx" :text="'四川省泸州市江阳区龙马大道海吉星农贸市场32号附一号2楼307号'" :flex1="true" align="left"
|
||||
wordWrap="normal" :show="true" prefixIcon="map"
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1" decoration="none">
|
||||
</up-text>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</view>
|
||||
<view class="flex box-border flex-row pb-2 ps-2 pe-2" style="">
|
||||
<up-text class="" size="26rpx" color="#59CB56" :text="'配送时间 7月17日(周三) 19:00-21:00 送达'" :flex1="true"
|
||||
align="left" prefixIcon="clock" wordWrap="normal" :show="true"
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1" decoration="none">
|
||||
</up-text>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<z-paging :fixed="false" height="calc(100vh - 350rpx)" width="calc(100vw - 50rpx)"
|
||||
:paging-style="{ 'background-color': '#FFFFFFFF', 'padding': '20rpx' }" ref="pagingRefSC"
|
||||
v-model="matchedItems_sc" @query="changeSC()" class="fv-page flex-col ">
|
||||
<view v-for="(item, index) in matchedItems_sc" :key="index">
|
||||
<u-cell>
|
||||
<template #icon>
|
||||
<up-image class="flex flex-row" style="border:1px solid #59CB56;border-radius: 5rpx;"
|
||||
:src="item.image" mode="aspectFill" width="120rpx" height="120rpx" shape="square"
|
||||
:lazyLoad="true" duration="500" bgColor="#f3f4f6NaN" :showMenuByLongpress="true">
|
||||
</up-image>
|
||||
</template>
|
||||
<template #title>
|
||||
<view class="h-60 flex">
|
||||
<text class=" ellipsis" style="font-size: 24rpx;font-weight: bold;">营养:{{ item.name
|
||||
}}</text>
|
||||
<up-text style="margin-right: 10rpx;" class="text-black" size="24rpx"
|
||||
:text="item.num + item.unit_name" :flex1="true" suffixIcon="" align="right"
|
||||
wordWrap="normal" :show="true" type="#59CB56"
|
||||
iconStyle="font-size: 36rpx;font-weight: bold;" decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
</template>
|
||||
<template #label>
|
||||
<view class="h-60 flex">
|
||||
<text class=" text-gray ellipsis" style="font-size: 22rpx;">菜谱:{{ item.label }}</text>
|
||||
</view>
|
||||
</template>
|
||||
</u-cell>
|
||||
|
||||
<up-navbar class=" " :autoBack="true" style="font-weight: bold;"
|
||||
leftIcon="arrow-left" title="订单列表" titleColor="#303133" bgColor="#FFFFFFFF" titleWidth="600rpx"
|
||||
height="80rpx" leftIconSize="38rpx" leftIconColor="#303133" :safeAreaInsetTop="true" :placeholder="true"
|
||||
:fixed="true"></up-navbar>
|
||||
<up-search v-model="search_sp.keyword" class="flex,flex-row p-1" style="" shape="round" bgColor="#f2f2f2"
|
||||
placeholder="输入食谱" :clearabled="true" :showAction="false" inputAlign="left" borderColor="transparent"
|
||||
searchIconColor="#909399" color="#606266" placeholderColor="#909399" searchIcon="search" margin="10rpx"
|
||||
maxlength="-1" height="60rpx" @change="searchSP()">
|
||||
</up-search>
|
||||
|
||||
<z-paging :fixed="false" height="calc(100vh - 320rpx)" width="calc(100vw - 50rpx)"
|
||||
:paging-style="{ 'background-color': '#FFFFFFFF', 'padding': '20rpx' }" ref="pagingRefSP"
|
||||
v-model="matchedItems_sp" @query="changeSP()" class="fv-page flex-col ">
|
||||
<view v-for="(item, index) in matchedItems_sp" :key="index">
|
||||
<view class="address_box">
|
||||
<view class=" pt-2 pb-2 ps-2 pe-2" style="">
|
||||
<u-cell class="" style="line-height: 60rpx;" :border="false" @click="orderDetail(item.id)">
|
||||
<template #title>
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="26rpx" color="#59CB56"
|
||||
:text="` 配送时间:${item.delivery_date} ${item.delivery_time} `" :flex1="true"
|
||||
align="left" prefixIcon="clock" wordWrap="normal" :show="true"
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="26rpx" color="#59CB56"
|
||||
:text="`${item.customer_name} ( ${item.phone})`" :flex1="true" align="left"
|
||||
wordWrap="normal" :show="true" prefixIcon="map"
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="26rpx" :text="item.address" margin="40rpx" :flex1="true"
|
||||
align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
<view @click.stop="getopenLocation(item)">
|
||||
<u-icon slot="right" label="查看地图" name="map"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="26rpx" :text="`订单编号:${item.order_sn}`" margin="40rpx"
|
||||
:flex1="true" align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="26rpx" :text="`创建时间:${item.create_time}`" margin="40rpx"
|
||||
:flex1="true" align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="26rpx" :text="`付款金额:¥${item.pay_amount}`" margin="40rpx"
|
||||
:flex1="true" align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
</template>
|
||||
</u-cell>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</z-paging>
|
||||
<view class="flex box-border flex-sub" style=" bottom: 20rpx;">
|
||||
<u-text class="" style="margin: 0rpx 0rpx 0rpx 20rpx;" color="#59CB56" size="26rpx"
|
||||
:text="'共计' + checkboxValueNum + '件'" :flex1="true" align="left" wordWrap="normal" :show="true"
|
||||
iconStyle="26rpx" decoration="none">
|
||||
</u-text>
|
||||
<up-button class="" style="" text="提交订单" type="primary" color="#59CB56" shape="circle" size="normal"
|
||||
custom-style="width:200rpx" @click="handleSubmit">
|
||||
</up-button>
|
||||
</view>
|
||||
|
||||
<up-button class="" style="" text="返回首页" type="primary" color="#59CB56" shape="circle" size="normal"
|
||||
custom-style="width:calc(100vw - 50rpx)" @click="goBackHome">
|
||||
</up-button>
|
||||
<!-- </view> -->
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
const CACHE_ADDRESS = {};
|
||||
import { CommonApi } from '@/api';
|
||||
// const { openLocation } = useLocation();
|
||||
import { useLocation } from '@/hooks';
|
||||
import { getCityV2 } from '@/api/api.js';
|
||||
import { useLocation, useModal } from '@/hooks';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
const { openLocation } = useLocation();
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
data () {
|
||||
return {
|
||||
aloneChecked: false, // 是否全选
|
||||
checkboxValueNum: 0, // 选中菜谱数量
|
||||
checkboxValue: [],
|
||||
propShow: false,
|
||||
currentTab: 0, // tab索引
|
||||
menu_list: [{ name: '食谱清单' }, { name: '食菜配置' }],
|
||||
totalNum: 0,
|
||||
keyword_sc: '',
|
||||
goods_info: {},
|
||||
menuIndex: 0,
|
||||
matchedItems_sc: [],
|
||||
goods_list_info:
|
||||
{
|
||||
total_num: 1,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: '猪肉',
|
||||
label: '青椒肉丝',
|
||||
image: ' ',
|
||||
disabled: true,
|
||||
num: 88,
|
||||
unit_name: 'g',
|
||||
default_num: 88,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '毛豆',
|
||||
label: '青椒肉丝',
|
||||
image: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: 'ml',
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '食用油',
|
||||
label: '青椒肉丝',
|
||||
image: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: 'g',
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '豆瓣酱',
|
||||
label: '青椒肉丝',
|
||||
image: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: 'ml',
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '豆瓣酱',
|
||||
label: '青椒肉丝',
|
||||
image: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: 'ml',
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '豆瓣酱',
|
||||
label: '青椒肉丝',
|
||||
image: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: 'ml',
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '豆瓣酱',
|
||||
label: '青椒肉丝',
|
||||
image: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: 'ml',
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '豆瓣酱',
|
||||
label: '青椒肉丝',
|
||||
image: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: 'ml',
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '豆瓣酱',
|
||||
label: '青椒肉丝',
|
||||
image: 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png',
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: 'ml',
|
||||
default_num: 100,
|
||||
},
|
||||
],
|
||||
search_sp: {
|
||||
keyword: '',
|
||||
page: 1,
|
||||
limit: 10,
|
||||
},
|
||||
matchedItems_sp: [],
|
||||
addFrom_address: '',
|
||||
};
|
||||
},
|
||||
created () {
|
||||
// 加载数据
|
||||
this.goodList();
|
||||
onShow () {
|
||||
//进入页面时刷新数据--避免加入购物车不显示
|
||||
this.searchSP();
|
||||
},
|
||||
methods: {
|
||||
goodList () {
|
||||
CommonApi.goodsMenu({ key: 123 }).catch((res) => {
|
||||
if (res.status === 200) {
|
||||
// this.goods_list_info = res.data;
|
||||
console.log(res);
|
||||
}
|
||||
else {
|
||||
uni.$u.toast(res.message);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
changeSC () {
|
||||
console.log('请求食谱数据');
|
||||
try {
|
||||
// 创建正则表达式进行匹配,忽略大小写
|
||||
const regex = new RegExp(this.keyword_sc, 'i');
|
||||
// 直接对 goods_list 使用 filter 进行匹配,并赋值给 matchedItems_sp.value
|
||||
this.matchedItems_sc = this.goods_list_info.info.filter(item => regex.test(item.name));
|
||||
// console.log(matchedItems_sp.value);
|
||||
}
|
||||
catch (error) {
|
||||
console.error('匹配过程中发生错误:', error);
|
||||
this.matchedItems_sc = []; // 发生错误时,将 matchedItems 清空
|
||||
}
|
||||
this.$refs.pagingRefSC.complete();
|
||||
this.$refs.pagingRefSC.complete(this.matchedItems_sc);
|
||||
//搜索事件--直接刷新数据
|
||||
searchSP () {
|
||||
// this.getAddressInfoListData();
|
||||
// console.log('搜索');
|
||||
this.$refs.pagingRefSP?.reload();
|
||||
},
|
||||
//列表分页
|
||||
changeSP () {
|
||||
CommonApi.commonGet('/api/order/list', this.search_sp).catch((res) => {
|
||||
if (res.code === 1) {
|
||||
this.$refs.pagingRefSP?.complete(res.data);
|
||||
// console.log('刷新页面');
|
||||
// res.data.forEach((item) => {
|
||||
// console.log(item);
|
||||
// if (!this.createOrderData.cart_ids.includes(item.id)) {
|
||||
// this.createOrderData.cart_ids.push(item.id);
|
||||
// }
|
||||
// });
|
||||
|
||||
// 点击详情
|
||||
handleClick (value) {
|
||||
console.log(value);
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/goods/detail?id=${value.name}`,
|
||||
});
|
||||
},
|
||||
// 提交订单
|
||||
handleSubmit () {
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/goods/order`,
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 打开地图
|
||||
getopenLocation () {
|
||||
openLocation(32.05, 32.05);
|
||||
getopenLocation (res) {
|
||||
useLocation().openLocation(res.latitude, res.longitude,res.address,res.address)
|
||||
},
|
||||
//点击详情
|
||||
orderDetail (id: number) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/goods/order_detail?id=${id}`
|
||||
});
|
||||
},
|
||||
goBackHome () {
|
||||
uni.switchTab({
|
||||
// url: '/pages/index/index'
|
||||
url: '/pages/tab/user/index'
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
209
src/pages/common/goods/order_detail.vue
Normal file
209
src/pages/common/goods/order_detail.vue
Normal file
@ -0,0 +1,209 @@
|
||||
<style>
|
||||
.flex-sub-cart {
|
||||
flex: 1;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
/* height: 100%; */
|
||||
bottom: 10rpx;
|
||||
position: fixed;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.detail_box {
|
||||
border-top: 2rpx solid #dfdfdf;
|
||||
border-radius: 5rpx;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view>
|
||||
<up-navbar class="" :autoBack="true" style="font-weight: bold;" leftIcon="arrow-left" title="订单详情"
|
||||
titleColor="#303133" bgColor="#FFFFFFFF" titleWidth="600rpx" height="80rpx" leftIconSize="38rpx"
|
||||
leftIconColor="#303133" :safeAreaInsetTop="true" :placeholder="true" :fixed="true"></up-navbar>
|
||||
<view class="address_box">
|
||||
<view class=" pt-2 pb-2 ps-2 pe-2" style="">
|
||||
<u-cell class="" style="line-height: 60rpx;" :border="false" >
|
||||
<template #title>
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="28rpx" color="#59CB56"
|
||||
:text="` 配送时间:${matchedItems_sc.delivery_date} ${matchedItems_sc.delivery_time} `" :flex1="true" align="left"
|
||||
prefixIcon="clock" wordWrap="normal" :show="true"
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="28rpx"
|
||||
:text="`${matchedItems_sc.customer_name} ${matchedItems_sc.phone} `" :flex1="true" align="left"
|
||||
wordWrap="normal" :show="true" prefixIcon="map"
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="28rpx" :text="matchedItems_sc.address" margin="40rpx" :flex1="true"
|
||||
align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:28rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
<view @click="getopenLocation(matchedItems_sc)">
|
||||
<u-icon slot="right" label="查看地图" name="map" color="#59CB56" labelColor="#59CB56"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="h-50 flex">
|
||||
<!-- <up-text class="" size="28rpx" :text="`订单编号:${matchedItems_sc.order_sn}`" margin="40rpx" :flex1="true"
|
||||
align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text> -->
|
||||
<u-icon customStyle="margin: 16rpx;" slot="left" label="订单编号:"></u-icon>
|
||||
<u-icon slot="right" :label="matchedItems_sc.order_sn" ></u-icon>
|
||||
</view>
|
||||
|
||||
<view class="h-50 flex">
|
||||
<!-- <up-text class="" size="28rpx" :text="`创建时间:${matchedItems_sc.create_time}`" margin="40rpx"
|
||||
:flex1="true" align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text> -->
|
||||
<u-icon customStyle="margin: 16rpx;" slot="left" label="创建时间:"></u-icon>
|
||||
<u-icon slot="right" :label="matchedItems_sc.create_time" ></u-icon>
|
||||
</view>
|
||||
<view class="h-50 flex">
|
||||
<!-- <up-text class="" size="28rpx" :text="`付款金额:¥${matchedItems_sc.pay_amount}`" margin="40rpx"
|
||||
:flex1="true" align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text> -->
|
||||
<u-icon customStyle="margin: 16rpx;" slot="left" label="应付金额:"></u-icon>
|
||||
<u-icon slot="right" :label="`¥${matchedItems_sc.pay_amount}`" ></u-icon>
|
||||
</view>
|
||||
<view class="h-50 flex">
|
||||
<u-icon customStyle="margin: 16rpx;" slot="left" label="实付金额:"></u-icon>
|
||||
<u-icon slot="right" :label="`¥${matchedItems_sc.pay_amount}`" ></u-icon>
|
||||
</view>
|
||||
</template>
|
||||
</u-cell>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="detail_box">
|
||||
<!-- <up-cell class=" " style="" :title="matchedItems_sc.name" :label="matchedItems_sc.intro">
|
||||
</up-cell> -->
|
||||
<view class="p-2">
|
||||
<view class="flex box-border flex-row pb-2 ps-2 pe-2" style="" @click="changeTab">
|
||||
<up-tabs v-model:current="currentTab" style="font-weight: bold;" :list="menu_list" key-name="name"
|
||||
line-color="#18C936" line-width="40rpx" line-height="6rpx" line-bg-size="cover"
|
||||
:scrollable="true" />
|
||||
</view>
|
||||
<z-paging v-if="!currentTab" :fixed="false" height="calc(100vh - 700rpx)" width="calc(100vw - 50rpx)"
|
||||
:paging-style="{ 'background-color': '#FFFFFFFF', 'padding': '20rpx' }" class="fv-page flex-col ">
|
||||
<view class="flex" style="padding:20rpx" v-for="(item, index) in matchedItems_sc.orderDishes"
|
||||
:key="index">
|
||||
<up-text class="" size="28rpx" color="#9b9b9b" :text="item.dishes_info.name" :flex1="true"
|
||||
align="left" wordWrap="normal" :show="true" lines="1" decoration="none">
|
||||
</up-text>
|
||||
<up-text class="" color="#9b9b9b" size="24rpx" :text="`${item.num}/份 ¥${item.price}`"
|
||||
:flex1="true" align="right" wordWrap="normal" :show="true"
|
||||
iconStyle="font-size: 28rpx;font-weight: bold;margin-right:10rpx;color: #59CB56;"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
</z-paging>
|
||||
<z-paging v-if="currentTab" :fixed="false" height="calc(100vh - 700rpx)" width="calc(100vw - 50rpx)"
|
||||
:paging-style="{ 'background-color': '#FFFFFFFF', 'padding': '20rpx' }" class="fv-page flex-col ">
|
||||
<view class="flex" style="padding:20rpx" v-for="(item, index) in matchedItems_sc.orderProduct"
|
||||
:key="index">
|
||||
<up-text class="" size="28rpx" color="#9b9b9b" :text="item.product_info.name" :flex1="true"
|
||||
align="left" wordWrap="normal" :show="true" lines="1" decoration="none">
|
||||
</up-text>
|
||||
<up-text class="" color="#9b9b9b" size="24rpx" :text="`${item.num}/份 ¥${item.price}`"
|
||||
:flex1="true" align="right" wordWrap="normal" :show="true"
|
||||
iconStyle="font-size: 28rpx;font-weight: bold;margin-right:10rpx;color: #59CB56;"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
</z-paging>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex box-border flex-sub-cart">
|
||||
<!-- <view>
|
||||
<u-icon custom-style="margin: 20rpx;" slot="right" :label="`总数:¥${matchedItems_sc.total_num} `" name="map" color="#59CB56"></u-icon>
|
||||
<u-icon custom-style="margin: 20rpx;" slot="right" :label="`总数:¥${matchedItems_sc.total_amount} `" name="map" color="#59CB56"></u-icon>
|
||||
</view> -->
|
||||
<!-- <u-text class=""
|
||||
custom-style="width: calc(100vw - 220rpx);text-align:center;display: flex; justify-content: center; align-items: center;height: 160rpx;border: 2px solid #59cb56;border-radius: 40rpx;background-color: #5acb5617;margin: 0rpx 20rpx!important;"
|
||||
color="#59CB56" size="28rpx" :text="'加入食谱清单'" :flex1="true" align="center" wordWrap="normal"
|
||||
:show="true" iconStyle="26rpx" decoration="none">
|
||||
</u-text> -->
|
||||
<up-button class="" style="" text="返回首页" type="primary" color="#59CB56" shape="circle" size="normal"
|
||||
custom-style="width:calc(100vw - 50rpx)" @click="goBackHome">
|
||||
</up-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { CommonApi, UserApi } from "@/api";
|
||||
import { useLocation, useModal } from '@/hooks';
|
||||
// import { setToken, getToken, isLogin } from '@/utils/auth';
|
||||
// import { image } from "@/uni_modules/uview-plus/libs/function/test";
|
||||
// import { url } from "inspector";
|
||||
export default defineComponent({
|
||||
data () {
|
||||
return {
|
||||
search: {
|
||||
id: 0,
|
||||
},
|
||||
currentTab: 0, // tab索引
|
||||
is_add: 0, //是否显示购物车
|
||||
matchedItems_sc: [],
|
||||
imageList: [],
|
||||
menu_list: [{ name: '食谱清单' }, { name: '食菜配置' }],
|
||||
};
|
||||
},
|
||||
onLoad (option) {
|
||||
// console.log(option);
|
||||
this.search.id = option.id;
|
||||
this.is_add = option.is_add | 0;
|
||||
this.getCategoryList()
|
||||
},
|
||||
created () {
|
||||
|
||||
},
|
||||
methods: {
|
||||
getCategoryList () {
|
||||
CommonApi.commonGet('/api/order/detail', this.search).catch((res) => {
|
||||
if (res.code === 1) {
|
||||
this.matchedItems_sc = res.data;
|
||||
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
changeTab () {
|
||||
|
||||
},
|
||||
goBackHome () {
|
||||
uni.switchTab({
|
||||
|
||||
url: '/pages/tab/user/index'
|
||||
});
|
||||
},
|
||||
// 打开地图
|
||||
getopenLocation (res) {
|
||||
useLocation().openLocation(res.latitude, res.longitude,res.address,res.address)
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
604
src/pages/common/goods/pay_order.vue
Normal file
604
src/pages/common/goods/pay_order.vue
Normal file
@ -0,0 +1,604 @@
|
||||
<style>
|
||||
.ellipsis {
|
||||
/* 在末尾显示省略号 */
|
||||
width: 420rpx;
|
||||
/* 防止文字换行 */
|
||||
overflow: hidden;
|
||||
/* 隐藏超出部分的文字 */
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
/* 确保元素有宽度 */
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<u-popup :show="propShowAddress" :round="10" mode="bottom" @close="closeAddress" :zIndex=2>
|
||||
<view style="padding: 20rpx;height:calc(100vh - 180rpx) ">
|
||||
|
||||
<u-cell class="" style="line-height: 60rpx;" :border="true">
|
||||
<template #title>
|
||||
<view class="h-50 flex" @click="closeAddress">
|
||||
<text class="ellipsis" style="font-size: 26rpx;font-weight: bold;">
|
||||
添加地址
|
||||
</text>
|
||||
<up-text class="pe-2" size="22rpx" text="取消" :flex1="true" suffix-icon="arrow-up"
|
||||
align="right" word-wrap="normal" :show="true" type="#59CB56"
|
||||
icon-style="font-size: 22rpx; " decoration="none" />
|
||||
</view>
|
||||
</template>
|
||||
</u-cell>
|
||||
<view class="address_box">
|
||||
<view class=" pt-2 pb-2 ps-2 pe-2" style="">
|
||||
<u-cell class="" style="line-height: 60rpx;" :border="false">
|
||||
<template #title>
|
||||
<up-input placeholder="请输入姓名" v-model="addFrom.real_name">
|
||||
<template #prefix>
|
||||
<up-text align="left" customStyle="width:120rpx" text="姓名" margin="0 8px 0 0"
|
||||
type="tips"></up-text>
|
||||
</template>
|
||||
</up-input>
|
||||
<up-input placeholder="请输入联系电话" v-model="addFrom.phone">
|
||||
<template #prefix>
|
||||
<up-text align="left" customStyle="width:120rpx" text="联系电话" margin="0 8px 0 0"
|
||||
type="tips"></up-text>
|
||||
</template>
|
||||
</up-input>
|
||||
<up-input placeholder="请选择地址" v-model="addFrom_address" @click="getopenLocation(0)">
|
||||
<template #prefix>
|
||||
<up-text align="left" customStyle="width:120rpx" text="所在地区" margin="0 8px 0 0"
|
||||
type="tips"></up-text>
|
||||
</template>
|
||||
<template #suffix>
|
||||
|
||||
<!-- <up-button @tap="getCode" text="2312312" type="success" size="mini"></up-button> -->
|
||||
<up-text class="" color="#59CB56" size="24rpx" text="定位" :flex1="true"
|
||||
prefix-icon="map" align="left" word-wrap="normal" :show="true"
|
||||
icon-style="font-size: 36rpx;font-weight: bold;color:#59CB56;"
|
||||
decoration="none" @click.stop="getopenLocation(1)" />
|
||||
</template>
|
||||
</up-input>
|
||||
<up-input placeholder="请输入详细地址" v-model="addFrom.detail">
|
||||
<template #prefix>
|
||||
<up-text align="left" customStyle="width:120rpx" text="详细地址" margin="0 8px 0 0"
|
||||
type="tips"></up-text>
|
||||
</template>
|
||||
</up-input>
|
||||
</template>
|
||||
</u-cell>
|
||||
</view>
|
||||
</view>
|
||||
<view class="address_box">
|
||||
<view class=" pt-2 pb-2 ps-2 pe-2" style="">
|
||||
<u-cell class="" style="line-height: 60rpx;" :border="false">
|
||||
<template #title>
|
||||
<view class="h-50 flex" @click="open">
|
||||
<up-checkbox-group v-model="aloneCheckedValue">
|
||||
<up-checkbox :checked="addFrom.is_default" class="" shape="circle"
|
||||
active-color="#59CB56" @change="handleAllCheckChange" />
|
||||
</up-checkbox-group>
|
||||
<up-text class="" size="24rpx" :text="`设置未默认地址`" :flex1="true" align="left"
|
||||
word-wrap="normal" :show="true" icon-style="22rpx" decoration="none" />
|
||||
</view>
|
||||
|
||||
</template>
|
||||
</u-cell>
|
||||
</view>
|
||||
</view>
|
||||
<up-button class="" style="" text="立即保存" type="primary" color="#59CB56" shape="circle" size="normal"
|
||||
custom-style="width: calc(100% - 100rpx);" @click="updateAddress">
|
||||
</up-button>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
|
||||
<u-popup :show="propShow" :round="10" mode="bottom" @close="closeProp" :zIndex=1>
|
||||
<view style="padding: 20rpx;">
|
||||
<u-cell class="" style="line-height: 60rpx;" :border="true">
|
||||
<template #title>
|
||||
<view class="h-50 flex" @click="closeProp">
|
||||
<text class="ellipsis" style="font-size: 26rpx;font-weight: bold;">
|
||||
选择地址
|
||||
</text>
|
||||
<up-text class="pe-2" size="22rpx" text="收起" :flex1="true" suffix-icon="arrow-up"
|
||||
align="right" word-wrap="normal" :show="true" type="#59CB56"
|
||||
icon-style="font-size: 22rpx; " decoration="none" />
|
||||
</view>
|
||||
</template>
|
||||
</u-cell>
|
||||
<scroll-view style="height: 700rpx;" scroll-y="true">
|
||||
<view class="address_box" v-for="(item, index) in addressInfoListData" :key="index">
|
||||
<view class="p-2" style="">
|
||||
<u-cell class="" style="line-height: 60rpx;" :border="false" @click="confirmAddress(item)">
|
||||
<template #title>
|
||||
<view class="h-50 flex">
|
||||
<u-text class="" size="26rpx" :text="`${item.real_name} ${item.phone}`"
|
||||
:flex1="true" align="left" wordWrap="normal" :show="true" prefixIcon="map"
|
||||
:color="item.id === createOrderData.address_id ? '#59CB56' : ''"
|
||||
:iconStyle="item.id === createOrderData.address_id ? 'color:#59CB56;font-size:32rpx;margin-right:10rpx;' : '' + 'font-size:32rpx;margin-right:10rpx;'"
|
||||
lines="1" decoration="none">
|
||||
</u-text>
|
||||
<view @click.stop="editAddress(item)"> <u-icon slot="right"
|
||||
name="edit-pen" label="修改" ></u-icon> </view>
|
||||
|
||||
<!-- <u-text class="" size="26rpx" :text="item.phone" :flex1="true" align="left"
|
||||
wordWrap="normal" :show="true"
|
||||
:color="item.id === createOrderData.address_id ? '#59CB56' : ''"
|
||||
decoration="none">
|
||||
</u-text> -->
|
||||
</view>
|
||||
<view class="h-50 flex">
|
||||
<up-text class="" size="26rpx" :text="item.address_info" margin="40rpx"
|
||||
:flex1="true" align="left" wordWrap="normal" :show="true"
|
||||
:color="item.id === createOrderData.address_id ? '#59CB56' : ''"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
<view @click.stop="deleteAddress(item.id)"> <u-icon slot="right"
|
||||
name="trash" label="删除"></u-icon></view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
</u-cell>
|
||||
</view>
|
||||
</view>
|
||||
<view class="pb-4" />
|
||||
</scroll-view>
|
||||
<up-button class="" style="" text="添加地址" type="primary" color="#59CB56" shape="circle" size="normal"
|
||||
custom-style="width: calc(100% - 100rpx);" @click="addAddress">
|
||||
</up-button>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<u-datetime-picker ref="datetimePicker" @close="cancelDelivery" :show="showDelivery" v-model="time_value"
|
||||
:formatter="formatter" mode="datetime" @confirm="confirmDelivery"
|
||||
@cancel="cancelDelivery"></u-datetime-picker>
|
||||
|
||||
<up-navbar class=" " :autoBack="true" style="font-weight: bold;" leftIcon="arrow-left" title="提交订单"
|
||||
titleColor="#303133" bgColor="#FFFFFFFF" titleWidth="600rpx" height="80rpx" leftIconSize="40rpx"
|
||||
leftIconColor="#303133" :safeAreaInsetTop="true" :placeholder="true" :fixed="true"></up-navbar>
|
||||
<view class="address_box">
|
||||
<view class=" pt-2 pb-2 ps-2 pe-2" style="">
|
||||
<u-cell class="" style="line-height: 60rpx;" :border="false">
|
||||
<template #title>
|
||||
<view class="h-50 flex" @click="open">
|
||||
<u-text class="" size="26rpx"
|
||||
:text="`${default_address.real_name} ${default_address.phone}`" :flex1="true"
|
||||
align="left" wordWrap="normal" :show="true" prefixIcon="map"
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</u-text>
|
||||
<!-- <u-text class="" size="26rpx" :text="default_address.phone" :flex1="true" align="left"
|
||||
wordWrap="normal" :show="true" margin="40rpx"
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</u-text> -->
|
||||
</view>
|
||||
<view class="h-50 flex" @click="open">
|
||||
<up-text class="" size="26rpx" :text="default_address.address_info" margin="40rpx"
|
||||
:flex1="true" align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</view>
|
||||
<view class="h-50 flex" @click="getopenDelivery">
|
||||
<up-text class="" size="26rpx" color="#59CB56" :text="delivery" :flex1="true" align="left"
|
||||
prefixIcon="clock" wordWrap="normal" :show="true"
|
||||
iconStyle="font-size:32rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</view>
|
||||
</template>
|
||||
</u-cell>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<z-paging :fixed="false" height="calc(100vh - 380rpx)" width="calc(100vw - 50rpx)"
|
||||
:paging-style="{ 'background-color': '#FFFFFFFF', 'padding': '20rpx' }" ref="pagingRefSP"
|
||||
v-model="matchedItems_sp" @query="changeSP()" class="fv-page flex-col ">
|
||||
<view v-for="(item, index) in matchedItems_sp" :key="index">
|
||||
<u-cell @click="goodsDetail(item.dishes_id)">
|
||||
<template #icon>
|
||||
<up-image class="flex flex-row" style="border:1px solid #59CB56;border-radius: 5rpx;"
|
||||
:src="item.cartDishes.image" mode="aspectFill" width="120rpx" height="120rpx" shape="square"
|
||||
:lazyLoad="true" duration="500" bgColor="#f3f4f6NaN" :showMenuByLongpress="true">
|
||||
</up-image>
|
||||
</template>
|
||||
<template #title>
|
||||
<view class="h-60 flex">
|
||||
<text class="ellipsis" style="font-size: 28rpx;">
|
||||
{{ item.cartDishes.name }}
|
||||
</text>
|
||||
<up-text class="text-black" size="24rpx" :text="` ${item.cartDishes.people}人份`"
|
||||
:flex1="true" suffix-icon="" align="right" word-wrap="normal" :show="true"
|
||||
type="#59CB56" icon-style="font-size: 36rpx;font-weight: bold;" decoration="none" />
|
||||
</view>
|
||||
</template>
|
||||
<template #label>
|
||||
<view class="h-60 flex">
|
||||
<text class=" text-gray ellipsis" style="font-size: 22rpx;"> 主料:{{ item.cartDishes.intro
|
||||
}}</text>
|
||||
<up-text class="text-black" size="24rpx" :text="`销量:${item.cartDishes.sale_num} `"
|
||||
:flex1="true" suffix-icon="" align="right" word-wrap="normal" :show="true"
|
||||
type="#59CB56" icon-style="font-size: 36rpx;font-weight: bold;" decoration="none" />
|
||||
</view>
|
||||
</template>
|
||||
</u-cell>
|
||||
|
||||
</view>
|
||||
</z-paging>
|
||||
<view class="flex box-border flex-sub" style=" bottom: 20rpx;">
|
||||
<u-text class="" style="margin: 0rpx 0rpx 0rpx 20rpx;" color="#59CB56" size="26rpx"
|
||||
:text="'共计' + cartNUM + '件'" :flex1="true" align="left" wordWrap="normal" :show="true" iconStyle="26rpx"
|
||||
decoration="none">
|
||||
</u-text>
|
||||
<up-button class="" style="" text="提交订单" type="primary" color="#59CB56" shape="circle" size="normal"
|
||||
custom-style="width:200rpx" @click="handleSubmit">
|
||||
</up-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
const CACHE_ADDRESS = {};
|
||||
import { CommonApi } from '@/api';
|
||||
import { getCityV2 } from '@/api/api.js';
|
||||
import { useLocation, useModal } from '@/hooks';
|
||||
import { it } from 'node:test';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
data () {
|
||||
return {
|
||||
cartNUM: 0, //当前购物车数量
|
||||
// search_sp: {
|
||||
// keyword: '',
|
||||
// page: 1,
|
||||
// limit: 10,
|
||||
// },
|
||||
propShowAddressDetail: false, //选择地址下拉
|
||||
propShowAddress: false, //是否显示添加地址
|
||||
propShow: false, //是否显示弹窗
|
||||
time_value: Number(new Date()),
|
||||
showDelivery: false, //是否显示配送时间
|
||||
// address_info: '请选择收货地址',
|
||||
delivery: '请选择配送时间',
|
||||
default_address: {
|
||||
real_name: '未选择地址',
|
||||
phone: '',
|
||||
address_info: '请选择收货地址',
|
||||
}, //默认地址
|
||||
addressInfoListData: [], //用户地址列表
|
||||
createOrderData: {
|
||||
address_id: '',
|
||||
delivery_date: '',
|
||||
delivery_time: '',
|
||||
cart_ids: [],
|
||||
},
|
||||
matchedItems_sp: [],
|
||||
aloneCheckedValue: [], //单独选中的值
|
||||
addFrom: {
|
||||
id: 0,
|
||||
real_name: '',
|
||||
phone: '',
|
||||
province: '',
|
||||
city: '',
|
||||
district: '',
|
||||
detail: '',
|
||||
is_default: false,
|
||||
latitude: '',
|
||||
longitude: '',
|
||||
},//新增地址
|
||||
default_addFrom: {
|
||||
id: 0,
|
||||
real_name: '',
|
||||
phone: '',
|
||||
province: '',
|
||||
city: '',
|
||||
district: '',
|
||||
detail: '',
|
||||
is_default: false,
|
||||
latitude: '',
|
||||
longitude: '',
|
||||
},//默认地址
|
||||
addFrom_address: '',
|
||||
|
||||
|
||||
};
|
||||
},
|
||||
onShow () {
|
||||
//进入页面时刷新数据--避免加入购物车不显示
|
||||
this.searchSP();
|
||||
},
|
||||
onReady () {
|
||||
// 微信小程序需要用此写法
|
||||
this.$refs.datetimePicker.setFormatter(this.formatter)
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 时间选择器--兼容小程序
|
||||
formatter (type, value) {
|
||||
if (type === 'year') {
|
||||
return `${value}年`
|
||||
}
|
||||
if (type === 'month') {
|
||||
return `${value}月`
|
||||
}
|
||||
if (type === 'day') {
|
||||
return `${value}日`
|
||||
}
|
||||
if (type === 'hour') {
|
||||
return `${value}时`
|
||||
}
|
||||
if (type === 'minute') {
|
||||
return `${value}分`
|
||||
}
|
||||
return value
|
||||
},
|
||||
// 选择配送时间
|
||||
confirmDelivery () {
|
||||
this.showDelivery = false;
|
||||
this.formattedDate()
|
||||
},
|
||||
formattedDate () {
|
||||
const date = new Date(this.time_value);
|
||||
this.delivery = '配送时间:' + ` ${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()} `;
|
||||
this.createOrderData.delivery_date = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
||||
this.createOrderData.delivery_time = `${date.getHours()}:${date.getMinutes()}`;
|
||||
// :${date.getSeconds()}
|
||||
},
|
||||
|
||||
cancelDelivery () {
|
||||
this.showDelivery = false;
|
||||
// this.showPicker = false;
|
||||
},
|
||||
//配送时间弹窗
|
||||
getopenDelivery () {
|
||||
this.showDelivery = true;
|
||||
},
|
||||
|
||||
//搜索事件--直接刷新数据
|
||||
searchSP () {
|
||||
this.getAddressInfoListData();
|
||||
// console.log('搜索');
|
||||
this.$refs.pagingRefSP?.reload();
|
||||
},
|
||||
//列表分页
|
||||
changeSP () {
|
||||
CommonApi.commonGet('/api/order/check').catch((res) => {
|
||||
if (res.code === 1) {
|
||||
this.$refs.pagingRefSP?.complete(res.data);
|
||||
// console.log('刷新页面');
|
||||
res.data.forEach((item) => {
|
||||
console.log(item);
|
||||
if (!this.createOrderData.cart_ids.includes(item.id)) {
|
||||
this.createOrderData.cart_ids.push(item.id);
|
||||
}
|
||||
});
|
||||
this.getCartNum()
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
//点击详情
|
||||
goodsDetail (id: number) {
|
||||
console.log(id);
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/goods/detail?id=${id}`
|
||||
});
|
||||
},
|
||||
// 提交订单
|
||||
handleSubmit () {
|
||||
console.log(this.cartNUM);
|
||||
if (this.cartNUM === 0) {
|
||||
useModal().showModal('error', {
|
||||
content: '当前购物车为空,请前往添加食谱',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.createOrderData.address_id === '') {
|
||||
useModal().showModal('error', {
|
||||
content: '请选择收货地址',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.createOrderData.delivery_date === '' || this.createOrderData.delivery_time === '') {
|
||||
useModal().showModal('error', {
|
||||
content: '请选择配送时间',
|
||||
});
|
||||
return;
|
||||
}
|
||||
// console.log(this.createOrderData);
|
||||
// //提交订单
|
||||
CommonApi.commonPost('/api/order/create', this.createOrderData).catch((res) => {
|
||||
if (res.code === 1) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/goods/order`,
|
||||
});
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
// 打开地图
|
||||
getopenLocation (is_local) {
|
||||
var that = this;
|
||||
//定位
|
||||
if (is_local) {
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
success: function (res) {
|
||||
CommonApi.commonGet(`https://test.shop.lihaink.cn/api/lbs/geocoder?location=${res.latitude},${res.longitude}`).catch((res) => {
|
||||
if (res.status === 200) {
|
||||
that.addFrom_address = res.data.address
|
||||
that.addFrom.province = res.data.address_component.province
|
||||
that.addFrom.city = res.data.address_component.city
|
||||
that.addFrom.district = res.data.address_component.district
|
||||
that.addFrom.latitude = res.data.location.latitude
|
||||
that.addFrom.longitude = res.data.location.longitude
|
||||
// that.addFrom.detail = res.data.address_component.street
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log(res)
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//打开导航
|
||||
// useLocation().openLocation(res.latitude, res.longitude);
|
||||
uni.chooseLocation({
|
||||
success: function (res) {
|
||||
console.log('选择地图', res);
|
||||
CommonApi.commonGet(`https://test.shop.lihaink.cn/api/lbs/geocoder?location=${res.latitude},${res.longitude}`).catch((res) => {
|
||||
if (res.status === 200) {
|
||||
console.log(res);
|
||||
that.addFrom_address = res.data.address
|
||||
that.addFrom.province = res.data.address_component.province
|
||||
that.addFrom.city = res.data.address_component.city
|
||||
that.addFrom.district = res.data.address_component.district
|
||||
that.addFrom.latitude = res.data.location.lat
|
||||
that.addFrom.longitude = res.data.location.long
|
||||
// that.addFrom.detail = res.data.address_component.street
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('取消选择或出错:', err);
|
||||
},
|
||||
complete: function () {
|
||||
console.log('选择位置操作完成');
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
//购物车数量
|
||||
getCartNum () {
|
||||
CommonApi.commonGet('/api/cart/count').catch((res) => {
|
||||
if (res.code === 1) {
|
||||
this.cartNUM = res.data.count;
|
||||
}
|
||||
});
|
||||
},
|
||||
//用户地址列表
|
||||
getAddressInfoListData () {
|
||||
CommonApi.commonGet('/api/user/address').catch((res) => {
|
||||
if (res.code === 1) {
|
||||
this.addressInfoListData = res.data;
|
||||
if (this.addressInfoListData.length > 0) {
|
||||
//格式化地址信息
|
||||
this.addressInfoListData.forEach((item, index) => {
|
||||
this.addressInfoListData[index].province = item.province === null ? '' : item.province;
|
||||
this.addressInfoListData[index].city = item.city === null ? '' : item.city;
|
||||
this.addressInfoListData[index].district = item.district === null ? '' : item.district;
|
||||
this.addressInfoListData[index].street = item.street === null ? '' : item.street;
|
||||
this.addressInfoListData[index].detail = item.detail === null ? '' : item.detail;
|
||||
this.addressInfoListData[index].address_info =
|
||||
item.province +
|
||||
item.city +
|
||||
item.district +
|
||||
item.street +
|
||||
item.detail;
|
||||
});
|
||||
//默认地址
|
||||
let find_address = this.addressInfoListData.find(item => item.is_default === 1);
|
||||
if (find_address) {
|
||||
this.default_address = find_address;
|
||||
this.createOrderData.address_id = find_address.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
//选择地址
|
||||
confirmAddress (find_address) {
|
||||
this.propShow = false;
|
||||
this.default_address = find_address;
|
||||
this.createOrderData.address_id = find_address.id;
|
||||
},
|
||||
|
||||
deleteAddress (id) {
|
||||
CommonApi.commonPost('/api/user/deleteAddress',{id:id}).catch((res) => {
|
||||
if (res.code === 1) {
|
||||
// this.propShowAddress = false;
|
||||
this.getAddressInfoListData();
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
//修改地址
|
||||
editAddress (itme) {
|
||||
this.addFrom = {
|
||||
id: itme.id,
|
||||
real_name: itme.real_name,
|
||||
phone: itme.phone,
|
||||
province: itme.province,
|
||||
city: itme.city,
|
||||
district: itme.district,
|
||||
detail: itme.detail,
|
||||
is_default: itme.is_default ? true : false,
|
||||
latitude: itme.latitude,
|
||||
longitude: itme.longitude,
|
||||
}
|
||||
//地址回填
|
||||
this.addFrom_address = itme.province +
|
||||
itme.city +
|
||||
itme.district +
|
||||
itme.street
|
||||
this.propShowAddress = true;
|
||||
|
||||
},
|
||||
//添加收货地址
|
||||
addAddress () {
|
||||
this.addFrom = this.default_addFrom;
|
||||
//地址回填
|
||||
this.addFrom_address = '';
|
||||
this.propShowAddress = true;
|
||||
},
|
||||
// 选择地址弹窗
|
||||
open () {
|
||||
this.propShow = true;
|
||||
},
|
||||
closeAddress () {
|
||||
this.propShowAddress = false;
|
||||
},
|
||||
|
||||
closeProp () {
|
||||
this.propShow = false;
|
||||
},
|
||||
// 添加选择地址
|
||||
updateAddress () {
|
||||
var url = '/api/user/updateAddress';
|
||||
if (this.addFrom.id === 0) {
|
||||
var url = '/api/user/addAddress';
|
||||
}
|
||||
// console.log(this.addFrom);
|
||||
CommonApi.commonPost(url, this.addFrom).catch((res) => {
|
||||
if (res.code === 1) {
|
||||
this.propShowAddress = false;
|
||||
this.getAddressInfoListData();
|
||||
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
handleAllCheckChange (e) {
|
||||
this.addFrom.is_default = e;
|
||||
},
|
||||
|
||||
},
|
||||
});
|
||||
</script>
|
@ -123,9 +123,12 @@ async function submit() {
|
||||
}
|
||||
await userStore.passwordLogin({ account: account.value, password: password.value }).catch((res) => {
|
||||
console.log(res);
|
||||
if (res.status === 200) {
|
||||
setToken(res.data.token);
|
||||
uni.$u.toast('登录成功');
|
||||
if (res.code === 1) {
|
||||
// const token = res.data.token;
|
||||
// if (token) {
|
||||
// setToken(token.token_type+' '+token.token);
|
||||
// }
|
||||
uni.$u.toast('登录成功');
|
||||
}
|
||||
else {
|
||||
uni.$u.toast(`登录失败,${res.message}`);
|
||||
@ -138,8 +141,11 @@ async function submit() {
|
||||
return;
|
||||
}
|
||||
await userStore.login({ account: account.value, code: password.value }).catch(() => {
|
||||
if (res.status === 200) {
|
||||
setToken(res.data.token);
|
||||
if (res.code === 1) {
|
||||
// const token = res.data.token;
|
||||
// if (token) {
|
||||
// setToken(token.token_type+' '+token.token);
|
||||
// }
|
||||
uni.$u.toast('登录成功');
|
||||
}
|
||||
else {
|
||||
@ -148,7 +154,7 @@ async function submit() {
|
||||
});
|
||||
}
|
||||
if(isLogin()){
|
||||
await userStore.info()
|
||||
// await userStore.info()
|
||||
setTimeout(() => {
|
||||
uni.$u.route({
|
||||
type: isTabBarPath(redirect) ? 'switchTab' : 'redirectTo',
|
||||
|
@ -12,7 +12,7 @@
|
||||
}
|
||||
|
||||
.ellipsis_text {
|
||||
width: 340rpx !important;
|
||||
// width: 340rpx !important;
|
||||
// width: calc(100% - 80rpx)!important;
|
||||
}
|
||||
|
||||
@ -30,33 +30,33 @@ body {
|
||||
<up-navbar class=" " style="font-weight: bold;" leftIcon="" title="食谱菜单" titleColor="#303133" bgColor="#FFFFFFFF"
|
||||
titleWidth="600rpx" height="80rpx" leftIconSize="40rpx" leftIconColor="#303133" :safeAreaInsetTop="true"
|
||||
:placeholder="true" :fixed="true"></up-navbar>
|
||||
<up-search v-model="keyword_sp" class="flex,flex-row p-1" style="" shape="round" bgColor="#f2f2f2" placeholder="输入食谱" :clearabled="true"
|
||||
:showAction="false" inputAlign="left" borderColor="transparent" searchIconColor="#909399" color="#606266"
|
||||
placeholderColor="#909399" searchIcon="search" margin="10rpx" maxlength="-1" height="60rpx"
|
||||
@change="changeSP">
|
||||
<up-search v-model="search.keyword" class="flex,flex-row p-1" style="" shape="round" bgColor="#f2f2f2"
|
||||
placeholder="输入食谱" :clearabled="true" :showAction="false" inputAlign="left" borderColor="transparent"
|
||||
searchIconColor="#909399" color="#606266" placeholderColor="#909399" searchIcon="search" margin="10rpx"
|
||||
maxlength="-1" height="60rpx" @change="searchSP()">
|
||||
</up-search>
|
||||
<u-scroll-list :indicator="false">
|
||||
<view class="scroll-list" style="flex-direction: row;">
|
||||
<view class="scroll-list__goods-item " v-for="(item, index) in list" :key="index"
|
||||
:class="(index === menuIndex) ? 'row-active' : ''" @click="handleClick(index)"
|
||||
<view class="scroll-list" style="flex-direction: row;width: 56px;">
|
||||
<view class="scroll-list__goods-item " v-for="(item, index) in categoryList" :key="index"
|
||||
:class="(index === categoryIndex) ? 'row-active' : ''" @click="handleClickCategory(index)"
|
||||
:style="{ backgroundColor: item.bgColor }">
|
||||
<image class="scroll-list__goods-item__image" :src="item.image"
|
||||
:class="(index === menuIndex) ? 'border-row-active' : ''"></image>
|
||||
<image class="scroll-list__goods-item__image"
|
||||
:src="item.image ? item.image : 'https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png'"
|
||||
:class="(index === categoryIndex) ? 'border-row-active' : ''"></image>
|
||||
<text class="scroll-list__goods-item__text">{{ item.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</u-scroll-list>
|
||||
|
||||
|
||||
<z-paging v-model="matchedItems_sp" :fixed="false" height="calc(100vh - 360rpx)" width="200rpx" ref="pagingRefSP"
|
||||
loading-more-default-text="" style=" left:0; padding: 0px; position: fixed;" class="fv-page flex-col px-4">
|
||||
<z-paging :fixed="false" height="calc(100vh - 360rpx)" width="200rpx" loading-more-default-text=""
|
||||
style=" left:0; padding: 0px; position: fixed;" class="fv-page flex-col px-4">
|
||||
<u-scroll-list :indicator="false">
|
||||
<view class="scroll-list" style="flex-direction: column;">
|
||||
<view class="scroll-list__goods-item-column " v-for="(item, index) in list" :key="index"
|
||||
:class="(index === menuIndex) ? 'column-active' : ''" @click="handleClick(index)"
|
||||
<view class="scroll-list__goods-item-column " v-for="(item, index) in tabList" :key="index"
|
||||
:class="(index === childrenIndex) ? 'column-active' : ''" @click="handleChildrenClick(index)"
|
||||
:style="{ backgroundColor: item.bgColor }">
|
||||
<!-- <image class="scroll-list__goods-item__image" :src="item.image"></image> -->
|
||||
|
||||
<slot name="tabItem">
|
||||
</slot>
|
||||
<!-- <view style="padding: 20px 0px;"> </view> -->
|
||||
@ -65,25 +65,39 @@ body {
|
||||
</view>
|
||||
</u-scroll-list>
|
||||
</z-paging>
|
||||
<z-paging ref="pagingRefSP" v-model="matchedItems_sp" @query="changeSP" :fixed="false" height="calc(100vh - 360rpx)"
|
||||
width="calc(100vw - 220rpx)" style="right: 0; background-color: #FFFFFFFF; position: fixed;"
|
||||
class="fv-page flex-col px-4">
|
||||
<z-paging ref="pagingRefSP" v-model="matchedItems_sp" @query="changeSP" :fixed="false" height="calc(100vh - 380rpx)"
|
||||
width="calc(100vw - 200rpx)" style="right: 0; background-color: #FFFFFFFF; position: fixed;"
|
||||
class="fv-page flex-col">
|
||||
|
||||
<view v-for="(item, index) in goods_list" :key="index">
|
||||
<view v-for="(item, index) in matchedItems_sp" :key="index">
|
||||
<up-cell :border='false' @click="goodsDetail(item.id)">
|
||||
<template #icon>
|
||||
<up-image :src="item.image" width="140rpx" height="140rpx"></up-image>
|
||||
</template>
|
||||
<template v-slot:title>
|
||||
<view class="h-50 text-md ellipsis" style="font-size: 24rpx;">
|
||||
{{ item.name }}
|
||||
</view>
|
||||
<view class="h-50 flex">
|
||||
<up-text size="28rpx" :text="`${item.name}`" :flex1="true" align="left"
|
||||
wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:26rpx;color:#59CB56;margin-right:10rpx;" lines="1" decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
|
||||
<view class="h-50 flex">
|
||||
<text class=" text-gray ellipsis" style="font-size: 22rpx;">主料:{{ item.label }}</text>
|
||||
<up-text color="#767676" size="24rpx" :text="`主料:${item.intro}`" :flex1="true"
|
||||
align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:26rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
</view>
|
||||
<view class="h-50 flex ellipsis_text">
|
||||
<text class=" text-md text-gray ellipsis" style="font-size: 22rpx;">营养:{{ item.label }}</text>
|
||||
<up-icon align="right" name="plus-circle" color="#59CB56" size="42rpx"></up-icon>
|
||||
<view class="h-50 flex ellipsis_text" >
|
||||
<up-text color="#767676" size="24rpx" :text="`营养:${item.intro}`" :flex1="true"
|
||||
align="left" wordWrap="normal" :show="true" prefixIcon=""
|
||||
iconStyle="font-size:26rpx;color:#59CB56;margin-right:10rpx;" lines="1"
|
||||
decoration="none">
|
||||
</up-text>
|
||||
<view @click.stop="addCart(item.id)">
|
||||
<u-icon slot="right" label="" size="42rpx" name="plus-circle" color="#59CB56" labelColor="#59CB56"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</up-cell>
|
||||
@ -96,743 +110,100 @@ body {
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { CommonApi, UserApi } from "@/api";
|
||||
import { setToken, getToken, isLogin } from '@/utils/auth';
|
||||
export default defineComponent({
|
||||
data () {
|
||||
return {
|
||||
keyword_sp: '',
|
||||
menuIndex: 0,
|
||||
matchedItems_sp: [],
|
||||
tabList: [],
|
||||
list1: [{
|
||||
title: "白菜",
|
||||
children: [
|
||||
{
|
||||
title: "水煮肉片",
|
||||
cover: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
price: 88,
|
||||
},
|
||||
],
|
||||
search: {
|
||||
category_id: '',
|
||||
keyword: '',
|
||||
page: 1,
|
||||
limit: 10,
|
||||
},
|
||||
{
|
||||
title: "配料",
|
||||
children: [
|
||||
{
|
||||
title: "酸菜鱼",
|
||||
cover: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
price: 99,
|
||||
},
|
||||
],
|
||||
}],
|
||||
goods_list: [
|
||||
{
|
||||
id: 1,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息,大份芒果芒果,加多加糖",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 22,
|
||||
unit_name: "斤",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 44,
|
||||
unit_name: "件",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 42,
|
||||
unit_name: "份",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 34236,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "青椒肉丝",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: "大份芒果芒果",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
name: "新鲜西瓜不甜不要钱,随便吃哦",
|
||||
label: "描述信息",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "个",
|
||||
default_num: 100,
|
||||
info: [
|
||||
{
|
||||
id: 1,
|
||||
name: "猪肉",
|
||||
label: "",
|
||||
image: " ",
|
||||
disabled: true,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "毛豆",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "食用油",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "g",
|
||||
default_num: 100,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "豆瓣酱",
|
||||
label: "(建议食材)",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
disabled: false,
|
||||
num: 100,
|
||||
unit_name: "ml",
|
||||
default_num: 100,
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
|
||||
list: [
|
||||
{
|
||||
name: "全部",
|
||||
image: "",
|
||||
},
|
||||
{
|
||||
name: "水果1",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品2",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品3",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品4",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
}, {
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
{
|
||||
name: "商品5",
|
||||
image: "https://s3.bmp.ovh/imgs/2024/12/16/35bc6d28ab1c8bc7.png",
|
||||
},
|
||||
|
||||
],
|
||||
// keyword_sp: '',
|
||||
categoryIndex: 0,
|
||||
childrenIndex: 0,
|
||||
categoryList: [],
|
||||
tabList: [],
|
||||
good_list: [],
|
||||
matchedItems_sp: [],
|
||||
|
||||
};
|
||||
},
|
||||
onLoad () {
|
||||
// if (isLogin()) {
|
||||
this.getCategoryList()
|
||||
// }
|
||||
},
|
||||
created () {
|
||||
this.handleClick(0)
|
||||
|
||||
},
|
||||
methods: {
|
||||
handleClick (index: number) {
|
||||
// menuIndex.value = index;
|
||||
this.menuIndex = index;
|
||||
CommonApi.goodsMenu({ key: 123 }).catch((res) => {
|
||||
if (res.status === 200) {
|
||||
// this.tabList = res.data.menuList;
|
||||
this.tabList = this.list1
|
||||
console.log(res);
|
||||
handleClickCategory (index: number) {
|
||||
this.categoryIndex = index;
|
||||
this.tabList = this.categoryList[index].children;
|
||||
this.handleChildrenClick(0);
|
||||
},
|
||||
handleChildrenClick (index: number) {
|
||||
this.childrenIndex = index;
|
||||
this.search.category_id = this.tabList[index].id;
|
||||
this.$refs.pagingRefSP?.reload();
|
||||
},
|
||||
|
||||
getCategoryList () {
|
||||
CommonApi.commonGet('/api/dishes/category').catch((res) => {
|
||||
if (res.code === 1) {
|
||||
this.categoryList = res.data;
|
||||
this.handleClickCategory(0)
|
||||
} else {
|
||||
uni.$u.toast(res.message);
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
//搜索事件
|
||||
searchSP(){
|
||||
this.$refs.pagingRefSP?.reload();
|
||||
// this.changeSP(1);
|
||||
},
|
||||
//列表分页
|
||||
changeSP (pageNo: number) {
|
||||
console.log(pageNo);
|
||||
this.search.page = pageNo;
|
||||
CommonApi.commonGet('/api/dishes/dishes', this.search).catch((res) => {
|
||||
if (res.code === 1) {
|
||||
// this.matchedItems_sp = res.data;
|
||||
this.$refs.pagingRefSP?.complete(res.data);
|
||||
// console.log(res);
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
//点击详情
|
||||
goodsDetail (id: number) {
|
||||
console.log(id);
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/goods/detail?id=${id}`
|
||||
url: `/pages/common/goods/detail?id=${id}&is_add=1`
|
||||
});
|
||||
},
|
||||
|
||||
changeSP () {
|
||||
console.log("请求食谱数据");
|
||||
try {
|
||||
// 创建正则表达式进行匹配,忽略大小写
|
||||
const regex = new RegExp(this.keyword_sp, "i");
|
||||
// 直接对 goods_list 使用 filter 进行匹配,并赋值给 matchedItems_sp.value
|
||||
this.matchedItems_sp = this.goods_list.filter((item) => regex.test(item.name));
|
||||
// console.log(matchedItems_sp.value);
|
||||
} catch (error) {
|
||||
console.error("匹配过程中发生错误:", error);
|
||||
this.matchedItems_sp = []; // 发生错误时,将 matchedItems 清空
|
||||
}
|
||||
this.$refs.pagingRefSP.complete();
|
||||
this.$refs.pagingRefSP.complete(this.matchedItems_sp);
|
||||
//加入购物车
|
||||
addCart (id) {
|
||||
CommonApi.commonPost('/api/cart/add',{
|
||||
buy_now: false,
|
||||
dishes_id: id,
|
||||
}).catch((res) => {
|
||||
if (res.code === 1) {
|
||||
uni.$u.toast('加入购物车成功');
|
||||
} else {
|
||||
uni.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,18 +27,19 @@
|
||||
/>
|
||||
|
||||
<u-cell
|
||||
icon="" title="ID" is-link right-icon="lock" :value="userStore.user.uid" :border="false" size="large"
|
||||
icon="" title="ID" is-link right-icon="lock" :value="userStore.user.id" :border="false" size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
/>
|
||||
|
||||
<u-cell
|
||||
icon="" title="手机号" is-link right-icon="lock" :value="userStore.user.phone" :border="false" size="large"
|
||||
icon="" title="微信号" is-link right-icon="lock" :value="userStore.user.code" :border="false" size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
/>
|
||||
|
||||
<u-cell
|
||||
icon="order" title="订单详情" is-link value="" :border="false" size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
@click="orderList"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@ -63,9 +64,9 @@ const { setClipboardData, getClipboardData } = useClipboard();
|
||||
|
||||
const userStore = useUserStore();
|
||||
const redirect = HOME_PATH;
|
||||
|
||||
console.log('userStore', userStore);
|
||||
console.log('userStore', userStore.user_name);
|
||||
console.log('userStore', userStore.token);
|
||||
console.log('userStore', userStore.user);
|
||||
// console.log('userStore', userStore.user_name);
|
||||
// import { CommonApi, UserApi } from "@/api";
|
||||
// profile
|
||||
// 复制
|
||||
@ -85,12 +86,23 @@ function loginOut() {
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 退出请求
|
||||
loginOuts();
|
||||
// loginOuts();
|
||||
setToken('');
|
||||
uni.$u.route({
|
||||
type: isTabBarPath(redirect) ? 'switchTab' : 'redirectTo',
|
||||
url: redirect,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
// userStore.info()
|
||||
function orderList() {
|
||||
uni.$u.route({
|
||||
type: 'navigateTo',
|
||||
url: '/pages/common/goods/order',
|
||||
});
|
||||
}
|
||||
|
||||
async function loginOuts() {
|
||||
// 退出请求
|
||||
await userStore.logout().catch(() => {
|
||||
|
@ -3,8 +3,23 @@ page {
|
||||
color: $u-main-color;
|
||||
background-color: $u-bg-color;
|
||||
}
|
||||
|
||||
// .category-item {
|
||||
// display: inline-flex;
|
||||
// flex-direction: column;
|
||||
// align-items: center;
|
||||
// margin: 0 9px;
|
||||
// width: 56px;
|
||||
// padding-bottom: 9px /* 增加底部内边距 */;
|
||||
// }
|
||||
.scroll-list {
|
||||
|
||||
// display: inline-flex;
|
||||
// flex-direction: column;
|
||||
// align-items: center;
|
||||
// margin: 0 9px;
|
||||
|
||||
// padding-bottom: 9px /* 增加底部内边距 */;
|
||||
|
||||
@include flex(column);
|
||||
|
||||
&__goods-item {
|
||||
|
@ -12,6 +12,7 @@ const useUserStore = defineStore('user', {
|
||||
avatar: 'https://test.shop.lihaink.cn/static/f.png',
|
||||
token: '',
|
||||
user: {},
|
||||
code: '',
|
||||
}),
|
||||
getters: {
|
||||
userInfo(state: UserState): UserState {
|
||||
@ -29,36 +30,64 @@ const useUserStore = defineStore('user', {
|
||||
},
|
||||
// 获取用户信息
|
||||
info() {
|
||||
UserApi.profile().catch((res) => {
|
||||
console.log('登录信息',res.data);
|
||||
// reject(error);
|
||||
this.setInfo({ user: res.data });
|
||||
});
|
||||
// UserApi.profile().catch((res) => {
|
||||
// // console.log('登录信息',res.data);
|
||||
// // reject(error);
|
||||
// this.setInfo({ user: res.data });
|
||||
// });
|
||||
},
|
||||
// 异步登录并存储token
|
||||
login(loginForm: LoginReq) {
|
||||
return new Promise((resolve, reject) => {
|
||||
UserApi.login(loginForm).then((res) => {
|
||||
const token = res.token;
|
||||
if (token) {
|
||||
setToken(token);
|
||||
UserApi.login(loginForm)
|
||||
// .then((res) => {
|
||||
// const token = res.data.token;
|
||||
// if (token) {
|
||||
// console.log('登录信息',res.data);
|
||||
// let authorization = token.token_type+' '+token.token;
|
||||
// setToken(authorization);
|
||||
// this.setInfo({ token:authorization , user: res.data });
|
||||
// }
|
||||
// resolve(res);
|
||||
// })
|
||||
.catch((res) => {
|
||||
if(res.code==1){
|
||||
const token = res.data.token;
|
||||
if (token) {
|
||||
console.log('登录信息',res.data);
|
||||
let authorization = token.token_type+' '+token.access_token;
|
||||
setToken(authorization);
|
||||
this.setInfo({ token: authorization , user: res.data });
|
||||
}
|
||||
}
|
||||
resolve(res);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
},
|
||||
passwordLogin(loginForm: LoginReqPassword) {
|
||||
return new Promise((resolve, reject) => {
|
||||
UserApi.passwordLogin(loginForm).then((res) => {
|
||||
const token = res.token;
|
||||
if (token) {
|
||||
setToken(token);
|
||||
UserApi.passwordLogin(loginForm)
|
||||
// .then((res) => {
|
||||
// const token = res.data.token;
|
||||
// if (token) {
|
||||
// console.log('登录信息',res.data);
|
||||
// let authorization = token.token_type+' '+token.token;
|
||||
// setToken(authorization);
|
||||
// this.setInfo({ token:authorization , user: res.data });
|
||||
// }
|
||||
// resolve(res);
|
||||
// })
|
||||
.catch((res) => {
|
||||
if(res.code==1){
|
||||
const token = res.data.token;
|
||||
if (token) {
|
||||
console.log('登录信息',res.data);
|
||||
let authorization = token.token_type+' '+token.access_token;
|
||||
setToken(authorization);
|
||||
this.setInfo({ token: authorization , user: res.data });
|
||||
}
|
||||
}
|
||||
resolve(res);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -1,10 +1,11 @@
|
||||
export type RoleType = '' | '*' | 'user';
|
||||
export interface UserState {
|
||||
user_id?: string;
|
||||
user_id?: string|number;
|
||||
user_name?: string;
|
||||
avatar?: string;
|
||||
token?: string;
|
||||
user?: any;
|
||||
code?: string;
|
||||
}
|
||||
|
||||
export type providerType =
|
||||
|
@ -84,7 +84,8 @@ function requestInterceptors(http: HttpRequestAbstract) {
|
||||
const isToken = custom?.auth === false;
|
||||
if (getToken() && !isToken && config.header) {
|
||||
// token设置
|
||||
config.header['X-Token'] = getToken();
|
||||
config.header['Content-Type'] ='application/json';
|
||||
config.header['authorization'] = getToken();
|
||||
}
|
||||
|
||||
// 是否显示 loading
|
||||
|
@ -1,7 +1,7 @@
|
||||
// 返回res.data的interface
|
||||
export interface IResponse<T = any> {
|
||||
code: number | string;
|
||||
result: T;
|
||||
message: string;
|
||||
status: string | number;
|
||||
code: number | string;
|
||||
show: string | number;
|
||||
msg: string;
|
||||
result: T;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user