Commit 0a1ab669 authored by zhijie.xue's avatar zhijie.xue

支持分享朋友圈

parent 786c38f4
......@@ -1000,9 +1000,12 @@
}
},
"@wepy/core": {
"version": "2.0.0-alpha.16",
"resolved": "http://npmprivate.quantgroups.com/@wepy%2fcore/-/core-2.0.0-alpha.16.tgz",
"integrity": "sha512-kIUlfmGwsOtKFEFxzmxGFyVL6CWojT9LWHQOTKQ6X+oRLGuUbSe6yYckLt2ZAu2Pg19J65OeSIie5hToicJO5Q=="
"version": "2.1.0",
"resolved": "https://registry.npm.taobao.org/@wepy/core/download/@wepy/core-2.1.0.tgz",
"integrity": "sha1-iU3Yj3m6rojfJa1VpDdUMnd6ShA=",
"requires": {
"miniprogram-api-typings": "^2.10.3-1"
}
},
"@wepy/use-promisify": {
"version": "2.0.6",
......@@ -4679,6 +4682,11 @@
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
},
"miniprogram-api-typings": {
"version": "2.11.0",
"resolved": "https://registry.npm.taobao.org/miniprogram-api-typings/download/miniprogram-api-typings-2.11.0.tgz?cache=0&sync_timestamp=1594824017901&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fminiprogram-api-typings%2Fdownload%2Fminiprogram-api-typings-2.11.0.tgz",
"integrity": "sha1-wKkcov6oDjRFCTmcWAy61QSo+QU="
},
"mixme": {
"version": "0.3.5",
"resolved": "http://npmprivate.quantgroups.com/mixme/-/mixme-0.3.5.tgz",
......
......@@ -17,7 +17,7 @@
"author": "郝聪敏 <congmin.hao@quantgroup.cn>",
"license": "MIT",
"dependencies": {
"@wepy/core": "^2.0.0-alpha.16",
"@wepy/core": "^2.1.0",
"@wepy/use-promisify": "^2.0.6",
"@wepy/x": "^2.0.2",
"qs": "^6.9.4"
......
......@@ -12,7 +12,15 @@
import wepy from '@wepy/core';
import vuex from '@wepy/x';
import promisify from '@wepy/use-promisify';
function copyWxProps() {
const target = {};
for (let key in wx) {
if (key === 'shareImageMessage') continue;
target[key] = wx[key];
}
return target;
}
wepy.wx = copyWxProps();
wepy.use(promisify);
wepy.use(vuex);
import { checkUpdateVersion } from './common/raffleProbability';
......@@ -25,9 +33,11 @@ wepy.app({
globalData: {
statusBarHeight: ''
},
onLaunch() {
onLaunch(param) {
if (param.screen !== 1154) {
checkUpdateVersion();
}
let that = this;
checkUpdateVersion();
wx.getSystemInfo({
success: function (res) {
that.$options.globalData.statusBarHeight = res.statusBarHeight;
......@@ -40,8 +50,7 @@ wepy.app({
},
onError(e) {
console.log('onError', e);
},
methods: {}
}
});
</script>
<config>
......
......@@ -25,6 +25,7 @@ function getProbability (quantity, coinQuantity) {
function checkUpdateVersion() {
// 创建 UpdateManager 实例
const updateManager = wx.getUpdateManager();
if (!updateManager) return;
// 检测版本更新
updateManager.onCheckForUpdate(function(res) {
console.log(res, '版本更新');
......
<template>
<view class="wrapper">
<van-image use-loading-slot src="{{url}}" fit="cover">
<van-loading slot="loading" type="spinner" size="30" vertical />
<text slot="error">加载失败</text>
</van-image>
</view>
</template>
<script>
import wepy from '@wepy/core';
wepy.component({
data: {
url: 'https://wx1.sinaimg.cn/large/e592b5dely4gfsut2a6nyj20j60yrjtx.jpg'
}
});
</script>
<style lang="less">
.wrapper {
width: 100%;
height: 100%;
background-color: #000;
image {
height: 100vh;
width: 100vw;
}
}
</style>
<config>
{
"usingComponents": {
"van-image": "~@/components/vant/image/index",
"van-loading": "~@/components/vant/loading/index",
}
}
</config>
......@@ -175,7 +175,8 @@
}
</style>
<template>
<view class="video-wrapper">
<introduce v-if="isShowIntroduce"></introduce>
<view class="video-wrapper" v-else>
<view class="prize">
<!--<prize-list :videoList="videoList" :userAccount="mainInfo && mainInfo.account && mainInfo.account.quantity || 0" bindchange="changeVideo" @getAwardsInfo="getAwardsInfo">
</prize-list>-->
......@@ -256,7 +257,8 @@
cornTextShow: true,
searchStyle: '',
avtivityModal: false, // 展示活动弹窗
awardsInfo: {}
awardsInfo: {},
isShowIntroduce: false
},
computed: {
......@@ -352,24 +354,7 @@
}
});
},
onShareAppMessage: function(res) {
if (res.from === 'button') {
console.log('onShareAppMessage2', res.target);
}
const openid = wx.getStorageSync('openId');
return {
title: `${(this.$wepy.userInfo && this.$wepy.userInfo.nickName) || '您的好朋友'}邀请您来抽奖啦~`,
path: `/pages/index?openid=${openid}&prizeId=${this.$wepy.awardsInfo.id}`,
imageUrl: decodeURIComponent(this.$wepy.awardsInfo.photoUrl),
success: function(res) {
let shareId = res.shareTickets[0];
console.log('shareId', shareId);
},
fail: function(res) {
console.log(res);
}
};
},
getAwards: function() {
const { id, photoUrl, name, chance } = this.awardsInfo;
if ((!id && id !== 0) || !this.mainInfo || !this.mainInfo.account) {
......@@ -505,13 +490,26 @@
},
toSearch() {
wx.navigateTo({url: '/pages/search'});
},
showInfo() {
this.isShowIntroduce = true;
}
},
async onLoad (options) {
async onLoad (query) {
const {scene} = wx.getLaunchOptionsSync();
if (scene === 1154) {
this.showInfo();
return;
}
wx.showShareMenu({
withShareTicket: false,
menus: ['shareAppMessage', 'shareTimeline']
});
this.cornText = '充值码错误';
// 获取分享人openid
if (options.openid) {
this.inviter = options.openid;
if (query.openid) {
this.inviter = query.openid;
}
// 获取头像安全距离
......@@ -522,7 +520,7 @@
await this.getOpenId();
// 获取奖品列表
this.videoList = await getPrizeList(options.prizeId);
this.videoList = await getPrizeList(query.prizeId);
this.getMainInfo();
flag = true;
......@@ -545,6 +543,11 @@
this.showActivity();
},
async onShow() {
const {scene} = wx.getLaunchOptionsSync();
if (scene === 1154) {
return;
}
// 获取主页信息
if (flag) {
this.getMainInfo();
......@@ -555,8 +558,29 @@
wx.removeStorageSync('userJoin');
this.showActivity();
}
},
onShareTimeline: function(res) {
return {
title: '又中奖了! 人品爆啊',
query: ''
};
},
onShareAppMessage: function(res) {
const openid = wx.getStorageSync('openId');
return {
title: `${(this.userInfo && this.userInfo.nickName) || '您的好朋友'}邀请您来抽奖啦~`,
path: `/pages/index?openid=${openid}&prizeId=${this.awardsInfo.id}`,
// todo: 图片大小减少了50%,但仍然偏大
imageUrl: decodeURIComponent(this.awardsInfo.photoUrl) + '?imageMogr2/auto-orient/thumbnail/500x800!/gravity/Center/crop/x500/blur/1x0/quality/75'
};
}
}, {
lifecycle: {
page: () => {
return ['onShareTimeline'];
}
}
});
</script>
<config>
......@@ -581,8 +605,12 @@
'video-list':'../components/custom/video',
"van-image": "../components/vant/image/index",
"van-loading": "../components/vant/loading/index",
"introduce": "../components/custom/introduce"
},
navigationStyle: "custom",
disableScroll: true
disableScroll: true,
singlePage: {
navigationBarFit: "squeezed"
}
}
</config>
......@@ -34,5 +34,4 @@ module.exports = {
appConfig: {
noPromiseAPI: ['createSelectorQuery']
}
}
};
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