Commit 2f2f1a2f authored by jyx's avatar jyx

添加到桌面功能

parent e4cda068
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</block> </block>
</view> </view>
<button v-if="signData.list[signData.todayMsgIndexInWeek].rewardMoreType==2" open-type="share" <button v-if="signData.list[signData.todayMsgIndexInWeek].rewardMoreType==2" open-type="share"
:class="signBtnStyle" @click="sign">{{signData.buttonText}}</button> :class="signBtnStyle">{{signData.buttonText}}</button>
<button v-else :class="signBtnStyle" @click="sign">{{signData.buttonText}}</button> <button v-else :class="signBtnStyle" @click="sign">{{signData.buttonText}}</button>
</view> </view>
</view> </view>
...@@ -63,7 +63,14 @@ ...@@ -63,7 +63,14 @@
}}</text> }}</text>
</view> </view>
</view> </view>
<text :class="(item2.status==0)?'task-btn':((item2.status==1)?'task-btn2':'task-btn3')"
<button v-if="item2.listCode == 3 && item2.status==0"
class="task-btn" open-type="addShortcut" @addshortcut="eventHandler">
{{ item2.buttonText }}
</button>
<text v-else
:class="(item2.status==0)?'task-btn':((item2.status==1)?'task-btn2':'task-btn3')"
@click="doTask(item2)">{{ item2.buttonText }}</text> @click="doTask(item2)">{{ item2.buttonText }}</text>
</view> </view>
</block> </block>
...@@ -246,30 +253,16 @@ ...@@ -246,30 +253,16 @@
} }
}); });
}, },
hasShortCut(taskId) { eventHandler(e) {
let that = this if (e.detail.errNo) {
shortcut.hasInstalled({ message.notify("添加到桌面失败")
success: function() { console.log("添加到桌面失败", e.detail);
$utils.showToast('桌面图标已创建!') } else {
that.reportCompleteTask(taskId)
}, this.isAddShort()
fail: function() { message.notify("添加到桌面成功")
that.createShortCut(taskId) console.log("添加到桌面成功");
}
})
},
createShortCut(taskId) {
let that = this
// 创建桌面图标
shortcut.install({
success: function() {
$utils.showToast('创建桌面图标成功!')
that.reportCompleteTask(taskId)
},
fail: function(data, code) {
$utils.showToast('创建桌面图标失败!')
} }
})
}, },
sign() { sign() {
let buttonStatus = this.signData.buttonStatus let buttonStatus = this.signData.buttonStatus
...@@ -288,8 +281,7 @@ ...@@ -288,8 +281,7 @@
let item = this.signList[this.signData.todayMsgIndexInWeek] let item = this.signList[this.signData.todayMsgIndexInWeek]
this.showAd(item, true) this.showAd(item, true)
} else if (ewardMoreType == 2) { } else if (ewardMoreType == 2) {
// 分享 // 分享 open-type实现
this.myShare(this.signList[this.signData.todayMsgIndexInWeek])
} }
}, },
reportTaskPoint(item, isSign) { reportTaskPoint(item, isSign) {
...@@ -399,7 +391,7 @@ ...@@ -399,7 +391,7 @@
} else if ( } else if (
item.listCode == TaskConstant.saveToPhonePage item.listCode == TaskConstant.saveToPhonePage
) { ) {
this.hasShortCut(item.taskId) // 保存到桌面
} else if ( } else if (
item.listCode == TaskConstant.openForHome item.listCode == TaskConstant.openForHome
) { ) {
...@@ -419,10 +411,6 @@ ...@@ -419,10 +411,6 @@
} }
} }
}, },
myShare(item) {
// TODO 分享
},
signMoreReward(item) { signMoreReward(item) {
// 签到-广告或者分享后领取更多 // 签到-广告或者分享后领取更多
let that = this let that = this
...@@ -447,6 +435,21 @@ ...@@ -447,6 +435,21 @@
signClose() { signClose() {
this.showSignPopup = false this.showSignPopup = false
}, },
isAddShort() {
let that = this
if (that.taskList.length > 0) {
for (var i = 0; i < that.taskList.length; i++) {
for (var j = 0; j < that.taskList[i].taskList.length; j++) {
if (that.taskList[i].taskList[j].listCode == TaskConstant.saveToPhonePage &&
that.taskList[i].taskList[j].status == 0
) {
that.reportCompleteTask(that.taskList[i].taskList[j].taskId)
return
}
}
}
}
},
isFromForHome() { isFromForHome() {
let that = this let that = this
if (uni.getEnterOptionsSync().launcher == 'shortcut') { if (uni.getEnterOptionsSync().launcher == 'shortcut') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment