Compare commits

..

No commits in common. "de96ecb2c470a2d3ed81200c409cbd80256d57f5" and "892d4e1608741931ccdaa1c9bc509f06e4ca19ee" have entirely different histories.

9 changed files with 77 additions and 123 deletions

View File

@ -3,12 +3,17 @@ import path from 'path'
const config = { const config = {
pages: './src/pages', pages: './src/pages',
pagesInclude: ['jlgh/coupon.vue', 'jlgh/redeem.vue'], // pagesInclude: ['jlgh/coupon.vue', 'jlgh/redeem.vue'],
// pagesInclude: ['jlgh/index.vue'], // pagesInclude: ['jlgh/index.vue'],
// pagesInclude: ['jlgh/login.vue'], // pagesInclude: ['jlgh/login.vue'],
// pagesInclude: ['jlgh'],
pagesInclude: ['index'],
} }
const { pages, pagesInclude } = config const {
pages,
pagesInclude
} = config
function getPages() { function getPages() {
const srcPath = path.resolve(__dirname, pages) const srcPath = path.resolve(__dirname, pages)
@ -70,4 +75,7 @@ function createOutputDir(pageInfo) {
} }
} }
export { getPages, createOutputDir } export {
getPages,
createOutputDir
}

6
env/.env vendored
View File

@ -5,13 +5,13 @@ VITE_UNI_APPID = 'H57F2ACE4'
VITE_WX_APPID = 'wxa2abb91f64032a2b' VITE_WX_APPID = 'wxa2abb91f64032a2b'
# h5部署网站的base配置到 manifest.config.ts 里的 h5.router.base # h5部署网站的base配置到 manifest.config.ts 里的 h5.router.base
VITE_APP_PUBLIC_BASE = './' VITE_APP_PUBLIC_BASE = ./
# 测试线上 # 测试线上
VITE_SERVER_BASEURL = 'https://gateway.dev.cdlsxd.cn' # VITE_SERVER_BASEURL = 'https://gateway.dev.cdlsxd.cn'
# 曾徐平 # 曾徐平
# VITE_SERVER_BASEURL = 'http://192.168.110.128:8081' # VITE_SERVER_BASEURL = 'http://192.168.110.128:8081'
# 正式环境 # 正式环境
# VITE_SERVER_BASEURL = 'https://scens.h5.86698.cn' VITE_SERVER_BASEURL = 'https://scens.h5.86698.cn'
VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload' VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload'

View File

@ -22,47 +22,7 @@
<body> <body>
<div id="app"><!--app-html--></div> <div id="app"><!--app-html--></div>
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/main.ts"></script>
<script> <!-- 调试工具 -->
var clickCount = 0
var timer = null
var isShow = false
function insertScript(src) {
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
if (clickCount < 6) {
clickCount++
console.log(`Clicked ${clickCount} times`)
// 如果是第一次点击,则开始计时
if (clickCount === 1) {
timer = setTimeout(() => {
clickCount = 0 // 重置点击计数
}, 2000)
}
// 如果点击次数达到6次则清除计时器并重置状态
if (clickCount === 6) {
clearTimeout(timer)
insertScript()
clickCount = 0 // 重置点击计数
}
}
})
</script>
<!-- <script src="https://fastly.jsdelivr.net/npm/eruda"></script> <!-- <script src="https://fastly.jsdelivr.net/npm/eruda"></script>
<script> <script>
eruda.init() eruda.init()

View File

@ -39,19 +39,11 @@
}, },
"pages": [ "pages": [
{ {
"path": "pages/jlgh/coupon", "path": "pages/index/index",
"type": "page", "type": "home",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarTitleText": "我的奖品" "navigationBarTitleText": "首页"
}
},
{
"path": "pages/jlgh/redeem",
"type": "page",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "奖品兑换"
} }
} }
], ],

View File

@ -208,7 +208,7 @@ export default {
}, },
onLoad(options) { onLoad(options) {
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
const { activity_code, token } = this.getUrlParams() const { activity_code = 'JLGH', token } = this.getUrlParams()
const useStore = useUserStore() const useStore = useUserStore()
if (token) { if (token) {
useStore.setUserInfo({ token }) useStore.setUserInfo({ token })
@ -279,6 +279,23 @@ export default {
} }
}) })
}, },
deepClone(obj) {
//
const objClone = Array.isArray(obj) ? [] : {}
//
if (obj && typeof obj === 'object') {
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (obj[key] && typeof obj[key] === 'object') {
objClone[key] = deepClone1(obj[key])
} else {
objClone[key] = obj[key]
}
}
}
}
return objClone
},
// //
getPrizeList() { getPrizeList() {
Api.getProducts({ Api.getProducts({
@ -286,6 +303,26 @@ export default {
}).then((res) => { }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
const { products } = res.data const { products } = res.data
const len = products.length
// len > 0 &&
// products.forEach((item) => {
// this.prizeList.push({
// prizeId: item.product_id,
// prizeName: item.show_name,
// name: item.show_name,
// })
// })
// if (len < 5) {
// const temp = this.deepClone(this.prizeList)
// for (let i = 0; i < 5 - len; i++) {
// if (this.prizeList.length >= 5) break
// this.prizeList.push(temp[i])
// if (i === len - 1) {
// i = 0
// }
// }
// }
// console.log(this.prizeList)
if (products.length > 0) { if (products.length > 0) {
while (this.prizeList.length < 5) { while (this.prizeList.length < 5) {
products.forEach((item) => { products.forEach((item) => {
@ -303,6 +340,8 @@ export default {
prizeName: '谢谢参与', prizeName: '谢谢参与',
name: '未中奖', name: '未中奖',
}) })
// const temp = this.prizeList
// this.prizeList = [...temp, ...temp]
} else { } else {
uni.showToast({ uni.showToast({
title: res.message, title: res.message,
@ -385,7 +424,6 @@ export default {
this.prizeIndex = index this.prizeIndex = index
} else if (notwinCode.includes(res.code)) { } else if (notwinCode.includes(res.code)) {
this.prizeIndex = this.prizeList.findIndex((ele) => ele.prizeId === 0) this.prizeIndex = this.prizeList.findIndex((ele) => ele.prizeId === 0)
this.jiang = res.message
} else { } else {
this.prizeing = false this.prizeing = false
uni.showToast({ uni.showToast({
@ -403,13 +441,15 @@ export default {
console.log('旋转结束,执行拿到结果后到逻辑') console.log('旋转结束,执行拿到结果后到逻辑')
// //
const prizeName = this.prizeList[this.prizeIndex].name const prizeName = this.prizeList[this.prizeIndex].name
let tipContent = ''
if (prizeName === '谢谢参与' || prizeName === '未中奖') { if (prizeName === '谢谢参与' || prizeName === '未中奖') {
// tipContent = '' tipContent = '很遗憾,没有中奖,请再接再厉'
this.isz = 0 this.isz = 0
} else { } else {
this.isz = 1 this.isz = 1
this.jiang = `${prizeName}` tipContent = `${prizeName}`
} }
this.jiang = tipContent
this.prizeing = false this.prizeing = false
this.ismask2 = true this.ismask2 = true
}, },

View File

@ -113,7 +113,7 @@ const login = async () => {
const params = { const params = {
phone: phone.value, phone: phone.value,
code: code.value, code: code.value,
activity_code: query.activity_code, activity_code: query.activity_code || 'JLGH',
} }
const res: any = await getLogin(params) const res: any = await getLogin(params)
if (res.code === 200) { if (res.code === 200) {

View File

@ -111,7 +111,7 @@ import api from './api'
const ismask = ref<boolean>(false) const ismask = ref<boolean>(false)
const info = reactive<any>({}) const info = reactive<any>({})
const linkUrl = ref<string>('') const phone = ref<string>('')
onLoad((options) => { onLoad((options) => {
const item = decodeURIComponent(options.item) const item = decodeURIComponent(options.item)
@ -120,44 +120,8 @@ onLoad((options) => {
function gomy() { function gomy() {
ismask.value = false ismask.value = false
if (linkUrl.value) { uni.navigateTo({
window.parent.postMessage( url: `/pages/jlgh/coupon?activity_code=${info.activity_code}`,
{
data: {
message: 'success',
type: 'location',
url: linkUrl.value,
},
},
'*',
)
return false
}
const params = { id: info.id, activity_code: info.activity_code }
api.getCouponList(params).then((res: any) => {
if (res.code === 200) {
const dataInfo = res.data.data[0]
if (dataInfo.order_info && typeof dataInfo.order_info === 'string') {
window.parent.postMessage(
{
data: {
message: 'success',
type: 'location',
url: dataInfo.order_info,
},
},
'*',
)
} else {
uni.navigateTo({
url: `/pages/jlgh/coupon?activity_code=${info.activity_code}`,
})
}
} else {
uni.navigateTo({
url: `/pages/jlgh/coupon?activity_code=${info.activity_code}`,
})
}
}) })
} }
@ -176,9 +140,6 @@ function dui() {
if (res.code === 200) { if (res.code === 200) {
ismask.value = true ismask.value = true
uni.hideLoading() uni.hideLoading()
if (res.data && typeof res.data === 'string') {
linkUrl.value = res.data
}
} else { } else {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({

View File

@ -4,8 +4,7 @@
// Generated by vite-plugin-uni-pages // Generated by vite-plugin-uni-pages
interface NavigateToOptions { interface NavigateToOptions {
url: "/pages/jlgh/coupon" | url: "/pages/index/index";
"/pages/jlgh/redeem";
} }
interface RedirectToOptions extends NavigateToOptions {} interface RedirectToOptions extends NavigateToOptions {}

View File

@ -78,22 +78,16 @@ export default ({ command, mode }) => {
// 通过这个插件在修改vite.config.js文件则不需要重新运行也生效配置 // 通过这个插件在修改vite.config.js文件则不需要重新运行也生效配置
restart: ['vite.config.js'], restart: ['vite.config.js'],
}), }),
UNI_PLATFORM === 'h5' && viteCopyToNewFolderPlugin({
mode === 'production' && outputDir: outputDirName,
viteCopyToNewFolderPlugin({ }),
outputDir: outputDirName, compresssionBuild({
}), sourceName: `dist/build/${outputDirName}`,
UNI_PLATFORM === 'h5' && type: 'zip',
mode === 'production' && targetName: `dist/build/${outputDirName}`,
compresssionBuild({ ignoreBase: false,
sourceName: `dist/build/${outputDirName}`, }),
type: 'zip', vitePluginRemoveDir({ dirName: outputDirName }),
targetName: `dist/build/${outputDirName}`,
ignoreBase: false,
}),
UNI_PLATFORM === 'h5' &&
mode === 'production' &&
vitePluginRemoveDir({ dirName: outputDirName }),
// h5环境增加编译时间 // h5环境增加编译时间
UNI_PLATFORM === 'h5' && { UNI_PLATFORM === 'h5' && {
name: 'html-transform', name: 'html-transform',