作者 韩昌

配置分享好友和朋友圈

1 <script> 1 <script>
2 - export default {  
3 - onLaunch: function() {  
4 - console.log('App Launch')  
5 - },  
6 - onShow: function() {  
7 - console.log('App Show')  
8 - },  
9 - onHide: function() {  
10 - console.log('App Hide')  
11 - }  
12 - } 2 +export default {
  3 + onLaunch: function () {
  4 + console.log('App Launch')
  5 + },
  6 + onShow: function () {
  7 + console.log('App Show')
  8 + },
  9 + onHide: function () {
  10 + console.log('App Hide')
  11 + }
  12 +}
13 </script> 13 </script>
14 14
15 <style lang="scss"> 15 <style lang="scss">
16 - /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */  
17 - @import "uview-plus/index.scss";  
18 - .flexJ {  
19 - display: flex;  
20 - justify-content: space-between;  
21 - align-items: center;  
22 - }  
23 -  
24 - .flexC {  
25 - display: flex;  
26 - justify-content: center;  
27 - align-items: center;  
28 - }  
29 -  
30 - .flexA {  
31 - display: flex;  
32 - align-items: center;  
33 - }  
34 -  
35 - .flexV {  
36 - display: flex;  
37 - flex-direction: column;  
38 - justify-content: center;  
39 - align-items: center;  
40 - }  
41 -  
42 - .flexW {  
43 - display: flex;  
44 - flex-wrap: wrap;  
45 - justify-content: space-between;  
46 - }  
47 - .ples {  
48 - color: #000000e6;  
49 - font-size: 30rpx;  
50 - font-weight: 700;  
51 - }  
52 - .lineFeed {  
53 - word-wrap: break-word;  
54 - word-break: break-all;  
55 - white-space: pre-line;  
56 - }  
57 -  
58 - .ellipsis {  
59 - display: -webkit-box;  
60 - -webkit-box-orient: vertical;  
61 - text-overflow: ellipsis;  
62 - overflow: hidden;  
63 - -webkit-line-clamp: 1;  
64 - }  
65 -  
66 - .ellipsisT {  
67 - display: -webkit-box;  
68 - -webkit-box-orient: vertical;  
69 - text-overflow: ellipsis;  
70 - overflow: hidden;  
71 - -webkit-line-clamp: 2;  
72 - color: rgba(0, 0, 0, 0.9);  
73 - font-size: 24rpx;  
74 - }  
75 -  
76 - .iosAuto {  
77 - padding-bottom:constant(safe-area-inset-bottom);  
78 - padding-bottom: env(safe-area-inset-bottom);  
79 - } 16 +/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  17 +@import 'uview-plus/index.scss';
  18 +.flexJ {
  19 + display: flex;
  20 + justify-content: space-between;
  21 + align-items: center;
  22 +}
  23 +
  24 +.flexC {
  25 + display: flex;
  26 + justify-content: center;
  27 + align-items: center;
  28 +}
  29 +
  30 +.flexA {
  31 + display: flex;
  32 + align-items: center;
  33 +}
  34 +
  35 +.flexV {
  36 + display: flex;
  37 + flex-direction: column;
  38 + justify-content: center;
  39 + align-items: center;
  40 +}
  41 +
  42 +.flexW {
  43 + display: flex;
  44 + flex-wrap: wrap;
  45 + justify-content: space-between;
  46 +}
  47 +.ples {
  48 + color: #000000e6;
  49 + font-size: 30rpx;
  50 + font-weight: 700;
  51 +}
  52 +.lineFeed {
  53 + word-wrap: break-word;
  54 + word-break: break-all;
  55 + white-space: pre-line;
  56 +}
  57 +
  58 +.ellipsis {
  59 + display: -webkit-box;
  60 + -webkit-box-orient: vertical;
  61 + text-overflow: ellipsis;
  62 + overflow: hidden;
  63 + -webkit-line-clamp: 1;
  64 +}
  65 +
  66 +.ellipsisT {
  67 + display: -webkit-box;
  68 + -webkit-box-orient: vertical;
  69 + text-overflow: ellipsis;
  70 + overflow: hidden;
  71 + -webkit-line-clamp: 2;
  72 + color: rgba(0, 0, 0, 0.9);
  73 + font-size: 24rpx;
  74 +}
  75 +
  76 +.iosAuto {
  77 + padding-bottom: constant(safe-area-inset-bottom);
  78 + padding-bottom: env(safe-area-inset-bottom);
  79 +}
80 </style> 80 </style>
1 import App from './App' 1 import App from './App'
  2 +// import share from './utils/share'
  3 +import share from './utils/share'
  4 +
2 // main.js 5 // main.js
3 import uviewPlus from 'uview-plus' 6 import uviewPlus from 'uview-plus'
4 // #ifndef VUE3 7 // #ifndef VUE3
5 import Vue from 'vue' 8 import Vue from 'vue'
6 Vue.config.productionTip = false 9 Vue.config.productionTip = false
7 App.mpType = 'app' 10 App.mpType = 'app'
8 - 11 +// Vue.mixin(share)
9 try { 12 try {
10 function isPromise(obj) { 13 function isPromise(obj) {
11 - return (  
12 - !!obj &&  
13 - (typeof obj === "object" || typeof obj === "function") &&  
14 - typeof obj.then === "function"  
15 - ); 14 + return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'
16 } 15 }
17 16
18 // 统一 vue2 API Promise 化返回格式与 vue3 保持一致 17 // 统一 vue2 API Promise 化返回格式与 vue3 保持一致
19 uni.addInterceptor({ 18 uni.addInterceptor({
20 returnValue(res) { 19 returnValue(res) {
21 if (!isPromise(res)) { 20 if (!isPromise(res)) {
22 - return res; 21 + return res
23 } 22 }
24 return new Promise((resolve, reject) => { 23 return new Promise((resolve, reject) => {
25 - res.then((res) => { 24 + res.then(res => {
26 if (res[0]) { 25 if (res[0]) {
27 - reject(res[0]); 26 + reject(res[0])
28 } else { 27 } else {
29 - resolve(res[1]); 28 + resolve(res[1])
30 } 29 }
31 - });  
32 - });  
33 - },  
34 - });  
35 -} catch (error) { } 30 + })
  31 + })
  32 + }
  33 + })
  34 +} catch (error) {}
36 35
37 const app = new Vue({ 36 const app = new Vue({
38 ...App 37 ...App
@@ -45,10 +44,11 @@ import { createSSRApp } from 'vue' @@ -45,10 +44,11 @@ import { createSSRApp } from 'vue'
45 import methods from './api/methods.js' 44 import methods from './api/methods.js'
46 export function createApp() { 45 export function createApp() {
47 const app = createSSRApp(App) 46 const app = createSSRApp(App)
48 - app.config.globalProperties.$methods = methods  
49 - app.use(uviewPlus) 47 + app.config.globalProperties.$methods = methods
  48 + app.use(uviewPlus)
  49 + app.mixin(share)
50 return { 50 return {
51 app 51 app
52 } 52 }
53 } 53 }
54 -// #endif  
  54 +// #endif
@@ -333,8 +333,8 @@ const getShopDetailes = async id => { @@ -333,8 +333,8 @@ const getShopDetailes = async id => {
333 background: linear-gradient(139deg, #fb753cff 0%, #fb3e3cff 100%); 333 background: linear-gradient(139deg, #fb753cff 0%, #fb3e3cff 100%);
334 } 334 }
335 } 335 }
336 -image {  
337 - width: 100% !important;  
338 - height: 100% !important;  
339 -} 336 +// image {
  337 +// width: 100% !important;
  338 +// height: 100% !important;
  339 +// }
340 </style> 340 </style>
1 -"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./common/vendor.js"),n=require("./api/methods.js"),p={onLaunch:function(){console.log("App Launch")},onShow:function(){console.log("App Show")},onHide:function(){console.log("App Hide")}},o=s._export_sfc(p,[["__file","D:/vue/大健康商城/healthMall/App.vue"]]);function a(){const e=s.createSSRApp(o);return e.config.globalProperties.$methods=n.methods,e.use(s.uviewPlus),{app:e}}a().app.mount("#app");exports.createApp=a; 1 +"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./common/vendor.js"),n=require("./utils/share.js"),p=require("./api/methods.js"),i={onLaunch:function(){console.log("App Launch")},onShow:function(){console.log("App Show")},onHide:function(){console.log("App Hide")}},o=s._export_sfc(i,[["__file","D:/vue/大健康商城/healthMall/App.vue"]]);function a(){const e=s.createSSRApp(o);return e.config.globalProperties.$methods=p.methods,e.use(s.uviewPlus),e.mixin(n.share),{app:e}}a().app.mount("#app");exports.createApp=a;
1 -.u-nav-slot image{width:48rpx;height:48rpx}.indicator-num{padding:2px 0;background-color:rgba(0,0,0,.35);border-radius:100px;width:35px;display:flex;flex-direction:row;justify-content:center}.indicator-num__text{color:#fff;font-size:12px}.swiperBox{margin-bottom:32rpx}.info{width:702rpx;margin:0 auto}.line{width:100%;height:6rpx;opacity:1;background:#f7f8faff;margin:32rpx 0}.mainBox{padding:0 24rpx}.mainBox .commentNmu{margin-bottom:40rpx}.mainBox .commentNmu text{color:#1a1a1a;font-size:28rpx;font-weight:700}.mainBox .commentNmu .see{color:#ff7534;font-size:24rpx}.mainBox .commentNmu .see image{margin-left:2rpx;width:24rpx;height:24rpx}.mainBox .commentNull{color:rgba(0,0,0,.4);font-size:26rpx;margin-bottom:212rpx}.mainBox .commentNull image{width:348rpx;height:240rpx;margin-bottom:16rpx}.titles{color:#1a1a1a;font-size:28rpx;font-weight:700}.lineBox{margin:24rpx 0 30rpx}.lineBox .lines{width:149rpx;height:1rpx;opacity:1;border:0 solid #979797ff;background:#dcdee0ff}.lineBox text{margin:0 24rpx;color:#969799;font-size:24rpx}.btnBox{position:fixed;left:0;bottom:0;width:100%;height:120rpx;background:#ffffffff}.btnBox .left{margin-left:32rpx}.btnBox .left .leftIc{margin-right:34rpx;position:relative}.btnBox .left .leftIc .images{position:relative;width:48rpx;height:48rpx;margin-bottom:8rpx}.btnBox .left .leftIc .images image{width:48rpx;height:48rpx}.btnBox .left .leftIc text{color:#323233;font-size:20rpx}.btnBox .left .leftIc button{position:absolute;bottom:0;left:0;top:0;right:0;background:transparent;font-size:20rpx;border:none!important;padding:0!important;line-height:28rpx}.btnBox .left .leftIc button:after{border:none}.btnBox .buy{margin-right:32rpx;width:200rpx;height:80rpx;border-radius:80rpx;color:#fff;font-size:24rpx;font-weight:700;background:linear-gradient(139deg,#fb753cff 0%,#fb3e3cff 100%)}.btnBox .add{margin-right:14rpx;width:200rpx;height:80rpx;border-radius:80rpx;color:#fff;font-size:24rpx;font-weight:700;background:linear-gradient(139deg,#ffac0bff 0%,#ffc24aff 100%)}.btnBox .exchange{margin-right:32rpx;width:358rpx;height:80rpx;border-radius:80rpx;color:#fff;font-size:30rpx;font-weight:700;background:linear-gradient(139deg,#fb753cff 0%,#fb3e3cff 100%)}image{width:100%!important;height:100%!important} 1 +.u-nav-slot image{width:48rpx;height:48rpx}.indicator-num{padding:2px 0;background-color:rgba(0,0,0,.35);border-radius:100px;width:35px;display:flex;flex-direction:row;justify-content:center}.indicator-num__text{color:#fff;font-size:12px}.swiperBox{margin-bottom:32rpx}.info{width:702rpx;margin:0 auto}.line{width:100%;height:6rpx;opacity:1;background:#f7f8faff;margin:32rpx 0}.mainBox{padding:0 24rpx}.mainBox .commentNmu{margin-bottom:40rpx}.mainBox .commentNmu text{color:#1a1a1a;font-size:28rpx;font-weight:700}.mainBox .commentNmu .see{color:#ff7534;font-size:24rpx}.mainBox .commentNmu .see image{margin-left:2rpx;width:24rpx;height:24rpx}.mainBox .commentNull{color:rgba(0,0,0,.4);font-size:26rpx;margin-bottom:212rpx}.mainBox .commentNull image{width:348rpx;height:240rpx;margin-bottom:16rpx}.titles{color:#1a1a1a;font-size:28rpx;font-weight:700}.lineBox{margin:24rpx 0 30rpx}.lineBox .lines{width:149rpx;height:1rpx;opacity:1;border:0 solid #979797ff;background:#dcdee0ff}.lineBox text{margin:0 24rpx;color:#969799;font-size:24rpx}.btnBox{position:fixed;left:0;bottom:0;width:100%;height:120rpx;background:#ffffffff}.btnBox .left{margin-left:32rpx}.btnBox .left .leftIc{margin-right:34rpx;position:relative}.btnBox .left .leftIc .images{position:relative;width:48rpx;height:48rpx;margin-bottom:8rpx}.btnBox .left .leftIc .images image{width:48rpx;height:48rpx}.btnBox .left .leftIc text{color:#323233;font-size:20rpx}.btnBox .left .leftIc button{position:absolute;bottom:0;left:0;top:0;right:0;background:transparent;font-size:20rpx;border:none!important;padding:0!important;line-height:28rpx}.btnBox .left .leftIc button:after{border:none}.btnBox .buy{margin-right:32rpx;width:200rpx;height:80rpx;border-radius:80rpx;color:#fff;font-size:24rpx;font-weight:700;background:linear-gradient(139deg,#fb753cff 0%,#fb3e3cff 100%)}.btnBox .add{margin-right:14rpx;width:200rpx;height:80rpx;border-radius:80rpx;color:#fff;font-size:24rpx;font-weight:700;background:linear-gradient(139deg,#ffac0bff 0%,#ffc24aff 100%)}.btnBox .exchange{margin-right:32rpx;width:358rpx;height:80rpx;border-radius:80rpx;color:#fff;font-size:30rpx;font-weight:700;background:linear-gradient(139deg,#fb753cff 0%,#fb3e3cff 100%)}
  1 +"use strict";const e=require("../common/vendor.js"),s={data(){return{share:{title:"魅力女人",path:"/pages/login/login",imageUrl:"",desc:"",content:""}}},onShareTimeline(){return{title:this.share.title,path:this.share.path,imageUrl:this.share.imageUrl}},onShareAppMessage(r){return{title:this.share.title,path:this.share.path,imageUrl:this.share.imageUrl,desc:this.share.desc,content:this.share.content,success(t){e.index.showToast({title:"分享成功"})},fail(t){e.index.showToast({title:"分享失败",icon:"none"})}}}};exports.share=s;
  1 +export default {
  2 + data() {
  3 + return {
  4 + //设置默认的分享参数
  5 + share: {
  6 + title: '魅力女人',
  7 + path: '/pages/login/login',
  8 + imageUrl: '',
  9 + desc: '',
  10 + content: ''
  11 + }
  12 + }
  13 + },
  14 + onShareTimeline() {
  15 + return {
  16 + title: this.share.title,
  17 + path: this.share.path,
  18 + imageUrl: this.share.imageUrl
  19 + }
  20 + },
  21 + onShareAppMessage(res) {
  22 + return {
  23 + title: this.share.title,
  24 + path: this.share.path,
  25 + imageUrl: this.share.imageUrl,
  26 + desc: this.share.desc,
  27 + content: this.share.content,
  28 + success(res) {
  29 + uni.showToast({
  30 + title: '分享成功'
  31 + })
  32 + },
  33 + fail(res) {
  34 + uni.showToast({
  35 + title: '分享失败',
  36 + icon: 'none'
  37 + })
  38 + }
  39 + }
  40 + }
  41 +}