Commit 8f4b89b0 authored by ziyu's avatar ziyu

合并

parents 1e484363 194143ef
...@@ -998,6 +998,11 @@ ...@@ -998,6 +998,11 @@
"resolved": "http://npmprivate.quantgroups.com/@wepy%2fcore/-/core-2.0.0-alpha.16.tgz", "resolved": "http://npmprivate.quantgroups.com/@wepy%2fcore/-/core-2.0.0-alpha.16.tgz",
"integrity": "sha512-kIUlfmGwsOtKFEFxzmxGFyVL6CWojT9LWHQOTKQ6X+oRLGuUbSe6yYckLt2ZAu2Pg19J65OeSIie5hToicJO5Q==" "integrity": "sha512-kIUlfmGwsOtKFEFxzmxGFyVL6CWojT9LWHQOTKQ6X+oRLGuUbSe6yYckLt2ZAu2Pg19J65OeSIie5hToicJO5Q=="
}, },
"@wepy/use-promisify": {
"version": "2.0.6",
"resolved": "http://npmprivate.quantgroups.com/@wepy%2fuse-promisify/-/use-promisify-2.0.6.tgz",
"integrity": "sha512-iZt4j1KU3YzNB5ilv5GS8kv0tqoLFtnAgcg6HDAmJ5Reol+imLsRENUxMdsfpO6oOxck4SSTzgSLOx3ccnC/qQ=="
},
"@wepy/x": { "@wepy/x": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "http://npmprivate.quantgroups.com/@wepy%2fx/-/x-2.0.4.tgz", "resolved": "http://npmprivate.quantgroups.com/@wepy%2fx/-/x-2.0.4.tgz",
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@wepy/core": "^2.0.0-alpha.16", "@wepy/core": "^2.0.0-alpha.16",
"@wepy/use-promisify": "^2.0.6",
"@wepy/x": "^2.0.2" "@wepy/x": "^2.0.2"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -8,8 +8,12 @@ ...@@ -8,8 +8,12 @@
</style> </style>
<script> <script>
import wepy from '@wepy/core'; import wepy from '@wepy/core';
import http from './common/wxRequest';
import vuex from '@wepy/x'; import vuex from '@wepy/x';
import promisify from '@wepy/use-promisify';
import { login } from './common/api';
wepy.use(promisify);
wepy.use(vuex); wepy.use(vuex);
wepy.app({ wepy.app({
...@@ -20,50 +24,47 @@ wepy.app({ ...@@ -20,50 +24,47 @@ wepy.app({
globalData: { globalData: {
statusBarHeight: '' statusBarHeight: ''
}, },
onLaunch() { async onLaunch() {
let that = this; let that = this;
wx.getSystemInfo({ wx.getSystemInfo({
success: function (res) { success: function (res) {
that.$options.globalData.statusBarHeight = res.statusBarHeight; that.$options.globalData.statusBarHeight = res.statusBarHeight;
} }
}); });
wx.setStorageSync('onNetworkStatusChange', true);
if (!wx.getStorageSync('openId')) { if (!wx.getStorageSync('openId')) {
wx.login({ const { code } = await wepy.wx.login();
success (res) { const userInfo = await login(code);
if (res.code) { wx.setStorageSync('openId', userInfo.openId);
// 发起网络请求,告诉后端 wx.setStorageSync('isRegister', userInfo.isRegister);
http.post('/');
wx.setStorageSync('wxCode', res.code);
} else {
console.log('登录失败!' + res.errMsg);
}
}
});
} }
wx.checkSession({ // wx.checkSession({
success () { // success () {
console.log('已登录'); // console.log('已登录');
// session_key 未过期,并且在本生命周期一直有效 // // session_key 未过期,并且在本生命周期一直有效
}, // },
fail () { // fail () {
// session_key 已经失效,需要重新执行登录流程 // // session_key 已经失效,需要重新执行登录流程
wx.login({ // wx.login({
success (res) { // success (res) {
if (res.code) { // if (res.code) {
// 发起网络请求,告诉后端 // // 发起网络请求,告诉后端
wx.setStorageSync('wxCode', res.code); // wx.setStorageSync('wxCode', res.code);
} else { // } else {
console.log('登录失败!' + res.errMsg); // console.log('登录失败!' + res.errMsg);
} // }
} // }
}); // });
} // }
}); // });
wx.setStorageSync('onNetworkStatusChange', true);
wx.onNetworkStatusChange((res) => { wx.onNetworkStatusChange((res) => {
console.log('onNetworkStatusChange', res.isConnected);
wx.setStorageSync('onNetworkStatusChange', res.isConnected); wx.setStorageSync('onNetworkStatusChange', res.isConnected);
}); });
}, },
onError(e) {
console.log('onError', e);
},
methods: {} methods: {}
}); });
</script> </script>
......
import http from './wxRequest'; import http from './wxRequest';
module.exports = { module.exports = {
login() { login(code) {
return http.post(); return http.post(`/api/user/login?code=1235`);
},
register(params) {
return http.post('/api/user/register', params, { 'content-type': 'application/json' });
},
getUserInfo(params) {
return http.post('/api/user/main', params);
},
getAwardsInfo(params) {
return http.post('/api/prize/list', params);
},
getAwardsDetail(params) {
return http.post('/api/prize/batch', params);
},
getActivityFeed(params) {
return http.post('/api/activity/feed', params);
},
addGold(params) {
return http.post('/api/user/book', params);
},
signIn(params) {
return http.post('/api/user/signin', params, { 'content-type': 'application/json' });
},
getPrizeList(params) {
return http.post('/api/prize/list', params, { 'content-type': 'application/json' });
} }
}; };
import wepy from '@wepy/core'; import wepy from '@wepy/core';
import Notify from '../components/vant/notify/notify';
const baseUrl = 'localhost:8000'; const baseUrl = 'https://luckiiapi.q-gp.com/yapi/mock/325';
const request = (url, options) => { const request = async (url, options) => {
const defaultOptions = { const defaultOptions = {
method: 'post', method: 'post',
header: { 'content-type': 'applicction/x-www-form-urlencoded' } header: { 'content-type': 'applicction/x-www-form-urlencoded' }
...@@ -11,6 +12,7 @@ const request = (url, options) => { ...@@ -11,6 +12,7 @@ const request = (url, options) => {
url = baseUrl + url; url = baseUrl + url;
const isConnected = wx.getStorageSync('onNetworkStatusChange'); const isConnected = wx.getStorageSync('onNetworkStatusChange');
console.log('isConnected', isConnected);
if (!isConnected) { if (!isConnected) {
wx.showToast({ wx.showToast({
title: '无网络', title: '无网络',
...@@ -20,26 +22,21 @@ const request = (url, options) => { ...@@ -20,26 +22,21 @@ const request = (url, options) => {
return; return;
} }
const promise = new Promise((resolve, reject) => { return wepy.wx.request({
/*wepy.request({ url: url,
url: url, data: options.data,
data: options.data, method: options.method,
method: options.method, header: options.header
header: options.header, }).then(res => {
success: res => { if (res.statusCode === 200) {
if (res.statusCode == 200) { if (res.data.code === 2000) {
if (res.data.code == '2000') { return res.data.data;
resolve(res.data.data);
}
}
reject(res);
},
fail: res => {
reject(res);
} }
});*/ }
Notify({ message: res.data.detail || '请求异常,请稍后重试', background: '#FF5D15', safeAreaInsetTop: true });
}).catch(res => {
Notify({ message: '请求失败,请稍后重试', background: '#FF5D15', safeAreaInsetTop: true });
}); });
return promise;
}; };
const post = (url, data, header) => { const post = (url, data, header) => {
......
...@@ -6,18 +6,6 @@ ...@@ -6,18 +6,6 @@
<div class="gift" @tap="click"></div> <div class="gift" @tap="click"></div>
</div> </div>
<div class="chest-open" :class="{'show': show, 'blur': blur}"> <div class="chest-open" :class="{'show': show, 'blur': blur}">
<!-- <div class="mod-chest-cont">
<div class="content">
<div>您可真幸运~</div>
<image class="gift-image" src="/static/images/peo2.jpg"></image>
<div>时尚卡通水杯</div>
</div>
<div class="func">
<button class="chest-btn" @tap="go">再去挑战</button>
<button class="chest-btn" @tap="go">查看</button>
</div>
</div> -->
<div class="dialog" :class="{'fail-dialog': !isWin}"> <div class="dialog" :class="{'fail-dialog': !isWin}">
<div class="star"> <div class="star">
<image class="star-image" src="/static/images/star@2x.png"></image> <image class="star-image" src="/static/images/star@2x.png"></image>
...@@ -35,8 +23,8 @@ ...@@ -35,8 +23,8 @@
</div> </div>
<div class="success-content" v-if="isWin"> <div class="success-content" v-if="isWin">
<div class="des">恭喜您中奖!</div> <div class="des">恭喜您中奖!</div>
<image class="image" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1590418868788&di=5f7d14c51ea4d224c68d2f84b528c6f0&imgtype=0&src=http%3A%2F%2Fimg2.imgtn.bdimg.com%2Fit%2Fu%3D2413142997%2C2945797382%26fm%3D214%26gp%3D0.jpg"></image> <image class="image" :src="joinRecord.prize.photoUrl"></image>
<div class="name">勃垦地进口红酒精装版</div> <div class="name">{{joinRecord.prize.name}}</div>
</div> </div>
<div class="dialog-footer"> <div class="dialog-footer">
<button class="btn" @tap="go">立即查看</button> <button class="btn" @tap="go">立即查看</button>
...@@ -52,7 +40,12 @@ ...@@ -52,7 +40,12 @@
wepy.component({ wepy.component({
props: { props: {
isWin: false joinRecord: {
type: Object,
default() {
return {};
}
}
}, },
data: { data: {
showAnimation: true, showAnimation: true,
...@@ -62,6 +55,13 @@ ...@@ -62,6 +55,13 @@
blur: false, blur: false,
opened: false opened: false
}, },
computed: {
isWin() {
console.log('this.joinRecord.status.value', this.joinRecord);
if (!this.joinRecord.id) return false;
return +this.joinRecord.status.value === 3;
}
},
methods: { methods: {
click: function() { click: function() {
this.shake = true; this.shake = true;
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
created() { created() {
// setTimeout(() => { // setTimeout(() => {
this.showAnimation = true; this.showAnimation = true;
this.click(); // this.click();
// }, 1000); // }, 1000);
} }
}); });
......
...@@ -20,15 +20,14 @@ ...@@ -20,15 +20,14 @@
<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">通过邀请以下好友,您获得15克币</div> <div class="info">通过邀请以下好友,您获得{{goldNum}}克币</div>
<div class="user"> <div class="user" :class="{'one-user': inviteinfo.length === 1 }">
<image class="user-img" src="/static/images/test1.jpg"></image> <image class="user-img" v-for="item in users" :src="item.avatarUrl"></image>
<image class="user-img" src="/static/images/test1.jpg"></image> <span class="user-rest" v-if="inviteinfo.length > 3">...</span>
<image class="user-img" src="/static/images/test1.jpg"></image>
</div> </div>
</div> </div>
<div class="dialog-footer"> <div class="dialog-footer">
<button class="btn" @tap="go">立即领取</button> <button class="btn" @tap="getGold">立即领取</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -38,39 +37,34 @@ ...@@ -38,39 +37,34 @@
wepy.component({ wepy.component({
props: { props: {
showMenus: { inviteinfo: {
type: Boolean, type: Array
default: false
}
},
data: {
menus: [
{ img: '/static/images/awards@2x.png', title: '我的抽奖', path: '/pages/awards' },
{ img: '/static/images/feedback@2x.png', title: '规则与帮助', path: '/pages/feedback' },
{ img: '/static/images/help@2x.png', title: '问题反馈', path: '/pages/help' }
],
show: false,
popupStyle: ''
},
watch: {
showMenus(v) {
if (!v) {
setTimeout(() => {
this.show = false;
}, 300);
} else {
this.show = true;
}
} }
}, },
computed: { computed: {
hide() { goldNum() {
return !this.showMenus; return this.inviteinfo.reduce((p, n) => {
p += +n.quantity;
return p;
}, 0);
},
users() {
return this.inviteinfo.slice(0, 3);
},
ids() {
return this.inviteinfo.reduce((p, n) => {
p.push(n.accountItemId);
return p;
}, []);
} }
}, },
methods: { methods: {
getAwards: function() { getGold: function() {
this.show = false; this.$emit('getSharedGold', {
openid: wx.getStorageSync('openId'),
itemIdList: this.ids.join(','),
quantity: this.goldNum
});
} }
} }
}); });
...@@ -250,13 +244,15 @@ ...@@ -250,13 +244,15 @@
height: 50rpx; height: 50rpx;
border-radius: 50%; border-radius: 50%;
} }
&:after { .user-rest {
content: '...';
position: absolute; position: absolute;
bottom: -5rpx; bottom: 11rpx;
right: -46rpx; right: -46rpx;
} }
} }
.one-user {
justify-content: center;
}
} }
.dialog-footer { .dialog-footer {
display: flex; display: flex;
......
<template> <template>
<div style="{{containerStyle}}" class="icon-container"> <div style="{{containerStyle}}" class="icon-container">
<star-animation v-if='flyAnimation'></star-animation> <star-animation v-if="flyAnimation"></star-animation>
<div class="sign" v-if="type === 'sign'" @tap="signIn"> <div class="sign" v-if="type === 'sign'" @tap="signIn">
<image class="sign-in" :src="signNotCompletedUrl" v-if="!signComplete" :class="{'jump': !sign, 'fly': sign}" ></image> <image class="sign-in" :src="signNotCompletedUrl" v-if="!signComplete" :class="{'jump': !sign, 'fly': sign}" ></image>
<image class="sign-comlete" :src="signCompletedUrl" v-if="sign"></image> <image class="sign-comlete" :src="signCompletedUrl" v-if="sign"></image>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<div v-if="type === 'gold'" class="gold"> <div v-if="type === 'gold'" class="gold">
<div class="add-gold" v-if="addGold"> <div class="add-gold" v-if="addGold">
<image class="add-gold-image" :src="addGoldUrl"></image> <image class="add-gold-image" :src="addGoldUrl"></image>
<span class="add-gold-num">+10</span> <span class="add-gold-num">+{{addGoldNum}}</span>
</div> </div>
<div class="show-gold" @tap="showAnimation"> <div class="show-gold" @tap="showAnimation">
<div class="sunshine" v-if="addsunshine"></div> <div class="sunshine" v-if="addsunshine"></div>
...@@ -57,27 +57,29 @@ ...@@ -57,27 +57,29 @@
data: { data: {
showAnimation: false, showAnimation: false,
addGold: false, addGold: false,
addGoldNum: 0,
addCount: 0,
addsunshine: false, addsunshine: false,
signComplete: false, signComplete: true,
signNotCompletedUrl: '/static/images/sign@2x.png', signNotCompletedUrl: '/static/images/sign@2x.png',
signCompletedUrl: '/static/images/sign-completed@2x-70_70px.png', signCompletedUrl: '/static/images/sign-completed@2x-70_70px.png',
shareUrl: '/static/images/share@2x.png', shareUrl: '/static/images/share@2x.png',
lotteryUrl: '/static/images/lottery@2x.png', lotteryUrl: '/static/images/lottery@2x.png',
containerStyle: '', containerStyle: '',
flyAnimation: false flyAnimation: false,
isFirst: true
}, },
props: { props: {
title: '', title: '',
sign: { sign: {
type: Boolean, type: Boolean,
default: false default: true
}, },
gold: { gold: {
type: Boolean, type: Boolean,
default: false default: true
}, },
des: { des: {
type: String | Number,
default: '' default: ''
}, },
type: { type: {
...@@ -117,27 +119,38 @@ ...@@ -117,27 +119,38 @@
} }
}, },
watch: { watch: {
des(newVal, oldVal) {
if (this.type === 'gold') {
if (!this.addCount) {
this.addCount ++;
return;
}
this.addGold = true;
this.addGoldNum = newVal - oldVal;
this.addCount ++;
}
},
gold(v) { gold(v) {
if (!v) { if (this.isFirst) {
this.addsunshine = false; this.isFirst = false;
timeout1 = null; return;
} else {
timeout1 = setTimeout(() => {
this.addsunshine = true;
}, 1500);
} }
setTimeout(() => {
this.addsunshine = true;
}, 1500);
}, },
sign(v) { sign(v) {
this.signComplete = false; if (this.isFirst) {
this.flyAnimation = false; this.signComplete = false;
console.log(v, this.signComplete); this.flyAnimation = false;
if (!v) { this.addsunshine = false;
timeout = null; this.isFirst = false;
} else { return;
timeout = setTimeout(() => { }
if (v) {
setTimeout(() => {
this.signComplete = true; this.signComplete = true;
this.flyAnimation = true; this.flyAnimation = true;
console.log('signComplete');
}, 1100); }, 1100);
} }
} }
...@@ -148,7 +161,8 @@ ...@@ -148,7 +161,8 @@
[this.bgColor, this.fontColor] = [this.fontColor, this.bgColor]; [this.bgColor, this.fontColor] = [this.fontColor, this.bgColor];
}, },
signIn: function() { signIn: function() {
this.$emit('sign-in', !this.sign); if (this.sign) return;
this.$emit('sign-in', true);
}, },
showAnimation: function() { showAnimation: function() {
this.addGold = !this.addGold; this.addGold = !this.addGold;
......
...@@ -84,14 +84,14 @@ ...@@ -84,14 +84,14 @@
</video> < !--> </video> < !-->
<view class="rightcont"> <view class="rightcont">
<view class="info">奖品库存: 1/8</view> <view class="info">奖品库存: 1/8</view>
<view class="info">中奖概率: {{item.id}}/3000</view> <view class="info">中奖概率: {{userAccount}}/3000</view>
<view class="progress"> <view class="progress">
<view class="text">{{progress}}%</view> <view class="text">{{progress}}%</view>
<view class="orange" style="{{progressStyle}}"></view> <view class="orange" style="{{progressStyle}}"></view>
</view> </view>
</view> </view>
<!-- <video-loading v-if="item.time === 0"/> --> <!-- <video-loading v-if="item.time === 0"/> -->
<image class="images" :src="item.url" mode="widthFix"></image> <image class="images" :src="item.photoUrl" mode="widthFix"></image>
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>
...@@ -116,6 +116,10 @@ ...@@ -116,6 +116,10 @@
total: { total: {
type: Number, type: Number,
value: 0 value: 0
},
userAccount: {
type: Number,
value: 0
} }
}, },
data: { data: {
......
This diff is collapsed.
...@@ -2,9 +2,7 @@ import Vuex from '@wepy/x'; ...@@ -2,9 +2,7 @@ import Vuex from '@wepy/x';
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
userInfo: { userInfo: '',
avatarUrl: '/static/images/user@2x.png'
},
isConnected: true isConnected: true
}, },
mutations: { mutations: {
......
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