微信分享你們見怪不怪了!就是再APP點擊分享,而後喚起微信,分享當前頁面到朋友圈或者分享給朋友。html
因此,我開發了這樣的一個工具。前端
就是一個帶有標題、描述文字、LOGO、分享來源的一個小卡片。vue
這個App是使用uni-app框架開發的。
沒了解過能夠取訪問:https://uniapp.dcloud.io/
瞭解一下!json
uni-app是一個使用 Vue.js 開發跨平臺應用的前端框架,開發者編寫一套代碼,可編譯到iOS、Android、H五、小程序等多個平臺。小程序
一、先下載開發工具HBuilderX
二、建立項目前端框架
三、選擇uni-app微信
四、建立完成後就會有一個模板了。app
五、打開pages/index/index.vue,拷貝下面代碼進去框架
<template> <view class="content"> <form @submit="formSubmit" @reset="formReset"> <input class="uni-input" name="title" placeholder="文章標題"/> <input class="uni-input" name="miaoshu" placeholder="文章描述"/> <input class="uni-input" name="imgurl" placeholder="圖片地址"/> <input class="uni-input" name="url" placeholder="跳轉連接"/> <button formType="submit">分享到微信羣或好友</button> <button type="default" formType="reset">清空以上信息</button> <view class="banquan">裏客雲科技開發</view> </form> </view> </template> <script> export default { data() { return {} }, // 執行事件 methods:{ formSubmit:function(e){ var title = e.detail.value.title; var miaoshu = e.detail.value.miaoshu; var imgurl = e.detail.value.imgurl; var url = e.detail.value.url; uni.share({ provider: "weixin", scene: "WXSceneSession", type: 0, href: url, title: title, summary: miaoshu, imageUrl: imgurl, success: function (res) { console.log(JSON.stringify(res)); uni.showToast({ title: '已分享', duration: 2000 }); }, fail: function (err) { var errrr = JSON.stringify(err); if(errrr){ uni.showModal({ title: '表單不能留空', content: '請完善全部信息再發起分享', success: function (res) { if (res.confirm) { console.log('用戶點擊肯定'); } else if (res.cancel) { console.log('用戶點擊取消'); } } }); } } }); }, }, } </script> <style> *{margin: 0;padding: 0;} .content{ width: 100%; margin: 20px auto; } .content .uni-input{ width: 80%; height: 45px; margin: 8px auto; border: 1px solid #ccc; margin-bottom: 8px; padding-left: 8px; border-radius: 10px; font-size: 16px; color: #333; } .content button{ width: 80%; height: 45px; line-height: 45px; margin: 8px auto; border: 1px solid #ccc; margin-bottom: 8px; padding-left: 8px; border-radius: 10px; font-size: 16px; color: #fff; background: #56b273; border: none; } button::after{ border: none;} .content .banquan{ text-align: center; margin-top: 50px; font-size: 15px; color: #666; } </style>
六、打開manifest.json,點擊App模塊權限配置,給Share(分享)打勾,表明咱們給這個App注入一個分享權限。ide
七、點擊App SDK配置,進去找到分享,填寫appid和appsecret
appid和appsecret在哪弄?
這是須要前往微信開放平臺申請的!
進去註冊一個賬號,登陸,建立移動應用。
填寫資料,上傳LOGO便可,等待審覈完成便可,此處省略詳細的講解,自行研究。
八、配置好了以後,App已是開發好了,製做自定義基座,在真機上進行調試。
其中Android包名必定要填你在微信開放平臺建立的應用時填寫的報名一致。
還有,微信開放平臺填應用簽名的時候,也是要獲取的,應用簽名要用簽名檢測工具
https://res.wx.qq.com/open/zh...
安裝上面的簽名工具在你的安卓設備
安裝你打包好的App
而後輸入包名便可獲取
而後再次調試,是否能夠喚起分享,若是能夠那就能夠打包了。
打包完成,就能夠在你的安卓設備安裝使用!
https://www.lanzous.com/i39swli
做者:TANKING
時間:2019-03-01
網站:http://likeyunba.com微信:likeyunba520