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