Commit 2f2f1a2f authored by jyx's avatar jyx

添加到桌面功能

parent e4cda068
......@@ -20,7 +20,7 @@
</block>
</view>
<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>
</view>
</view>
......@@ -63,7 +63,14 @@
}}</text>
</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>
</view>
</block>
......@@ -246,30 +253,16 @@
}
});
},
hasShortCut(taskId) {
let that = this
shortcut.hasInstalled({
success: function() {
$utils.showToast('桌面图标已创建!')
that.reportCompleteTask(taskId)
},
fail: function() {
that.createShortCut(taskId)
}
})
},
createShortCut(taskId) {
let that = this
// 创建桌面图标
shortcut.install({
success: function() {
$utils.showToast('创建桌面图标成功!')
that.reportCompleteTask(taskId)
},
fail: function(data, code) {
$utils.showToast('创建桌面图标失败!')
eventHandler(e) {
if (e.detail.errNo) {
message.notify("添加到桌面失败")
console.log("添加到桌面失败", e.detail);
} else {
this.isAddShort()
message.notify("添加到桌面成功")
console.log("添加到桌面成功");
}
})
},
sign() {
let buttonStatus = this.signData.buttonStatus
......@@ -288,8 +281,7 @@
let item = this.signList[this.signData.todayMsgIndexInWeek]
this.showAd(item, true)
} else if (ewardMoreType == 2) {
// 分享
this.myShare(this.signList[this.signData.todayMsgIndexInWeek])
// 分享 open-type实现
}
},
reportTaskPoint(item, isSign) {
......@@ -399,7 +391,7 @@
} else if (
item.listCode == TaskConstant.saveToPhonePage
) {
this.hasShortCut(item.taskId)
// 保存到桌面
} else if (
item.listCode == TaskConstant.openForHome
) {
......@@ -419,10 +411,6 @@
}
}
},
myShare(item) {
// TODO 分享
},
signMoreReward(item) {
// 签到-广告或者分享后领取更多
let that = this
......@@ -447,6 +435,21 @@
signClose() {
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() {
let that = this
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