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
113159ef
Commit
113159ef
authored
Jun 16, 2020
by
ziyu
Browse files
Options
Browse Files
Download
Plain Diff
合并
parents
eee933be
cc931467
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
78 additions
and
49 deletions
+78
-49
.eslintcache
.eslintcache
+1
-1
api.js
src/common/api.js
+1
-1
raffleProbability.js
src/common/raffleProbability.js
+1
-1
activityList.wpy
src/components/custom/activityList.wpy
+7
-4
goodsList.wpy
src/components/custom/goodsList.wpy
+11
-12
popup.wpy
src/components/custom/popup.wpy
+3
-2
prizeList.wpy
src/components/custom/prizeList.wpy
+2
-2
sign.wpy
src/components/custom/sign.wpy
+10
-3
index.wpy
src/pages/index.wpy
+27
-17
prize.wpy
src/pages/prize.wpy
+8
-4
raffle.wpy
src/pages/raffle.wpy
+7
-2
No files found.
.eslintcache
View file @
113159ef
This diff is collapsed.
Click to expand it.
src/common/api.js
View file @
113159ef
...
@@ -53,5 +53,5 @@ module.exports = {
...
@@ -53,5 +53,5 @@ module.exports = {
},
},
checkCornCode
(
params
)
{
checkCornCode
(
params
)
{
return
http
.
post
(
'
/api/user/addCoins
'
,
params
);
return
http
.
post
(
'
/api/user/addCoins
'
,
params
);
}
,
}
};
};
src/common/raffleProbability.js
View file @
113159ef
...
@@ -16,7 +16,7 @@ function getProbability (quantity, coinQuantity) {
...
@@ -16,7 +16,7 @@ function getProbability (quantity, coinQuantity) {
var
value2
=
coinQuantity
/
divisor
;
var
value2
=
coinQuantity
/
divisor
;
// 如果分子比分母大说明中奖概率是100%,那么返回中奖概率
// 如果分子比分母大说明中奖概率是100%,那么返回中奖概率
if
(
value
>=
value2
)
{
if
(
value
>=
value2
)
{
return
coinQuantity
+
'
/
'
+
coinQuantity
;
return
'
100%
'
;
}
else
{
}
else
{
return
value
+
'
/
'
+
value2
;
return
value
+
'
/
'
+
value2
;
}
}
...
...
src/components/custom/activityList.wpy
View file @
113159ef
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<swiper
<swiper
class="list-wrapper"
class="list-wrapper"
vertical="{{true}}"
vertical="{{true}}"
circular="{{
tru
e}}"
circular="{{
fals
e}}"
display-multiple-items="{{activityDisplayItems}}"
display-multiple-items="{{activityDisplayItems}}"
bindchange="onActivityChange"
bindchange="onActivityChange"
autoplay="{{isAuto}}"
autoplay="{{isAuto}}"
...
@@ -45,10 +45,13 @@
...
@@ -45,10 +45,13 @@
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.$wx.detail.current === lastIndex) {
this.isActiveDone = 'anima';
this.isAuto = false;
// 当最后一个出来的时候等一秒再消失
setTimeout(() => {
setTimeout(() => {
this.isActiveDone = 'anima hide';
this.isActiveDone = 'anima';
this.isAuto = false;
setTimeout(() => {
this.isActiveDone = 'anima hide';
}, 2000);
}, 2000);
}, 2000);
}
}
}
}
...
...
src/components/custom/goodsList.wpy
View file @
113159ef
...
@@ -54,18 +54,18 @@
...
@@ -54,18 +54,18 @@
watch: {
watch: {
goodsList(val) {
goodsList(val) {
/* let list = val || [];
/* let list = val || [];
this.list = list;*/
this.list = list;
*/
}
}
},
},
created() {
created() {
//获取推荐的商品列表
//
获取推荐的商品列表
this.list = [{value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: '100004549235'},
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: 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: 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: 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: 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'}
,
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: '100004549235'}
];
];
},
},
methods: {
methods: {
moveSwiper(e) {
moveSwiper(e) {
...
@@ -116,9 +116,8 @@
...
@@ -116,9 +116,8 @@
that.lastPage += 1;
that.lastPage += 1;
if (that.lastPage + that.topPage >= totalPage) {
if (that.lastPage + that.topPage >= totalPage) {
that.circular = true;
that.circular = true;
return;
}
}
//
that.list = [...that.list, ...nextlist];
that.list = [...that.list, ...nextlist];
}, 1000), 500);
}, 1000), 500);
}
}
}
}
...
@@ -200,22 +199,22 @@
...
@@ -200,22 +199,22 @@
if (list.length <= 4) {
if (list.length <= 4) {
this.circular = false;
this.circular = false;
}
}
console.log(current.itemid,
this.currentIndex,this.current,111)
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;
}
}
setTimeout(function() {
setTimeout(function() {
let newlist = that.list.filter((item, index) => index !== +current.itemid);
let newlist = that.list.filter((item, index) => index !== +current.itemid);
// 正常情况下,current.itemid都会比current大一个,当相等或小于的时候就有问题,要重新设置current,最小不能超过0
// 正常情况下,current.itemid都会比current大一个,当相等或小于的时候就有问题,要重新设置current,最小不能超过0
if(newlist.length <= that.swiperItem) {
if
(newlist.length <= that.swiperItem) {
that.swiperItem = newlist.length;
that.swiperItem = newlist.length;
}
}
that.list = newlist;
that.list = newlist;
if (current.itemid - that.current !==
1
) {
if (current.itemid - that.current !==
1
) {
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)
console.log(current.itemid,
that.currentIndex, that.current, 222);
}, 500);
}, 500);
}
}
}
}
...
...
src/components/custom/popup.wpy
View file @
113159ef
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
</template>
</template>
<script>
<script>
import wepy from '@wepy/core';
import wepy from '@wepy/core';
let showMenusTimer = null;
wepy.component({
wepy.component({
props: {
props: {
showMenus: {
showMenus: {
...
@@ -34,7 +34,8 @@
...
@@ -34,7 +34,8 @@
watch: {
watch: {
showMenus(v) {
showMenus(v) {
if (!v) {
if (!v) {
setTimeout(() => {
if (showMenusTimer) clearTimeout(showMenusTimer);
showMenusTimer = setTimeout(() => {
this.show = false;
this.show = false;
}, 300);
}, 300);
} else {
} else {
...
...
src/components/custom/prizeList.wpy
View file @
113159ef
...
@@ -160,8 +160,8 @@
...
@@ -160,8 +160,8 @@
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;
if (detail.join > detail.quantity) detail.join = detail.quantity;
const progressFloat = detail.join / detail.quantity;
const progressFloat = detail.join / detail.quantity
* 100
;
let progress = Math.round(progressFloat
* 100
) + '%';
let progress = Math.round(progressFloat) + '%';
if (progressFloat > 0 && progressFloat < 1) progress = '1%';
if (progressFloat > 0 && progressFloat < 1) progress = '1%';
this.curQueue.forEach(v => {
this.curQueue.forEach(v => {
...
...
src/components/custom/sign.wpy
View file @
113159ef
...
@@ -57,6 +57,7 @@
...
@@ -57,6 +57,7 @@
share: '/static/images/share@2x.png',
share: '/static/images/share@2x.png',
lottery: '/static/images/lottery@2x.png'
lottery: '/static/images/lottery@2x.png'
};
};
let addGoldTimer = null;
wepy.component({
wepy.component({
store,
store,
data: {
data: {
...
@@ -98,7 +99,7 @@
...
@@ -98,7 +99,7 @@
authmodal: {
authmodal: {
type: Boolean,
type: Boolean,
default: false
default: false
}
,
}
},
},
computed: {
computed: {
...mapState(['safeAreaStyle']),
...mapState(['safeAreaStyle']),
...
@@ -126,7 +127,13 @@
...
@@ -126,7 +127,13 @@
},
},
watch: {
watch: {
isReceive(newVal, oldVal) {
isReceive(newVal, oldVal) {
this.addGold = true;
this.addGold = newVal;
if (newVal) {
if (addGoldTimer) clearTimeout(addGoldTimer);
addGoldTimer = setTimeout(() => {
this.$emit('resetAddGold');
}, 1000);
}
},
},
des(newVal, oldVal) {
des(newVal, oldVal) {
if (this.type === 'gold') {
if (this.type === 'gold') {
...
@@ -178,7 +185,7 @@
...
@@ -178,7 +185,7 @@
showCornModal() {
showCornModal() {
this.$emit('showCorn');
this.$emit('showCorn');
}
}
}
,
}
});
});
</script>
</script>
<style lang="less">
<style lang="less">
...
...
src/pages/index.wpy
View file @
113159ef
...
@@ -171,7 +171,7 @@
...
@@ -171,7 +171,7 @@
<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>
<view>
<gold type="gold" :des="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" :gold="sign" :isReceive="isReceive" @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="分享"></share>
...
@@ -205,6 +205,7 @@
...
@@ -205,6 +205,7 @@
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, 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 awardsInfo = {};
let awardsInfo = {};
wepy.page({
wepy.page({
store,
store,
...
@@ -218,18 +219,18 @@
...
@@ -218,18 +219,18 @@
mainInfo: null,
mainInfo: null,
showModal: 0, // 1: 展示领取金币弹窗 2: 展示抽奖弹窗 3: 头像菜单弹窗
showModal: 0, // 1: 展示领取金币弹窗 2: 展示抽奖弹窗 3: 头像菜单弹窗
isReceive: false, // 是否显示领取克币动画
isReceive: false, // 是否显示领取克币动画
cornModal:false,
cornModal:
false,
cornCode: '', //克币充值码
cornCode: '', //
克币充值码
cornText:'',
cornText:
'',
cornTextShow: false
,
cornTextShow: false
},
},
computed: {
computed: {
...mapState([ 'isConnected', 'userInfo', 'safeAreaStyle' ])
...mapState([ 'isConnected', 'userInfo', 'safeAreaStyle' ])
},
},
watch: {
watch: {
cornCode(val,oldval) {
cornCode(val,
oldval) {
if (val
!==
oldval && this.cornTextShow) {
if (val
!==
oldval && this.cornTextShow) {
this.cornTextShow = false;
this.cornTextShow = false;
}
}
}
}
...
@@ -410,26 +411,31 @@
...
@@ -410,26 +411,31 @@
this.cornModal = false;
this.cornModal = false;
},
},
checkCode() {
checkCode() {
if
(this.cornCode
== '') {
if
(this.cornCode =
== '') {
this.cornText = '请输入克币充值码';
this.cornText = '请输入克币充值码';
this.cornTextShow = true;
this.cornTextShow = true;
return;
return;
}
}
const msg = ['充值码无效,请重新输入','该充值码已被使用,请重新输入'];
const msg = ['充值码无效,请重新输入',
'该充值码已被使用,请重新输入'];
checkCornCode({code:
this.cornCode}).then(data=>
{
checkCornCode({code:
this.cornCode}).then(data =>
{
if
(data.code === 0)
{
if
(data.code === 0)
{
//充值成功
//
充值成功
this.cornModal = false;
this.cornModal = false;
this.mainInfo.account.quantity = data.accountCoins;
this.isReceive = true;
} else {
} else {
const msgindex = data.code
+
2;
const msgindex = data.code
+
2;
this.cornText = msg[msgindex];
this.cornText = msg[msgindex];
this.cornTextShow = true;
this.cornTextShow = true;
}
}
});
});
},
},
resetAddGold() {
this.isReceive = false;
}
},
},
async onLoad (options) {
async onLoad (options) {
this.cornText = '充值码错误';
// 获取分享人openid
// 获取分享人openid
if (options.openid) {
if (options.openid) {
this.inviter = options.openid;
this.inviter = options.openid;
...
@@ -441,6 +447,8 @@
...
@@ -441,6 +447,8 @@
// 获取openid
// 获取openid
await this.getOpenId();
await this.getOpenId();
this.getMainInfo();
flag = true;
// 获取用户信息并注册
// 获取用户信息并注册
if (this.userInfo.nickName) {
if (this.userInfo.nickName) {
...
@@ -456,18 +464,20 @@
...
@@ -456,18 +464,20 @@
}
}
}
}
// 获取主页信息
this.getMainInfo();
// 获取活动信息
// 获取活动信息
this.showActivity();
this.showActivity();
// 获取奖品列表
// 获取奖品列表
this.videoList = await getPrizeList(options.prizeId);
this.videoList = await getPrizeList(options.prizeId);
},
},
async onShow() {
async onShow() {
// 获取主页信息
if(flag) {
this.getMainInfo();
}
let join = wx.getStorageSync('userJoin');
let join = wx.getStorageSync('userJoin');
if (join === 1) {
if (join === 1) {
wx.removeStorageSync('userJoin');
wx.removeStorageSync('userJoin');
this.getMainInfo();
this.showActivity();
this.showActivity();
}
}
}
}
...
...
src/pages/prize.wpy
View file @
113159ef
...
@@ -44,6 +44,7 @@
...
@@ -44,6 +44,7 @@
position: fixed;
position: fixed;
bottom:0;
bottom:0;
left:0;
left:0;
z-index: 9;
.getprize{
.getprize{
position: absolute;
position: absolute;
width:160rpx;
width:160rpx;
...
@@ -58,6 +59,9 @@
...
@@ -58,6 +59,9 @@
font-size: @font-large;
font-size: @font-large;
}
}
}
}
.addtitle{
color:#c8c9cc
}
.van-picker .van-picker__cancel,.van-picker .van-picker__confirm{
.van-picker .van-picker__cancel,.van-picker .van-picker__confirm{
color:@maincolor;
color:@maincolor;
}
}
...
@@ -78,9 +82,9 @@
...
@@ -78,9 +82,9 @@
<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>
<van-field value="{{phone}}" data-form="phone" placeholder="手机号码" bind:input ="setValue"></van-field>
<van-field value="{{phone}}" data-form="phone" placeholder="手机号码" bind:input ="setValue"
maxlength="{{11}}"
></van-field>
<van-field value="{{idNumber}}" data-form="idNumber" placeholder="收货人身份证号" bind:input ="setValue"></van-field>
<van-field value="{{idNumber}}" data-form="idNumber" placeholder="收货人身份证号
(应监管要求,必须填写)
" bind:input ="setValue"></van-field>
<van-
field value="{{cityValue}}" placeholder="所在地区" bindtap="onClose" is-link readonly></van-field
>
<van-
cell title="{{cityValue}}" is-link bindtap="onClose" title-class="{{!city?'addtitle':''}}"></van-cell
>
<van-field value="{{address}}" data-form="address" placeholder="详细地址:如街道、小区、门牌号、楼栋号等" bind:input ="setValue"></van-field>
<van-field value="{{address}}" data-form="address" placeholder="详细地址:如街道、小区、门牌号、楼栋号等" bind:input ="setValue"></van-field>
</view>
</view>
</view>
</view>
...
@@ -112,7 +116,7 @@
...
@@ -112,7 +116,7 @@
province: '',
province: '',
city: '',
city: '',
county: '',
county: '',
cityValue: '',
cityValue: '
所在地区
',
areaList: [],
areaList: [],
showAddress: false,
showAddress: false,
joinRecordId: null,
joinRecordId: null,
...
...
src/pages/raffle.wpy
View file @
113159ef
...
@@ -283,6 +283,7 @@
...
@@ -283,6 +283,7 @@
function goprize() {
function goprize() {
updateUserPhone(detail).then(() => {
updateUserPhone(detail).then(() => {
wx.setStorageSync('hasPhone', true);
wx.setStorageSync('hasPhone', true);
that.btnfont = '立即参与';
hasPhone = true;
hasPhone = true;
that.joinin();
that.joinin();
}).catch(() => {
}).catch(() => {
...
@@ -316,6 +317,10 @@
...
@@ -316,6 +317,10 @@
await register(store.state.userInfo);
await register(store.state.userInfo);
wx.setStorageSync('isRegister', true);
wx.setStorageSync('isRegister', true);
}
}
if (!this.batchId) {
Notify({message: '数据加载中,请稍后重试!'});
return;
}
this.btnfont = '参与中...';
this.btnfont = '参与中...';
confirmRaffle({batchId: batchId}).then(data => {
confirmRaffle({batchId: batchId}).then(data => {
this.btnfont = '立即参与';
this.btnfont = '立即参与';
...
@@ -355,8 +360,8 @@
...
@@ -355,8 +360,8 @@
batchId = detail.id;
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;
const progressFloat = detail.join / detail.quantity
* 100
;
this.progress = Math.round(progressFloat
* 100
) + '%';
this.progress = Math.round(progressFloat) + '%';
// 当进度介于0 - 1之间时显示1
// 当进度介于0 - 1之间时显示1
if (progressFloat > 0 && progressFloat < 1) this.progress = '1%';
if (progressFloat > 0 && progressFloat < 1) this.progress = '1%';
this.progressStyle = 'width:' + this.progress;
this.progressStyle = 'width:' + this.progress;
...
...
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