Vue enables WeChat to share the circle of friends, send examples of friends, and vue circle of friends

Source: Internet
Author: User
Tags es6 tutorial

Vue allows you to share a circle of friends, send examples of friends, and vue circle of friends.

First download jssdk to introduce the project. Here I will not talk about how to install it. If not, you can take a look at the npm tutorial and es6 tutorial.

Step 1,Introduce jssdk. Here, I download jssdk and use webpack to introduce the entry.

Step 2,Get detailed data and render the page.

Step 3,After obtaining detailed data, you can obtain configuration information such as signature and token.

Step 4,Configure the desired functions through api

Code:

<Template> <div class = "details"> <player: videoUrl = "details. videoUrl ": coverUrl =" details. coverUrl ": videoId =" details. videoId "/> <div class =" description "> <span class =" label ": style =" {backgroundColor: details. videoLabelColor} ">{{ details. videoLabel }}</span> <p class = "title" >{{ details. videoTitle }</p> <p class = "info"> <span >{{ details. mtime }}</span> <I class = "iconfont icon --"> </I> {details. videoPlayTi Mes }}</p> <p class = "summary"> overview </p> <p class = "article ql-editor" v-html = "details. videoDescription "> </p> </div> </template> <script> import player from '@/components/player' import {videoDtails, getApp} from '@/config/api'/* eslint-disable no-undef */export default {components: {player}, data () {return {details :{}, appId: '', signature:'', timestamp: '', nonceStr:''}, beforeDestro Y () {document.querySelector('.html title '). text = 'title'}, mounted () {// obtain detailed data <span class = "space" style = "white-space: pre; display: inline-block; text-indent: 2em; line-height: inherit; "> let url = window. location. href. split ("#") [0] </span> this. $ http. get (this, videoDtails, {videoId: this. $ route. query. id}, res => {this. details = res document.querySelector('.html title '). text = this. details. videoTitle This. $ http. get (this, getApp, {url: url, refresh: true}, res => {this. appId = res. appId this. signature = res. signature this. timestamp = res. timestamp this. nonceStr = res. nonceStr this. shard (url)}, methods: {shard (url) {wx. config ({debug: true, // enable the debugging mode. The returned values of all called APIs are displayed in the client alert. To view the input parameters, you can open them on the pc, the parameter information is output through log and printed only on the pc end. AppId: this. appId, // required. timestamp: this is the unique identifier of the public account. timestamp, // required. The signature timestamp nonceStr: this. nonceStr, // required. The random signature string signature: this. signature, // required, signature. For details, see Appendix 1 jsApiList: ['onmenusharetimeline', 'onmenushareappmessage'] // required. List of JS interfaces to be used, for a list of all JS interfaces, see Appendix 2}) wx. onMenuShareTimeline ({title: this. details. videoTitle, // share the title link: url + '#/... ', // share a link. The domain name or path of this link must be consistent with the official account JS Security Domain Name of the current page. imgUrl: this. details. coverUrl, // share icon success () {alert ('shared moments successfully') // callback function executed after the user confirms the sharing}, cancel () {// callback function executed after the user cancels the sharing}) wx. onMenuShareAppMessage ({title: this. details. videoTitle, // share the title desc: this. details. videoTitle, // share description link: url + '#/... ', // share a link. The domain name or path of this link must be consistent with the official account JS Security Domain Name of the current page. imgUrl: this. details. coverUrl, // share icon type: 'video', // share type, music, video, or link. If not specified, the default value is link dataUrl: this. details. videoUrl. // if the type is music or video, a data link is provided. The default value is success: function () {alert ('shared with friends successfully ') // callback function executed after the user confirms the sharing}, cancel: function () {// callback function executed after the user cancels the sharing }})}}} </script> <style lang = "less" scoped>. details {overflow: hidden ;. description {padding: 10px ;. label {display: inline-block; padding: 0 10px; height: 22px; line-height: 22px; color: # fff; font-size: 12px; text-align: center ;}. title {line-height: 30px; font-size: 18px ;}. info {line-height: 26px; color: #949494; span {margin-right: 15px ;}. iconfont {font-size: 12px ;}}. summary {margin-top: 20px; color: # 4b4b4b; font-size: 16px ;}. article {margin-top: 10px ;}}</style>

The above vue is used to share the circle of friends. The example of sending a friend is all the content shared by the small editor. I hope you can give us a reference and support the customer's house.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.