diff --git a/config/index.ts b/config/index.ts index 89ae3fc..e3bfe0d 100644 --- a/config/index.ts +++ b/config/index.ts @@ -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', diff --git a/src/app.ts b/src/app.ts index 0e82fd7..3f58132 100644 --- a/src/app.ts +++ b/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 diff --git a/src/pages/goods/goods_detail/index.vue b/src/pages/goods/goods_detail/index.vue index c78320e..c4f51ee 100644 --- a/src/pages/goods/goods_detail/index.vue +++ b/src/pages/goods/goods_detail/index.vue @@ -2,8 +2,8 @@ - - + + @@ -14,18 +14,21 @@ auto-play="3000" > - + - + + + 库存剩余:{{ goodInfo.stock }} + {{ goodInfo.name }} {{ goodInfo.profile }} @@ -46,7 +49,7 @@ - + 首页 @@ -58,7 +61,7 @@ - + 客服 @@ -73,7 +76,7 @@ {{ payType === "jf" ? "立即兑换" : "立即购买" }} + >{{ payType === 'jf' ? '立即兑换' : '立即购买' }} @@ -120,39 +123,28 @@ diff --git a/src/pages/mer/mer_detail/index.vue b/src/pages/mer/mer_detail/index.vue index e496ac8..aff8be9 100644 --- a/src/pages/mer/mer_detail/index.vue +++ b/src/pages/mer/mer_detail/index.vue @@ -23,25 +23,26 @@ {{ mer_info.name }} - {{ mer_info.address || "暂无商家地址" }} + {{ mer_info.address || '暂无商家地址' }} 距你{{ + >距你{{ calculateDistance( userLocalNum.t, userLocalNum.l, Number(mer_info.lat), Number(mer_info.lon) ) - }} - + 导航 - + 电话 @@ -62,30 +63,36 @@ @click="clickTab" > - + {{ item.name }} + + 库存剩余:{{ item.stock }} + {{ - item.number - }} + > + {{ + item.number + }} + {{ mer_info.bType === 1 - ? "元" - : "积分" - }} 去购买去购买 + 去兑换去兑换 + - + @@ -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({}); +const mer_info = ref({}) -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}` + }) +}