修改若干安卓端的语法
This commit is contained in:
parent
eb3257f1bd
commit
d643abe7e1
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,3 +10,4 @@ node_modules/
|
||||
.claude/settings.local.json
|
||||
.hbuilderx/project.config.json
|
||||
clean-cache.bat
|
||||
.hbuilderx/launch.json
|
||||
|
||||
1
App.vue
1
App.vue
@ -4,6 +4,7 @@ import { getPublicConfig } from '@/api/appUser'
|
||||
export default {
|
||||
onLaunch: function(options) {
|
||||
console.log('App Launch', options)
|
||||
|
||||
try { uni.setStorageSync('app_session_id', String(Date.now())) } catch (_) {}
|
||||
if (options && options.query && options.query.invite_code) {
|
||||
console.log('App Launch captured invite_code:', options.query.invite_code)
|
||||
|
||||
@ -222,6 +222,10 @@ export function createWechatOrder(data) {
|
||||
return authRequest({ url: '/api/app/pay/wechat/jsapi/preorder', method: 'POST', data })
|
||||
}
|
||||
|
||||
export function createWechatAppOrder(data) {
|
||||
return authRequest({ url: '/api/app/pay/wechat/app/preorder', method: 'POST', data })
|
||||
}
|
||||
|
||||
export function getLotteryResult(order_no) {
|
||||
return authRequest({ url: '/api/app/lottery/result', method: 'GET', data: { order_no } })
|
||||
}
|
||||
|
||||
@ -17,7 +17,9 @@
|
||||
"delay" : 0
|
||||
},
|
||||
/* 模块配置 */
|
||||
"modules" : {},
|
||||
"modules" : {
|
||||
"Payment" : {}
|
||||
},
|
||||
/* 应用发布信息 */
|
||||
"distribute" : {
|
||||
/* android打包配置 */
|
||||
@ -37,7 +39,10 @@
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>"
|
||||
]
|
||||
},
|
||||
/* ios打包配置 */
|
||||
@ -45,7 +50,22 @@
|
||||
"dSYMs" : false
|
||||
},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {}
|
||||
"sdkConfigs" : {
|
||||
"payment" : {
|
||||
"weixin" : {
|
||||
"__platform__" : ["android", "ios"],
|
||||
"appid" : "wx26ad074017e1e63f",
|
||||
"UniversalLinks" : ""
|
||||
}
|
||||
},
|
||||
"share" : {},
|
||||
"oauth" : {
|
||||
"weixin" : {
|
||||
"appid" : "wx26ad074017e1e63f",
|
||||
"UniversalLinks" : ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
/* 快应用特有相关 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<view v-else-if="isOutOfStock" class="empty">商品库存不足,由于市场价格存在波动,请联系客服核实价格和补充库存</view>
|
||||
<view v-else-if="detail.id" class="detail-wrap">
|
||||
<!-- 商品图片轮播 -->
|
||||
<swiper class="main-image-swiper" v-if="imageList.length > 0" circular autoplay interval="3000" duration="500">
|
||||
<swiper v-if="imageList.length > 0" :key="'detail-' + swiperKey" class="main-image-swiper" :circular="swiperAutoplay" :autoplay="swiperAutoplay" interval="3000" duration="500">
|
||||
<swiper-item v-for="(img, index) in imageList" :key="index">
|
||||
<image class="main-image" :src="img" mode="aspectFill" @tap="previewImage(index)" />
|
||||
</swiper-item>
|
||||
@ -45,13 +45,15 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { onLoad, onShow, onHide, onUnload } from '@dcloudio/uni-app'
|
||||
import { getProductDetail } from '../../api/appUser'
|
||||
import { redeemProductByPoints } from '../../utils/request.js'
|
||||
|
||||
const detail = ref({})
|
||||
const loading = ref(false)
|
||||
const isOutOfStock = ref(false)
|
||||
const swiperAutoplay = ref(true)
|
||||
const swiperKey = ref(0)
|
||||
|
||||
// 计算属性:处理商品图片
|
||||
const imageList = computed(() => {
|
||||
@ -221,6 +223,19 @@ onLoad((opts) => {
|
||||
const id = opts && opts.id
|
||||
if (id) fetchDetail(id)
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
swiperKey.value++
|
||||
swiperAutoplay.value = true
|
||||
})
|
||||
|
||||
onHide(() => {
|
||||
swiperAutoplay.value = false
|
||||
})
|
||||
|
||||
onUnload(() => {
|
||||
swiperAutoplay.value = false
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@ -235,9 +235,9 @@
|
||||
}
|
||||
],
|
||||
"tabBar": {
|
||||
"custom": true,
|
||||
"custom": false,
|
||||
"color": "#7A7E83",
|
||||
"selectedColor": "#007AFF",
|
||||
"selectedColor": "#FF6B00",
|
||||
"backgroundColor": "#FFFFFF",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
<view class="bg-decoration"></view>
|
||||
|
||||
<!-- 自定义 tabBar -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<customTabBar />
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-TOUTIAO -->
|
||||
<customTabBarToutiao />
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-TOUTIAO -->
|
||||
<customTabBar />
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 顶部 Tab -->
|
||||
<view class="tabs glass-card">
|
||||
@ -258,12 +258,12 @@ import { getSynthesisRecipes, doSynthesis } from '@/api/synthesis.js'
|
||||
import { vibrateShort } from '@/utils/vibrate.js'
|
||||
import { checkPhoneBound, checkPhoneBoundSync } from '@/utils/checkPhone.js'
|
||||
import { executePaymentFlow } from '@/utils/payment.js'
|
||||
// #ifdef MP-WEIXIN
|
||||
import customTabBar from '@/components/app-tab-bar.vue'
|
||||
// #endif
|
||||
// #ifdef MP-TOUTIAO
|
||||
import customTabBarToutiao from '@/components/app-tab-bar-toutiao.vue'
|
||||
// #endif
|
||||
// #ifndef MP-TOUTIAO
|
||||
import customTabBar from '@/components/app-tab-bar.vue'
|
||||
// #endif
|
||||
|
||||
const currentTab = ref(0)
|
||||
const aggregatedList = ref([])
|
||||
|
||||
@ -7,12 +7,12 @@
|
||||
<view class="bg-decoration"></view>
|
||||
|
||||
<!-- 自定义 tabBar -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<customTabBar />
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-TOUTIAO -->
|
||||
<customTabBarToutiao />
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-TOUTIAO -->
|
||||
<customTabBar />
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 顶部导航栏 (搜索) -->
|
||||
<view class="nav-header">
|
||||
@ -23,7 +23,7 @@
|
||||
<scroll-view class="main-content" scroll-y>
|
||||
<!-- Banner 区域 (现代级浮动设计) -->
|
||||
<view class="banner-container">
|
||||
<swiper class="banner-swiper" circular autoplay interval="5000" duration="600" :indicator-dots="false" @change="onBannerChange">
|
||||
<swiper :key="'banner-' + swiperKey" class="banner-swiper" :current="bannerIndex" :circular="swiperAutoplay" :autoplay="swiperAutoplay" interval="5000" duration="600" :indicator-dots="false" @change="onBannerChange">
|
||||
<swiper-item v-for="(b, index) in displayBanners" :key="b.id">
|
||||
<view class="banner-card" :class="{ 'active': bannerIndex === index }">
|
||||
<image v-if="b.image" class="banner-image" :src="b.image" mode="aspectFit" @tap="onBannerTap(b)" />
|
||||
@ -45,7 +45,7 @@
|
||||
<!-- 品牌动态栏 (极简风格) -->
|
||||
<view class="notice-bar-v2" @tap="onNoticeTap">
|
||||
<view class="notice-icon">📢</view>
|
||||
<swiper class="notice-swiper" vertical circular autoplay interval="3500">
|
||||
<swiper :key="'notice-' + swiperKey" class="notice-swiper" vertical :circular="swiperAutoplay" :autoplay="swiperAutoplay" interval="3500">
|
||||
<swiper-item v-for="n in displayNotices" :key="n.id">
|
||||
<view class="notice-item">{{ n.text }}</view>
|
||||
</swiper-item>
|
||||
@ -145,22 +145,22 @@
|
||||
import { authRequest, request } from '../../utils/request.js'
|
||||
import SplashScreen from '@/components/SplashScreen.vue'
|
||||
import { checkPhoneBound, checkPhoneBoundSync } from '../../utils/checkPhone.js'
|
||||
// #ifdef MP-WEIXIN
|
||||
import customTabBar from '@/components/app-tab-bar.vue'
|
||||
// #endif
|
||||
// #ifdef MP-TOUTIAO
|
||||
import customTabBarToutiao from '@/components/app-tab-bar-toutiao.vue'
|
||||
// #endif
|
||||
// #ifndef MP-TOUTIAO
|
||||
import customTabBar from '@/components/app-tab-bar.vue'
|
||||
// #endif
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SplashScreen
|
||||
// #ifdef MP-WEIXIN
|
||||
, customTabBar
|
||||
// #endif
|
||||
// #ifdef MP-TOUTIAO
|
||||
, customTabBarToutiao
|
||||
// #endif
|
||||
// #ifndef MP-TOUTIAO
|
||||
, customTabBar
|
||||
// #endif
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -169,7 +169,9 @@ export default {
|
||||
activities: [],
|
||||
selectedGroupName: '',
|
||||
bannerIndex: 0,
|
||||
isHomeLoading: false
|
||||
isHomeLoading: false,
|
||||
swiperAutoplay: true,
|
||||
swiperKey: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -225,11 +227,21 @@ export default {
|
||||
this.loadHomeData(true)
|
||||
},
|
||||
onShow() {
|
||||
// 只有非首次进入或数据为空时才触发刷新,避免 onLoad/onShow 双重触发
|
||||
this.swiperKey++
|
||||
this.swiperAutoplay = true
|
||||
if (this.activities.length === 0 && !this.isHomeLoading) {
|
||||
this.loadHomeData()
|
||||
}
|
||||
},
|
||||
onHide() {
|
||||
this.swiperAutoplay = false
|
||||
},
|
||||
onUnload() {
|
||||
this.swiperAutoplay = false
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.swiperAutoplay = false
|
||||
},
|
||||
methods: {
|
||||
onBannerChange(e) {
|
||||
this.bannerIndex = e.detail.current
|
||||
|
||||
@ -93,7 +93,7 @@
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 短信登录 -->
|
||||
<view v-else class="login-panel sms-panel">
|
||||
<view v-if="loginMode === 'sms'" class="login-panel sms-panel">
|
||||
<text class="panel-title">手机号验证码登录</text>
|
||||
<text class="panel-desc">输入手机号,获取验证码完成登录</text>
|
||||
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
<view class="bg-decoration"></view>
|
||||
|
||||
<!-- 自定义 tabBar -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<customTabBar />
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-TOUTIAO -->
|
||||
<customTabBarToutiao />
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-TOUTIAO -->
|
||||
<customTabBar />
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 头部区域 -->
|
||||
<view class="header-section">
|
||||
@ -500,21 +500,21 @@ import {
|
||||
getUserTasks, getTaskProgress, getInviteRecords, modifyUser, getUserProfile, bindDouyinID, getPublicConfig
|
||||
} from '../../api/appUser.js'
|
||||
import { checkPhoneBoundSync } from '../../utils/checkPhone.js'
|
||||
// #ifdef MP-WEIXIN
|
||||
import customTabBar from '@/components/app-tab-bar.vue'
|
||||
// #endif
|
||||
// #ifdef MP-TOUTIAO
|
||||
import customTabBarToutiao from '@/components/app-tab-bar-toutiao.vue'
|
||||
// #endif
|
||||
// #ifndef MP-TOUTIAO
|
||||
import customTabBar from '@/components/app-tab-bar.vue'
|
||||
// #endif
|
||||
|
||||
export default {
|
||||
components: {
|
||||
// #ifdef MP-WEIXIN
|
||||
customTabBar,
|
||||
// #endif
|
||||
// #ifdef MP-TOUTIAO
|
||||
customTabBarToutiao,
|
||||
// #endif
|
||||
// #ifndef MP-TOUTIAO
|
||||
customTabBar
|
||||
// #endif
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@ -3,12 +3,12 @@
|
||||
<view class="bg-decoration"></view>
|
||||
|
||||
<!-- 自定义 tabBar -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<customTabBar />
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-TOUTIAO -->
|
||||
<customTabBarToutiao />
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-TOUTIAO -->
|
||||
<customTabBar />
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- [NEW] 全新左右布局布局容器 -->
|
||||
<view class="shop-layout">
|
||||
@ -169,12 +169,12 @@ import { ref, watch, onUnmounted } from 'vue'
|
||||
import { getStoreItems, redeemProductByPoints, redeemCouponByPoints, redeemItemCardByPoints, getProductCategories } from '../../api/appUser'
|
||||
import { checkPhoneBound, checkPhoneBoundSync } from '../../utils/checkPhone.js'
|
||||
import { vibrateShort } from '@/utils/vibrate.js'
|
||||
// #ifdef MP-WEIXIN
|
||||
import customTabBar from '@/components/app-tab-bar.vue'
|
||||
// #endif
|
||||
// #ifdef MP-TOUTIAO
|
||||
import customTabBarToutiao from '@/components/app-tab-bar-toutiao.vue'
|
||||
// #endif
|
||||
// #ifndef MP-TOUTIAO
|
||||
import customTabBar from '@/components/app-tab-bar.vue'
|
||||
// #endif
|
||||
|
||||
// 由于是 setup 语法,组件会自动注册,无需手动声明
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* 用于统一 一番赏、无限赏、对对碰 三种玩法的支付流程
|
||||
*/
|
||||
|
||||
import { createWechatOrder } from '../api/appUser'
|
||||
import { createWechatOrder, createWechatAppOrder } from '../api/appUser'
|
||||
import { hasPhoneBound } from './checkPhone'
|
||||
|
||||
/**
|
||||
@ -17,6 +17,16 @@ export function extractOrderNo(res) {
|
||||
return res.order_no || res.orderNo || res.data?.order_no || res.data?.orderNo || res.result?.order_no || res.result?.orderNo || null
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为 App 平台
|
||||
*/
|
||||
function isAppPlatform() {
|
||||
// #ifdef APP-PLUS
|
||||
return true
|
||||
// #endif
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行微信支付流程
|
||||
*
|
||||
@ -30,6 +40,12 @@ export async function doWechatPayment({ orderNo, openid }) {
|
||||
throw new Error('订单号不能为空')
|
||||
}
|
||||
|
||||
// App 端支付流程
|
||||
if (isAppPlatform()) {
|
||||
return doAppWechatPayment({ orderNo })
|
||||
}
|
||||
|
||||
// 小程序端支付流程
|
||||
const finalOpenid = openid || uni.getStorageSync('openid')
|
||||
if (!finalOpenid) {
|
||||
throw new Error('缺少OpenID,请重新登录')
|
||||
@ -64,6 +80,47 @@ export async function doWechatPayment({ orderNo, openid }) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* App 端微信支付流程
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {string} options.orderNo - 订单号
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function doAppWechatPayment({ orderNo }) {
|
||||
// 1. 获取 APP 支付参数
|
||||
const payRes = await createWechatAppOrder({ order_no: orderNo })
|
||||
if (!payRes || !payRes.prepayid) {
|
||||
throw new Error('获取支付参数失败')
|
||||
}
|
||||
|
||||
// 2. 调起微信支付 (App 端使用 orderInfo 对象)
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
orderInfo: {
|
||||
appid: payRes.appid,
|
||||
partnerid: payRes.partnerid,
|
||||
prepayid: payRes.prepayid,
|
||||
package: payRes.package || 'Sign=WXPay',
|
||||
noncestr: payRes.noncestr,
|
||||
timestamp: payRes.timestamp,
|
||||
sign: payRes.sign
|
||||
},
|
||||
success: resolve,
|
||||
fail: (err) => {
|
||||
if (err?.errMsg && String(err.errMsg).includes('cancel')) {
|
||||
const cancelErr = new Error('支付已取消')
|
||||
cancelErr.cancelled = true
|
||||
reject(cancelErr)
|
||||
} else {
|
||||
reject(err)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 完整支付流程(创建订单 + 支付)
|
||||
*
|
||||
@ -99,7 +156,6 @@ export async function executePaymentFlow({ createOrder, openid, onOrderCreated }
|
||||
*/
|
||||
export function checkLoginStatus() {
|
||||
const token = uni.getStorageSync('token')
|
||||
const openid = uni.getStorageSync('openid')
|
||||
|
||||
if (!token) {
|
||||
return { ok: false, message: '请先登录' }
|
||||
@ -110,6 +166,12 @@ export function checkLoginStatus() {
|
||||
return { ok: false, message: '请先绑定手机号' }
|
||||
}
|
||||
|
||||
// App 端不需要 openid
|
||||
if (isAppPlatform()) {
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
const openid = uni.getStorageSync('openid')
|
||||
if (!openid) {
|
||||
return { ok: false, message: '缺少OpenID,请重新登录' }
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const BASE_URL = 'http://127.0.0.1:9991'
|
||||
// const BASE_URL = 'https://kdy.1024tool.vip'
|
||||
//const BASE_URL = 'http://127.0.0.1:9991'
|
||||
const BASE_URL = 'https://kdy.1024tool.vip'
|
||||
let authModalShown = false
|
||||
|
||||
function handleAuthExpired() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user