Commit 1e47e363 authored by 付清曌's avatar 付清曌

Merge branch 'feature/goods' into 'master'

Feature/goods

See merge request !58
parents 3c3f216e fc194110
{"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/app.wpy":{"size":1382,"mtime":1591613433299,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/app.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/api.js":{"size":1635,"mtime":1592215601788,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/api.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/eventHub.js":{"size":85,"mtime":1589422331949,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/eventHub.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/raffleProbability.js":{"size":665,"mtime":1592213686500,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/raffleProbability.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/wxRequest.js":{"size":2283,"mtime":1591932403845,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/wxRequest.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/china.js":{"size":98459,"mtime":1591238093273,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/china.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/loading.wpy":{"size":1200,"mtime":1591932403848,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/loading.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/network.wpy":{"size":1449,"mtime":1591613433302,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/network.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/openAnimation.wpy":{"size":17057,"mtime":1591613433303,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/openAnimation.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/popup.wpy":{"size":4345,"mtime":1592215601790,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/popup.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/sharedPopup.wpy":{"size":7858,"mtime":1591613433305,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/sharedPopup.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/sign.wpy":{"size":11701,"mtime":1592215601790,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/sign.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/starAnimation.wpy":{"size":3928,"mtime":1590659119391,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/starAnimation.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/videoPause.wpy":{"size":898,"mtime":1589889870499,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/videoPause.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/help.wpy":{"size":3088,"mtime":1591786781412,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/help.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/morehelp.wpy":{"size":253,"mtime":1590498072492,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/morehelp.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/myraffles.wpy":{"size":3149,"mtime":1591776725635,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/myraffles.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/prize.wpy":{"size":7686,"mtime":1592218750771,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/prize.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/raffle.wpy":{"size":12698,"mtime":1592216321629,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/raffle.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/store/index.js":{"size":816,"mtime":1591777292874,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/store/index.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/prizeList.wpy":{"size":7838,"mtime":1592216321628,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/prizeList.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/activityList.wpy":{"size":2430,"mtime":1592215601789,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/activityList.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/goodsList.wpy":{"size":10585,"mtime":1592215630500,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/goodsList.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/index.wpy":{"size":16109,"mtime":1592216321629,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/index.wpy","messages":[],"errorCount":0,"warningCount":0}}} {"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/app.wpy":{"size":1489,"mtime":1593414427222,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/app.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/api.js":{"size":1883,"mtime":1592808132670,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/api.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/eventHub.js":{"size":85,"mtime":1589422331949,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/eventHub.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/raffleProbability.js":{"size":1732,"mtime":1593414427224,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/raffleProbability.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/wxRequest.js":{"size":2437,"mtime":1593414749561,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/common/wxRequest.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/china.js":{"size":98459,"mtime":1591238093273,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/china.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/loading.wpy":{"size":1200,"mtime":1592561147880,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/loading.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/network.wpy":{"size":1449,"mtime":1591613433302,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/network.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/openAnimation.wpy":{"size":17057,"mtime":1591613433303,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/openAnimation.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/popup.wpy":{"size":4787,"mtime":1593414427232,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/popup.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/sharedPopup.wpy":{"size":8245,"mtime":1593414427234,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/sharedPopup.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/sign.wpy":{"size":11721,"mtime":1593414427235,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/sign.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/starAnimation.wpy":{"size":3927,"mtime":1592296708688,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/starAnimation.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/videoPause.wpy":{"size":898,"mtime":1589889870499,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/videoPause.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/help.wpy":{"size":3088,"mtime":1591786781412,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/help.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/morehelp.wpy":{"size":253,"mtime":1590498072492,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/morehelp.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/myraffles.wpy":{"size":3149,"mtime":1591776725635,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/myraffles.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/prize.wpy":{"size":7710,"mtime":1592983633308,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/prize.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/raffle.wpy":{"size":12912,"mtime":1593414427238,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/raffle.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/store/index.js":{"size":816,"mtime":1591777292874,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/store/index.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/activityList.wpy":{"size":2520,"mtime":1593414427226,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/activityList.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/index.wpy":{"size":19050,"mtime":1593414427236,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/index.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/goloading.wpy":{"size":1050,"mtime":1593414427227,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/goloading.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/agreement.wpy":{"size":210,"mtime":1592903977922,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/agreement.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/search.wpy":{"size":5487,"mtime":1593414427239,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/pages/search.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/goodsList.wpy":{"size":9202,"mtime":1593414506553,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/goodsList.wpy","messages":[],"errorCount":0,"warningCount":0}},"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/video.wpy":{"size":12052,"mtime":1593414554361,"hashOfConfig":"qbd0oj","results":{"filePath":"/Users/fukiyoshi/work/quantgroup/mini-program-wepy/src/components/custom/video.wpy","messages":[],"errorCount":0,"warningCount":0}}}
\ No newline at end of file \ No newline at end of file
...@@ -15,6 +15,7 @@ import promisify from '@wepy/use-promisify'; ...@@ -15,6 +15,7 @@ import promisify from '@wepy/use-promisify';
wepy.use(promisify); wepy.use(promisify);
wepy.use(vuex); wepy.use(vuex);
import { checkUpdateVersion } from './common/raffleProbability';
wepy.app({ wepy.app({
hooks: { hooks: {
...@@ -24,8 +25,9 @@ wepy.app({ ...@@ -24,8 +25,9 @@ wepy.app({
globalData: { globalData: {
statusBarHeight: '' statusBarHeight: ''
}, },
async onLaunch() { onLaunch() {
let that = this; let that = this;
checkUpdateVersion();
wx.getSystemInfo({ wx.getSystemInfo({
success: function (res) { success: function (res) {
that.$options.globalData.statusBarHeight = res.statusBarHeight; that.$options.globalData.statusBarHeight = res.statusBarHeight;
...@@ -50,7 +52,8 @@ wepy.app({ ...@@ -50,7 +52,8 @@ wepy.app({
'pages/prize', 'pages/prize',
'pages/myraffles', 'pages/myraffles',
'pages/help', 'pages/help',
'pages/morehelp', 'pages/search',
'pages/agreement'
], ],
window: { window: {
backgroundTextStyle: 'light', backgroundTextStyle: 'light',
......
...@@ -53,5 +53,14 @@ module.exports = { ...@@ -53,5 +53,14 @@ module.exports = {
}, },
checkCornCode(params) { checkCornCode(params) {
return http.post('/api/user/addCoins', params); return http.post('/api/user/addCoins', params);
},
getGoodsList(params) {
return http.post(`/api/goods/list/${params}`);
},
getSearchList(params) {
return http.post('/api/goods/query', params);
},
getGoodsUrl(params) {
return http.post('/api/goods/promotionUrl', params);
} }
}; };
...@@ -13,20 +13,10 @@ function computClass (current,index,length,circular) { ...@@ -13,20 +13,10 @@ function computClass (current,index,length,circular) {
function getClass (status) { function getClass (status) {
var cls=['','green','grey','','red','red']; var cls=['','green','grey','','red','red'];
var index = status.value || 0; var index = status.value || 0;
console.log(status)
return cls[index] return cls[index]
}; };
function showVideo(item,current,index) {
if(item.showType && item.showType.value ==2) {
if(current === index) {
return true
} else {
return false;
}
}
}
module.exports = { module.exports = {
computClass:computClass, computClass:computClass,
getClass:getClass, getClass:getClass,
showVideo:showVideo
} }
...@@ -21,6 +21,40 @@ function getProbability (quantity, coinQuantity) { ...@@ -21,6 +21,40 @@ function getProbability (quantity, coinQuantity) {
return value + '/' + value2; return value + '/' + value2;
} }
} }
function checkUpdateVersion() {
// 创建 UpdateManager 实例
const updateManager = wx.getUpdateManager();
// 检测版本更新
updateManager.onCheckForUpdate(function(res) {
console.log(res, '版本更新');
// 请求完新版本信息的回调
if (res.hasUpdate) {
// 监听小程序有版本更新事件
updateManager.onUpdateReady(function() {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(function() {
// 新版本下载失败
wx.showModal({
title: '已经有新版本咯~',
content: '请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开呦~'
});
});
}
});
}
module.exports = { module.exports = {
getProbability getProbability,
checkUpdateVersion
}; };
...@@ -8,8 +8,14 @@ if (env === 'test') { ...@@ -8,8 +8,14 @@ if (env === 'test') {
// baseUrl = 'https://luckiiapi.q-gp.com/yapi/mock/325'; // 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() || [];
const safeAreaInsetTop = pages && pages.length > 0 ? pages[pages.length - 1].route === 'pages/index' : false; let safeAreaInsetTop = false;
if (pages.length === 0) {
// 如果页面还没加载出来,只能说明现在刚进入首页
safeAreaInsetTop = true;
} else if (pages[pages.length - 1].route === 'pages/index') {
safeAreaInsetTop = true;
}
const defaultOptions = { const defaultOptions = {
method: 'post', method: 'post',
header: { 'content-type': 'application/x-www-form-urlencoded' } header: { 'content-type': 'application/x-www-form-urlencoded' }
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
</template> </template>
<script> <script>
import wepy from '@wepy/core'; import wepy from '@wepy/core';
wepy.component({ wepy.component({
props: { props: {
activityList: { activityList: {
...@@ -39,19 +38,22 @@ ...@@ -39,19 +38,22 @@
activityList(val) { activityList(val) {
let list = val || []; let list = val || [];
this.list = list; this.list = list;
if (list.length && list.length < 3) {
this.onActivityChange();
}
} }
}, },
methods: { methods: {
onActivityChange(e) { onActivityChange(e) {
const lastIndex = this.list.length - this.activityDisplayItems; const lastIndex = this.list.length - this.activityDisplayItems;
if (e.$wx.detail.current === lastIndex) { if (!e || e.$wx.detail.current === lastIndex) {
this.isAuto = false; this.isAuto = false;
// 当最后一个出来的时候等一秒再消失 // 当最后一个出来的时候等一秒再消失
setTimeout(() => { setTimeout(() => {
this.isActiveDone = 'anima'; this.isActiveDone = 'anima';
setTimeout(() => { setTimeout(() => {
this.isActiveDone = 'anima hide'; this.isActiveDone = 'hide';
}, 2000); }, 1500);
}, 2000); }, 2000);
} }
} }
......
<template>
<div class="loading-wrapper">
<van-popup show="{{show}}" close-on-click-overlay="{{false}}" overlay-style="{{overLayStyle}}" round>
<view class="loading" v-show="!overLayStyle">
<van-loading type="spinner">跳转中...</van-loading>
</view>
</van-popup>
</div>
</template>
<script>
import wepy from '@wepy/core';
wepy.component({
props: {
show: {
type: Boolean,
default: false
}
},
data: {
overLayStyle: 'background-color:transparent'
},
watch: {
show(val) {
if (val) {
this.overLayStyle = 'background-color:transparent';
setTimeout(() => {
this.overLayStyle = '';
}, 500);
}
}
},
created() {
},
methods: {
}
});
</script>
<style lang="less">
.loading{
padding:40rpx;
}
</style>
<config>
{
usingComponents: {
'van-popup':'~@/components/vant/popup/index',
'van-loading': '~@/components/vant/loading/index'
}
}
</config>
<wxs module="tools" src="../../common/common.wxs"></wxs> <wxs module="tools" src="../../common/common.wxs"></wxs>
<template> <template>
<view>
<view class="footer"> <view class="footer">
<swiper <swiper
class="footswiper" class="footswiper"
display-multiple-items="{{swiperItem}}" display-multiple-items="{{swiperItem}}"
duration="300"
current="{{current}}" current="{{current}}"
bindchange="moveSwiper" bindchange="moveSwiper"
circular="{{circular}}" circular="{{circular}}"
previous-margin="140rpx" previous-margin="140rpx"
next-margin="120rpx" next-margin="120rpx"
catch:touchmove catch:touchmove
bindanimationfinish="swipermoveDone"
> >
<!--bindtouchstart="touchStart" <!--bindtouchstart="touchStart"
bindtouchend="touchEnd"--> bindtouchend="touchEnd"-->
<!-- {{item.select?'delete':''}} -->
<swiper-item wx:for="{{list}}" wx:key="index"> <swiper-item wx:for="{{list}}" wx:key="index">
<view <view
data-itemid="{{index}}" data-itemid="{{index}}"
bindtap="toViewPage" bindtap="toViewPage"
data-item="{{item}}" data-item="{{item}}"
class="list-item {{item.select?'delete':''}} {{tools.computClass(currentIndex,index,list.length,circular)}}" class="list-item {{tools.computClass(currentIndex,index,list.length,circular)}}"
bindtouchstart="touchStart"
bindtouchend="touchEnd"
> >
<image src="{{item.imgsrc}}" class="img"></image> <van-image use-loading-slot src="{{item.images}}" class="img" width="220rpx" height="210rpx" radius="10rpx" fit="cover">
<view class="text">{{item.text}}</view> <van-loading slot="loading" type="spinner" size="20" vertical />
<p class="price">{{item.price}}</p> </van-image>
<p class="buy">{{item.people}}人购买</p> <!--<image src="{{item.images}}" class="img"></image>-->
<view class="title">{{item.title}}</view>
<p class="price">¥{{item.price}}</p>
<p class="buy">{{item.saleCount}}人购买</p>
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
<go-loading show="{{showLoading}}"></go-loading>
</view>
</template> </template>
<script> <script>
import wepy from '@wepy/core'; import wepy from '@wepy/core';
import { getGoodsList, getGoodsUrl } from '../../common/api';
let touchDotX = 0; let touchDotX = 0;
let touchDotY = 0; let touchDotY = 0;
let page = 0;
wepy.component({ wepy.component({
props: {
goodsList: {
type: Array,
default: []
}
},
data: { data: {
swiperItem: 2, swiperItem: 2,
current: 1, current: 1,
currentIndex: 1, // 商品当前滑动到第几个 currentIndex: 1, // 商品当前滑动到第几个
circular: false, // 商品是否无限循环 circular: false, // 商品是否无限循环
topPage: 0, list: [],
lastPage: 0, showLoading: false,
list: [] isListDone: false
}, },
watch: { attached() {
goodsList(val) { this.getList();
/* let list = val || [];
this.list = list; */
}
},
created() {
// 获取推荐的商品列表
this.list = [{value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: '100004549235'},
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: '100004549235'},
{value: 13, text: '白色条纹马克杯,马克吐温同款13', imgsrc: '/static/images/peo1.jpg', price: '¥39.08', people: 2200, sku: '100004549235'},
{value: 14, text: '白色条纹马克杯,马克吐温同款14', imgsrc: '/static/images/peo2.jpg', price: '¥599.20', people: 2200, sku: '100004549235'},
{value: 15, text: '白色条纹马克杯,马克吐温同款15', imgsrc: '/static/images/peo3.jpg', price: '¥2399.01', people: 2200, sku: '100004549235'}, {value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: '100004549235'},
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: '100004549235'}
];
}, },
methods: { methods: {
moveSwiper(e) { moveSwiper(e) {
...@@ -89,50 +79,49 @@ ...@@ -89,50 +79,49 @@
if (e.$wx.detail.source === 'touch') { if (e.$wx.detail.source === 'touch') {
let current = e.$wx.detail.current; let current = e.$wx.detail.current;
let totalPage = 0;
let nextlist = [
{value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: '100004549235'},
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: '100004549235'},
{value: 13, text: '白色条纹马克杯,马克吐温同款13', imgsrc: '/static/images/peo1.jpg', price: '¥39.08', people: 2200, sku: '100004549235'},
{value: 14, text: '白色条纹马克杯,马克吐温同款14', imgsrc: '/static/images/peo2.jpg', price: '¥599.20', people: 2200, sku: '100004549235'},
{value: 15, text: '白色条纹马克杯,马克吐温同款15', imgsrc: '/static/images/peo3.jpg', price: '¥2399.01', people: 2200, sku: '100004549235'}
];
let that = this; let that = this;
/* if(current <= 2) {
debounce(setTimeout(function(){
that.topPage +=1;
if(that.lastPage+that.topPage >= totalPage) {
that.circular = true;
return;
}
that.list = [...newlist, ...that.list];
// that.current = current+1;
// that.currentIndex = current+1;
},1000),500);
} */
if (current >= this.list.length - 3) { if (current >= this.list.length - 3) {
debounce(setTimeout(function() { debounce(setTimeout(function() {
that.lastPage += 1; that.getList();
if (that.lastPage + that.topPage >= totalPage) { // 当新得到的list长度不足20个时,表明商品全部得到,开启无限循环
/* if(nextlist.length < goodsNum) {
that.circular = true; that.circular = true;
} }
that.list = [...that.list, ...nextlist]; that.list = [...that.list, ...nextlist]; */
}, 1000), 500); }, 1000), 500);
} }
} }
}, },
getList() {
if (this.isListDone) return;
page++;
getGoodsList(page).then(data => {
// 没有更多了
if (!data.hasMore) {
// 如果小于4个商品,一行就能显示,不用循环
this.list.length > 4 && (this.circular = true);
this.isListDone = true;
}
this.list = [...this.list, ...data.items];
});
},
toViewPage(e) { toViewPage(e) {
let item = e.$wx.currentTarget.dataset.item; let item = e.$wx.currentTarget.dataset.item;
if (this.showLoading) return;
this.showLoading = true;
getGoodsUrl({skuId: item.sourceId, couponUrl: item.couponUrl || null}).then(data => {
wx.navigateToMiniProgram({ wx.navigateToMiniProgram({
appId: 'wx91d27dbf599dff74', appId: 'wx91d27dbf599dff74',
path: 'pages/item/detail/detail?sku=' + item.sku, // 跳转小程序的路径 path: 'pages/union/proxy/proxy?spreadUrl=' + encodeURIComponent(data), // 跳转小程序的路径
// 有效值 develop(开发版),trial(体验版),release(正式版) // 有效值 develop(开发版),trial(体验版),release(正式版)
envVersion: 'release', envVersion: 'release',
success(res) { success(res) {
// console.log('跳转成功');
} }
}); });
this.showLoading = false;
}).catch(() => {
this.showLoading = false;
});
}, },
touchStart (event) { touchStart (event) {
touchDotX = event.touches[0].pageX; // 获取触摸时的原点 touchDotX = event.touches[0].pageX; // 获取触摸时的原点
...@@ -199,7 +188,6 @@ ...@@ -199,7 +188,6 @@
if (list.length <= 4) { if (list.length <= 4) {
this.circular = false; this.circular = false;
} }
console.log(current.itemid, this.currentIndex, this.current, 111);
if (current.itemid >= list.length - 1) { if (current.itemid >= list.length - 1) {
this.current = this.currentIndex - 1; this.current = this.currentIndex - 1;
} }
...@@ -214,7 +202,6 @@ ...@@ -214,7 +202,6 @@
that.current = Math.max(that.current - 1, 0); that.current = Math.max(that.current - 1, 0);
} }
// 删除完成之后 // 删除完成之后
console.log(current.itemid, that.currentIndex, that.current, 222);
}, 500); }, 500);
} }
} }
...@@ -245,13 +232,13 @@ ...@@ -245,13 +232,13 @@
position: relative; position: relative;
} }
.list-item .img { .list-item .img {
width: 210rpx; width: 220rpx;
display: block; display: block;
height: 210rpx; height: 210rpx;
margin:0 auto; margin:0 auto;
border-radius: 10rpx; border-radius: 10rpx;
} }
.list-item .text { .list-item .title {
font-size: @font-small; font-size: @font-small;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
...@@ -259,6 +246,7 @@ ...@@ -259,6 +246,7 @@
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
overflow: hidden; overflow: hidden;
line-height:24rpx; line-height:24rpx;
word-break:break-all;
margin-top:10rpx; margin-top:10rpx;
} }
.list-item .price{ .list-item .price{
...@@ -286,5 +274,11 @@ ...@@ -286,5 +274,11 @@
} }
</style> </style>
<config> <config>
{} {
"usingComponents": {
"go-loading": "~@/components/custom/goloading",
"van-image": "~@/components/vant/image/index",
"van-loading": "~@/components/vant/loading/index",
}
}
</config> </config>
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</div> </div>
<div class="popup-item"> <div class="popup-item">
<button class="help-button" open-type="contact"></button> <button class="help-button" open-type="contact"></button>
<image class="image" src="/static/images/feedback@2x.png"></image> <image class="image" src="/static/images/feedback.png"></image>
<span class="desc">问题反馈</span> <span class="desc">问题反馈</span>
</div> </div>
</div> </div>
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
data: { data: {
menus: [ menus: [
{ img: '/static/images/awards@2x.png', title: '我的抽奖', path: '/pages/myraffles' }, { img: '/static/images/awards@2x.png', title: '我的抽奖', path: '/pages/myraffles' },
{ img: '/static/images/order.png', title: '我的订单', path: 'jd' },
{ img: '/static/images/help@2x.png', title: '规则与帮助', path: '/pages/help' } { img: '/static/images/help@2x.png', title: '规则与帮助', path: '/pages/help' }
], ],
show: false, show: false,
...@@ -54,6 +55,17 @@ ...@@ -54,6 +55,17 @@
}, },
goNextPage: function(path) { goNextPage: function(path) {
this.$emit('showMenu', false); this.$emit('showMenu', false);
if (path === 'jd') {
wx.navigateToMiniProgram({
appId: 'wx91d27dbf599dff74',
path: 'pages/order/list/list',
// 有效值 develop(开发版),trial(体验版),release(正式版)
envVersion: 'release',
success(res) {
}
});
return;
}
wx.navigateTo({ wx.navigateTo({
url: path url: path
}); });
...@@ -72,13 +84,13 @@ ...@@ -72,13 +84,13 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
background: rgba(0, 0, 0, 0.7); background: rgba(0, 0, 0, 0.7);
z-index: 9; z-index: 10;
// animation: menuEnter .3s linear forwards; // animation: menuEnter .3s linear forwards;
.popup-wrapper { .popup-wrapper {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
width: 350rpx; width: 430rpx;
height: 114rpx; height: 114rpx;
position: absolute; position: absolute;
left: 20rpx; left: 20rpx;
......
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
<div class="content"> <div class="content">
<div class="des">恭喜您!</div> <div class="des">恭喜您!</div>
<image class="image" src="/static/images/gold@2x.png"></image> <image class="image" src="/static/images/gold@2x.png"></image>
<div class="info">通过邀请以下好友,您获得{{goldNum}}克币</div> <div class="info" v-if="showFriends">通过邀请以下好友,您获得{{goldNum}}克币</div>
<div class="user" :class="{'one-user': inviteinfo.length === 1 }"> <div class="info padding" v-if="!showFriends">购买成功,获得{{goldNum}}克币</div>
<div class="user" :class="{'one-user': inviteinfo.length === 1 }" v-if="showFriends">
<image class="user-img" v-for="item in users" :src="item.avatarUrl"></image> <image class="user-img" v-for="item in users" :src="item.avatarUrl"></image>
<span class="user-rest" v-if="inviteinfo.length > 3">...</span> <span class="user-rest" v-if="inviteinfo.length > 3">...</span>
</div> </div>
...@@ -39,7 +40,8 @@ ...@@ -39,7 +40,8 @@
props: { props: {
inviteinfo: { inviteinfo: {
type: Array type: Array
} },
type: String
}, },
computed: { computed: {
goldNum() { goldNum() {
...@@ -56,7 +58,16 @@ ...@@ -56,7 +58,16 @@
p.push(n.accountItemId); p.push(n.accountItemId);
return p; return p;
}, []); }, []);
},
showFriends() {
if (this.type === 'buy') {
return false;
} else {
return true;
} }
}
},
created() {
}, },
methods: { methods: {
getGold: function() { getGold: function() {
...@@ -230,6 +241,9 @@ ...@@ -230,6 +241,9 @@
text-overflow: ellipsis; text-overflow: ellipsis;
font-size: @font-middle; font-size: @font-middle;
text-align: center; text-align: center;
&.padding {
padding-bottom:25rpx;
}
} }
.user { .user {
height: 84rpx; height: 84rpx;
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
lotteryUrl: '/static/images/lottery@2x.png', lotteryUrl: '/static/images/lottery@2x.png',
containerStyle: '', containerStyle: '',
flyAnimation: false, flyAnimation: false,
isFirst:true, isFirst: true
}, },
props: { props: {
title: '', title: '',
......
<style lang="less">
@import "../../style/common";
.container,.video-swiper{
width:100%;
height:100%;
}
.video-item {
height:100%;
width:100%;
position: absolute;
background-color: #000;
z-index: 1;
}
.image-item{
height:100%;
width:100%;
position: absolute;
z-index: 1;
display: flex;
align-items: center;
}
.video-wrapper {
width: 100%;
}
.rightcont {
font-size: @font-normal;
position: absolute;
z-index: 9;
bottom: 415rpx;
width:30%;
right: 30rpx;
color: @whitecolor;
will-change: transform;
.info {
line-height: 40rpx;
}
}
.progress {
width: 180rpx;
height: 20rpx;
background-color: @whiteback;
margin-top: 10rpx;
color: @greycolor;
position: relative;
.text {
position: absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index: 2;
text-align: center;
line-height:20rpx;
background-color: transparent;
font-size: 18rpx;
}
.orange {
width: 0;
height:100%;
transition:all .6s;
background-color: @maincolor;
}
}
.images {
width: 100%;
}
</style>
<wxs module="video" src="../../common/common.wxs"></wxs>
<template> <template>
<view class="container"> <view class="container">
<swiper <swiper
class="video-swiper" class="video-swiper"
duration= "400" duration="600"
circular="{{true}}" circular="{{circular}}"
vertical vertical
current="0" current="1"
bindanimationfinish="bindanimationfinish"
bindchange="moveSwiper" bindchange="moveSwiper"
> bindanimationfinish="animationfinish">
<swiper-item :class="{'image-item': item.showType && item.showType.value === 1}" v-for="(item, idx) in curQueue" :key="item.id"> <swiper-item wx:for="{{curQueue}}" wx:key="index">
<view class="video-wrapper"> <view class="video-swiper">
<video <video
id="video_{{idx}}"
class="video-item" class="video-item"
id="video_{{index}}"
loop loop
show-center-play-btn="{{false}}"
enable-progress-gesture="{{false}}" enable-progress-gesture="{{false}}"
show-center-play-btn="{{false}}"
controls="{{false}}" controls="{{false}}"
src="{{video.showVideo(item,currentIndex,idx)?item.videoUrl:null}}" src="{{currentIndex == index ?item.videoUrl :null}}"
data-id="{{item.id}}" data-id="{{item.id}}"
data-index="{{idx}}" object-fit="contain"
binderror="onError" data-index="{{index}}"
bindtimeupdate="onTimeUpdate"
@tap="videoTap" @tap="videoTap"
custom-cache="{{false}}" custom-cache="{{false}}"
object-fit="contain"
wx:if="{{item.showType && item.showType.value ==2}}" wx:if="{{item.showType && item.showType.value ==2}}"
bindplay="loadMedia"
bindloadedmetadata="loadMedia"
> >
<video-loading v-if="item.time === 0" :snapshot="item.videoSnapUrl"/> <video-pause :pause="videoPause"></video-pause>
<video-pause :pause="pause"></video-pause> <van-loading type="spinner" size="40" v-if="videoLoading" custom-class="video-loading"/>
<!--<video-loading v-if="videoLoading" :snapshot="item.videoSnapUrl"/>-->
</video> </video>
<image wx:if="{{item.showType && item.showType.value ==1}}" lazy-load class="images" :src="item.photoUrl" mode="widthFix" bindload="imageLoad(item.id)"> <van-image wx:if="{{item.showType && item.showType.value ==1}}" use-loading-slot src="{{item.photoUrl || item.videoSnapUrl}}" class="images" radius="10rpx" fit="contain" width="100%" height="100%">
<image-loading v-if="item.time === 0"/> <van-loading slot="loading" type="spinner" size="20" vertical/>
</image> </van-image>
<view class="rightcont" v-show="item.id > 0"> <view class="rightcont" v-show="item.id > 0">
<view class="info">奖品库存: {{item.stock}}/{{item.totalStock}}</view> <view class="info">奖品剩余: {{item.stock}}</view>
<view class="info">中奖概率: {{item.probability}}</view> <view class="info">中奖概率: {{item.probability}}</view>
<view class="progress"> <view class="progress">
<view class="text">{{item.progress}}</view> <view class="text">{{item.progress}}</view>
...@@ -114,13 +45,13 @@ ...@@ -114,13 +45,13 @@
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>
<van-popup show="{{showPopup}}" close-on-click-overlay="{{false}}" overlay-style="background-color:transparent"></van-popup>
</view> </view>
</template> </template>
<script> <script>
import wepy from '@wepy/core'; import wepy from '@wepy/core';
import { getProbability } from '../../common/raffleProbability'; import { getProbability } from '../../common/raffleProbability';
import { getAwardsDetail } from '../../common/api.js'; import { getAwardsDetail, getPrizeList } from '../../common/api.js';
let _videoContexts = [], videoCurrent = 0;
wepy.component({ wepy.component({
props: { props: {
videoList: { videoList: {
...@@ -132,23 +63,38 @@ ...@@ -132,23 +63,38 @@
value: 0 value: 0
} }
}, },
options: {
styleIsolation: 'shared'
},
data: { data: {
pause: false, nextQueue: [],
prevQueue: [],
curQueue: [], curQueue: [],
currentIndex:0, circular: false,
_last: 1,
_invalidUp: 0,
_invalidDown: 0,
_videoContexts: [],
currentIndex: 1,
videoPause: false,
showPopup: false,
videoLoading: true
}, },
watch: { watch: {
videoList () { videoList (list) {
const newVal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; const newVal = list || [];
this._videoListChanged(newVal); this._videoListChanged(newVal);
this.compute(this.userAccount);
}, },
userAccount(newVal) { userAccount(newVal) {
this.compute(newVal); this.compute(newVal);
} }
}, },
created() { attached() {
this.compute(this.userAccount); this._videoContexts = [
wx.createVideoContext('video_0', this.$wx),
wx.createVideoContext('video_1', this.$wx),
wx.createVideoContext('video_2', this.$wx)
];
}, },
methods: { methods: {
compute (newVal) { compute (newVal) {
...@@ -156,130 +102,273 @@ ...@@ -156,130 +102,273 @@
this.curQueue.forEach(v => { this.curQueue.forEach(v => {
v.probability = getProbability(+newVal, +v.coinQuantity); v.probability = getProbability(+newVal, +v.coinQuantity);
}); });
this.curQueue = [...this.curQueue]; this.nextQueue.forEach(v => {
this.updateAwardsInfo(videoCurrent); v.probability = getProbability(+newVal, +v.coinQuantity);
},
moveSwiper(e) {
if (e.$wx.detail.source === 'touch') {
let current = e.$wx.detail.current;
this.currentIndex = current;
}
},
async getProgress(id) {
if (id <= 0) return;
let detail = await getAwardsDetail({ prizeId: id });
detail = detail || {};
if (detail.join > detail.quantity) detail.join = detail.quantity;
const progressFloat = detail.join / detail.quantity * 100;
let progress = Math.round(progressFloat) + '%';
if (progressFloat > 0 && progressFloat < 1) progress = '1%';
this.curQueue.forEach(v => {
if (v.id === id) {
v.progress = progress;
v.batchId = detail.id;
v.progressStyle = 'width:' + progress;
}
}); });
this.prevQueue.forEach(v => {
v.probability = getProbability(+newVal, +v.coinQuantity);
});
this.prevQueue = [...this.prevQueue];
this.curQueue = [...this.curQueue]; this.curQueue = [...this.curQueue];
this.nextQueue = [...this.nextQueue];
this.updateAwardsInfo(this.currentIndex);
}, },
_videoListChanged (newVal) { _videoListChanged (newVal) {
this.curQueue = newVal.map((item, index) => { const _this = this;
_videoContexts.push(item.videoUrl ? wx.createVideoContext(`video_${index}`, this.$wx) : null); if (this.curQueue.length === 0) {
item.time = 0; // 因为列表默认展示1的位置,而后端逻辑会把要展示的放在0的位置,所以交换位置,展示出来
return item; // 同时展示的元素只有三个,curQueue中始终只有三个元素,用来解决吧video过多时,资源加载问题
// 当前的资源加载解决方案是参考小程序的video-swiper源码
newVal.forEach(function (item, index) {
if (index === 1) {
_this.curQueue[0] = item;
} else if (index === 0) {
_this.curQueue[1] = item;
} else if (index === 2) {
_this.curQueue[2] = item;
} else {
_this.nextQueue.push(item);
}
});
this.playCurrent(1);
} else {
// 新进入的数组要去重,新进入的数组去重是需求的逻辑
const curIds = this.curQueue.map(item => item.id);
const nextIds = _this.nextQueue.map(item => item.id);
const allIds = [...curIds, ...nextIds];
const theList = newVal.filter(item => (allIds.indexOf(item.id) === -1));
theList.forEach(function (item) {
_this.nextQueue.push(item);
}); });
}
this.compute(this.userAccount); this.compute(this.userAccount);
},
moveSwiper(e) {
this.videoPause = false;
this.videoLoading = true;
if (e.$wx.detail.source === 'touch') {
// 增加一个透明遮罩层,控制用户滑动速度,500ms内只能滑动一次,解决用户滑动过快,不触发animationfinish的bug
this.showPopup = true;
setTimeout(() => { setTimeout(() => {
this.playCurrent(0); this.showPopup = false;
}, 300); }, 500);
const current = e.$wx.detail.current;
this.currentIndex = current;
// 如果next中如果就剩下4个了,请求下一页
if (this.nextQueue.length === 4) {
getPrizeList().then(data => {
this._videoListChanged(data);
});
}
}
}, },
async bindanimationfinish(e) { animationfinish (e) {
let _last = this._last;
let curQueue = this.curQueue;
let prevQueue = this.prevQueue;
let nextQueue = this.nextQueue;
// 一共三个数组,curQueue是要显示的数组,prevQueue放上滑过去的元素,nextQueue放即将进入的元素
// 一次最多只展示3个video标签,提高加载视频的速度
const current = e.$wx.detail.current; const current = e.$wx.detail.current;
videoCurrent = current; const diff = current - _last;
this.pause = false; if (diff === 0) return;
this._last = current;
this.playCurrent(current); this.playCurrent(current);
this.trigger(e, 'change'); // 如果上滑的时候,当前滑动到第0元素,那么被划走,放入prevQueue是第一个元素,这个要自己画图才会更理解
}, const upChange = [1, 2, 0];
onError(e) { const downChange = [2, 0, 1];
this.trigger(e, 'error'); this.$emit('change', { activeId: curQueue[current].id });
}, const direction = (diff === 1 || diff === -2) ? 'up' : 'down';
onTimeUpdate(e) { if (direction === 'up') {
const currentTime = e.$wx.detail.currentTime; if (this._invalidDown === 0) {
if (currentTime > 0 && currentTime < 10) { const uchange = upChange[current];
const id = e.target.dataset.id; const add = nextQueue.shift();
this.curQueue.forEach((v, i) => { const remove = curQueue[uchange];
if (v.id === id && v.time === 0) { if (add) {
this.curQueue[i].time = currentTime; prevQueue.push(remove);
curQueue[uchange] = add;
} else {
this._invalidUp += 1;
} }
}); } else {
this.curQueue = [...this.curQueue]; this._invalidDown -= 1;
} }
}
if (direction === 'down') {
if (this._invalidUp === 0) {
const dchange = downChange[current];
const _remove = curQueue[dchange];
const _add = prevQueue.pop();
if (_add) {
curQueue[dchange] = _add;
nextQueue.unshift(_remove);
} else {
this._invalidDown += 1;
}
} else {
this._invalidUp -= 1;
}
}
// 当滑动到头时,circular改成false
let circular = true;
if (nextQueue.length === 0 && current !== 0) {
circular = false;
}
if (prevQueue.length === 0 && current !== 2) {
circular = false;
}
this.curQueue = [...curQueue];
this.circular = circular;
}, },
updateAwardsInfo(current) { playCurrent (current) {
const { id, photoUrl, name, probability } = this.curQueue[current]; this.curQueue[current] && this.getProgress(this.curQueue[current].id);
this.$emit('getAwardsInfo', { // 滑动到当前元素时,其他video都暂停,只播放当前video
id, this._videoContexts.forEach(function (ctx, index) {
photoUrl: encodeURIComponent(photoUrl), if (ctx) {
name,
chance: probability
});
},
playCurrent(current) {
if (!this.curQueue || this.curQueue.length <= 1) return;
// 播放当前视频
_videoContexts.forEach((ctx, index) => {
if (index !== current) { if (index !== current) {
ctx && ctx.pause(); ctx.pause();
} else { } else {
//将视频重置到最开始的位置并播放 ctx.play();
// ctx && ctx.seek(0); }
ctx && ctx.play();
} }
}); });
// 更新抽奖页面参数
this.updateAwardsInfo(current); this.updateAwardsInfo(current);
// 更新奖品进度
this.getProgress(this.curQueue[current].id);
},
trigger(e, type) {
var ext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var detail = e.$wx.detail;
var activeId = e.target.dataset.id;
this.$emit(type, Object.assign(Object.assign(Object.assign({}, detail), { activeId: activeId }), ext));
}, },
videoTap(e) { videoTap(e) {
const current = e.currentTarget.dataset.index; const current = e.currentTarget.dataset.index;
_videoContexts.forEach((ctx, index) => { const ctx = this._videoContexts[current];
if (index === current) { if (this.videoPause) {
this.pause ? ctx.play() : ctx.pause(); ctx.play();
this.videoPause = false;
} else {
ctx.pause();
this.videoPause = true;
} }
},
updateAwardsInfo(current) {
if (this.curQueue[current]) {
const { id, photoUrl, name, probability } = this.curQueue[current];
this.$emit('getAwardsInfo', {
id,
photoUrl: encodeURIComponent(photoUrl),
name,
chance: probability
}); });
this.curQueue.forEach((item, index) => {
if (index === current && item.time !== 0) {
this.pause = !this.pause;
} }
});
}, },
imageLoad(id) { async getProgress(id) {
this.curQueue.forEach(item => { if (id <= 0) return;
if (item.id === id) { let detail = await getAwardsDetail({ prizeId: id });
item.time = 1; detail = detail || {};
if (detail.join > detail.quantity) detail.join = detail.quantity;
const progressFloat = detail.join / detail.quantity * 100;
let progress = Math.round(progressFloat) + '%';
if (progressFloat > 0 && progressFloat < 1) progress = '1%';
this.curQueue.forEach(v => {
if (v.id === id) {
v.progress = progress;
v.batchId = detail.id;
v.progressStyle = 'width:' + progress;
} }
}); });
this.curQueue = [...this.curQueue]; this.curQueue = [...this.curQueue];
},
loadMedia() {
// 如果只是视频数据加载完触发,则当再滑到这个视频的视频loading还在,如果只是paly的时候触发,初始化的时候会有问题
this.videoLoading = false;
} }
} }
}); });
</script> </script>
<config> <config>
{ {
usingComponents: { usingComponents: {
'video-pause': '~@/components/custom/videoPause', 'video-pause': '~@/components/custom/videoPause',
'video-loading': '~@/components/custom/loading', 'video-loading': '~@/components/custom/loading',
'image-loading': '~@/components/custom/loading', "van-loading": "~@/components/vant/loading/index",
"van-image": "~@/components/vant/image/index" "van-image": "~@/components/vant/image/index",
"image-loading":"~@/components/custom/loading",
'van-popup':'~@/components/vant/popup/index',
},
} }
}
</config> </config>
<style lang="less">
@import "../../style/common";
.container,.video-swiper{
width:100%;
height:100%;
}
.video-item {
height:100%;
width:100%;
position: absolute;
background-color: #000;
z-index: 1;
}
.video-loading {
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
margin:0 auto;
}
.image-item{
height:100%;
width:100%;
position: absolute;
z-index: 1;
display: flex;
align-items: center;
}
.rightcont {
font-size: @font-normal;
position: absolute;
z-index: 9;
bottom: 415rpx;
width:30%;
right: 30rpx;
color: @whitecolor;
will-change: transform;
.info {
line-height: 40rpx;
}
}
.progress {
width: 180rpx;
height: 20rpx;
background-color: @whiteback;
margin-top: 10rpx;
color: @greycolor;
position: relative;
.text {
position: absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index: 2;
text-align: center;
line-height:20rpx;
background-color: transparent;
font-size: 18rpx;
}
.orange {
width: 0;
height:100%;
transition:all .6s;
background-color: @maincolor;
}
}
.images {
width: 100%;
.van-image__loading {
background-color: rgba(0,0,0,0.7);
}
}
.container .van-overlay {
background-color: transparent;
}
</style>
<template>
<web-view src="https://luckii.q-gp.com/agreement.html"></web-view>
</template>
<script>
import wepy from '@wepy/core';
wepy.page({
data: {
}
});
</script>
<config>
{
}
</config>
...@@ -41,6 +41,19 @@ ...@@ -41,6 +41,19 @@
height: 80rpx; height: 80rpx;
border-radius: 50%; border-radius: 50%;
} }
.search{
position: fixed;
z-index: 10;
top:100rpx;
left: 310rpx;
font-size: @font-large;
color: @whitecolor;
.searchimg {
width: 34rpx;
height: 34rpx;
vertical-align: middle;
}
}
@-webkit-keyframes fadeout { @-webkit-keyframes fadeout {
0% { 0% {
opacity:1 ; opacity:1 ;
...@@ -157,35 +170,45 @@ ...@@ -157,35 +170,45 @@
margin-top:10rpx; margin-top:10rpx;
} }
} }
.img-wrapper{
padding:30rpx;
}
</style> </style>
<template> <template>
<view class="video-wrapper"> <view class="video-wrapper">
<view class="prize"> <view class="prize">
<prize-list :videoList="videoList" :userAccount="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" bindchange="changeVideo" @getAwardsInfo="getAwardsInfo"> <!--<prize-list :videoList="videoList" :userAccount="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" bindchange="changeVideo" @getAwardsInfo="getAwardsInfo">
</prize-list> </prize-list>-->
<video-list :videoList="videoList" :userAccount="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" bindchange="changeVideo" @getAwardsInfo="getAwardsInfo"></video-list>
</view> </view>
<view class="userInfo" style="{{safeAreaStyle}}"> <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"></image> <image class="userinfo-image" :src="userInfo.avatarUrl"></image>
</button> </button>
<image v-if="!authmodal" @tap="showMenu(!showModal)" :src="userInfo.avatarUrl" mode="cover" class="userimage"></image> <image v-if="!authmodal" @tap="showMenu(!showModal)" :src="userInfo.avatarUrl" mode="cover" class="userimage"></image>
</view> </view>
<view class="search" style="{{ searchStyle }}" bindtap="toSearch">
<image src="/static/images/search.png" class="searchimg"></image>
搜索
</view>
<view> <view>
<gold type="gold" :des="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :gold="sign" :isReceive="isReceive" @resetAddGold="resetAddGold" @showCorn="cornModalShow"></gold> <gold type="gold" :des="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :gold="sign" :isReceive="isReceive" @resetAddGold="resetAddGold" @showCorn="cornModalShow"></gold>
<sign type="sign" des="签到" :sign="sign" @sign-in="signIn"></sign> <sign type="sign" des="签到" :sign="sign" @sign-in="signIn"></sign>
<lottery type="lottery" des="抽奖" @getAwards="getAwards" @getUserInfo="getUserInfo" :authmodal="authmodal"></lottery> <lottery type="lottery" des="抽奖" @getAwards="getAwards" @getUserInfo="getUserInfo" :authmodal="authmodal"></lottery>
<share type="share" des="分享"></share> <share type="share" des="分享" v-if="awardsInfo.id == undefined || awardsInfo.id >0"></share>
</view> </view>
<activity-list :activityList="activityList"></activity-list> <activity-list :activityList="activityList"></activity-list>
<network v-if="isConnected === false"/> <network v-if="isConnected === false"/>
<open-animation v-if="showModal === 2" :joinRecord="mainInfo && mainInfo.joinRecord"/> <open-animation v-if="showModal === 2" :joinRecord="mainInfo && mainInfo.joinRecord"/>
<shared-popup v-if="showModal === 1" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"/> <shared-popup v-if="showModal === 1" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"/>
<shared-popup v-if="showModal === 4" :inviteinfo="mainInfo && mainInfo.buyRecord" type="buy" @getSharedGold="getSharedGold"/>
<popup @showMenu="showMenu" :showMenus="showModal === 3"/> <popup @showMenu="showMenu" :showMenus="showModal === 3"/>
<!--商品推荐列表--> <!--商品推荐列表-->
<!--<goods-list></goods-list>--> <goods-list></goods-list>
<van-dialog id="van-dialog"/> <van-dialog id="van-dialog"/>
<van-notify id="van-notify"/> <van-notify id="van-notify"/>
<van-popup show="{{ cornModal }}" bind:close="cornModalClose" custom-style="background-color:transparent"> <!--克币充值弹窗-->
<van-popup show="{{ cornModal }}" bind:close="ModalClose" custom-style="background-color:transparent">
<view class="corn-cont"> <view class="corn-cont">
<image src="/static/images/cornback.png" class="imgs"></image> <image src="/static/images/cornback.png" class="imgs"></image>
<view class="corn-title">请输入充值码</view> <view class="corn-title">请输入充值码</view>
...@@ -195,6 +218,14 @@ ...@@ -195,6 +218,14 @@
<button class="corn-button" bindtap="checkCode">确定</button> <button class="corn-button" bindtap="checkCode">确定</button>
</view> </view>
</van-popup> </van-popup>
<!--活动图片弹窗-->
<van-popup show="{{ avtivityModal }}" bind:close="ModalClose" round closeable>
<view class="img-wrapper">
<van-image use-loading-slot src="{{ mainInfo.activity && mainInfo.activity.linkUrl }}" width="400rpx" fit="widthFix" radius="10rpx">
<van-loading slot="loading" type="spinner" size="30" vertical />
</van-image>
</view>
</van-popup>
</view> </view>
</template> </template>
...@@ -206,7 +237,6 @@ ...@@ -206,7 +237,6 @@
import Dialog from '../components/vant/dialog/dialog'; import Dialog from '../components/vant/dialog/dialog';
import { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed, checkCornCode } from '../common/api.js'; import { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed, checkCornCode } from '../common/api.js';
let flag = false; let flag = false;
let awardsInfo = {};
wepy.page({ wepy.page({
store, store,
data: { data: {
...@@ -217,12 +247,15 @@ ...@@ -217,12 +247,15 @@
sign: true, sign: true,
inviter: '', inviter: '',
mainInfo: null, mainInfo: null,
showModal: 0, // 1: 展示领取金币弹窗 2: 展示抽奖弹窗 3: 头像菜单弹窗 showModal: 0, // 1: 邀请好友金币弹窗 2: 展示抽奖弹窗 3: 头像菜单弹窗 4: 购买获得金币弹窗
isReceive: false, // 是否显示领取克币动画 isReceive: false, // 是否显示领取克币动画
cornModal: false, cornModal: false,
cornCode: '', // 克币充值码 cornCode: '', // 克币充值码
cornText: '', cornText: '',
cornTextShow: false cornTextShow: true,
searchStyle: '',
avtivityModal: false, // 展示活动弹窗
awardsInfo: {}
}, },
computed: { computed: {
...@@ -315,8 +348,8 @@ ...@@ -315,8 +348,8 @@
const openid = wx.getStorageSync('openId'); const openid = wx.getStorageSync('openId');
return { return {
title: `${(this.$wepy.userInfo && this.$wepy.userInfo.nickName) || '您的好朋友'}邀请您来抽奖啦~`, title: `${(this.$wepy.userInfo && this.$wepy.userInfo.nickName) || '您的好朋友'}邀请您来抽奖啦~`,
path: `/pages/index?openid=${openid}&prizeId=${awardsInfo.id}`, path: `/pages/index?openid=${openid}&prizeId=${this.$wepy.awardsInfo.id}`,
imageUrl: decodeURIComponent(awardsInfo.photoUrl), imageUrl: decodeURIComponent(this.$wepy.awardsInfo.photoUrl),
success: function(res) { success: function(res) {
let shareId = res.shareTickets[0]; let shareId = res.shareTickets[0];
console.log('shareId', shareId); console.log('shareId', shareId);
...@@ -327,7 +360,7 @@ ...@@ -327,7 +360,7 @@
}; };
}, },
getAwards: function() { getAwards: function() {
const { id, photoUrl, name, chance } = awardsInfo; const { id, photoUrl, name, chance } = this.awardsInfo;
if ((!id && id !== 0) || !this.mainInfo || !this.mainInfo.account) { if ((!id && id !== 0) || !this.mainInfo || !this.mainInfo.account) {
Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop: true }); Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop: true });
return; return;
...@@ -346,12 +379,13 @@ ...@@ -346,12 +379,13 @@
}); });
}, },
getAwardsInfo: function(v) { getAwardsInfo: function(v) {
awardsInfo = v; this.awardsInfo = v;
}, },
showMenu: function(v) { showMenu: function(v) {
this.showModal = v ? 3 : 0; this.showModal = v ? 3 : 0;
}, },
getSharedGold: async function(v) { getSharedGold: async function(v) {
let modal = this.showModal;
this.showModal = 0; this.showModal = 0;
await addGold(v); await addGold(v);
this.showActivity(); this.showActivity();
...@@ -360,6 +394,10 @@ ...@@ -360,6 +394,10 @@
this.mainInfo.account.quantity = quantity + v.quantity; this.mainInfo.account.quantity = quantity + v.quantity;
this.isReceive = true; this.isReceive = true;
setTimeout(() => { setTimeout(() => {
if (this.mainInfo.buyRecord && this.mainInfo.buyRecord.length && modal !== 4) {
this.showModal = 4;
return;
}
if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) { if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) {
this.showModal = 2; this.showModal = 2;
} }
...@@ -369,14 +407,24 @@ ...@@ -369,14 +407,24 @@
this.mainInfo = await getMainInfo(); this.mainInfo = await getMainInfo();
this.sign = this.mainInfo && this.mainInfo.signin; this.sign = this.mainInfo && this.mainInfo.signin;
wx.setStorageSync('hasPhone', this.mainInfo.phone); wx.setStorageSync('hasPhone', this.mainInfo.phone);
const activityId = wx.getStorageSync('activityId');
if (this.mainInfo && this.mainInfo.innerActivity) { if (this.mainInfo && this.mainInfo.innerActivity) {
wx.setStorageSync('innerActivity', this.mainInfo.innerActivity); wx.setStorageSync('innerActivity', this.mainInfo.innerActivity);
} else { } else {
wx.setStorageSync('innerActivity', ''); wx.setStorageSync('innerActivity', '');
} }
if (this.mainInfo.inviteRecord && this.mainInfo.inviteRecord.length) { // 弹窗有多个,展示顺序 活动弹窗->邀请好友->购买获得克币->开奖宝箱
if (this.mainInfo.activity && this.mainInfo.activity.id && this.mainInfo.activity.id !== +activityId) {
// 活动弹窗
this.avtivityModal = true;
} else if (this.mainInfo.inviteRecord && this.mainInfo.inviteRecord.length) {
// 邀请好友
this.showModal = 1; this.showModal = 1;
} else if (this.mainInfo.buyRecord && this.mainInfo.buyRecord.length) {
// 购买获得金币
this.showModal = 4;
} else if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) { } else if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) {
// 开奖宝箱
this.showModal = 2; this.showModal = 2;
} }
}, },
...@@ -407,8 +455,19 @@ ...@@ -407,8 +455,19 @@
this.cornCode = ''; this.cornCode = '';
this.cornModal = true; this.cornModal = true;
}, },
cornModalClose() { ModalClose() {
this.cornModal = false; this.cornModal && (this.cornModal = false);
if (this.avtivityModal) {
wx.setStorageSync('activityId', this.mainInfo.activity.id);
this.avtivityModal = false;
if (this.mainInfo.inviteRecord && this.mainInfo.inviteRecord.length) {
this.showModal = 1;
} else if (this.mainInfo.buyRecord && this.mainInfo.buyRecord.length) {
this.showModal = 4;
} else if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) {
this.showModal = 2;
}
}
}, },
checkCode() { checkCode() {
if (this.cornCode === '') { if (this.cornCode === '') {
...@@ -432,6 +491,9 @@ ...@@ -432,6 +491,9 @@
}, },
resetAddGold() { resetAddGold() {
this.isReceive = false; this.isReceive = false;
},
toSearch() {
wx.navigateTo({url: '/pages/search'});
} }
}, },
async onLoad (options) { async onLoad (options) {
...@@ -444,9 +506,13 @@ ...@@ -444,9 +506,13 @@
// 获取头像安全距离 // 获取头像安全距离
let statusHeight = this.$app.$options.globalData.statusBarHeight || ''; let statusHeight = this.$app.$options.globalData.statusBarHeight || '';
this.setSafeAreaStyle('top:' + statusHeight + 'px'); this.setSafeAreaStyle('top:' + statusHeight + 'px');
this.searchStyle = 'top:' + (statusHeight + 12) + 'px';
// 获取openid // 获取openid
await this.getOpenId(); await this.getOpenId();
// 获取奖品列表
this.videoList = await getPrizeList(options.prizeId);
this.getMainInfo(); this.getMainInfo();
flag = true; flag = true;
...@@ -466,12 +532,10 @@ ...@@ -466,12 +532,10 @@
// 获取活动信息 // 获取活动信息
this.showActivity(); this.showActivity();
// 获取奖品列表
this.videoList = await getPrizeList(options.prizeId);
}, },
async onShow() { async onShow() {
// 获取主页信息 // 获取主页信息
if(flag) { if (flag) {
this.getMainInfo(); this.getMainInfo();
} }
...@@ -489,7 +553,6 @@ ...@@ -489,7 +553,6 @@
navigationBarTitleText: '主页', navigationBarTitleText: '主页',
usingComponents: { usingComponents: {
'van-button': '../components/vant/button/index', 'van-button': '../components/vant/button/index',
'prize-list': '~@/components/custom/prizeList',
'van-icon': '../components/vant/icon/index', 'van-icon': '../components/vant/icon/index',
'sign': '~@/components/custom/sign', 'sign': '~@/components/custom/sign',
'gold': '~@/components/custom/sign', 'gold': '~@/components/custom/sign',
...@@ -503,7 +566,10 @@ ...@@ -503,7 +566,10 @@
'van-dialog': '~@/components/vant/dialog/index', 'van-dialog': '~@/components/vant/dialog/index',
'goods-list': '../components/custom/goodsList', 'goods-list': '../components/custom/goodsList',
'activity-list': '../components/custom/activityList', 'activity-list': '../components/custom/activityList',
'van-popup':'../components/vant/popup/index' 'van-popup':'../components/vant/popup/index',
'video-list':'../components/custom/video',
"van-image": "../components/vant/image/index",
"van-loading": "../components/vant/loading/index",
}, },
navigationStyle: "custom", navigationStyle: "custom",
disableScroll: true disableScroll: true
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
<view class="prize-info">中奖概率: {{chance}}</view> <view class="prize-info">中奖概率: {{chance}}</view>
<view class="prize-info">中奖结果: <text class="red">已中奖</text></view> <view class="prize-info">中奖结果: <text class="red">已中奖</text></view>
</view> </view>
<view class="prize-address" v-show="!prize.cash"> <view class="prize-address" v-show="!prize.cash&&prize.cash!==undefined">
<view class="address-title">添加收货地址</view> <view class="address-title">添加收货地址</view>
<view class="address-cont"> <view class="address-cont">
<van-field value="{{name}}" data-form="name" placeholder="收货人" bind:input ="setValue"></van-field> <van-field value="{{name}}" data-form="name" placeholder="收货人" bind:input ="setValue"></van-field>
......
...@@ -92,6 +92,7 @@ ...@@ -92,6 +92,7 @@
border-radius: 4rpx; border-radius: 4rpx;
vertical-align: middle; vertical-align: middle;
position: relative; position: relative;
margin-right:10rpx;
&.checked{ &.checked{
background-color: @maincolor; background-color: @maincolor;
border:3rpx solid @maincolor; border:3rpx solid @maincolor;
...@@ -107,9 +108,11 @@ ...@@ -107,9 +108,11 @@
} }
} }
.checktext{ .checktext{
margin-left:10rpx;
position: relative; position: relative;
top:3rpx; top:3rpx;
&.red {
color:@maincolor
}
} }
} }
.joinin { .joinin {
...@@ -227,7 +230,9 @@ ...@@ -227,7 +230,9 @@
<view class="checkimg {{isCheck?'checked':''}}"> <view class="checkimg {{isCheck?'checked':''}}">
<van-icon name="success" color="#fff" size="24rpx" class="checkicon {{isCheck?'':'hide'}}"/> <van-icon name="success" color="#fff" size="24rpx" class="checkicon {{isCheck?'':'hide'}}"/>
</view> </view>
<text class="checktext">我同意花费所有克币参与抽奖,并承诺商品不退货。</text> <text class="checktext">阅读</text>
<text class="checktext red" catchtap="toAgreement">《隐私协议》</text>
<text class="checktext">并同意花费所有克币参与抽奖且商品不退货</text>
</view> </view>
<button class="joinin" open-type="{{opentype}}" bindtap="joinin" bindgetphonenumber="getPhoneNumber">{{btnfont}}</button> <button class="joinin" open-type="{{opentype}}" bindtap="joinin" bindgetphonenumber="getPhoneNumber">{{btnfont}}</button>
<van-notify id="van-notify" /> <van-notify id="van-notify" />
...@@ -253,7 +258,7 @@ ...@@ -253,7 +258,7 @@
import Dialog from '../components/vant/dialog/dialog'; import Dialog from '../components/vant/dialog/dialog';
import { updateUserPhone, confirmRaffle, register, login, getAwardsDetail, checkInnerCode } from '../common/api'; import { updateUserPhone, confirmRaffle, register, login, getAwardsDetail, checkInnerCode } from '../common/api';
import store from '../store'; import store from '../store';
let hasPhone = false, innerActivity= '', batchId = null; let innerActivity = '';
wepy.page({ wepy.page({
store, store,
data: { data: {
...@@ -269,7 +274,9 @@ ...@@ -269,7 +274,9 @@
isError: false, isError: false,
code: '', code: '',
errorText: '', errorText: '',
errorBtn: '确定' errorBtn: '确定',
hasPhone: false,
batchId: null
}, },
methods: { methods: {
check() { check() {
...@@ -284,7 +291,7 @@ ...@@ -284,7 +291,7 @@
updateUserPhone(detail).then(() => { updateUserPhone(detail).then(() => {
wx.setStorageSync('hasPhone', true); wx.setStorageSync('hasPhone', true);
that.btnfont = '立即参与'; that.btnfont = '立即参与';
hasPhone = true; that.hasPhone = true;
that.joinin(); that.joinin();
}).catch(() => { }).catch(() => {
that.btnfont = '立即参与'; that.btnfont = '立即参与';
...@@ -317,12 +324,12 @@ ...@@ -317,12 +324,12 @@
await register(store.state.userInfo); await register(store.state.userInfo);
wx.setStorageSync('isRegister', true); wx.setStorageSync('isRegister', true);
} }
if (!batchId) { if (!this.batchId) {
Notify({message: '数据加载中,请稍后重试!'}); Notify({message: '数据加载中,请稍后重试!'});
return; return;
} }
this.btnfont = '参与中...'; this.btnfont = '参与中...';
confirmRaffle({batchId: batchId}).then(data => { confirmRaffle({batchId: this.batchId}).then(data => {
this.btnfont = '立即参与'; this.btnfont = '立即参与';
let code = data.joinCode; let code = data.joinCode;
if (code === undefined) code = 3; if (code === undefined) code = 3;
...@@ -334,7 +341,7 @@ ...@@ -334,7 +341,7 @@
title: title[code], title: title[code],
message: message[code] message: message[code]
}).then(() => { }).then(() => {
wx.navigateBack({url: '/pages/index'}); wx.navigateBack({delta: 1});
}); });
}).catch(() => { }).catch(() => {
this.btnfont = '立即参与'; this.btnfont = '立即参与';
...@@ -345,7 +352,7 @@ ...@@ -345,7 +352,7 @@
Notify({message: '勾选同意后才可以抽奖!'}); Notify({message: '勾选同意后才可以抽奖!'});
return; return;
} }
if (hasPhone) { if (this.hasPhone) {
// 当有innerActivity并且没有邀请码(没有验证过)并且不是VIP的时候才显示modal // 当有innerActivity并且没有邀请码(没有验证过)并且不是VIP的时候才显示modal
if (innerActivity && !innerActivity.haveCode && !innerActivity.vip) { if (innerActivity && !innerActivity.haveCode && !innerActivity.vip) {
this.showModal(); this.showModal();
...@@ -357,7 +364,7 @@ ...@@ -357,7 +364,7 @@
async getProgress(id) { async getProgress(id) {
let detail = await getAwardsDetail({ prizeId: id }); let detail = await getAwardsDetail({ prizeId: id });
detail = detail || {}; detail = detail || {};
batchId = detail.id; this.batchId = detail.id;
if (detail.quantity) { if (detail.quantity) {
if (detail.join > detail.quantity) detail.join = detail.quantity; if (detail.join > detail.quantity) detail.join = detail.quantity;
const progressFloat = detail.join / detail.quantity * 100; const progressFloat = detail.join / detail.quantity * 100;
...@@ -378,6 +385,9 @@ ...@@ -378,6 +385,9 @@
this.isError = false; this.isError = false;
this.code = ''; this.code = '';
}, },
toAgreement() {
wx.navigateTo({url: '/pages/agreement'});
},
checkCode () { checkCode () {
if (this.code === '') { if (this.code === '') {
this.errorText = '请输入邀请码'; this.errorText = '请输入邀请码';
...@@ -406,7 +416,7 @@ ...@@ -406,7 +416,7 @@
}, },
computed: { computed: {
opentype() { opentype() {
if (this.isCheck && !hasPhone) { if (this.isCheck && !this.hasPhone) {
return 'getPhoneNumber'; return 'getPhoneNumber';
} else { } else {
return ''; return '';
...@@ -427,7 +437,7 @@ ...@@ -427,7 +437,7 @@
this.name = name; this.name = name;
this.chance = chance; this.chance = chance;
this.photoUrl = decodeURIComponent(photoUrl); this.photoUrl = decodeURIComponent(photoUrl);
hasPhone = wx.getStorageSync('hasPhone'); this.hasPhone = wx.getStorageSync('hasPhone');
innerActivity = wx.getStorageSync('innerActivity'); innerActivity = wx.getStorageSync('innerActivity');
} }
}); });
......
<template>
<view>
<view class="search-head">
<view class="search-wrapper">
<van-field clearable left-icon="search" placeholder="搜索" bind:confirm="search" value="{{value}}" bind:input ="setValue" auto-focus ></van-field>
</view>
<view class="search-cancel" bindtap="search">搜索</view>
</view>
<view class="search-list" v-show="list.length">
<view class="search-item" wx:for="{{list}}" wx:key="index" bindtap="toJingdong" data-item="{{item}}">
<view class="image-left">
<van-image use-loading-slot src="{{item.images}}" class="img" width="240rpx" height="240rpx" radius="10rpx" fit="cover">
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
</view>
<view class="cont-right">
<view class="cont-wrap">
<view class="cont-title">
{{item.title}}
</view>
<view class="cont-price"><text class="dollar">¥</text>{{item.price}}</view>
<view class="cont-count">{{item.shopName || '京东自营店'}}</view>
</view>
</view>
</view>
</view>
<view class="search-last" v-show="isLoading"><van-loading type="spinner" text-size="26rpx">加载中</van-loading></view>
<view class="search-last" v-show="isDone">没有更多了~</view>
<go-loading show="{{showLoading}}"></go-loading>
</view>
</template>
<script>
import wepy from '@wepy/core';
import { getSearchList, getGoodsUrl } from '../common/api';
let page = 1;
wepy.page({
data: {
list: [],
isDone: false,
isLoading: false,
showLoading: false,
value: ''
},
methods: {
setValue(event) {
this.value = event.$wx.detail || '';
},
search() {
page = 1;
this.list = [];
this.getList();
},
getList() {
this.isLoading = true;
this.isDone = false;
getSearchList({keyword: this.value, page: page}).then(data => {
this.isLoading = false;
if (!data.hasMore) {
this.isDone = true;
}
this.list = [...this.list, ...data.items];
}).catch(() => {
this.isLoading = false;
});
},
toJingdong(event) {
const item = event.$wx.currentTarget.dataset.item;
if (item === undefined) return;
if (this.showLoading) return;
this.showLoading = true;
getGoodsUrl({skuId: item.sourceId, couponUrl: item.couponUrl || null}).then(data => {
wx.navigateToMiniProgram({
appId: 'wx91d27dbf599dff74',
path: 'pages/union/proxy/proxy?spreadUrl=' + encodeURIComponent(data), // 跳转小程序的路径
// 有效值 develop(开发版),trial(体验版),release(正式版)
envVersion: 'release',
success(res) {
}
});
this.showLoading = false;
}).catch(() => {
this.showLoading = false;
});
}
},
onReachBottom() {
if (this.isDone) return;
page++;
this.getList();
}
});
</script>
<config>
{
navigationBarTitleText: '搜索',
"usingComponents": {
"van-field": "../components/vant/field/index",
"van-image": "../components/vant/image/index",
"van-loading": "../components/vant/loading/index",
"go-loading": "~@/components/custom/goloading",
}
}
</config>
<style lang="less">
@import "../style/common";
.search-head{
background-color: @whiteback;
padding:35rpx 30rpx;
position: relative;
.search-wrapper{
width:88%;
.van-cell {
border:1rpx solid @maincolor;
background-color: #f6f6f6;
border-radius: 35rpx;
padding:10rpx 25rpx;
font-size: 26rpx;
}
.van-cell::after{
border:none;
}
.van-field__input{
height:30rpx;
outline:none;
}
}
.search-cancel{
font-size: @font-middle;
width:90rpx;
height:60rpx;
position: absolute;
right:10rpx;
top:40rpx;
text-align: center;
line-height:60rpx;
}
}
.search-list {
background-color: @whiteback;
margin-top:20rpx;
padding-left:30rpx;
}
.search-item {
padding-top:30rpx;
overflow: hidden;
}
.image-left {
width: 240rpx;
float: left;
height: 240rpx;
.img{
width:100%;
height:100%;
}
}
.cont-right {
padding-left:260rpx;
.cont-wrap {
border-bottom:1rpx solid #E6E6E6;
min-height: 240rpx;
padding-bottom: 20rpx;
padding-right:30rpx;
position: relative;
}
.cont-title {
font-size: @font-middle;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2; //行数
-webkit-box-orient: vertical;
overflow: hidden;
word-break:break-all;
}
.cont-count {
position: absolute;
bottom:20rpx;
left:0;
font-size: @font-common;
color:@lightgrey;
}
.cont-price {
.dollar{
font-size: @font-common;
}
position: absolute;
bottom:55rpx;
left:0;
font-size:34rpx;
color:@maincolor;
}
}
.search-item:last-child {
.cont-wrap {
border-bottom: none;
}
}
.search-last {
text-align: center;
padding:30rpx 0;
font-size: @font-middle;
color:@greycolor;
}
</style>
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