修改部分代码
This commit is contained in:
parent
13dd373aa2
commit
d2c9edfbd4
|
@ -3,10 +3,10 @@ import path from 'path'
|
|||
|
||||
const config = {
|
||||
pages: './src/pages',
|
||||
pagesInclude: ['jlgh/coupon.vue', 'jlgh/redeem.vue'],
|
||||
// pagesInclude: ['jlgh/index.vue'],
|
||||
// pagesInclude: ['jlgh/coupon.vue', 'jlgh/redeem.vue'],
|
||||
pagesInclude: ['jlgh/index.vue'],
|
||||
// pagesInclude: ['jlgh/login.vue'],
|
||||
// pagesInclude: ['index'],
|
||||
// pagesInclude: ['jlgh'],
|
||||
}
|
||||
|
||||
const { pages, pagesInclude } = config
|
||||
|
|
|
@ -15,19 +15,12 @@
|
|||
},
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/jlgh/coupon",
|
||||
"path": "pages/jlgh/index",
|
||||
"type": "page",
|
||||
"layout": "default",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "我的奖品"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/jlgh/redeem",
|
||||
"type": "page",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "奖品兑换"
|
||||
"navigationBarTitleText": "工行长春消费季"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
// import AlmostLottery from '@/uni_modules/almost-lottery/components/almost-lottery/almost-lottery.vue'
|
||||
import AlmostLottery from '@/uni_modules/almost-lottery/components/almost-lottery/almost-lottery.vue'
|
||||
import lotteryBg from '../../assets/images/jlgh/panpan.png'
|
||||
import dizuo from '../../assets/images/jlgh/dizuo.png'
|
||||
import Api from './api'
|
||||
|
@ -176,7 +176,7 @@ import { useUserStore } from '@/store'
|
|||
export default {
|
||||
name: 'Home',
|
||||
components: {
|
||||
// AlmostLottery,
|
||||
AlmostLottery,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -207,7 +207,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 })
|
||||
|
@ -278,25 +278,52 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
// 获取奖品列表
|
||||
getPrizeList() {
|
||||
Api.getProducts({
|
||||
activity_code: this.activity_code || 'zgp',
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
const { products } = res.data
|
||||
if (products.length > 0) {
|
||||
while (this.prizeList.length < 5) {
|
||||
products.forEach((item) => {
|
||||
this.prizeList.push({
|
||||
// 额外填充奖品到6个,未中奖谢谢参与算一个,所以默认值为5
|
||||
fillPrize(prizes, targetLength = 5) {
|
||||
if (!prizes.length || !prizes) return []
|
||||
if (prizes.length >= targetLength) {
|
||||
return prizes.map((ele) => ({
|
||||
prizeId: ele.product_id,
|
||||
prizeName: ele.show_name,
|
||||
name: ele.show_name,
|
||||
}))
|
||||
}
|
||||
const result = []
|
||||
let index = 0
|
||||
while (result.length < targetLength) {
|
||||
const item = prizes[index]
|
||||
result.push({
|
||||
prizeId: item.product_id,
|
||||
prizeName: item.show_name,
|
||||
name: item.show_name,
|
||||
})
|
||||
})
|
||||
index++
|
||||
if (index > prizes.length - 1) {
|
||||
index = 0
|
||||
}
|
||||
}
|
||||
this.prizeList = this.prizeList.slice(0, 5)
|
||||
return result
|
||||
},
|
||||
// 获取奖品列表
|
||||
getPrizeList() {
|
||||
Api.getProducts({
|
||||
activity_code: this.activity_code,
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
const { products } = res.data
|
||||
// if (products.length > 0) {
|
||||
// while (this.prizeList.length < 5) {
|
||||
// products.forEach((item) => {
|
||||
// this.prizeList.push({
|
||||
// prizeId: item.product_id,
|
||||
// prizeName: item.show_name,
|
||||
// name: item.show_name,
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// this.prizeList = this.prizeList.slice(0, 5)
|
||||
this.prizeList = this.fillPrize(products)
|
||||
this.prizeList.push({
|
||||
prizeId: 0,
|
||||
prizeName: '谢谢参与',
|
||||
|
|
|
@ -112,26 +112,26 @@ const login = async () => {
|
|||
const params = {
|
||||
phone: phone.value,
|
||||
code: code.value,
|
||||
activity_code: query.activity_code,
|
||||
activity_code: query.activity_code || 'JLGH',
|
||||
}
|
||||
const res: any = await Api.getLogin(params)
|
||||
if (res.code === 200) {
|
||||
const token = res.data.token
|
||||
useStore.setUserInfo({ token })
|
||||
// #ifdef H5
|
||||
window.parent.postMessage(
|
||||
{
|
||||
data: {
|
||||
message: 'success',
|
||||
type: 'login',
|
||||
},
|
||||
},
|
||||
'*',
|
||||
)
|
||||
// window.parent.postMessage(
|
||||
// {
|
||||
// data: {
|
||||
// message: 'success',
|
||||
// type: 'login',
|
||||
// },
|
||||
// },
|
||||
// '*',
|
||||
// )
|
||||
// #endif
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/jlgh/index',
|
||||
// })
|
||||
uni.navigateTo({
|
||||
url: '/pages/jlgh/index',
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message,
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
// Generated by vite-plugin-uni-pages
|
||||
|
||||
interface NavigateToOptions {
|
||||
url: "/pages/jlgh/coupon" |
|
||||
"/pages/jlgh/redeem";
|
||||
url: "/pages/jlgh/index";
|
||||
}
|
||||
interface RedirectToOptions extends NavigateToOptions {}
|
||||
|
||||
|
|
|
@ -77,13 +77,6 @@ export default ({ command, mode }) => {
|
|||
// 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
|
||||
restart: ['vite.config.js'],
|
||||
}),
|
||||
// UNI_PLATFORM === 'h5' &&
|
||||
// mode === 'production' &&
|
||||
// vitePluginRemoveDir({
|
||||
// source: `dist/build/h5/static/images`,
|
||||
// target: `${outputDirName.split('-')[0]}`,
|
||||
// mode: 2,
|
||||
// }),
|
||||
UNI_PLATFORM === 'h5' &&
|
||||
mode === 'production' &&
|
||||
viteCopyToNewFolderPlugin({
|
||||
|
|
|
@ -22,7 +22,7 @@ function viteCopyToNewFolderPlugin(options = {}) {
|
|||
* options下各个参数说明
|
||||
* soure 路径
|
||||
* target 目标文件夹
|
||||
* mode 1代表删除target文件夹 2代表删除target以外的所有文件夹 默认1
|
||||
* mode 1代表删除target文件夹 2代表删除target以外的所有文件夹(暂时还用不上) 默认1
|
||||
*/
|
||||
|
||||
function vitePluginRemoveDir(options = {}) {
|
||||
|
|
Loading…
Reference in New Issue