|
@@ -51,7 +51,6 @@
|
|
title="立即赠送给好友"
|
|
title="立即赠送给好友"
|
|
:options="options"
|
|
:options="options"
|
|
@select="onSelect"
|
|
@select="onSelect"
|
|
- :aria-label="giveLink"
|
|
|
|
class="linkCodeShare"
|
|
class="linkCodeShare"
|
|
/>
|
|
/>
|
|
<van-overlay :show="showGive" @click="showGive = false">
|
|
<van-overlay :show="showGive" @click="showGive = false">
|
|
@@ -70,12 +69,15 @@
|
|
<van-button
|
|
<van-button
|
|
style="padding: 0 1rem;border-radius: 0.4rem;"
|
|
style="padding: 0 1rem;border-radius: 0.4rem;"
|
|
color="#26A2FF"
|
|
color="#26A2FF"
|
|
|
|
+ class="copyCode"
|
|
@click="getCourseCode"
|
|
@click="getCourseCode"
|
|
- >复制链接</van-button
|
|
|
|
- >
|
|
|
|
|
|
+ >复制链接</van-button>
|
|
|
|
+ <!-- <button ref="copys" :disabled="giveLink == ''" id="copyLink" data-clipboard-action="copy" data-clipboard-target="#copy_text" @click="copy">复制</button> -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</van-overlay>
|
|
</van-overlay>
|
|
|
|
+
|
|
|
|
+ <input type="text" v-model="giveLink" id="copy_text" style="opacity: 0">
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
@@ -94,7 +96,7 @@ export default {
|
|
finished: false,
|
|
finished: false,
|
|
activeTab: 0,
|
|
activeTab: 0,
|
|
title: "课程详情",
|
|
title: "课程详情",
|
|
- giveLink: "",
|
|
|
|
|
|
+ giveLink: "232123123",
|
|
noDate: false,
|
|
noDate: false,
|
|
showGive: false,
|
|
showGive: false,
|
|
options: [
|
|
options: [
|
|
@@ -123,7 +125,8 @@ export default {
|
|
transferInAmount: 0 //已转出
|
|
transferInAmount: 0 //已转出
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- recordList: []
|
|
|
|
|
|
+ recordList: [],
|
|
|
|
+ copyBtn:null,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -138,29 +141,28 @@ export default {
|
|
created() {
|
|
created() {
|
|
this.init();
|
|
this.init();
|
|
},
|
|
},
|
|
|
|
+ mounted(){
|
|
|
|
+
|
|
|
|
+ this.copyBtn = new Clipboard(this.$refs.copys);
|
|
|
|
+
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
|
|
+ //复制
|
|
|
|
+ copy () {
|
|
|
|
+ let _this = this
|
|
|
|
+ let clipboard = _this.copyBtn
|
|
|
|
+ clipboard.on('success', function () {
|
|
|
|
+ _this.$toast.success('复制成功')
|
|
|
|
+ })
|
|
|
|
+ clipboard.on('error', function (e) {
|
|
|
|
+ console.error('复制失败',e)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
// 分享课程方式选择
|
|
// 分享课程方式选择
|
|
onSelect(option) {
|
|
onSelect(option) {
|
|
if (option.name == "复制链接") {
|
|
if (option.name == "复制链接") {
|
|
this.showGive = true;
|
|
this.showGive = true;
|
|
this.showShare = false;
|
|
this.showShare = false;
|
|
- // this.$dialog
|
|
|
|
- // .confirm({
|
|
|
|
- // title: "赠送课程给好友",
|
|
|
|
- // message: "请提醒好友尽快点击链接领取课程份额。链接分享后,1小时内有效"
|
|
|
|
- // })
|
|
|
|
- // .then(() => {
|
|
|
|
- // this.showGive = true;
|
|
|
|
- // createCourseCode(this.courseDetail.subjectId).then(res => {
|
|
|
|
- // this.giveLink = `${
|
|
|
|
- // window.location.href.split("#")[0]
|
|
|
|
- // }#/courseDetail/${this.$route.params.id}?code=${res}`;
|
|
|
|
- // this.copyLink(this.giveLink);
|
|
|
|
- // });
|
|
|
|
- // })
|
|
|
|
- // .catch(err => {
|
|
|
|
- // this.showShare = false;
|
|
|
|
- // });
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 获取课程码
|
|
// 获取课程码
|
|
@@ -169,86 +171,37 @@ export default {
|
|
this.giveLink = `${window.location.href.split("#")[0]}#/courseDetail/${
|
|
this.giveLink = `${window.location.href.split("#")[0]}#/courseDetail/${
|
|
this.$route.params.id
|
|
this.$route.params.id
|
|
}?code=${res}`;
|
|
}?code=${res}`;
|
|
- this.copyLink(this.giveLink);
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- // 微信分享/未使用
|
|
|
|
- wxShare() {
|
|
|
|
- let that = this;
|
|
|
|
- let url = window.location.href;
|
|
|
|
- let newurl = url.split("#")[0];
|
|
|
|
- axios(
|
|
|
|
- "https://i.g107.com/564/Ajax/getJsSdk",
|
|
|
|
- {
|
|
|
|
- url: newurl
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- headers: {
|
|
|
|
- "Content-Type": "application/x-www-form-urlencoded"
|
|
|
|
- },
|
|
|
|
- transformRequest: [
|
|
|
|
- function(data) {
|
|
|
|
- // 对 data 进行任意转换处理
|
|
|
|
- return qs.stringify(data);
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
- .then(function(response) {
|
|
|
|
- console.log(response);
|
|
|
|
- var config = response.data;
|
|
|
|
- var adress = "ceshi";
|
|
|
|
- wx.config({
|
|
|
|
- debug: false,
|
|
|
|
- appId: config.appId,
|
|
|
|
- timestamp: config.timestamp,
|
|
|
|
- nonceStr: config.nonceStr,
|
|
|
|
- signature: config.signature,
|
|
|
|
- jsApiList: ["updateAppMessageShareData"]
|
|
|
|
- });
|
|
|
|
- wx.ready(function() {
|
|
|
|
- wx.updateAppMessageShareData({
|
|
|
|
- title: `${that.courseDetail.subjectName}`, // 分享标题
|
|
|
|
- desc: `分享简介`, // 分享描述
|
|
|
|
- link: `${window.location.href.split("#")[0]}#/courseAdDetail/${
|
|
|
|
- this.$route.params.id
|
|
|
|
- }/code=${res}`, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
- imgUrl: `${that.courseDetail.subjectThumb}`, // 分享图标
|
|
|
|
- success: function() {
|
|
|
|
- // 设置成功
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ this.copyLink().then(()=>{
|
|
|
|
+ this.$toast.success('复制成功')
|
|
})
|
|
})
|
|
- .catch(function(error) {
|
|
|
|
- console.log(error);
|
|
|
|
- });
|
|
|
|
|
|
+ // this.showGive = true;
|
|
|
|
+ });
|
|
},
|
|
},
|
|
// 复制剪切板
|
|
// 复制剪切板
|
|
copyLink() {
|
|
copyLink() {
|
|
- //创建输入框
|
|
|
|
- var input = document.createElement("input");
|
|
|
|
- //对输入框进行赋值
|
|
|
|
- input.value = this.giveLink;
|
|
|
|
-
|
|
|
|
- //添加到body中。
|
|
|
|
- document.body.appendChild(input);
|
|
|
|
- input.select();
|
|
|
|
- var copyResult = document.execCommand("copy");
|
|
|
|
- if (copyResult) {
|
|
|
|
- this.$toast.success("复制成功~");
|
|
|
|
- this.showGive = false;
|
|
|
|
- //移除
|
|
|
|
- document.body.removeChild(input);
|
|
|
|
- } else {
|
|
|
|
- navigator.clipboard.writeText(str);
|
|
|
|
- this.$toast.success("复制成功~");
|
|
|
|
- this.showGive = false;
|
|
|
|
|
|
+ let oInput = document.createElement("input");
|
|
|
|
+ oInput.value = this.giveLink;
|
|
|
|
+ document.body.appendChild(oInput);
|
|
|
|
+ oInput.select(); // 选择对象
|
|
|
|
+ if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {//兼容ios
|
|
|
|
+ if (!document.execCommand("Copy")) {
|
|
|
|
+ oInput.setSelectionRange(0, oInput.value.length);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ document.execCommand("Copy"); // 执行浏览器复制命令
|
|
|
|
+ document.body.removeChild(oInput);
|
|
|
|
+ return new Promise((resolve,reject)=>{
|
|
|
|
+ if (document.execCommand("Copy")) {
|
|
|
|
+ resolve(this.giveLink);
|
|
|
|
+ }else{
|
|
|
|
+ reject(this.giveLink);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
// 分享弹出
|
|
// 分享弹出
|
|
comfirmCode() {
|
|
comfirmCode() {
|
|
this.showGive = true;
|
|
this.showGive = true;
|
|
|
|
+ // this.getCourseCode()
|
|
},
|
|
},
|
|
// 触底加载
|
|
// 触底加载
|
|
getMoreList(done) {
|
|
getMoreList(done) {
|
|
@@ -419,6 +372,16 @@ img {
|
|
.copy {
|
|
.copy {
|
|
text-align: center;
|
|
text-align: center;
|
|
margin-top: 0.5rem;
|
|
margin-top: 0.5rem;
|
|
|
|
+ #copyLink{
|
|
|
|
+ padding: 0px 1rem;
|
|
|
|
+ border-radius: 0.4rem;
|
|
|
|
+ color: white;
|
|
|
|
+ background: rgb(38, 162, 255);
|
|
|
|
+ border-color: rgb(38, 162, 255);
|
|
|
|
+ line-height: .75rem;
|
|
|
|
+ border: 0;
|
|
|
|
+ outline: none;
|
|
|
|
+ }
|
|
p {
|
|
p {
|
|
font-size: 0.22rem;
|
|
font-size: 0.22rem;
|
|
color: #888;
|
|
color: #888;
|