Compare commits

...

2 Commits

Author SHA1 Message Date
xiaogang de96ecb2c4 解决掉冲突 2024-07-19 10:01:00 +08:00
xiaogang 1a41a89a44 吉林工行模板基本改动完毕 2024-07-19 09:58:49 +08:00
9 changed files with 123 additions and 77 deletions

View File

@ -3,17 +3,12 @@ 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 { const { pages, pagesInclude } = config
pages,
pagesInclude
} = config
function getPages() { function getPages() {
const srcPath = path.resolve(__dirname, pages) const srcPath = path.resolve(__dirname, pages)
@ -75,7 +70,4 @@ function createOutputDir(pageInfo) {
} }
} }
export { export { getPages, createOutputDir }
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,7 +22,47 @@
<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,11 +39,19 @@
}, },
"pages": [ "pages": [
{ {
"path": "pages/index/index", "path": "pages/jlgh/coupon",
"type": "home", "type": "page",
"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 = 'JLGH', token } = this.getUrlParams() const { activity_code, token } = this.getUrlParams()
const useStore = useUserStore() const useStore = useUserStore()
if (token) { if (token) {
useStore.setUserInfo({ token }) useStore.setUserInfo({ token })
@ -279,23 +279,6 @@ 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({
@ -303,26 +286,6 @@ 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) => {
@ -340,8 +303,6 @@ 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,
@ -424,6 +385,7 @@ 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({
@ -441,15 +403,13 @@ 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
tipContent = `${prizeName}` this.jiang = `${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 || 'JLGH', activity_code: query.activity_code,
} }
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 phone = ref<string>('') const linkUrl = ref<string>('')
onLoad((options) => { onLoad((options) => {
const item = decodeURIComponent(options.item) const item = decodeURIComponent(options.item)
@ -120,8 +120,44 @@ onLoad((options) => {
function gomy() { function gomy() {
ismask.value = false ismask.value = false
uni.navigateTo({ if (linkUrl.value) {
url: `/pages/jlgh/coupon?activity_code=${info.activity_code}`, window.parent.postMessage(
{
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}`,
})
}
}) })
} }
@ -140,6 +176,9 @@ 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,7 +4,8 @@
// Generated by vite-plugin-uni-pages // Generated by vite-plugin-uni-pages
interface NavigateToOptions { interface NavigateToOptions {
url: "/pages/index/index"; url: "/pages/jlgh/coupon" |
"/pages/jlgh/redeem";
} }
interface RedirectToOptions extends NavigateToOptions {} interface RedirectToOptions extends NavigateToOptions {}

View File

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