Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mini-program-wepy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
mini-program-wepy
Commits
e3f0ec5d
Commit
e3f0ec5d
authored
May 28, 2020
by
郝聪敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增奖品相关接口;修改request函数
parent
59228abc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
63 deletions
+124
-63
wxRequest.js
src/common/wxRequest.js
+10
-4
popup.wpy
src/components/custom/popup.wpy
+2
-2
sign.wpy
src/components/custom/sign.wpy
+3
-1
videolist.wpy
src/components/custom/videolist.wpy
+88
-18
index.wpy
src/pages/index.wpy
+21
-38
No files found.
src/common/wxRequest.js
View file @
e3f0ec5d
...
...
@@ -4,15 +4,21 @@ import Notify from '../components/vant/notify/notify';
const
baseUrl
=
'
https://luckiiapi.q-gp.com/yapi/mock/325
'
;
const
request
=
async
(
url
,
options
)
=>
{
const
pages
=
getCurrentPages
();
const
safeAreaInsetTop
=
pages
&&
pages
.
length
>
0
?
pages
[
pages
.
length
-
1
].
route
===
'
pages/index
'
:
false
;
const
defaultOptions
=
{
method
:
'
post
'
,
header
:
{
'
content-type
'
:
'
applicction/x-www-form-urlencoded
'
}
};
options
=
{
...
defaultOptions
,
...
options
};
options
.
header
=
{
...
options
.
header
,
openid
:
wx
.
getStorageSync
(
'
openId
'
)
||
''
};
url
=
baseUrl
+
url
;
const
isConnected
=
wx
.
getStorageSync
(
'
onNetworkStatusChange
'
);
console
.
log
(
'
isConnected
'
,
isConnected
);
if
(
!
isConnected
)
{
wx
.
showToast
({
title
:
'
无网络
'
,
...
...
@@ -32,10 +38,10 @@ const request = async (url, options) => {
if
(
res
.
data
.
code
===
2000
)
{
return
res
.
data
.
data
;
}
Notify
({
message
:
res
.
data
.
detail
||
'
请求异常,请稍后重试
'
,
background
:
'
#FF5D15
'
,
safeAreaInsetTop
});
throw
new
Error
(
res
.
data
.
detail
||
'
请求异常,请稍后重试
'
);
}
Notify
({
message
:
res
.
data
.
detail
||
'
请求异常,请稍后重试
'
,
background
:
'
#FF5D15
'
,
safeAreaInsetTop
:
true
});
}).
catch
(
res
=>
{
Notify
({
message
:
'
请求失败,请稍后重试
'
,
background
:
'
#FF5D15
'
,
safeAreaInsetTop
:
true
});
Notify
({
message
:
'
请求异常,请稍后重试
'
,
background
:
'
#FF5D15
'
,
safeAreaInsetTop
});
});
};
...
...
src/components/custom/popup.wpy
View file @
e3f0ec5d
...
...
@@ -7,7 +7,7 @@
</div>
<div class="popup-item">
<button class="help-button" open-type="contact"></button>
<image class="image" src="/static/images/
help
@2x.png"></image>
<image class="image" src="/static/images/
feedback
@2x.png"></image>
<span class="desc">问题反馈</span>
</div>
</div>
...
...
@@ -26,7 +26,7 @@
data: {
menus: [
{ img: '/static/images/awards@2x.png', title: '我的抽奖', path: '/pages/myraffles' },
{ img: '/static/images/
feedback@2x.png', title: '规则与帮助', path: '/pages/help' },
{ img: '/static/images/
help@2x.png', title: '规则与帮助', path: '/pages/help' }
],
show: false,
popupStyle: ''
...
...
src/components/custom/sign.wpy
View file @
e3f0ec5d
...
...
@@ -131,6 +131,9 @@
}
},
gold(v) {
if (v) {
this.addCount = 0;
}
if (this.isFirst) {
this.isFirst = false;
return;
...
...
@@ -171,7 +174,6 @@
created() {
let statusHeight = this.$app.$options.globalData.statusBarHeight || '';
statusHeight && (this.containerStyle = 'position:relative; top:' + statusHeight + 'px');
console.log(this.type, this.$app.$options.globalData.statusBarHeight, this.containerStyle);
}
});
</script>
...
...
src/components/custom/videolist.wpy
View file @
e3f0ec5d
...
...
@@ -41,6 +41,7 @@
line-height: 20rpx;
}
.orange {
width: 0;
height:100%;
transition:all 1s;
background-color: #FF5D15;
...
...
@@ -84,10 +85,10 @@
</video> < !-->
<view class="rightcont">
<view class="info">奖品库存: 1/8</view>
<view class="info">中奖概率: {{
userAccount}}/3000
</view>
<view class="info">中奖概率: {{
item.probability}}
</view>
<view class="progress">
<view class="text">{{
progress}}%
</view>
<view class="orange" style="{{progressStyle}}"></view>
<view class="text">{{
item.progress}}
</view>
<view class="orange" style="{{
item.
progressStyle}}"></view>
</view>
</view>
<!-- <video-loading v-if="item.time === 0"/> -->
...
...
@@ -99,6 +100,8 @@
</template>
<script>
import wepy from '@wepy/core';
import { getProbability } from '../../common/raffleProbability';
import { getAwardsDetail } from '../../common/api.js';
wepy.component({
props: {
videoList: {
...
...
@@ -133,27 +136,94 @@
_invalidUp: 0,
_invalidDown: 0,
_videoContexts: [],
progress: 0,
progressStyle: '',
loading: false
},
watch: {
videoList () {
const newVal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
this.loading = false;
this.init();
if (newVal.length) this._videoListChanged(newVal);
this.compute(this.userAccount);
},
userAccount(newVal) {
this.compute(newVal);
}
},
attached() {
this.progress = 47;
this.progressStyle = 'width:' + this.progress + '%';
this._videoContexts = [
wx.createVideoContext('video_0', this.$wx),
wx.createVideoContext('video_1', this.$wx),
wx.createVideoContext('video_2', this.$wx)
];
},
created() {
this.compute(this.userAccount);
},
methods: {
compute (newVal) {
this.nextQueue.forEach(v => {
v.probability = getProbability(+newVal, +v.coinQuantity);
});
this.curQueue.forEach(v => {
v.probability = getProbability(+newVal, +v.coinQuantity);
});
this.prevQueue.forEach(v => {
v.probability = getProbability(+newVal, +v.coinQuantity);
});
this.curQueue = [...this.curQueue];
this.nextQueue = [...this.nextQueue];
this.prevQueue = [...this.prevQueue];
},
async getProgress(id) {
const detail = await getAwardsDetail();
const progress = Math.round((detail.join / detail.quantity) * 100) + '%';
this.nextQueue.forEach(v => {
if (v.id === id) {
if (v.id === id) {
v.progress = progress;
v.batchId = detail.id;
v.progressStyle = 'width:' + progress;
}
}
});
this.curQueue.forEach(v => {
if (v.id === id) {
v.progress = progress;
v.batchId = detail.id;
v.progressStyle = 'width:' + progress;
}
});
this.prevQueue.forEach(v => {
if (v.id === id) {
v.progress = progress;
v.batchId = detail.id;
v.progressStyle = 'width:' + progress;
}
});
this.curQueue = [...this.curQueue];
this.nextQueue = [...this.nextQueue];
this.prevQueue = [...this.prevQueue];
},
init() {
this.pause = false;
this.nextQueue = [];
this.prevQueue = [];
this.curQueue = [];
this.circular = false;
this._last = 1;
this._change = -1;
this._invalidUp = 0;
this._invalidDown = 0;
this._videoContexts = [];
this.loading = false;
},
_videoListChanged (newVal) {
newVal.forEach((item, index) => {
item.time = 0;
...
...
@@ -178,8 +248,6 @@
const direction = diff === 1 || diff === -2 ? 'up' : 'down';
if (direction === 'up') {
if (this._invalidDown === 0) {
// console.log(this.nextQueue, this.nextQueue.length, this.prevQueue, this.prevQueue.length);
// if (this.nextQueue.length === 0) {this.nextQueue.push(this.prevQueue.shift())}
const change = (this._change + 1) % 3;
const add = this.nextQueue.shift();
const remove = this.curQueue[change];
...
...
@@ -197,7 +265,6 @@
}
if (direction === 'down') {
if (this._invalidUp === 0) {
// if (this.prevQueue.length === 0) {this.prevQueue.push(this.nextQueue.pop())}
const _change2 = this._change;
const _remove = this.curQueue[_change2];
const _add = this.prevQueue.pop();
...
...
@@ -214,13 +281,6 @@
}
}
this.circular = true;
// if (this.nextQueue.length === 0 && current !== 0) {
// this.circular = false;
// }
// if (this.prevQueue.length === 0 && current !== 2) {
// console.log('circular2');
// this.circular = false;
// }
});
},
onWaiting (e) {
...
...
@@ -244,7 +304,17 @@
this.curQueue = [...this.curQueue];
}
},
playCurrent(current) {
async playCurrent(current) {
await this.getProgress(this.curQueue[current].id);
const { batchId, photoUrl, name, probability, progress } = this.curQueue[current];
this.$emit('getAwardsInfo', {
batchId,
photoUrl,
quantity: this.userAccount,
name,
chance: probability,
progress: progress
});
this._videoContexts.forEach((ctx, index) => {
if (index !== current) {
ctx.pause();
...
...
src/pages/index.wpy
View file @
e3f0ec5d
...
...
@@ -170,7 +170,7 @@
<view class="video-wrapper">
<view id="myvideo">
<van-notify id="van-notify" />
<video-list :videoList.sync="videoList" :userAccount="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :total="total" bindchange="changeVideo">
<video-list :videoList.sync="videoList" :userAccount="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :total="total" bindchange="changeVideo"
@getAwardsInfo="getAwardsInfo"
>
</video-list>
</view>
<view class="userInfo" style="{{userImgStyle}}" @tap="showMenu(!showMenus)">
...
...
@@ -194,7 +194,7 @@
</swiper>
</view>
</view>
<view class="footer">
<
!-- <
view class="footer">
<swiper
class="footswiper"
display-multiple-items="{{swiperItem}}"
...
...
@@ -206,8 +206,6 @@
next-margin="120rpx"
catch:touchmove
>
<!--bindtouchstart="touchStart"-->
<!--bindtouchend="touchEnd"-->
<swiper-item wx:for="{{list}}" wx:key="index">
<view
data-itemid="{{index}}"
...
...
@@ -222,7 +220,7 @@
</view>
</swiper-item>
</swiper>
</view>
</view>
-->
<view class="authmodal" v-show="authmodal">
<view class="wrap">
<view class="text">来到lukii,再平凡的人,<br>也有幸运的权利!</view>
...
...
@@ -230,8 +228,8 @@
</view>
</view>
<network v-if="isConnected === false"></network>
<open-animation v-if="showAwardsModal" :joinRecord="mainInfo && mainInfo.joinRecord"></open-animation>
<shared-popup v-if="showShareModal" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"></shared-popup>
<
!-- <
open-animation v-if="showAwardsModal" :joinRecord="mainInfo && mainInfo.joinRecord"></open-animation>
<shared-popup v-if="showShareModal" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"></shared-popup>
-->
<popup @showMenu="showMenu" :showMenus="showMenus"></popup>
</view>
</template>
...
...
@@ -244,7 +242,7 @@
import { mapState, mapActions } from '@wepy/x';
import wepy from '@wepy/core';
import Notify from '../components/vant/notify/notify';
import { register, getUserInfo, addGold, getPrizeList } from '../common/api.js';
import { register, getUserInfo, addGold, getPrizeList
, signIn
} from '../common/api.js';
wepy.page({
store,
hooks: {
...
...
@@ -275,7 +273,8 @@
inviter: '',
mainInfo: null,
showShareModal: false,
showAwardsModal: false
showAwardsModal: false,
awardsInfo: {}
},
computed: {
...
...
@@ -339,7 +338,6 @@
},
toViewPage(e) {
let item = e.$wx.currentTarget.dataset.item;
// console.log(sku,12)
// 解决长按触发tap事件的bug
wx.navigateToMiniProgram({
appId: 'wx91d27dbf599dff74',
...
...
@@ -405,7 +403,6 @@
},
async getUserInfo (e) {
if (e.$wx.detail.userInfo) {
console.log('userInfo', e.$wx.detail.userInfo);
this.setUserInfo(e.$wx.detail.userInfo);
await this.getMainInfo();
this.authmodal = false;
...
...
@@ -421,7 +418,6 @@
},
changeVideo(e) {
this.setIsConnected();
console.log(this.length, e.activeId);
// if (this.length - e.activeId === 1) {
// this.videoList = [{id: e.activeId + 2, url: 'https://ip1707952229.mobgslb.tbcache.com/youku/6974c3708c0337150e1743b1c/03000801005EA2A6C8FB4C2003E8807282A547-8207-4F52-9663-969096765248.mp4?sid=158960247500010009412_00_Bac09720260d484f23ac2ccebe5206930&sign=b76f4099e108fc306d3db993d1bec0a8&ctype=50&ali_redirect_domain=vali.cp31.ott.cibntv.net&ali_redirect_ex_ftag=5898cd25832bbff232de6d9fa668e8ddf8bacc5fef3f2e7b&ali_redirect_ex_tmining_ts=1589602477&ali_redirect_ex_tmining_expire=3600&ali_redirect_ex_hot=111'}];
// this.length += 1;
...
...
@@ -457,13 +453,14 @@
}, 500);
}
},
signIn: function() {
signIn:
async
function() {
let that = this;
const tmplIds = [
'xbA7XopO2j0V0Ne0F61UzSxoyfKrf92GQk6Z4pQvnd4',
'_yZWJYT-3lGCQG6g7Wa7F-0zxvGaPe4zwAI9D4zW4EY',
'7YzXgiVNGXiRvXNmR6WUtH_WplUyo97eAy45dsyviKQ'
];
wx.requestSubscribeMessage({
tmplIds: [
'xbA7XopO2j0V0Ne0F61UzSxoyfKrf92GQk6Z4pQvnd4',
...
...
@@ -471,16 +468,12 @@
'7YzXgiVNGXiRvXNmR6WUtH_WplUyo97eAy45dsyviKQ'
],
success (res) {
console.log('requestSubscribeMessage success', res);
if (res.errMsg === 'requestSubscribeMessage:ok') {
const rs = tmplIds.some(v => res[v] === 'accept');
if (rs) {
that.sign = true;
// if (!that.sign) {
// that.showAnimation = false;
// timeout = null;
// timeout1 = null;
// } else {
setTimeout(() => {
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = '/static/audio/supermarie.mp3';
...
...
@@ -491,17 +484,11 @@
console.log(res.errMsg);
console.log(res.errCode);
});
// setTimeout(() => {
// that.showAnimation = that.sign;
// setTimeout(() => {
// const num = [1, 2, 4, 501, 2501, 5001];
// that.goldNum = 1;
// }, 600);
// }, 1100);
// }
that.mainInfo.account.quantity += 1;
signIn();
}, 1500);
} else {
Notify({message: '请先勾选协议!', background: '#FF5D15', safeAreaInsetTop: true });
// Notify({ backgroundColor: '#ff976a', text: '签到必须同意推送授权', safeAreaInsetTop: true });
Notify({ message: '签到必须同意推送授权!', background: '#FF5D15', safeAreaInsetTop: true });
}
}
},
...
...
@@ -532,13 +519,15 @@
};
},
getAwards: function() {
const { batchId, photoUrl, quantity, name, chance, progress } = this.awardsInfo;
wx.navigateTo({
url:
'/pages/raffle?id=1&progress=70&chance=1/780&corn=50000&imgsrc=/static/images/test2.png&goods=Nintendo Switch任天堂游戏机任天堂游戏机'
url:
`/pages/raffle?batchId=${batchId}&progress=${progress}&chance=${chance}&photoUrl=${photoUrl}}&quantity=${quantity}&name=${name}`
});
// this.awards = !this.awards;
},
getAwardsInfo: function(v) {
this.awardsInfo = v;
},
showMenu: function(v) {
console.log(v);
this.showMenus = v;
},
getSharedGold: async function(v) {
...
...
@@ -565,7 +554,6 @@
let self = this;
let statusHeight = this.$app.$options.globalData.statusBarHeight || '';
statusHeight && (this.userImgStyle = 'top:' + statusHeight + 'px');
console.log(this.userImgStyle);
if (store.state.userInfo) {
this.userInfo = store.state.userInfo;
} else {
...
...
@@ -617,7 +605,6 @@
];
// console.log(this.$app.$options.globalData.info,111)
// 如果已经存在store里就不用再获取用户信息了
console.log('userInfo', this.userInfo);
if (!this.userInfo) {
const setting = await wepy.wx.getSetting();
if (setting.authSetting['scope.userInfo']) {
...
...
@@ -681,9 +668,5 @@
'video-loading': '~@/components/custom/loading'
},
navigationStyle: "custom",
"navigateToMiniProgramAppIdList":[
"wx91d27dbf599dff74"
],
}
</config>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment