Commit b7eae932 authored by 郝聪敏's avatar 郝聪敏

优化

parent b8b162ca
...@@ -8,7 +8,7 @@ module.exports = { ...@@ -8,7 +8,7 @@ module.exports = {
register(params) { register(params) {
return http.post('/api/user/register', params, { 'content-type': 'application/json' }); return http.post('/api/user/register', params, { 'content-type': 'application/json' });
}, },
getUserInfo(params) { getMainInfo(params) {
return http.post('/api/user/main', params); return http.post('/api/user/main', params);
}, },
getAwardsInfo(params) { getAwardsInfo(params) {
......
...@@ -5,6 +5,7 @@ const env = 'test'; // 每次上线手动切换成 prod/test ...@@ -5,6 +5,7 @@ const env = 'test'; // 每次上线手动切换成 prod/test
let baseUrl = 'https://api-luckii.q-gp.com'; let baseUrl = 'https://api-luckii.q-gp.com';
if (env === 'test') { if (env === 'test') {
baseUrl = 'https://luckii-qa.liangkebang.net'; baseUrl = 'https://luckii-qa.liangkebang.net';
// baseUrl = 'https://luckiiapi.q-gp.com/yapi/mock/325';
} }
const request = async (url, options) => { const request = async (url, options) => {
const pages = getCurrentPages(); const pages = getCurrentPages();
......
...@@ -74,11 +74,11 @@ ...@@ -74,11 +74,11 @@
current="0" current="0"
bindanimationfinish="bindanimationfinish" bindanimationfinish="bindanimationfinish"
> >
<swiper-item class="{{item.photoUrl ? 'image-item' : 'video-item'}}" v-for="(item, idx) in curQueue" :key="item.id"> <swiper-item :class="{'image-item': item.showType && item.showType.value === 1}" v-for="(item, idx) in curQueue" :key="item.id">
<view class="video-wrapper"> <view class="video-wrapper">
<video <video
id="video_{{idx}}" id="video_{{idx}}"
class="video_item" class="video-item"
loop loop
show-center-play-btn="{{false}}" show-center-play-btn="{{false}}"
enable-progress-gesture="{{false}}" enable-progress-gesture="{{false}}"
...@@ -90,12 +90,12 @@ ...@@ -90,12 +90,12 @@
binderror="onError" binderror="onError"
bindtimeupdate="onTimeUpdate" bindtimeupdate="onTimeUpdate"
@tap="videoTap" @tap="videoTap"
v-if="!item.photoUrl" v-if="item.showType && item.showType.value === 2"
> >
<video-loading v-if="item.time === 0" :snapshot="item.snapshot"/> <video-loading v-if="item.time === 0" :snapshot="item.videoSnapUrl"/>
<video-pause :pause="pause"></video-pause> <video-pause :pause="pause"></video-pause>
</video> </video>
<image v-if="item.photoUrl" class="images" :src="item.photoUrl" mode="widthFix"></image> <image v-if="item.showType && item.showType.value === 1" class="images" :src="item.photoUrl" mode="widthFix"></image>
<view class="rightcont"> <view class="rightcont">
<view class="info">奖品库存: {{item.stock}}/{{item.totalStock}}</view> <view class="info">奖品库存: {{item.stock}}/{{item.totalStock}}</view>
<view class="info">中奖概率: {{item.probability}}</view> <view class="info">中奖概率: {{item.probability}}</view>
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
videoList () { videoList () {
const newVal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; const newVal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
this._videoListChanged(newVal); this._videoListChanged(newVal);
// this.compute(this.userAccount); this.compute(this.userAccount);
}, },
userAccount(newVal) { userAccount(newVal) {
this.compute(newVal); this.compute(newVal);
...@@ -154,6 +154,7 @@ ...@@ -154,6 +154,7 @@
async getProgress(id) { async getProgress(id) {
let detail = await getAwardsDetail({ prizeId: id }); let detail = await getAwardsDetail({ prizeId: id });
detail = detail || {}; detail = detail || {};
if (detail.join > detail.quantity) detail.join = detail.quantity;
const progress = Math.round((detail.join / detail.quantity) * 100) + '%'; const progress = Math.round((detail.join / detail.quantity) * 100) + '%';
this.curQueue.forEach(v => { this.curQueue.forEach(v => {
...@@ -179,6 +180,7 @@ ...@@ -179,6 +180,7 @@
const current = e.$wx.detail.current; const current = e.$wx.detail.current;
this.pause = false; this.pause = false;
this.playCurrent(current); this.playCurrent(current);
this.trigger(e, 'change');
}, },
onError(e) { onError(e) {
this.trigger(e, 'error'); this.trigger(e, 'error');
...@@ -211,7 +213,6 @@ ...@@ -211,7 +213,6 @@
this.$emit('getAwardsInfo', { this.$emit('getAwardsInfo', {
id, id,
photoUrl, photoUrl,
quantity: this.userAccount,
name, name,
chance: probability chance: probability
}); });
...@@ -229,7 +230,11 @@ ...@@ -229,7 +230,11 @@
this.pause ? ctx.play() : ctx.pause(); this.pause ? ctx.play() : ctx.pause();
} }
}); });
this.pause = !this.pause; this.curQueue.forEach((item, index) => {
if (index === current && item.time !== 0) {
this.pause = !this.pause;
}
});
} }
} }
}); });
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
</template> </template>
<script> <script>
import wepy from '@wepy/core'; import wepy from '@wepy/core';
import store from '../../store';
import { mapState } from '@wepy/x';
const images = { const images = {
sign: { sign: {
notComplete: '/static/images/sign@2x.png', notComplete: '/static/images/sign@2x.png',
...@@ -56,6 +58,7 @@ ...@@ -56,6 +58,7 @@
lottery: '/static/images/lottery@2x.png' lottery: '/static/images/lottery@2x.png'
}; };
wepy.component({ wepy.component({
store,
data: { data: {
showAnimation: false, showAnimation: false,
addGold: false, addGold: false,
...@@ -98,6 +101,7 @@ ...@@ -98,6 +101,7 @@
} }
}, },
computed: { computed: {
...mapState(['safeAreaStyle']),
goldUrl() { goldUrl() {
let result = images['gold'].goldOne; let result = images['gold'].goldOne;
if (this.des === 2) { if (this.des === 2) {
...@@ -115,6 +119,9 @@ ...@@ -115,6 +119,9 @@
}, },
addGoldUrl: function() { addGoldUrl: function() {
return images['gold'].addGoldUrl; return images['gold'].addGoldUrl;
},
containerStyle() {
return 'position:relative; ' + this.safeAreaStyle;
} }
}, },
watch: { watch: {
...@@ -169,10 +176,6 @@ ...@@ -169,10 +176,6 @@
} }
} }
}, },
created() {
let statusHeight = this.$app.$options.globalData.statusBarHeight || '';
statusHeight && (this.containerStyle = 'position:relative; top:' + statusHeight + 'px');
}
}); });
</script> </script>
<style lang="less"> <style lang="less">
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
#myvideo{ .prize{
width: 100%; width: 100%;
height: 100%; height: 100%;
position: absolute; position: absolute;
...@@ -49,43 +49,123 @@ ...@@ -49,43 +49,123 @@
opacity: 0; opacity: 0;
} }
} }
.authmodal{ .content{
width:100%; position: absolute;
height:100%; z-index: 9;
background-color: rgba(0,0,0,0.7); bottom: 400rpx;
position: fixed; width: 100%;
z-index:20; color: @whitecolor;
.wrap { clear: both;
width: 90%; &.anima {
margin:0 auto; animation:fadeout 2s;
position: relative;
top:200px;
padding: 50rpx 0;
background-color: @whiteback;
border-radius: 20rpx;
.text {
color:#333;
text-align: center;
padding-top:30rpx;
padding-bottom: 60rpx;
}
button {
width:80%;
}
} }
&.hide {
display: none;
}
}
.leftcont {
width: 44%;
float: left;
font-size: @font-normal;
margin-left: 30rpx;
}
.list-wrapper {
height: 120rpx;
}
.leftcont .img {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
vertical-align: middle;
}
.leftcont .text {
max-width: 200rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-left: 10rpx;
vertical-align: middle;
border-radius: 20rpx;
display: inline-block;
font-size: @font-small;
box-sizing: border-box;
padding:6rpx 15rpx;
background-color:rgba(238, 238, 238, 0.2);
}
.footer {
position: absolute;
z-index: 9;
bottom: 20rpx;
width: 100%;
}
.footswiper {
height: 360rpx;
}
.list-item{
width:220rpx;
/*height: 330rpx;*/
background-color:@whiteback;
border-radius: 10rpx;
transform: scale(0.7,0.7) translateY(65rpx);
transition: all 0.5s;
padding:10rpx 10rpx 5rpx 10rpx;
margin:0 auto;
margin-top: 2rpx;
position: relative;
}
.list-item image {
width: 210rpx;
display: block;
height: 210rpx;
margin:0 auto;
border-radius: 10rpx;
}
.list-item .text {
font-size: @font-small;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2; //行数
-webkit-box-orient: vertical;
overflow: hidden;
line-height:24rpx;
margin-top:10rpx;
}
.list-item .price{
color:@maincolor;
font-size:@font-common;
margin-top:2rpx;
}
.list-item .buy{
font-size: 16rpx;
color:@darkgrey;
}
.list-item.subright {
transform: scale(0.85,0.85) translateY(26rpx) translateX(25rpx);
}
.list-item.subleft {
transform: scale(0.85,0.85) translateY(26rpx) translateX(-25rpx);
}
.list-item.select{
transform: scale(1,1);
bottom: 2rpx;
}
.list-item.delete {
opacity:0;
transform:translateY(-220rpx)
} }
</style> </style>
<template> <template>
<view class="video-wrapper"> <view class="video-wrapper">
<view id="myvideo"> <view class="prize">
<prize-list v-if="videoList && videoList.length" :videoList.sync="videoList" :userAccount="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :total="total" bindchange="changeVideo" @getAwardsInfo="getAwardsInfo"> <prize-list :videoList="videoList" :userAccount="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :total="total" bindchange="changeVideo" @getAwardsInfo="getAwardsInfo">
</prize-list> </prize-list>
</view> </view>
<view class="userInfo" style="{{userImgStyle}}"> <view class="userInfo" style="{{safeAreaStyle}}">
<button v-if="authmodal" open-type="getUserInfo" bindgetuserinfo="getUserInfo" class="userinfo-button"> <button v-if="authmodal" open-type="getUserInfo" bindgetuserinfo="getUserInfo" class="userinfo-button">
<image class="userinfo-image" src="{{userInfo.avatarUrl || '/static/images/user@2x.png'}}"></image> <image class="userinfo-image" :src="userInfo.avatarUrl"></image>
</button> </button>
<image v-if="!authmodal" @tap="showMenu(!showMenus)" src="{{userInfo.avatarUrl || '/static/images/user@2x.png'}}" mode="cover" class="userimage"></image> <image v-if="!authmodal" @tap="showMenu(!showModal)" :src="userInfo.avatarUrl" mode="cover" class="userimage"></image>
</view> </view>
<view> <view>
<gold type="gold" :des="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :gold="sign" :isReceive="isReceive"></gold> <gold type="gold" :des="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :gold="sign" :isReceive="isReceive"></gold>
...@@ -94,14 +174,12 @@ ...@@ -94,14 +174,12 @@
<share type="share" des="分享"></share> <share type="share" des="分享"></share>
</view> </view>
<activity-list :activityList="activityList"></activity-list> <activity-list :activityList="activityList"></activity-list>
<network v-if="isConnected === false"></network> <network v-if="isConnected === false"/>
<open-animation v-if="showAwardsModal" :joinRecord="mainInfo && mainInfo.joinRecord"></open-animation> <open-animation v-if="showModal === 2" :joinRecord="mainInfo && mainInfo.joinRecord"/>
<shared-popup v-if="showShareModal" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"></shared-popup> <shared-popup v-if="showModal === 1" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"/>
<popup @showMenu="showMenu" :showMenus="showMenus"></popup> <popup @showMenu="showMenu" :showMenus="showModal === 3"/>
<!--推荐商品列表-->
<!--<goods-list :goodsList="goodsList"></goods-list>-->
<van-dialog id="van-dialog"/> <van-dialog id="van-dialog"/>
<van-notify id="van-notify" /> <van-notify id="van-notify"/>
</view> </view>
</template> </template>
...@@ -111,7 +189,7 @@ ...@@ -111,7 +189,7 @@
import wepy from '@wepy/core'; import wepy from '@wepy/core';
import Notify from '../components/vant/notify/notify'; import Notify from '../components/vant/notify/notify';
import Dialog from '../components/vant/dialog/dialog'; import Dialog from '../components/vant/dialog/dialog';
import { login, register, getUserInfo, addGold, getPrizeList, signIn, getActivityFeed } from '../common/api.js'; import { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed } from '../common/api.js';
wepy.page({ wepy.page({
store, store,
data: { data: {
...@@ -120,23 +198,19 @@ ...@@ -120,23 +198,19 @@
activityList: [], activityList: [],
authmodal: false, authmodal: false,
sign: true, sign: true,
userImgStyle: '',
awards: false,
showMenus: false,
inviter: '', inviter: '',
mainInfo: null, mainInfo: null,
showShareModal: false, showModal: 0, // 1: 展示领取金币弹窗 2: 展示抽奖弹窗 3: 头像菜单弹窗
showAwardsModal: false,
awardsInfo: {}, awardsInfo: {},
isReceive: false isReceive: false
}, },
computed: { computed: {
...mapState([ 'isConnected', 'userInfo' ]) ...mapState([ 'isConnected', 'userInfo', 'safeAreaStyle' ])
}, },
methods: { methods: {
...mapActions([ 'setIsConnected', 'setUserInfo' ]), ...mapActions([ 'setIsConnected', 'setUserInfo', 'setSafeAreaStyle' ]),
async getUserInfo (e, isFromLottery) { async getUserInfo (e, isFromLottery) {
if (e.$wx.detail.userInfo) { if (e.$wx.detail.userInfo) {
this.setUserInfo(e.$wx.detail.userInfo); this.setUserInfo(e.$wx.detail.userInfo);
...@@ -231,7 +305,7 @@ ...@@ -231,7 +305,7 @@
}; };
}, },
getAwards: function() { getAwards: function() {
const { id, photoUrl, quantity, name, chance } = this.awardsInfo; const { id, photoUrl, name, chance } = this.awardsInfo;
if (!id || !this.mainInfo || !this.mainInfo.account) { if (!id || !this.mainInfo || !this.mainInfo.account) {
Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop: true }); Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop: true });
return; return;
...@@ -241,17 +315,17 @@ ...@@ -241,17 +315,17 @@
return; return;
} }
wx.navigateTo({ wx.navigateTo({
url: `/pages/raffle?prizeId=${id}&chance=${chance}&photoUrl=${photoUrl}&quantity=${quantity}&name=${name}` url: `/pages/raffle?prizeId=${id}&chance=${chance}&photoUrl=${photoUrl}&quantity=${this.mainInfo.account.quantity}&name=${name}`
}); });
}, },
getAwardsInfo: function(v) { getAwardsInfo: function(v) {
this.awardsInfo = v; this.awardsInfo = v;
}, },
showMenu: function(v) { showMenu: function(v) {
this.showMenus = v; this.showModal = v ? 3 : 0;
}, },
getSharedGold: async function(v) { getSharedGold: async function(v) {
this.showShareModal = false; this.showModal = 0;
await addGold(v); await addGold(v);
let account = this.mainInfo.account || {}; let account = this.mainInfo.account || {};
let quantity = account.quantity || 0; let quantity = account.quantity || 0;
...@@ -259,13 +333,13 @@ ...@@ -259,13 +333,13 @@
this.isReceive = true; this.isReceive = true;
setTimeout(() => { setTimeout(() => {
if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) { if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) {
this.showAwardsModal = true; this.showModal = 2;
} }
}, 1000); }, 1000);
}, },
getMainInfo: async function() { getMainInfo: async function() {
this.mainInfo = await getUserInfo(wx.getStorageSync('openId')); this.mainInfo = await getMainInfo();
this.sign = this.mainInfo && this.mainInfo.signin; this.sign = (this.mainInfo && this.mainInfo.signin) || true;
wx.setStorageSync('hasPhone', this.mainInfo.phone); wx.setStorageSync('hasPhone', this.mainInfo.phone);
if (this.mainInfo && this.mainInfo.innerActivity) { if (this.mainInfo && this.mainInfo.innerActivity) {
wx.setStorageSync('innerActivity', this.mainInfo.innerActivity); wx.setStorageSync('innerActivity', this.mainInfo.innerActivity);
...@@ -273,9 +347,9 @@ ...@@ -273,9 +347,9 @@
wx.setStorageSync('innerActivity', ''); wx.setStorageSync('innerActivity', '');
} }
if (this.mainInfo.inviteRecord && this.mainInfo.inviteRecord.length) { if (this.mainInfo.inviteRecord && this.mainInfo.inviteRecord.length) {
this.showShareModal = true; this.showModal = 1;
} else if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) { } else if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) {
this.showAwardsModal = true; this.showModal = 2;
} }
}, },
async registUser(userInfo) { async registUser(userInfo) {
...@@ -292,25 +366,31 @@ ...@@ -292,25 +366,31 @@
// 1期方案先一次取50 // 1期方案先一次取50
const list = await getActivityFeed({ count: 50 }); const list = await getActivityFeed({ count: 50 });
this.activityList = list; this.activityList = list;
},
async getOpenId() {
const { code } = await wepy.wx.login();
let loginInfo = await login(code);
loginInfo = loginInfo || {};
wx.setStorageSync('openId', loginInfo.openid);
wx.setStorageSync('isRegister', loginInfo.register);
} }
}, },
async onLoad (options) { async onLoad (options) {
// 获取分享人openid
if (options.openid) { if (options.openid) {
this.inviter = options.openid; this.inviter = options.openid;
} }
// 获取头像安全距离
let statusHeight = this.$app.$options.globalData.statusBarHeight || ''; let statusHeight = this.$app.$options.globalData.statusBarHeight || '';
statusHeight && (this.userImgStyle = 'top:' + statusHeight + 'px'); this.setSafeAreaStyle('top:' + statusHeight + 'px');
if (!wx.getStorageSync('openId')) { // 获取openid
const { code } = await wepy.wx.login(); await this.getOpenId();
let userInfo = await login(code);
userInfo = userInfo || {}; // 获取用户信息并注册
wx.setStorageSync('openId', userInfo.openid); if (this.userInfo.nickName) {
wx.setStorageSync('isRegister', userInfo.register);
}
if (store.state.userInfo) {
this.userInfo = store.state.userInfo;
this.registUser(this.userInfo); this.registUser(this.userInfo);
} else { } else {
const setting = await wepy.wx.getSetting(); const setting = await wepy.wx.getSetting();
...@@ -322,9 +402,13 @@ ...@@ -322,9 +402,13 @@
this.authmodal = true; this.authmodal = true;
} }
} }
// 获取主页信息
this.getMainInfo(); this.getMainInfo();
this.videoList = await getPrizeList(); // 获取活动信息
this.showActivity(); this.showActivity();
// 获取奖品列表
this.videoList = await getPrizeList();
}, },
async onShow() { async onShow() {
} }
......
...@@ -2,8 +2,11 @@ import Vuex from '@wepy/x'; ...@@ -2,8 +2,11 @@ import Vuex from '@wepy/x';
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
userInfo: '', userInfo: {
isConnected: true avatarUrl: '/static/images/user@2x.png'
},
isConnected: true,
safeAreaStyle: ''
}, },
mutations: { mutations: {
setInfo (state, info) { setInfo (state, info) {
...@@ -11,6 +14,9 @@ export default new Vuex.Store({ ...@@ -11,6 +14,9 @@ export default new Vuex.Store({
}, },
setIsConnected (state, isConnected) { setIsConnected (state, isConnected) {
state.isConnected = isConnected; state.isConnected = isConnected;
},
setSafeAreaStyle (state, safeAreaStyle) {
state.safeAreaStyle = safeAreaStyle;
} }
}, },
actions: { actions: {
...@@ -20,6 +26,9 @@ export default new Vuex.Store({ ...@@ -20,6 +26,9 @@ export default new Vuex.Store({
setIsConnected ({ commit }) { setIsConnected ({ commit }) {
const isConnected = wx.getStorageSync('onNetworkStatusChange'); const isConnected = wx.getStorageSync('onNetworkStatusChange');
commit('setIsConnected', isConnected); commit('setIsConnected', isConnected);
},
setSafeAreaStyle ({ commit }, safeAreaStyle) {
commit('setSafeAreaStyle', safeAreaStyle);
} }
} }
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment