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