This commit is contained in:
parent
aeb7d272e1
commit
2f7e887a73
|
@ -9,7 +9,7 @@ lerna-debug.log*
|
|||
|
||||
node_modules
|
||||
.DS_Store
|
||||
# dist
|
||||
dist
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
|
|
|
@ -8,8 +8,8 @@ const config = {
|
|||
pages: './src/pages',
|
||||
// pagesInclude: ['jlgh/coupon.vue', 'jlgh/redeem.vue'],
|
||||
// pagesInclude: ['jlgh/index.vue'],
|
||||
// pagesInclude: ['jlgh/login.vue'],
|
||||
pagesInclude: ['index'],
|
||||
pagesInclude: ['jlgh/login.vue'],
|
||||
// pagesInclude: ['jlgh'],
|
||||
}
|
||||
|
||||
const { pages, pagesInclude } = config
|
||||
|
|
|
@ -7,12 +7,12 @@ VITE_SHOW_SOURCEMAP = false
|
|||
|
||||
# VITE_APP_PUBLIC_BASE = ./
|
||||
# 测试线上
|
||||
# VITE_SERVER_BASEURL = 'https://gateway.dev.cdlsxd.cn'
|
||||
VITE_SERVER_BASEURL = 'https://gateway.dev.cdlsxd.cn'
|
||||
# 正式环境
|
||||
VITE_SERVER_BASEURL = 'https://scens.h5.86698.cn'
|
||||
# VITE_SERVER_BASEURL = 'https://scens.h5.86698.cn'
|
||||
|
||||
# VITE_APP_PROXY = true
|
||||
# 测试线上
|
||||
# VITE_APP_PROXY_PREFIX = 'https://gateway.dev.cdlsxd.cn'
|
||||
VITE_APP_PROXY_PREFIX = 'https://gateway.dev.cdlsxd.cn'
|
||||
# 正式环境
|
||||
VITE_APP_PROXY_PREFIX = 'https://scens.h5.86698.cn'
|
||||
# VITE_APP_PROXY_PREFIX = 'https://scens.h5.86698.cn'
|
||||
|
|
36
index.html
36
index.html
|
@ -22,23 +22,27 @@
|
|||
<body>
|
||||
<div id="app"><!--app-html--></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
<script src="https://fastly.jsdelivr.net/npm/eruda"></script>
|
||||
<script>
|
||||
var clickCount = 0
|
||||
var timer = null
|
||||
var isShow = false
|
||||
function insertScript() {
|
||||
isShow = true
|
||||
// 创建一个新的script元素
|
||||
var src = 'https://fastly.jsdelivr.net/npm/eruda'
|
||||
var script = document.createElement('script')
|
||||
script.type = 'text/javascript'
|
||||
script.src = src
|
||||
// 插入到head中
|
||||
document.head.appendChild(script)
|
||||
script.onload = function () {
|
||||
eruda.init()
|
||||
}
|
||||
}
|
||||
eruda.init()
|
||||
</script>
|
||||
<script>
|
||||
// var clickCount = 0
|
||||
// var timer = null
|
||||
// var isShow = false
|
||||
// function insertScript() {
|
||||
// isShow = true
|
||||
// // 创建一个新的script元素
|
||||
// var src = 'https://fastly.jsdelivr.net/npm/eruda'
|
||||
// var script = document.createElement('script')
|
||||
// script.type = 'text/javascript'
|
||||
// script.src = src
|
||||
// // 插入到head中
|
||||
// document.head.appendChild(script)
|
||||
// script.onload = function () {
|
||||
// eruda.init()
|
||||
// }
|
||||
// }
|
||||
|
||||
// document.addEventListener('click', function () {
|
||||
// if (isShow) return false
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
},
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"path": "pages/jlgh/login",
|
||||
"type": "home",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "首页"
|
||||
"navigationBarTitleText": "登录"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -36,6 +36,20 @@ export const getOrderDetail = (params: any) => {
|
|||
return http.get('/v1/auth/user/order/detail', params)
|
||||
}
|
||||
|
||||
// 获取活动的支付方式
|
||||
export const getPayConfig = (params: any) => {
|
||||
return http.get('/v1/pay/config', params)
|
||||
}
|
||||
// 发起支付
|
||||
export const goPay = (params: any) => {
|
||||
return http.post('/v1/pay/order/url', params)
|
||||
}
|
||||
|
||||
// 支付结果查询
|
||||
export const queryPayResult = (params: any) => {
|
||||
return http.get('/v1/pay/order/query', params)
|
||||
}
|
||||
|
||||
export default {
|
||||
getSms,
|
||||
getLogin,
|
||||
|
@ -46,4 +60,7 @@ export default {
|
|||
exchange,
|
||||
getProductDetail,
|
||||
getOrderDetail,
|
||||
getPayConfig,
|
||||
goPay,
|
||||
queryPayResult,
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ const istrue = ref<boolean>(false)
|
|||
const list = reactive<any>([])
|
||||
const query = reactive<any>({
|
||||
activity_code: '',
|
||||
// activity_code: 'JLGH',
|
||||
})
|
||||
|
||||
const dui = (item) => {
|
||||
|
|
|
@ -208,7 +208,7 @@ export default {
|
|||
},
|
||||
onLoad(options) {
|
||||
// eslint-disable-next-line camelcase
|
||||
const { activity_code, token } = this.getUrlParams()
|
||||
const { activity_code = 'JLGH', token } = this.getUrlParams()
|
||||
const useStore = useUserStore()
|
||||
if (token) {
|
||||
useStore.setUserInfo({ token })
|
||||
|
|
|
@ -64,18 +64,18 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import Api from './api'
|
||||
import { debounce } from '@/utils/index'
|
||||
import { debounce, throttle } from '@/utils/index'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||
|
||||
const code = ref<number>(null)
|
||||
const phone = ref<number>(null)
|
||||
const phone = ref<string>(null)
|
||||
const codemsg = ref<string>('发送验证码')
|
||||
const codesecond = ref<number>(60)
|
||||
const useStore = useUserStore()
|
||||
const query = reactive<any>({})
|
||||
|
||||
const phoneRegex = /^(\+\d{1,2}\s)?\(?\d{3,4}\)?[\s.-]?\d{3,4}[\s.-]?\d{4}$/
|
||||
const getUrlParm = () => {
|
||||
const url = window.location.href
|
||||
const theRequest = {}
|
||||
|
@ -95,9 +95,9 @@ onLoad(() => {
|
|||
})
|
||||
|
||||
const login = async () => {
|
||||
if (!phone.value) {
|
||||
if (!phoneRegex.test(phone.value)) {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
title: '手机号格式不正确',
|
||||
icon: 'none',
|
||||
})
|
||||
return false
|
||||
|
@ -112,7 +112,7 @@ const login = async () => {
|
|||
const params = {
|
||||
phone: phone.value,
|
||||
code: code.value,
|
||||
activity_code: query.activity_code || 'JLGH',
|
||||
activity_code: query.activity_code,
|
||||
}
|
||||
const res: any = await Api.getLogin(params)
|
||||
if (res.code === 200) {
|
||||
|
@ -171,10 +171,11 @@ const getPhoneVaild = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
const getValid = debounce(async () => {
|
||||
if (!phone.value) {
|
||||
const getValid = throttle(() => {
|
||||
// 手机号
|
||||
if (!phoneRegex.test(phone.value)) {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
title: '手机号格式不正确',
|
||||
icon: 'none',
|
||||
})
|
||||
return false
|
||||
|
@ -183,7 +184,7 @@ const getValid = debounce(async () => {
|
|||
return false
|
||||
}
|
||||
getPhoneVaild()
|
||||
}, 300)
|
||||
}, 1000)
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
@ -104,6 +104,26 @@
|
|||
</scroll-view>
|
||||
</view>
|
||||
<view @click="dui" class="dui_btn">立即兑换</view>
|
||||
<wd-popup
|
||||
v-model="showPayConfig"
|
||||
position="bottom"
|
||||
custom-style="max-height:400rpx;background-color:#fff !important"
|
||||
>
|
||||
<view style="padding-bottom: 20rpx">
|
||||
<view class="pay-top">
|
||||
<view style="flex: 1; margin-left: 80rpx; text-align: center">请选择支付方式</view>
|
||||
<wd-icon
|
||||
name="close"
|
||||
size="20px"
|
||||
style="margin-right: 20rpx"
|
||||
@click="clickEvent"
|
||||
></wd-icon>
|
||||
</view>
|
||||
<view v-for="(item, index) in payList" :key="index" class="pay-item" @click="toPay(item)">
|
||||
{{ payConfig[item.pay_type].label }}({{ wait_pay_amount }}元)
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
@ -115,12 +135,28 @@ const info = reactive<any>({})
|
|||
const linkUrl = ref<string>('')
|
||||
const remark = ref('')
|
||||
|
||||
const showPayConfig = ref(false)
|
||||
const payList = ref([])
|
||||
const payConfig = {
|
||||
1: {
|
||||
label: '支付宝',
|
||||
},
|
||||
2: {
|
||||
label: '微信',
|
||||
},
|
||||
}
|
||||
// eslint-disable-next-line camelcase
|
||||
const pay_order_no = ref('')
|
||||
// eslint-disable-next-line camelcase
|
||||
const wait_pay_amount = ref(0)
|
||||
|
||||
onLoad((options) => {
|
||||
const item = decodeURIComponent(options.item)
|
||||
Object.assign(info, JSON.parse(item))
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
console.log('onMounted')
|
||||
// eslint-disable-next-line camelcase
|
||||
const { goods_id, activity_code } = info
|
||||
// eslint-disable-next-line camelcase
|
||||
|
@ -134,8 +170,24 @@ onMounted(() => {
|
|||
})
|
||||
}
|
||||
})
|
||||
queryOrder()
|
||||
})
|
||||
|
||||
function getUrlParams() {
|
||||
const url = window.location.href
|
||||
const theRequest = {}
|
||||
if (url.indexOf('?') !== -1) {
|
||||
const index = url.indexOf('?')
|
||||
let str = url.slice(index + 1)
|
||||
str = str.indexOf('#') !== -1 ? str.split('#')[0] : str
|
||||
const strs = str.split('&')
|
||||
for (let i = 0; i < strs.length; i++) {
|
||||
theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1]
|
||||
}
|
||||
}
|
||||
return theRequest
|
||||
}
|
||||
|
||||
function gomy() {
|
||||
ismask.value = false
|
||||
if (linkUrl.value) {
|
||||
|
@ -179,7 +231,67 @@ function gomy() {
|
|||
})
|
||||
}
|
||||
|
||||
function dui() {
|
||||
function clickEvent() {
|
||||
showPayConfig.value = false
|
||||
}
|
||||
|
||||
async function toPay(item) {
|
||||
// eslint-disable-next-line camelcase
|
||||
const { pay_type, pay_center_channel_id } = item
|
||||
// eslint-disable-next-line camelcase
|
||||
const order_no = pay_order_no.value
|
||||
// eslint-disable-next-line camelcase
|
||||
const params = {
|
||||
// eslint-disable-next-line camelcase
|
||||
order_no,
|
||||
// eslint-disable-next-line camelcase
|
||||
pay_center_channel_id,
|
||||
// eslint-disable-next-line camelcase
|
||||
return_url: location.href + `&order_no=${order_no}`,
|
||||
}
|
||||
const res = await api.goPay(params)
|
||||
const { code, message, data } = res as any
|
||||
if (code === 200) {
|
||||
window.location.href = data.url
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: message,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 支付订单状态查询
|
||||
function queryOrder() {
|
||||
// eslint-disable-next-line camelcase
|
||||
const { order_no } = getUrlParams() as any
|
||||
// eslint-disable-next-line camelcase
|
||||
if (!order_no) {
|
||||
console.log('没有订单号,不是支付回调回来')
|
||||
return
|
||||
}
|
||||
// eslint-disable-next-line camelcase
|
||||
api.queryPayResult({ order_no }).then((res) => {})
|
||||
}
|
||||
|
||||
// 获取支付方式
|
||||
// function getPay() {
|
||||
// // eslint-disable-next-line camelcase
|
||||
// const { activity_code } = info
|
||||
// // eslint-disable-next-line camelcase
|
||||
// api.getPayConfig({ activity_code }).then((res: any) => {
|
||||
// if (res.code === 200) {
|
||||
// payList.value = res.data
|
||||
// } else {
|
||||
// uni.showToast({
|
||||
// icon: 'none',
|
||||
// title: res.message,
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
async function dui() {
|
||||
uni.showLoading({
|
||||
title: '兑换中...',
|
||||
})
|
||||
|
@ -190,27 +302,54 @@ function dui() {
|
|||
})
|
||||
}
|
||||
const params = { id: info.id, account: info.mobile, account_type: info.account_type }
|
||||
api.exchange(params).then((res: any) => {
|
||||
if (res.code === 200) {
|
||||
const res1 = await api.exchange(params)
|
||||
const { code, data, message } = res1 as any
|
||||
uni.hideLoading()
|
||||
if (code === 200) {
|
||||
// eslint-disable-next-line camelcase
|
||||
const { shortUrl, status, order_no, wait_amount } = data
|
||||
// 待支付
|
||||
if (status === 1) {
|
||||
const res2 = await api.getPayConfig({ activity_code: info.activity_code })
|
||||
payList.value = (res2 as any).data
|
||||
// eslint-disable-next-line camelcase
|
||||
pay_order_no.value = order_no
|
||||
// eslint-disable-next-line camelcase
|
||||
wait_pay_amount.value = wait_amount
|
||||
showPayConfig.value = true
|
||||
} else if (shortUrl && typeof shortUrl === 'string') {
|
||||
ismask.value = true
|
||||
uni.hideLoading()
|
||||
if (res.data && typeof res.data === 'string') {
|
||||
linkUrl.value = res.data
|
||||
}
|
||||
linkUrl.value = shortUrl
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: res.message,
|
||||
icon: 'none',
|
||||
})
|
||||
ismask.value = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use './style.css';
|
||||
|
||||
.pay-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 80rpx;
|
||||
}
|
||||
.pay-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100rpx;
|
||||
&:not(:last-child) {
|
||||
border-bottom: 1px solid red;
|
||||
}
|
||||
}
|
||||
|
||||
.redeem-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Generated by vite-plugin-uni-pages
|
||||
|
||||
interface NavigateToOptions {
|
||||
url: "/pages/index/index";
|
||||
url: "/pages/jlgh/login";
|
||||
}
|
||||
interface RedirectToOptions extends NavigateToOptions {}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable prefer-rest-params */
|
||||
/* eslint-disable @typescript-eslint/no-this-alias */
|
||||
// import { pages, subPackages, tabBar } from '@/pages.json'
|
||||
import { pages, subPackages } from '@/pages.json'
|
||||
|
@ -127,3 +128,37 @@ export function debounce<T extends (...args: any[]) => any>(func: T, wait: numbe
|
|||
}, wait)
|
||||
} as T
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 函数节流,用于将多次执行变为间隔多少秒执行一次
|
||||
* @param {function} func - 需要使用函数的被执行的函数。必传
|
||||
* @param {Number} wait - 每隔多少秒执行一次
|
||||
* @param {Boolean} isRunNow - 是否立即执行一次 默认true
|
||||
*/
|
||||
export function throttle<T extends (...args: any[]) => any>(
|
||||
func: T,
|
||||
wait: number,
|
||||
isRunNow: boolean = true,
|
||||
): T {
|
||||
if (isRunNow) {
|
||||
let previous = 0
|
||||
return function (this: any, ...args: Parameters<T>) {
|
||||
const now = new Date().valueOf()
|
||||
if (now - previous > wait) {
|
||||
func.apply(this, args)
|
||||
previous = now
|
||||
}
|
||||
} as T
|
||||
} else {
|
||||
let canRun: boolean = true
|
||||
return function (this: any, ...args: Parameters<T>) {
|
||||
if (!canRun) return
|
||||
canRun = false
|
||||
// 设置定时器,定时执行传入的函数
|
||||
setTimeout(() => {
|
||||
func.apply(this, args)
|
||||
canRun = true
|
||||
}, wait)
|
||||
} as T
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue