about.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="about">
  3. <view class="content">
  4. <view class="qrcode">
  5. <image src="https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/app_download.png" @longtap="save"></image>
  6. <text class="tip">扫码体验uni-app</text>
  7. </view>
  8. <view class="desc">
  9. <text class="code">uni-app</text>
  10. 是一个使用 <text class="code">Vue.js</text> 开发跨平台应用的前端框架。
  11. </view>
  12. <view class="source">
  13. <view class="title">本示例源码获取方式:</view>
  14. <view class="source-list">
  15. <view class="source-cell">
  16. <text space="nbsp">1. </text>
  17. <text>下载 HBuilderX,新建 uni-app 项目时选择 <text class="code">Hello uni-app</text> 模板。</text>
  18. </view>
  19. <view class="source-cell">
  20. <text space="nbsp">2. </text>
  21. <u-link class="link" :href="'https://github.com/dcloudio/hello-uniapp'" :text="'https://github.com/dcloudio/hello-uniapp'"></u-link>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- #ifdef APP-PLUS -->
  26. <button type="primary" @click="share">分享</button>
  27. <!-- #endif -->
  28. </view>
  29. <!-- #ifdef APP-PLUS -->
  30. <view class="version">
  31. 当前版本:{{version}}
  32. </view>
  33. <!-- #endif -->
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. providerList: [],
  41. version: ''
  42. }
  43. },
  44. onLoad() {
  45. // #ifdef APP-PLUS
  46. this.version = plus.runtime.version;
  47. uni.getProvider({
  48. service: 'share',
  49. success: (result) => {
  50. const data = [];
  51. for (let i = 0; i < result.provider.length; i++) {
  52. switch (result.provider[i]) {
  53. case 'weixin':
  54. data.push({
  55. name: '分享到微信好友',
  56. id: 'weixin'
  57. });
  58. data.push({
  59. name: '分享到微信朋友圈',
  60. id: 'weixin',
  61. type: 'WXSenceTimeline'
  62. });
  63. break;
  64. case 'qq':
  65. data.push({
  66. name: '分享到QQ',
  67. id: 'qq'
  68. });
  69. break;
  70. default:
  71. break;
  72. }
  73. }
  74. this.providerList = data;
  75. },
  76. fail: (error) => {
  77. console.log('获取分享通道失败' + JSON.stringify(error));
  78. }
  79. });
  80. // #endif
  81. },
  82. methods: {
  83. // #ifdef APP-PLUS
  84. save() {
  85. uni.showActionSheet({
  86. itemList: ['保存图片到相册'],
  87. success: () => {
  88. plus.gallery.save('https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/app_download.png', function() {
  89. uni.showToast({
  90. title: '保存成功',
  91. icon: 'none'
  92. });
  93. }, function() {
  94. uni.showToast({
  95. title: '保存失败,请重试!',
  96. icon: 'none'
  97. });
  98. });
  99. }
  100. });
  101. },
  102. share(e) {
  103. if (this.providerList.length === 0) {
  104. uni.showModal({
  105. title: '当前环境无分享渠道!',
  106. showCancel: false
  107. });
  108. return;
  109. }
  110. let itemList = this.providerList.map(function(value) {
  111. return value.name;
  112. })
  113. uni.showActionSheet({
  114. itemList: itemList,
  115. success: (res) => {
  116. let provider = this.providerList[res.tapIndex].id;
  117. uni.share({
  118. provider: provider,
  119. scene: this.providerList[res.tapIndex].type && this.providerList[res.tapIndex].type === 'WXSenceTimeline' ?
  120. 'WXSenceTimeline' : "WXSceneSession",
  121. type: (provider === "qq") ? 1 : 0,
  122. title: '欢迎体验uni-app',
  123. summary: 'uni-app 是一个使用 Vue.js 开发跨平台应用的前端框架',
  124. imageUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b09e38e0-5168-11eb-b680-7980c8a877b8.jpg',
  125. href: "https://m3w.cn/uniapp",
  126. success: (res) => {
  127. console.log("success:" + JSON.stringify(res));
  128. },
  129. fail: (e) => {
  130. uni.showModal({
  131. content: e.errMsg,
  132. showCancel: false
  133. })
  134. }
  135. });
  136. }
  137. })
  138. }
  139. // #endif
  140. }
  141. }
  142. </script>
  143. <style>
  144. page,
  145. view {
  146. display: flex;
  147. }
  148. page {
  149. min-height: 100%;
  150. background-color: #FFFFFF;
  151. }
  152. image {
  153. width: 360rpx;
  154. height: 360rpx;
  155. }
  156. .about {
  157. flex-direction: column;
  158. flex: 1;
  159. }
  160. .content {
  161. flex: 1;
  162. padding: 30rpx;
  163. flex-direction: column;
  164. justify-content: center;
  165. }
  166. .qrcode {
  167. display: flex;
  168. align-items: center;
  169. flex-direction: column;
  170. }
  171. .qrcode .tip {
  172. margin-top: 20rpx;
  173. }
  174. .desc {
  175. margin-top: 30rpx;
  176. display: block;
  177. }
  178. .code {
  179. color: #e96900;
  180. background-color: #f8f8f8;
  181. }
  182. button {
  183. width: 100%;
  184. margin-top: 40rpx;
  185. }
  186. .version {
  187. height: 80rpx;
  188. line-height: 80rpx;
  189. justify-content: center;
  190. color: #ccc;
  191. }
  192. .source {
  193. margin-top: 30rpx;
  194. flex-direction: column;
  195. }
  196. .source-list {
  197. flex-direction: column;
  198. }
  199. .link {
  200. color: #007AFF;
  201. }
  202. </style>