123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <template>
- <view></view>
- </template>
- <script>
- import wx from 'weixin-js-sdk'
- import * as API_WeiXin from '@/apis/weixin'
- export default {
- name: 'Share',
- props: {
-
- },
- data() {
- return {
- id:'',
- title:'',
- url:'',
- isLoading: false,
- nowItem: {
- shareTitle: '',
- shareImg: '',
- shareDescription: ''
- }
- }
- },
- created() {},
- methods: {
- addPoint(){
- if(this.id){
- API_WeiXin.addPoint({
- id:this.id,
- pointCode:"70007"
- }).then(response => {
- //("积分添加成功")
- uni.showToast({
- title: "分享成功",
- icon: "none"
- })
-
- })
- }
-
- },
-
- //获取微信jssdk配置信息
- get_wx_config() {
-
-
- API_WeiXin.getConfig(window.location.href.split("#")[0]).then(response => {
-
-
- var wxconfig = response.data.wxConfig;
-
- //(wxconfig.nonceStr)
- //this.wxConfig = wxconfig;
-
- wx.config({
- debug: false, // 开启调试模式,
- appId: wxconfig.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
- timestamp: wxconfig.timestamp, // 必填,生成签名的时间戳
- nonceStr: wxconfig.nonceStr, // 必填,生成签名的随机串
- signature: wxconfig.signature, // 必填,签名,见附录1
- jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage',
- 'onMenuShareQQ', 'onMenuShareQZone'] ,// 必填,需要使用的JS接口列表,所有JS接口列表见附录2
- //'checkJsApi',,'updateAppMessageShareData','updateTimelineShareData'
- });
-
- //("aaa")
- //this.wxShare()
- }).catch(error => {
- //(error)
- //("errorerror")
- })
- },
- setUrl(url){
- this.url=process.car.IMG_URL+"railroad-phone/#"+url;
- },
- setTitle(text,id){
- this.title=text;
- this.id=id;
- this.wxShare()
-
- },
- //微信分享自定义
- wxShare() {
- var userInfo=this.carhelp.getPersonInfo()
- var img=process.car.IMG_URL+"railroad-phone/"+require("@/assets/img/logo.png")
-
- var title=this.title
- // var desc=
- let joinUrl = this.url;
- //(img);
- //(title);
- //(joinUrl);
- var _this = this;
-
- wx.ready(function() {
-
-
- // wx.updateTimelineShareData({
- // title: title,
- // // desc:desc ,
- // link: joinUrl,
- // imgUrl: img,
- // success: function() {
- // if(userInfo){
- // //_this.addPoint()
- // }
- // // 设置成功
- // _this.$emit("wxShare",null);
- // }
- // })
- // wx.updateAppMessageShareData({
- // title: title,
- // // desc:desc ,
- // link: joinUrl,
- // imgUrl: img,
- // success: function() {
- // if(userInfo){
- // //_this.addPoint()
- // }
- // // 设置成功
- // _this.$emit("wxShare",null);
- // }
- // })
- wx.onMenuShareAppMessage({
- title: title,
- desc:"[电管家]" ,
- link: joinUrl,
- imgUrl: img,
- success: function() {
- //('111')
- if(userInfo){
- _this.addPoint()
- }
- // 设置成功
- _this.$emit("wxShare",null);
- }
- })
- wx.onMenuShareTimeline({
- title: title,
- desc:"[电管家]" ,
- link: joinUrl,
- imgUrl: img,
- success: function() {
- //('222')
- if(userInfo){
- _this.addPoint()
- }
- // 设置成功
- _this.$emit("wxShare",null);
- }
- })
- });
- }
- },
- mounted() {
- this.url=window.location.href;
- this.get_wx_config();
- },
- }
- </script>
- <style>
- </style>
|