Merge branch 'dev' into 'test'
增加库存显示 See merge request xinling/points-mall!1
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import Components from 'unplugin-vue-components/webpack'
|
||||
import NutUIResolver from '@nutui/nutui-taro/dist/resolver'
|
||||
import { join } from 'node:path'
|
||||
import {join} from 'node:path'
|
||||
|
||||
const config = {
|
||||
projectName: 'taroApp',
|
||||
|
||||
70
src/app.ts
70
src/app.ts
@@ -1,8 +1,9 @@
|
||||
import { createApp } from "vue";
|
||||
import "./app.scss";
|
||||
import Taro from "@tarojs/taro";
|
||||
import {createApp} from 'vue'
|
||||
import './app.scss'
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
const scenes = [1007, 1008, 1011, 1012, 1013, 1047, 1048, 1049];
|
||||
// 小程序场景值
|
||||
const scenes = [1007, 1008, 1011, 1012, 1013, 1047, 1048, 1049]
|
||||
|
||||
const App = createApp({
|
||||
onLaunch(options: {
|
||||
@@ -12,61 +13,50 @@ const App = createApp({
|
||||
shareTicket: string;
|
||||
referrerInfo: object | any;
|
||||
}) {
|
||||
// if (scenes.includes(options.scene)) {
|
||||
// if (options.query.scene) {
|
||||
// Taro.showToast({
|
||||
// title: "已检测到推荐人",
|
||||
// icon: "none",
|
||||
// });
|
||||
// Taro.setStorageSync("bind_id", options.query.scene);
|
||||
// }
|
||||
// }
|
||||
// 检测更新
|
||||
if (Taro.canIUse("getUpdateManager") && options.scene !== 1154) {
|
||||
const updateManager = Taro.getUpdateManager();
|
||||
if (Taro.canIUse('getUpdateManager') && options.scene !== 1154) {
|
||||
const updateManager = Taro.getUpdateManager()
|
||||
updateManager.onCheckForUpdate(function (res) {
|
||||
if (res.hasUpdate) {
|
||||
updateManager.onUpdateFailed(function () {
|
||||
return Taro.showToast({
|
||||
title: "新版本下载失败",
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
title: '新版本下载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
updateManager.onUpdateReady(function () {
|
||||
Taro.showModal({
|
||||
title: "更新提示",
|
||||
content: "新版本已经下载好,是否重启当前应用?",
|
||||
title: '更新提示',
|
||||
content: '新版本已经下载好,是否重启当前应用?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
updateManager.applyUpdate();
|
||||
updateManager.applyUpdate()
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
updateManager.onUpdateFailed(function () {
|
||||
Taro.showModal({
|
||||
title: "发现新版本",
|
||||
content: "请删除当前小程序,重启搜索打开...",
|
||||
});
|
||||
});
|
||||
title: '发现新版本',
|
||||
content: '请删除当前小程序,重启搜索打开...'
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
const options = Taro.getCurrentInstance().router as any;
|
||||
console.log("onShow", options);
|
||||
const options = Taro.getCurrentInstance().router as any
|
||||
if (scenes.includes(options.scene)) {
|
||||
if (options.query.scene) {
|
||||
Taro.showToast({
|
||||
title: "已检测到推荐人",
|
||||
icon: "none",
|
||||
});
|
||||
Taro.setStorageSync("bind_id", options.query.scene);
|
||||
title: '已检测到推荐人',
|
||||
icon: 'none'
|
||||
})
|
||||
Taro.setStorageSync('bind_id', options.query.scene)
|
||||
}
|
||||
}
|
||||
},
|
||||
// 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
export default App;
|
||||
export default App
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<view class="app">
|
||||
<view class="head-wrapper" :style="{ top: BarHeight + 'px' }">
|
||||
<view class="head-menu">
|
||||
<Left class="iconfont" @click="returns" />
|
||||
<Home class="iconfont" @click="goHome" />
|
||||
<Left class="iconfont" @click="returns"/>
|
||||
<Home class="iconfont" @click="goHome"/>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 幻灯片 -->
|
||||
@@ -14,18 +14,21 @@
|
||||
auto-play="3000"
|
||||
>
|
||||
<nut-swiper-item v-for="(itm, idx) in swiperList" :key="idx">
|
||||
<img :src="itm" :alt="idx.toString()" />
|
||||
<img :alt="idx.toString()" :src="itm"/>
|
||||
</nut-swiper-item>
|
||||
</nut-swiper>
|
||||
<!-- 标题价格 -->
|
||||
<view class="card">
|
||||
<view>
|
||||
<view class="header">
|
||||
<nut-price
|
||||
size="large"
|
||||
:price="goodInfo.number as number"
|
||||
position="after"
|
||||
:symbol="payType === 'jf' ? '积分' : '元'"
|
||||
/>
|
||||
<view class="stock">
|
||||
库存剩余:{{ goodInfo.stock }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="title">{{ goodInfo.name }}</view>
|
||||
<view class="sub">{{ goodInfo.profile }}</view>
|
||||
@@ -46,7 +49,7 @@
|
||||
<view class="bottom-box">
|
||||
<view class="left">
|
||||
<view class="icon" @click="toPage('/pages/index/index')">
|
||||
<Home />
|
||||
<Home/>
|
||||
<view>首页</view>
|
||||
</view>
|
||||
<!-- <view-->
|
||||
@@ -58,7 +61,7 @@
|
||||
<!-- <view>购物车</view>-->
|
||||
<!-- </view>-->
|
||||
<view class="icon" @click="toPage('/pages/kefu/index', 2)">
|
||||
<My />
|
||||
<My/>
|
||||
<view>客服</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -73,7 +76,7 @@
|
||||
<!-- >加入购物车-->
|
||||
<!-- </nut-button>-->
|
||||
<nut-button type="primary" block @click="toOrderDetail()"
|
||||
>{{ payType === "jf" ? "立即兑换" : "立即购买" }}
|
||||
>{{ payType === 'jf' ? '立即兑换' : '立即购买' }}
|
||||
</nut-button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -120,39 +123,28 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
var statusBarHeight = Taro.getSystemInfoSync()?.statusBarHeight;
|
||||
import { ref } from "vue";
|
||||
import Taro from "@tarojs/taro";
|
||||
import {
|
||||
Left,
|
||||
Home,
|
||||
// Cart,
|
||||
My,
|
||||
} from "@nutui/icons-vue-taro";
|
||||
import {
|
||||
getGoodsDetail,
|
||||
getActiveGoodsDetail,
|
||||
// addCart,
|
||||
createOrder,
|
||||
createActiveOrder,
|
||||
} from "@/api/goods";
|
||||
import Pay from "@/components/Pay.vue";
|
||||
const statusBarHeight = Taro.getSystemInfoSync()?.statusBarHeight
|
||||
import {ref} from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {Home, Left, My} from '@nutui/icons-vue-taro'
|
||||
import {createActiveOrder, createOrder, getActiveGoodsDetail, getGoodsDetail} from '@/api/goods'
|
||||
import Pay from '@/components/Pay.vue'
|
||||
|
||||
const BarHeight = ref((statusBarHeight as number) + 7);
|
||||
const BarHeight = ref((statusBarHeight as number) + 7)
|
||||
|
||||
const swiperList = ref([]);
|
||||
const swiperList = ref([])
|
||||
|
||||
const isSkuShow = ref(false);
|
||||
const isSkuShow = ref(false)
|
||||
|
||||
const isShowPay = ref(false);
|
||||
const isShowPay = ref(false)
|
||||
|
||||
// const sku = ref([]);
|
||||
|
||||
const payType = ref("");
|
||||
const payType = ref('')
|
||||
|
||||
const orderData = ref([]);
|
||||
const orderData = ref([])
|
||||
|
||||
const count = ref(1);
|
||||
const count = ref(1)
|
||||
|
||||
interface GoodInfo {
|
||||
gid?: number;
|
||||
@@ -165,61 +157,61 @@ interface GoodInfo {
|
||||
profile?: string;
|
||||
}
|
||||
|
||||
const goodInfo = ref<GoodInfo>({});
|
||||
const goodInfo = ref<GoodInfo>({})
|
||||
|
||||
Taro.useLoad((options) => {
|
||||
payType.value = options.type === "1" ? "wx" : "jf";
|
||||
get_good_detail(options.gid);
|
||||
});
|
||||
payType.value = options.type === '1' ? 'wx' : 'jf'
|
||||
get_good_detail(options.gid)
|
||||
})
|
||||
|
||||
const get_good_detail = async (gid: string) => {
|
||||
try {
|
||||
let res: any;
|
||||
if (payType.value === "jf") {
|
||||
res = await getGoodsDetail({ gid: gid });
|
||||
let res: any
|
||||
if (payType.value === 'jf') {
|
||||
res = await getGoodsDetail({gid: gid})
|
||||
} else {
|
||||
res = await getActiveGoodsDetail({ gid: gid });
|
||||
res = await getActiveGoodsDetail({gid: gid})
|
||||
}
|
||||
goodInfo.value = {
|
||||
...res.data.data,
|
||||
...res.data.data
|
||||
// details: res.data.data.details.,
|
||||
};
|
||||
}
|
||||
|
||||
swiperList.value = res.data.data.rotation.split(",");
|
||||
swiperList.value = res.data.data.rotation.split(',')
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: e.msg,
|
||||
icon: "none",
|
||||
});
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const addCount = () => {
|
||||
if (count.value >= (goodInfo.value.stock as number)) {
|
||||
count.value = goodInfo.value.stock as number;
|
||||
count.value = goodInfo.value.stock as number
|
||||
Taro.showToast({
|
||||
title: "库存不足",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
title: '库存不足',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const returns = () => {
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
};
|
||||
delta: 1
|
||||
})
|
||||
}
|
||||
|
||||
const goHome = () => {
|
||||
Taro.switchTab({
|
||||
url: "/pages/index/index",
|
||||
});
|
||||
};
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
|
||||
const openSku = () => {
|
||||
isSkuShow.value = true;
|
||||
};
|
||||
isSkuShow.value = true
|
||||
}
|
||||
|
||||
// const selectSku = () => {};
|
||||
// const clickBtnOperate = () => {};
|
||||
@@ -243,76 +235,76 @@ const openSku = () => {
|
||||
// };
|
||||
|
||||
const toOrderDetail = async () => {
|
||||
if (!Taro.getStorageSync("token")) {
|
||||
if (!Taro.getStorageSync('token')) {
|
||||
return Taro.showModal({
|
||||
title: "提示",
|
||||
content: "你还没登录,请先登录",
|
||||
cancelText: "先逛逛",
|
||||
confirmText: "去登录",
|
||||
title: '提示',
|
||||
content: '你还没登录,请先登录',
|
||||
cancelText: '先逛逛',
|
||||
confirmText: '去登录',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
Taro.reLaunch({
|
||||
url: "/pages/users/login/index",
|
||||
});
|
||||
url: '/pages/users/login/index'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
if (isSkuShow.value === false) return openSku();
|
||||
if (isSkuShow.value === false) return openSku()
|
||||
// Taro.navigateTo({
|
||||
// url: '/pages/goods/order_create/index'
|
||||
// })
|
||||
try {
|
||||
let res: any;
|
||||
if (payType.value === "jf") {
|
||||
let res: any
|
||||
if (payType.value === 'jf') {
|
||||
res = await createOrder([
|
||||
{
|
||||
gid: goodInfo.value.gid,
|
||||
count: Number(count.value),
|
||||
},
|
||||
]);
|
||||
count: Number(count.value)
|
||||
}
|
||||
])
|
||||
} else {
|
||||
res = await createActiveOrder({
|
||||
gid: goodInfo.value.gid,
|
||||
stock: Number(count.value),
|
||||
});
|
||||
stock: Number(count.value)
|
||||
})
|
||||
}
|
||||
|
||||
orderData.value = res?.data?.data;
|
||||
orderData.value = res?.data?.data
|
||||
|
||||
isShowPay.value = true;
|
||||
isShowPay.value = true
|
||||
|
||||
count.value = 1;
|
||||
count.value = 1
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: e.msg,
|
||||
icon: "none",
|
||||
});
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
isSkuShow.value = false;
|
||||
};
|
||||
isSkuShow.value = false
|
||||
}
|
||||
|
||||
const closePay = (val: boolean) => {
|
||||
isShowPay.value = val;
|
||||
orderData.value = [];
|
||||
};
|
||||
isShowPay.value = val
|
||||
orderData.value = []
|
||||
}
|
||||
|
||||
const toPage = (url: string, type: number = 1) => {
|
||||
if (type === 1) {
|
||||
Taro.switchTab({
|
||||
url: url,
|
||||
});
|
||||
url: url
|
||||
})
|
||||
} else {
|
||||
// Taro.navigateTo({
|
||||
// url: url,
|
||||
// });
|
||||
Taro.showToast({
|
||||
title: "暂未开放",
|
||||
icon: "none",
|
||||
});
|
||||
title: '暂未开放',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -363,12 +355,24 @@ page {
|
||||
padding: 30px;
|
||||
background-color: #fff;
|
||||
|
||||
.title {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
.header {
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.title {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.stock {
|
||||
color: #8f8f8f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.sub {
|
||||
font-size: 24px;
|
||||
color: #999;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
auto-play="3000"
|
||||
>
|
||||
<nut-swiper-item v-for="(itm, idx) in swiperList" :key="idx">
|
||||
<img :src="itm.url" :alt="itm.ID.toString()" />
|
||||
<img :alt="itm.ID.toString()" :src="itm.url"/>
|
||||
</nut-swiper-item>
|
||||
</nut-swiper>
|
||||
<!-- 金刚区 -->
|
||||
@@ -25,39 +25,10 @@
|
||||
:text="item.label"
|
||||
@click="toPage(item.url)"
|
||||
>
|
||||
<image :src="item.icon" />
|
||||
<image :src="item.icon"/>
|
||||
</nut-grid-item>
|
||||
</nut-grid>
|
||||
</view>
|
||||
<!-- 标题 -->
|
||||
<!-- <view class="titleImg">为你推荐</view> -->
|
||||
<!-- 商品列表 -->
|
||||
<!-- <view class="goodBox">
|
||||
<view
|
||||
class="good"
|
||||
v-for="item in list"
|
||||
:key="item.gid"
|
||||
@click.stop="toGoodDetails(item.gid as number)"
|
||||
>
|
||||
<image :src="(item.cover as string)" />
|
||||
<view class="good-text-box">
|
||||
<text class="good-text">{{ item.name }}</text>
|
||||
<view class="good-price-box">
|
||||
<text class="good-text-price">
|
||||
<text style="font-size: 20px"
|
||||
>{{ item.number }}
|
||||
</text>
|
||||
积分
|
||||
</text>
|
||||
<Cart
|
||||
size="20"
|
||||
color="#ff0000"
|
||||
@click.stop="add_cart(item.gid as number)"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="goodBox">
|
||||
<view
|
||||
class="good"
|
||||
@@ -65,196 +36,132 @@
|
||||
:key="item.ID"
|
||||
@click.stop="toMerDetails(item)"
|
||||
>
|
||||
<image :src="(item.head_photo as string)" />
|
||||
<image :src="(item.head_photo as string)"/>
|
||||
<view class="good-text-box">
|
||||
<text class="good-text">{{ item.name }}</text>
|
||||
<text style="color: #999"
|
||||
>距离我{{
|
||||
>距离我{{
|
||||
calculateDistance(
|
||||
userLocalNum.t,
|
||||
userLocalNum.l,
|
||||
Number(item.lat),
|
||||
Number(item.lon)
|
||||
)
|
||||
}}</text
|
||||
}}
|
||||
</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 商家列表 -->
|
||||
<!-- <view class="merBox">
|
||||
<view class="item" v-for="item in merdata" :key="item.ID">
|
||||
<view class="left">
|
||||
<image
|
||||
class="img"
|
||||
src="//www.wanzhuanyongcheng.cn/static/bdae68d9512fecacf744eea61f92e71.jpg"
|
||||
></image>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="title">{{ item.name }}</view>
|
||||
<view class="tag">
|
||||
<view class="left">
|
||||
<text>喷射</text>
|
||||
<text>汉堡</text>
|
||||
<text>炸鸡</text>
|
||||
</view>
|
||||
<view class="right">距我900m</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from "vue";
|
||||
// import { Cart } from "@nutui/icons-vue-taro";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { getBanner, bindParent } from "@/api/user";
|
||||
import {
|
||||
// getGoodsList,
|
||||
getMerList,
|
||||
} from "@/api/goods";
|
||||
import { calculateDistance } from "@/utils";
|
||||
import {ref} from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {bindParent, getBanner} from '@/api/user'
|
||||
import {getMerList} from '@/api/goods'
|
||||
import {calculateDistance} from '@/utils'
|
||||
|
||||
const searchValue = ref("");
|
||||
// const tabvalue = ref("0");
|
||||
const searchValue = ref('')
|
||||
|
||||
const swiperList = ref<any>([]);
|
||||
const swiperList = ref<any>([])
|
||||
|
||||
const userMenuList = ref([
|
||||
{
|
||||
id: 1,
|
||||
label: "活动游戏",
|
||||
url: `/pages/game/gamehome/index?uid=${Taro.getStorageSync("token")}`,
|
||||
icon: "http://jdt168.com/uploads/merchant/20220829/caad6be8983e88c41d28da7d124bc37b.png",
|
||||
label: '活动游戏',
|
||||
url: `/pages/game/gamehome/index?uid=${Taro.getStorageSync('token')}`,
|
||||
icon: 'http://jdt168.com/uploads/merchant/20220829/caad6be8983e88c41d28da7d124bc37b.png'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: "活动商品",
|
||||
url: "/pages/hotGoods/index/index",
|
||||
icon: "http://jdt168.com/uploads/def/20230509/d59e7fcb65a88bc56694dae4f9d21b51.png",
|
||||
label: '活动商品',
|
||||
url: '/pages/hotGoods/index/index',
|
||||
icon: 'http://jdt168.com/uploads/def/20230509/d59e7fcb65a88bc56694dae4f9d21b51.png'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
label: "商户入驻",
|
||||
url: "/pages/users/settled_mer/index",
|
||||
icon: "http://jdt168.com/uploads/merchant/20220829/6fe67b93721a42aedc842c4f19d6f2d3.png",
|
||||
label: '商户入驻',
|
||||
url: '/pages/users/settled_mer/index',
|
||||
icon: 'http://jdt168.com/uploads/merchant/20220829/6fe67b93721a42aedc842c4f19d6f2d3.png'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
label: "最新资讯",
|
||||
url: "",
|
||||
icon: "http://jdt168.com/uploads/merchant/20220829/b975136a9b64aab69bf11d75a194f1ea.png",
|
||||
},
|
||||
]);
|
||||
|
||||
// interface List {
|
||||
// gid?: number;
|
||||
// name?: string;
|
||||
// number?: number;
|
||||
// cover?: string;
|
||||
// }
|
||||
|
||||
// const list = ref<Array<List>>([]);
|
||||
label: '最新资讯',
|
||||
url: '',
|
||||
icon: 'http://jdt168.com/uploads/merchant/20220829/b975136a9b64aab69bf11d75a194f1ea.png'
|
||||
}
|
||||
])
|
||||
|
||||
Taro.useDidShow(async () => {
|
||||
getBannerList();
|
||||
// get_goods_list();
|
||||
get_mer_list();
|
||||
if (Taro.getStorageSync("token") && Taro.getStorageSync("bind_id")) {
|
||||
await getBannerList()
|
||||
await get_mer_list()
|
||||
if (Taro.getStorageSync('token') && Taro.getStorageSync('bind_id')) {
|
||||
try {
|
||||
const res = await bindParent({
|
||||
uid: Taro.getStorageSync("bind_id"),
|
||||
});
|
||||
uid: Taro.getStorageSync('bind_id')
|
||||
})
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
});
|
||||
Taro.removeStorageSync("bind_id");
|
||||
title: res.msg
|
||||
})
|
||||
Taro.removeStorageSync('bind_id')
|
||||
} catch (error) {
|
||||
Taro.removeStorageSync("bind_id");
|
||||
throw error;
|
||||
Taro.removeStorageSync('bind_id')
|
||||
throw error
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
Taro.useShareAppMessage(() => ({
|
||||
title: "捷兑通",
|
||||
path: `/pages/index/index?scene=${Taro.getStorageSync("token")}`,
|
||||
title: '捷兑通',
|
||||
path: `/pages/index/index?scene=${Taro.getStorageSync('token')}`,
|
||||
imageUrl:
|
||||
"https://upload.jdt168.com/1694242954957988438_微信图片_20230909150016.jpg",
|
||||
}));
|
||||
'https://upload.jdt168.com/1694242954957988438_微信图片_20230909150016.jpg'
|
||||
}))
|
||||
|
||||
// const get_goods_list = async () => {
|
||||
// const { data } = await getGoodsList();
|
||||
// list.value = data.data;
|
||||
// };
|
||||
|
||||
const merdata = ref([]);
|
||||
const merdata = ref([])
|
||||
|
||||
const userLocalNum = ref({
|
||||
l: 0,
|
||||
t: 0,
|
||||
});
|
||||
t: 0
|
||||
})
|
||||
|
||||
const get_mer_list = async () => {
|
||||
Taro.getLocation({
|
||||
type: "wgs84",
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
userLocalNum.value.l = res.longitude;
|
||||
userLocalNum.value.t = res.latitude;
|
||||
},
|
||||
});
|
||||
userLocalNum.value.l = res.longitude
|
||||
userLocalNum.value.t = res.latitude
|
||||
}
|
||||
})
|
||||
|
||||
const res = await getMerList({
|
||||
PageNum: 1,
|
||||
PageSize: 10,
|
||||
Btype: 2,
|
||||
classid: 0,
|
||||
});
|
||||
merdata.value = res.data.data;
|
||||
console.log(res);
|
||||
};
|
||||
classid: 0
|
||||
})
|
||||
merdata.value = res.data.data
|
||||
}
|
||||
|
||||
const getBannerList = async () => {
|
||||
const { data }: any = await getBanner();
|
||||
swiperList.value = data.data;
|
||||
};
|
||||
|
||||
// const add_cart = async (gid: number) => {
|
||||
// try {
|
||||
// await addCart({ gid });
|
||||
// Taro.showToast({
|
||||
// title: "加入购物车成功",
|
||||
// icon: "success",
|
||||
// duration: 2000,
|
||||
// });
|
||||
// } catch (e) {
|
||||
// Taro.showToast({
|
||||
// title: e.msg,
|
||||
// icon: "none",
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
const {data}: any = await getBanner()
|
||||
swiperList.value = data.data
|
||||
}
|
||||
|
||||
const toPage = (url: string) => {
|
||||
Taro.navigateTo({
|
||||
url: url,
|
||||
});
|
||||
};
|
||||
|
||||
// const toGoodDetails = (gid: number) => {
|
||||
// Taro.navigateTo({
|
||||
// url: `/pages/goods/goods_detail/index?gid=${gid}`,
|
||||
// });
|
||||
// };
|
||||
url: url
|
||||
})
|
||||
}
|
||||
|
||||
const toMerDetails = (item: any) => {
|
||||
Taro.setStorageSync("mer_info", item);
|
||||
Taro.setStorageSync('mer_info', item)
|
||||
Taro.navigateTo({
|
||||
url: `/pages/mer/mer_detail/index`,
|
||||
});
|
||||
};
|
||||
url: `/pages/mer/mer_detail/index`
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -339,60 +246,4 @@ const toMerDetails = (item: any) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.merBox {
|
||||
padding: 10px;
|
||||
.item {
|
||||
display: flex;
|
||||
// align-items: center;
|
||||
background-color: #fff;
|
||||
border-radius: 20px;
|
||||
padding: 20px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.left {
|
||||
.img {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
flex: 1;
|
||||
margin-left: 15px;
|
||||
border-bottom: 2px solid #f5f5f5;
|
||||
.title {
|
||||
width: 100%;
|
||||
font-weight: bold;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 1;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.tag {
|
||||
margin: 10px 0;
|
||||
color: #999;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
width: 50%;
|
||||
text {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -23,25 +23,26 @@
|
||||
<view class="title">{{ mer_info.name }}</view>
|
||||
<view class="bom">
|
||||
<view class="left">
|
||||
<view>{{ mer_info.address || "暂无商家地址" }}</view>
|
||||
<view>{{ mer_info.address || '暂无商家地址' }}</view>
|
||||
<view class="sub"
|
||||
>距你{{
|
||||
>距你{{
|
||||
calculateDistance(
|
||||
userLocalNum.t,
|
||||
userLocalNum.l,
|
||||
Number(mer_info.lat),
|
||||
Number(mer_info.lon)
|
||||
)
|
||||
}}</view
|
||||
}}
|
||||
</view
|
||||
>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view @click="clickMap">
|
||||
<Locationg3 color="red" size="25" />
|
||||
<Locationg3 color="red" size="25"/>
|
||||
<view>导航</view>
|
||||
</view>
|
||||
<view @click="clickPhone">
|
||||
<Find color="red" size="25" />
|
||||
<Find color="red" size="25"/>
|
||||
<view>电话</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -62,30 +63,36 @@
|
||||
@click="clickTab"
|
||||
>
|
||||
<nut-tab-pane
|
||||
v-for="(item, index) in class_list"
|
||||
v-for="(item, index) in class_list as any[]"
|
||||
:title="item.name"
|
||||
:pane-key="index"
|
||||
>
|
||||
<view v-if="good_list.length > 0">
|
||||
<view
|
||||
class="list"
|
||||
v-for="(item, index) in (good_list as any)"
|
||||
v-for="(item, index) in good_list as any[]"
|
||||
:key="index"
|
||||
>
|
||||
<view class="item">
|
||||
<img :src="item.cover" />
|
||||
<img :src="item.cover"/>
|
||||
<view class="right">
|
||||
<view class="name">{{ item.name }}</view>
|
||||
<view class="stock">
|
||||
库存剩余:{{ item.stock }}
|
||||
</view>
|
||||
<view class="bom">
|
||||
<view class="price"
|
||||
><text style="font-size: 15px">{{
|
||||
item.number
|
||||
}}</text>
|
||||
>
|
||||
<text style="font-size: 15px">{{
|
||||
item.number
|
||||
}}
|
||||
</text>
|
||||
{{
|
||||
mer_info.bType === 1
|
||||
? "元"
|
||||
: "积分"
|
||||
}}</view
|
||||
? '元'
|
||||
: '积分'
|
||||
}}
|
||||
</view
|
||||
>
|
||||
<nut-button
|
||||
size="mini"
|
||||
@@ -97,7 +104,8 @@
|
||||
1
|
||||
)
|
||||
"
|
||||
>去购买</nut-button
|
||||
>去购买
|
||||
</nut-button
|
||||
>
|
||||
<nut-button
|
||||
size="mini"
|
||||
@@ -109,12 +117,14 @@
|
||||
2
|
||||
)
|
||||
"
|
||||
>去兑换</nut-button
|
||||
>去兑换
|
||||
</nut-button
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view></view
|
||||
</view>
|
||||
</view
|
||||
>
|
||||
<nut-empty v-else description="该分类暂无商品"></nut-empty>
|
||||
</nut-tab-pane>
|
||||
@@ -128,41 +138,41 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import {Find, Locationg3} from '@nutui/icons-vue-taro'
|
||||
import {ref} from 'vue'
|
||||
import {calculateDistance} from '../../../utils'
|
||||
import {getGoodList, getMerCategory} from '../../../api/goods'
|
||||
import {calculateDistance} from '@/utils'
|
||||
import {getGoodList, getMerCategory} from '@/api/goods'
|
||||
|
||||
const swiperList = ref([]);
|
||||
const swiperList = ref([])
|
||||
|
||||
const mer_info = ref<any>({});
|
||||
const mer_info = ref<any>({})
|
||||
|
||||
const value = ref("0");
|
||||
const value = ref('0')
|
||||
|
||||
const userLocalNum = ref({
|
||||
l: 0,
|
||||
t: 0,
|
||||
});
|
||||
t: 0
|
||||
})
|
||||
|
||||
Taro.useLoad(() => {
|
||||
Taro.getLocation({
|
||||
type: "wgs84",
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
userLocalNum.value.l = res.longitude;
|
||||
userLocalNum.value.t = res.latitude;
|
||||
},
|
||||
});
|
||||
mer_info.value = Taro.getStorageSync("mer_info");
|
||||
userLocalNum.value.l = res.longitude
|
||||
userLocalNum.value.t = res.latitude
|
||||
}
|
||||
})
|
||||
mer_info.value = Taro.getStorageSync('mer_info')
|
||||
Taro.setNavigationBarTitle({
|
||||
title: mer_info.value.name,
|
||||
});
|
||||
swiperList.value = mer_info.value.img.split(",");
|
||||
get_class_list();
|
||||
});
|
||||
title: mer_info.value.name
|
||||
})
|
||||
swiperList.value = mer_info.value.img.split(',')
|
||||
get_class_list()
|
||||
})
|
||||
|
||||
const clickPhone = () => {
|
||||
Taro.makePhoneCall({
|
||||
phoneNumber: mer_info.value.mobile
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
const clickMap = () => {
|
||||
Taro.openLocation({
|
||||
@@ -170,50 +180,50 @@ const clickMap = () => {
|
||||
address: mer_info.value.address,
|
||||
latitude: Number(mer_info.value.lat),
|
||||
longitude: Number(mer_info.value.lon),
|
||||
scale: 18,
|
||||
});
|
||||
};
|
||||
scale: 18
|
||||
})
|
||||
}
|
||||
|
||||
const class_list = ref<
|
||||
Array<{
|
||||
ID?: number;
|
||||
name?: string;
|
||||
}>
|
||||
>([]);
|
||||
>([])
|
||||
const get_class_list = async () => {
|
||||
const res = await getMerCategory({
|
||||
Bid: mer_info.value.bid,
|
||||
});
|
||||
class_list.value = res.data.data || [];
|
||||
get_good_list(class_list.value[0].ID as number);
|
||||
};
|
||||
Bid: mer_info.value.bid
|
||||
})
|
||||
class_list.value = res.data.data || []
|
||||
await get_good_list(class_list.value[0].ID as number)
|
||||
}
|
||||
|
||||
const clickTab = (val: any) => {
|
||||
get_good_list(class_list.value[val.paneKey].ID as number);
|
||||
};
|
||||
get_good_list(class_list.value[val.paneKey].ID as number)
|
||||
}
|
||||
|
||||
const good_list = ref([]);
|
||||
const good_list = ref([])
|
||||
const get_good_list = async (id: number) => {
|
||||
Taro.showLoading({
|
||||
title: "加载中",
|
||||
mask: true,
|
||||
});
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
const res = await getGoodList({
|
||||
bid: mer_info.value.bid,
|
||||
BType: mer_info.value.bType,
|
||||
class_id: id,
|
||||
status: 1,
|
||||
state: 1,
|
||||
});
|
||||
good_list.value = res.data.data || [];
|
||||
Taro.hideLoading();
|
||||
};
|
||||
state: 1
|
||||
})
|
||||
good_list.value = res.data.data || []
|
||||
Taro.hideLoading()
|
||||
}
|
||||
|
||||
const toGoodDetails = (id: number, type: number) => {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/goods/goods_detail/index?gid=${id}&type=${type}`,
|
||||
});
|
||||
};
|
||||
url: `/pages/goods/goods_detail/index?gid=${id}&type=${type}`
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -237,6 +247,7 @@ const toGoodDetails = (id: number, type: number) => {
|
||||
|
||||
.left {
|
||||
width: 80%;
|
||||
|
||||
.sub {
|
||||
color: #999;
|
||||
}
|
||||
@@ -254,6 +265,7 @@ const toGoodDetails = (id: number, type: number) => {
|
||||
|
||||
.good-class {
|
||||
margin-top: 10px;
|
||||
|
||||
.nut-tabs {
|
||||
height: 100vh;
|
||||
border-top: #fff 10px solid;
|
||||
@@ -264,9 +276,10 @@ const toGoodDetails = (id: number, type: number) => {
|
||||
.item {
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
|
||||
img {
|
||||
width: 140px;
|
||||
height: 140px;
|
||||
height: 150px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
@@ -278,6 +291,11 @@ const toGoodDetails = (id: number, type: number) => {
|
||||
justify-content: center;
|
||||
// text-align: right;
|
||||
|
||||
.stock {
|
||||
margin-top: 10px;
|
||||
color: #8f8f8f;
|
||||
}
|
||||
|
||||
.name {
|
||||
// height: 20px;
|
||||
font-size: 28px;
|
||||
@@ -292,7 +310,8 @@ const toGoodDetails = (id: number, type: number) => {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
margin-top: 10px;
|
||||
//margin-top: 10px;
|
||||
|
||||
.price {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
|
||||
Reference in New Issue
Block a user