授权打卡拒绝需要增加一个再次授权的入口;修改提示

This commit is contained in:
donqi 2022-12-02 02:27:42 +08:00
parent bd3532fe7a
commit f06e270b35
3 changed files with 52 additions and 4 deletions

View File

@ -659,6 +659,43 @@ export default {
}) })
return res[1].data; return res[1].data;
}, },
async checkAuth(authScope, callbackName, callbackSuccessKey) {
let _this = this;
// 通过 wx.getSetting 先查询一下用户是否授权了authScope
let res1 = await wx.getSetting();
if (res1) {
if (!res1.authSetting[authScope]) {
let res = _this[callbackName]();
if (res && res[callbackSuccessKey]) {
return res;
}
// 用户授权
uni.showToast({
title: '请先授权',
icon: 'none',
duration: 1500
})
return 'rejected';
} else {
return _this[callbackName]();
}
}
},
async openAndAuthSetting(authScope) {
wx.openSetting({
success(res) {
if (res[authScope]) {
return true;
}
}
})
uni.showToast({
icon: 'error',
duration: 1500,
title: '授权失败'
})
return false;
},
async wxGetLocation() { async wxGetLocation() {
let res = await wx.getLocation({ let res = await wx.getLocation({
type: 'gcj02' type: 'gcj02'

View File

@ -65,7 +65,7 @@
<set-take-rate ref="setTakeRateModal" :leaderTeamRate="Number(curUserInfo.leaderTeamRate)*100" <set-take-rate ref="setTakeRateModal" :leaderTeamRate="Number(curUserInfo.leaderTeamRate)*100"
:leaderTeamMoney="curUserInfo.leaderTeamMoney" @confirm="applySetTakeRate"></set-take-rate> :leaderTeamMoney="curUserInfo.leaderTeamMoney" @confirm="applySetTakeRate"></set-take-rate>
<invite-master ref="inviteMasterModal" :inviteMasterObj="inviteMasterObj" @confirm="inviteMaster"></invite-master> <invite-master ref="inviteMasterModal" :inviteMasterObj="inviteMasterObj" @confirm="inviteMaster"></invite-master>
<confirm-modal ref="loginTipModal" :content="'当前无法加入师傅团队,请完成注册。'" @confirm="goToPage('/pages/login/login?inviter=', inviteMasterObj, true)"></confirm-modal> <confirm-modal ref="loginTipModal" :content="'当前无法加入团队,请完成注册。如您已注册,请登录后重新点击此链接,完成加入团队。'" @confirm="goToPage('/pages/login/login?inviter=', inviteMasterObj, true)"></confirm-modal>
<confirm-modal ref="certifyTipModal" :content="'请前往完成师傅实名及银行账户绑定以激活'" @confirm="goToPage('/pages/index/index?menuCode=myPage')"></confirm-modal> <confirm-modal ref="certifyTipModal" :content="'请前往完成师傅实名及银行账户绑定以激活'" @confirm="goToPage('/pages/index/index?menuCode=myPage')"></confirm-modal>
</view> </view>
</template> </template>

View File

@ -210,7 +210,8 @@
</view> </view>
<view v-if="order.orderStatus === 3"> <view v-if="order.orderStatus === 3">
<button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click="showServOrderDetail(order)">查看</button> <button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click="showServOrderDetail(order)">查看</button>
<button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click="recordClockInLocation(order)" v-show="order.orderDetailId != null && !order.clockInLocation">打卡到达</button> <button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click="recordClockInLocation(order)" v-if="hasAuthLocation && order.orderDetailId != null && !order.clockInLocation">打卡到达</button>
<button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" open-type="openSetting" @opensetting="authLocationCallback" v-else-if="order.orderDetailId != null && !order.clockInLocation">授权打卡</button>
<button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click = "changePrice($event, order)" data-ref="newServPriceOffline" data-modal="showNewServPriceOfflineModal" v-show="order.orderDetailId != null && order.clockInLocation && order.payType === 1">报价/完单</button> <button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click = "changePrice($event, order)" data-ref="newServPriceOffline" data-modal="showNewServPriceOfflineModal" v-show="order.orderDetailId != null && order.clockInLocation && order.payType === 1">报价/完单</button>
<button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click = "changePrice($event, order)" data-ref="newServPriceOnline" data-modal="showNewServPriceOnlineModal" v-show="order.orderDetailId != null && order.clockInLocation && order.payType === 0">报价/完单</button> <button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click = "changePrice($event, order)" data-ref="newServPriceOnline" data-modal="showNewServPriceOnlineModal" v-show="order.orderDetailId != null && order.clockInLocation && order.payType === 0">报价/完单</button>
<!-- <button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click = "changePrice($event, order)" data-ref="newServPriceOffline" data-modal="showNewServPriceOfflineModal" v-show="order.orderDetailId != null && order.payType === 1">报价/完单</button> --> <!-- <button class="cu-btn bg-main-color margin-right-xs shadow-blur margin-top-sm" @click = "changePrice($event, order)" data-ref="newServPriceOffline" data-modal="showNewServPriceOfflineModal" v-show="order.orderDetailId != null && order.payType === 1">报价/完单</button> -->
@ -503,7 +504,8 @@
picModalImgList: [], picModalImgList: [],
curDate: '', curDate: '',
curUserInfo: {}, curUserInfo: {},
orderStatistics: {} orderStatistics: {},
hasAuthLocation: true
} }
}, },
onLoad(option) { onLoad(option) {
@ -1170,8 +1172,17 @@
current: e.currentTarget.dataset.url current: e.currentTarget.dataset.url
}); });
}, },
async authLocationCallback(res) {
if (res.detail.authSetting['scope.userLocation']) {
this.hasAuthLocation = true;
}
},
async recordClockInLocation(order) { async recordClockInLocation(order) {
let res = await this.$request.wxGetLocation(); let res = await this.$request.checkAuth('scope.userLocation', 'wxGetLocation', 'latitude');
if (res && res === 'rejected') {
this.hasAuthLocation = false;
return;
}
if (!res || !res.latitude) { if (!res || !res.latitude) {
uni.showToast({ uni.showToast({
title: '定位获取失败,打卡失败,请稍后重试', title: '定位获取失败,打卡失败,请稍后重试',