|
@@ -37,6 +37,7 @@
|
|
|
<view class="funItem" @click="smChange()">
|
|
|
<label class="simple-radio"
|
|
|
><radio
|
|
|
+ :disabled="generateFlag == true"
|
|
|
:value="messageFlag"
|
|
|
color="#7c5345"
|
|
|
:checked="messageFlag == true"
|
|
@@ -48,6 +49,7 @@
|
|
|
<view class="funItem">
|
|
|
<label class="simple-radio" @click="snChange()"
|
|
|
><radio
|
|
|
+ :disabled="generateFlag == true"
|
|
|
:value="serviceNumberFlag"
|
|
|
color="#7c5345"
|
|
|
:checked="serviceNumberFlag == true"
|
|
@@ -59,6 +61,7 @@
|
|
|
<view class="funItem">
|
|
|
<label class="simple-radio" @click="vfChange()"
|
|
|
><radio
|
|
|
+ :disabled="generateFlag == true"
|
|
|
:value="voipFlag"
|
|
|
color="#7c5345"
|
|
|
:checked="voipFlag == true"
|
|
@@ -69,10 +72,10 @@
|
|
|
>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <button class="btn1" open-type="share" v-if="shareFlag">
|
|
|
- 确认分享
|
|
|
+ <button class="btn1" @click="shareUserLink()" v-if="!generateFlag">
|
|
|
+ 生成分享链接
|
|
|
</button>
|
|
|
- <button class="btn1" v-else @click="unShare()">暂不可分享</button>
|
|
|
+ <button class="btn1" open-type="share" v-else>确认分享</button>
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
@@ -86,83 +89,91 @@ export default {
|
|
|
voipFlag: false,
|
|
|
shareFlag: false,
|
|
|
shareId: "",
|
|
|
+ generateFlag: false,
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 切换短信分享
|
|
|
smChange() {
|
|
|
this.messageFlag = !this.messageFlag;
|
|
|
- this.shareUserLink();
|
|
|
},
|
|
|
+
|
|
|
+ // 切换服务号分享
|
|
|
snChange() {
|
|
|
this.serviceNumberFlag = !this.serviceNumberFlag;
|
|
|
- this.shareUserLink();
|
|
|
},
|
|
|
|
|
|
+ // 切换语音分享
|
|
|
vfChange() {
|
|
|
this.voipFlag = !this.voipFlag;
|
|
|
- this.shareUserLink();
|
|
|
},
|
|
|
onShareAppMessage() {
|
|
|
return {
|
|
|
title: "好友向您分享了一台设备",
|
|
|
path:
|
|
|
"/pagesA/sharePages/sharePages?phone=" +
|
|
|
- this.phone +
|
|
|
+ uni.getStorageSync("phone") +
|
|
|
"&devInfo=" +
|
|
|
JSON.stringify(this.devInfo) +
|
|
|
"&shareId=" +
|
|
|
this.shareId,
|
|
|
};
|
|
|
},
|
|
|
+
|
|
|
+ // 调用后端接口生成分享链接
|
|
|
shareUserLink() {
|
|
|
- let shareParam = {
|
|
|
- devId: this.devInfo.devId,
|
|
|
- sharerUserId: uni.getStorageSync("userId"),
|
|
|
- sharerPhone: uni.getStorageSync("phone"),
|
|
|
- sharedUserId: "",
|
|
|
- sharedPhone: "",
|
|
|
- messageFlag: this.messageFlag == true ? 0 : 1,
|
|
|
- serviceNumberFlag: this.serviceNumberFlag == true ? 0 : 1,
|
|
|
- voipFlag: this.voipFlag == true ? 0 : 1,
|
|
|
- };
|
|
|
- this.$http
|
|
|
- .post("wap/share/shareByUrl", shareParam, {
|
|
|
- header: {
|
|
|
- "Content-Type": "application/json;charset=UTF-8",
|
|
|
- },
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res.data.code == 200) {
|
|
|
- // uni.showToast({
|
|
|
- // title: itemTitle,
|
|
|
- // icon: "none",
|
|
|
- // duration: 1500,
|
|
|
- // });
|
|
|
- this.shareFlag = true;
|
|
|
- this.shareId = res.data.data.shareId;
|
|
|
- } else {
|
|
|
- this.shareFlag = false;
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const shareParam = {
|
|
|
+ devId: this.devInfo.devId,
|
|
|
+ sharerUserId: uni.getStorageSync("userId"),
|
|
|
+ sharerPhone: uni.getStorageSync("phone"),
|
|
|
+ sharedUserId: "",
|
|
|
+ sharedPhone: "",
|
|
|
+ messageFlag: this.messageFlag ? 0 : 1,
|
|
|
+ serviceNumberFlag: this.serviceNumberFlag ? 0 : 1,
|
|
|
+ voipFlag: this.voipFlag ? 0 : 1,
|
|
|
+ };
|
|
|
+
|
|
|
+ this.$http
|
|
|
+ .post("wap/share/shareByUrl", shareParam, {
|
|
|
+ header: {
|
|
|
+ "Content-Type": "application/json;charset=UTF-8",
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ const { code, data, message } = res.data;
|
|
|
+ if (code == 200 && data.shareId) {
|
|
|
+ this.shareId = data.shareId;
|
|
|
+ this.generateFlag = true;
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: message || "生成分享链接失败",
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ this.generateFlag = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
uni.showToast({
|
|
|
- title: res.data.message,
|
|
|
+ title: "网络异常,请稍后再试",
|
|
|
icon: "none",
|
|
|
- duration: 1500,
|
|
|
});
|
|
|
- }
|
|
|
- });
|
|
|
+ reject();
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
unShare() {
|
|
|
uni.showToast({
|
|
|
title: "当前用户暂不可分享",
|
|
|
icon: "none",
|
|
|
- duration: 1500,
|
|
|
});
|
|
|
},
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
this.devInfo = JSON.parse(options.devInfo);
|
|
|
- setTimeout(() => {
|
|
|
- this.shareUserLink();
|
|
|
- }, 500);
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.shareUserLink();
|
|
|
+ // }, 500);
|
|
|
},
|
|
|
};
|
|
|
</script>
|